text
stringlengths
11
4.05M
package handler import ( "context" "errors" "path/filepath" "testing" proto "github.com/jinmukeji/proto/v3/gen/micro/idl/partner/xima/user/v1" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/suite" ) // UserGetSecureQuestionListTestSuite 获取密保问题列表测试 type UserGetSecureQuestionListTestSuite str...
/* The localfile backend, for dealing with a Vagrant catalog on a local filesystem */ package caryatid import ( "bytes" "fmt" "log" "os" "regexp" "strings" "github.com/aws/aws-sdk-go/aws" "github.com/aws/aws-sdk-go/aws/awserr" "github.com/aws/aws-sdk-go/aws/session" "github.com/aws/aws-sdk-go/service/s3" ...
package raw_client import ( "context" ) type PostDevAppDeleteRequest struct { App string `json:"app"` /*RequestToken string `json:"__REQUEST_TOKEN__"`*/ } type PostDevAppDeleteResponse struct { } func PostDevAppDelete(ctx context.Context, apiClient *ApiClient, req PostDevAppDeleteRequest) (*PostDevAppDeleteRespo...
package theme import ( "flag" "fmt" ) func Scaffold() { // Declare flags. name := flag.String("name", "test", "The name of your theme.") // Command line parsing of flags. flag.Parse() // Output. fmt.Println("The theme you are making is called: " + *name) }
package main import "fmt" func main() { for i := 65; i <= 90; i++ { fmt.Println(i, " - ", string(i), " - ", []byte(string(i))) } fmt.Println("\n rune example: ") x := 'A' fmt.Println(x) fmt.Printf("%T \n", x) fmt.Println("\n string example: ") y := "A" fmt.Println(y) fmt.Printf("%T \n", y) } /* NOTE:...
/* Copyright 2016 Vastech SA (PTY) LTD Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed ...
// Package flatten provides a Flatten() func for flattenning out nested slices of ints. package flatten import "fmt" // Flatten will take a slice of arbitrarily nested (slices of) interfaces and/or ints, and return a flat slice of ints. func Flatten(input interface{}) []int { result := make([]int, 0) switch typeSw...
package main import ( "crypto/sha1" "fmt" ) func main() { str1 := "this is a test str, first" str2 := "this is a test str, second" mSha1 := sha1.New() mSha1.Write([]byte(str1)) ret1 := mSha1.Sum(nil) fmt.Printf("raw ret:%s, hex ret:%x \n", ret1, ret1) mSha1.Write([]byte(str2)) ret2 := mSha1.Sum(nil) fmt...
package main import ( "html/template" "log" "os" ) func main() { // say this is a template and put it in tpl tpl, err := template.ParseFiles("tpl.gohtml") if err != nil { log.Fatal(err) } // err = tpl.Execute(os.Stdout, nil) // we execute the first of the templates in the terminal err = tpl.ExecuteTemplat...
package access import ( "github.com/ololko/simple-HTTP-server/pkg/events/models" ) type DataAccessor interface{ ReadEvent(models.RequestT, chan<- models.AnswerT, chan<- error) WriteEvent(models.EventT, chan<- error) }
// vi:nu:et:sts=4 ts=4 sw=4 package main import ( "fmt" "html/template" "log" "net/http" "strconv" "sync" "github.com/gomodule/redigo/redis" ) var hitmeTpl = `<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <title>Document</title> </head> <body> <p>OUCH - You ...
package entity import ( "errors" ) type CustomError int const ( ErrInvalidNumber CustomError = iota ErrDataMalformed ErrInvalidID ) func (s CustomError) Error() error { return [...]error{ errors.New("ErrInvalidNumber"), errors.New("ErrDataMalformed"), errors.New("ErrInvalidID"), }[s] }
package main // build vars var ( Version string Build string mlCli = &mlCLI{} config = &CliConfig{} ) func main() { config.init(Version, Build) cli() }
package main import ( "flag" "fmt" "log" "net/http" "net/url" "os" "strings" "sync" "time" "github.com/PuerkitoBio/fetchbot" "github.com/PuerkitoBio/goquery" "github.com/goccy/go-json" ) var ( // Protect access to dup dupMu sync.RWMutex // Duplicates table dup = make(map[string]struct{}) // Command...
package _const const ( AlphaNum = "alphaNum" Alpha = "alpha" Number = "number" )
/* You are given a number n. Determine whether n has exactly 3 divisors or not. Examples isExactlyThree(4) ➞ true // 4 has only 3 divisors: 1, 2 and 4 isExactlyThree(12) ➞ false // 12 has 6 divisors: 1, 2, 3, 4, 6, 12 isExactlyThree(25) ➞ true // 25 has only 3 divisors: 1, 5, 25 Notes 1 ≤ n ≤ 10^12 */ package ...
package add import ( "github.com/devspace-cloud/devspace/cmd/flags" "github.com/devspace-cloud/devspace/pkg/util/factory" "github.com/spf13/cobra" ) // NewAddCmd creates a new cobra command func NewAddCmd(f factory.Factory, globalFlags *flags.GlobalFlags) *cobra.Command { addCmd := &cobra.Command{ Use: "add",...
/* * Tencent is pleased to support the open source community by making Blueking Container Service available. * Copyright (C) 2019 THL A29 Limited, a Tencent company. All rights reserved. * Licensed under the MIT License (the "License"); you may not use this file except * in compliance with the License. You may obta...
package aws import ( "context" "sync" awssdk "github.com/aws/aws-sdk-go/aws" "github.com/aws/aws-sdk-go/aws/session" "github.com/pkg/errors" typesaws "github.com/openshift/installer/pkg/types/aws" ) // Metadata holds additional metadata for InstallConfig resources that // does not need to be user-supplied (e....
package httputil import "strings" // NormalizeBase adds a leading slash and a trailing slash if missing. func NormalizeBase(base string) string { if base == "" { return "" } if !strings.HasPrefix(base, "/") { base = "/" + base } if !strings.HasSuffix(base, "/") { base = base + "/" } return base } // Tri...
package stack import "testing" func TestBrowser(t *testing.T) { b := NewBrowser() b.Push("www.qq.com") t.Log((b)) b.Push("www.baidu.com") b.Push("www.sina.com") t.Log((b)) b.Back() t.Log((b)) b.Forward() t.Log((b)) }
package main import ( "server/controllers" "github.com/gin-contrib/cors" "github.com/gin-gonic/gin" ) func main() { router := gin.Default() router.Use(cors.Default()) router.POST("/admin/register", controllers.KitchenRegister) router.POST("/admin/signin", controllers.KitchenSignin) router.POST("/signup", con...
package main import ( "log" "time" "github.com/disq/werify/cmd/werifyd/pool" t "github.com/disq/werify/cmd/werifyd/types" ) const healthCheckInterval = 60 * time.Second func (s *Server) healthchecker() { for { select { case <-s.context.Done(): return case <-s.forceHealthcheck: log.Println("Starting...
package request import ( "context" "fmt" "testing" ) type M map[string]Upstream func TestRequest(t *testing.T) { r := NewRequest(context.Background()) p := map[string]interface{}{ "extend_flag": 1, } rs, err := r.Get("$api_server/internal/enterprise/getMultiCompanyBrief", p, []string{"eeqeq"}) if err != ni...
// Copyright 2022 Gabriel Boorse // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // http://www.apache.org/licenses/LICENSE-2.0 // Unless required by applicable law or agreed to in writin...
/* @Time : 2019-03-28 10:45 @Author : zhangjun @File : contributors @Description: @Run: */ package main import ( "encoding/json" "fmt" "log" "net/http" ) //GET /repos/:owner/:repo/contributors var contributorsURL = "https://api.github.com/repos/childeYin/Cultivate/contributors" var reposContributorsUrl = "https...
package websocket import ( "bufio" "crypto/sha1" "encoding/base64" "fmt" "github.com/pkg/errors" "net" "net/http" "strings" ) // Currently, only ignores if no |Host| was supplied in the header. const Strict = false // GUID used by every WebSocket server (as specified on the RFC). const...
package set import ( "fmt" "sync" ) type SafeInt64Set struct { sync.RWMutex M map[int64]struct{} } func NewSafeInt64Set() *SafeInt64Set { return &SafeInt64Set{M: make(map[int64]struct{})} } func (this *SafeInt64Set) String() string { s := this.Slice() return fmt.Sprint(s) } func (this *SafeInt64Set) Add(ite...
package main import ( "fmt" "strconv" "github.com/Cloud-Foundations/Dominator/imageserver/client" "github.com/Cloud-Foundations/Dominator/lib/log" ) func deleteUnreferencedObjectsSubcommand(args []string, logger log.DebugLogger) error { imageSClient, _ := getClients() percentage, err := strconv.ParseUint(args...
package models import ( "database/sql" "encoding/json" "fmt" "github.com/astaxie/beego/orm" "github.com/devplayg/ipas-mcs/objs" "strings" ) func GetAllSystemConfig() ([]objs.SysConfig, error) { query := "select section, keyword, value_s, value_n from sys_config" var rows []objs.SysConfig o := orm.NewOrm() ...
package camt import ( "encoding/xml" "github.com/thought-machine/finance-messaging/iso20022" ) type Document04400103 struct { XMLName xml.Name `xml:"urn:iso:std:iso:20022:tech:xsd:camt.044.001.03 Document"` Message *FundConfirmedCashForecastReportCancellationV03 `xml:"FndCo...
package rest import ( "fmt" "github.com/jinmukeji/jiujiantang-services/pkg/rest" proto "github.com/jinmukeji/proto/v3/gen/micro/idl/partner/xima/user/v1" "github.com/kataras/iris/v12" ) const ( // SendViaPhone 发送途径为手机号码 SendViaPhone = "phone" // SendViaEmail 发送途径为邮箱 SendViaEmail = "email" ) // GetLatestVeri...
// Widget use to display single item details. // // @author TSS package gui import ( "fmt" "time" "github.com/jroimartin/gocui" "github.com/mashmb/1pass/1pass-core/core/domain" ) const ( detailsHelp string = `Scroll up/down: k/j Scroll left/right: h/l Cover item: TAB` ) type detailsWidget struct { name ...
package leetcode /*Given an integer array arr. You have to sort the integers in the array in ascending order by the number of 1's in their binary representation and in case of two or more integers have the same number of 1's you have to sort them in ascending order. Return the sorted array. 来源:力扣(LeetCode) 链接:https:...
package main import "fmt" type Person struct { First string Last string Age int } type Gamer struct { Person First string Plays int FavoriteGame string } type BoardGamer struct { Person Gamer First string } func main() { b := BoardGamer{} b.First = "BoardGamer Joe" b.Gamer.First = "Ga...
package main import ( "github.com/streadway/amqp" "log" "os" "sync" ) type ConsumerHandler func(amqp.Delivery) type Consumer struct { uri string conn *amqp.Connection connLock *sync.Mutex handLock *sync.Mutex wg *sync.WaitGroup done chan bool closes []chan error } type ConsumerSubscr...
package resolver import ( "github.com/taktakty/netlabi/models" genModels "github.com/taktakty/netlabi/models/generated" "context" ) func (r *queryResolver) GetRack(ctx context.Context, input genModels.GetIDInput) (*models.Rack, error) { var rack models.Rack rack.ID = input.ID if err := db.First(&rack).Error; er...
package sessionmanager import ( "context" "sync" cid "gx/ipfs/QmR8BauakNcBa3RbE4nbQu76PDiJgoQgz8AJdhJuiU4TAw/go-cid" blocks "gx/ipfs/QmWoXtvgC8inqFkAATB7cp2Dax7XBi9VDvSg9RCCZufmRk/go-block-format" exchange "gx/ipfs/QmP2g3VxmC7g7fyRJDj1VJ72KHZbJ9UW24YjSWEj1XTb4H/go-ipfs-exchange-interface" peer "gx/ipfs/QmPJxxD...
package main import "fmt" const ( // SatoshiPerBitcent is the number of satoshi in one bitcoin cent. SatoshiPerBitcent = 1e6 // SatoshiPerBitcoin is the number of satoshi in one bitcoin (1 BTC). SatoshiPerBitcoin = 1e8 // MaxSatoshi is the maximum transaction amount allowed in satoshi. MaxSa...
// main package main import ( "flag" "fmt" "log" "os" "os/signal" "sync" "syscall" "time" nsq "github.com/bitly/go-nsq" "labix.org/v2/mgo" "labix.org/v2/mgo/bson" ) const updateDuration = 5 * time.Second var ( fatalErr error counts map[string]int countsLock sync.Mutex ) func fatal(e error) { f...
package main import ( "bufio" "fmt" "os" "regexp" "strconv" "strings" ) type BagProperty struct { name string num int } var graph = make(map[string][]BagProperty, 0) var visited = make(map[string]bool, 0) func buildGraph() map[string][]BagProperty { f, _ := os.Open("input.txt") defer f.Close() re := re...
// Copyright 2017 Mirantis // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // // http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed to in writi...
package chain import ( "github.com/btcsuite/btcd/btcutil" "github.com/btcsuite/btcd/btcutil/gcs" "github.com/btcsuite/btcd/chaincfg" "github.com/btcsuite/btcd/chaincfg/chainhash" "github.com/btcsuite/btcd/wire" "github.com/lightninglabs/neutrino" "github.com/lightninglabs/neutrino/banman" "github.com/lightning...
package configuration import ( "labix.org/v2/mgo" "log" "os" ) const ERROR_MESSAGE = "Erreur lors du dialogue avec la base de donnée : %s" func GetAnnouncementCollection() (*mgo.Collection, *mgo.Session) { db := GetConfiguration().GetDatabase() session, err := mgo.Dial(os.Getenv("MONGOLAB_URI")) if err != nil ...
package categories import ( "fmt" "sort" "strings" "github.com/Nv7-Github/Nv7Haven/eod/base" "github.com/Nv7-Github/Nv7Haven/eod/types" "github.com/Nv7-Github/Nv7Haven/eod/util" ) type catSortInfo struct { Name string Cnt int } func (b *Categories) CatCmd(category string, sortKind string, hasUser bool, use...
package utils import ( "net/url" "path" "strings" ) // URLPathFullClean returns a URL path with the query parameters appended (full path) with the path portion parsed // through path.Clean given a *url.URL. func URLPathFullClean(u *url.URL) (output string) { lengthPath := len(u.Path) lengthQuery := len(u.RawQuer...
package xmlsec // EncryptedData represents the <EncryptedData> XML tag. See // https://www.w3.org/TR/2002/REC-xmlenc-core-20021210/Overview.html#sec-Usage type EncryptedData struct { XMLName string `xml:"http://www.w3.org/2001/04/xmlenc# EncryptedData"` Type string `xml:",attr"` Encrypt...
package fingerprint import "os" // Fingerprinter defines operations for calculating fingerprints from audio files type Fingerprinter interface { // CalcFingerprint returns a list of fingerprints from an input path CalcFingerprint(fPath string) ([]*Fingerprint, error) } // Fingerprint is an audio file fingerprint....
package UI const ( RUNEVT=1 )
package suffix import ( "sort" ) type Suffix interface { DistinctSubCount() int DistinctSub() [][]byte SubCount() int LongestRepeatedSubs() [][]byte } type array struct { txt []byte sa []int lcp []int } func NewArray(txt []byte) Suffix { a := &array{txt: txt} a.sa = a.newArray() a.lcp = a.newLcp() ret...
package config import ( "encoding/json" "fmt" "os" ) const configPath = "config.json" var ( config *Config ) func init() { file, err := os.Open(configPath) if err != nil { panic(err) } defer file.Close() cfg := &Config{} decoder := json.NewDecoder(file) if err := decoder.Decode(cfg); err != nil { pa...
package context import ( "MainApplication/config" "MainApplication/internal/User/UserModel" "context" crypto "crypto/rand" "errors" "github.com/microcosm-cc/bluemonday" "math/big" "net/http" "time" ) const ( CookieName = "session_id" CsrfCookieName = "token" ) var UserFromContextError = errors.New("C...
package coinbase import ( "errors" "net/http" "time" "github.com/fabioberger/coinbase-go/config" ) // ClientOAuthAuthentication Struct implements the Authentication interface // and takes care of authenticating OAuth RPC requests on behalf of a client // (i.e GetBalance()) type clientOAuthAuthentication struct {...
package main import ( "bufio" "encoding/binary" "errors" "flag" "fmt" "hash/crc32" "io" "log" "net" "os" "os/signal" "strings" "sync" "time" "github.com/kawasin73/umutex" ) const ( LInsert = 1 + iota LDelete LUpdate LRead LCommit LAbort ) var ( ErrExist = errors.New("record already exist...
package main import ( "github.com/deluan/bring" "github.com/faiface/pixel/pixelgl" ) var ( keys map[pixelgl.Button]bring.KeyCode ) // Rant: why pixelgl keyboard events handling is so messy?!? func collectKeyStrokes(win *pixelgl.Window) (pressed []bring.KeyCode, released []bring.KeyCode) { for k, v := range keys ...
package main import "fmt" func main() { var studentName [10]string var studentAge [10]int var studentEmail [10]string studentName[0] = "Goku" studentAge[0] = 18 studentEmail[0] = "Goku@super.saiya" fmt.Println(studentName[0], studentAge[0], studentEmail[0]) }
// Galang - Golang common utilities // Copyright (c) 2020-present, gakkiiyomi@gamil.com // // gakkiyomi is licensed under Mulan PSL v2. // You can use this software according to the terms and conditions of the Mulan PSL v2. // You may obtain a copy of Mulan PSL v2 at: // http://license.coscl.org.cn/MulanPSL2 //...
package main // 改编自Twitter: // https://github.com/twitter/snowflake/blob/snowflake-2010/src/main/scala/com/twitter/service/snowflake/IdWorker.scala import ( "errors" "sync" "time" ) // 0 - 00000000 00000000 00000000 00000000 00000000 0 - 00000000 00 - 00000000 0000 // 1bit 41bit时间戳 ...
// stream_check project m3u8Info.go package m3u8 import ( "product_code/check_stream/public" "strconv" "strings" "time" ) const ( TsStatusDefault = 0 TsStatusDownloading = 1 TsStatusOk = 2 TsStatusFail = 3 ) //#EXT-X-PROGRAM-DATE-TIME:2018-09-04T18:49:17Z //#EXTINF:4.000,4.000000000 12120...
package limits import ( "sync/atomic" "unsafe" ) var Lhits int type Sysatomic_t int64 type Syslimit_t struct { // protected by proclock Sysprocs int // proctected by idmonl lock Vnodes int // proctected by _allfutex lock Futexes int // proctected by arptbl lock Arpents int // proctected by routetbl lock ...
package zerointerface //Describer interface type Describer interface { Describe() }
//go:build !go1.18 // +build !go1.18 package gflag_test // alias of interface{}, use for go < 1.18 type any = interface{}
package klusterlet import ( "context" "errors" "fmt" "io/ioutil" "time" "github.com/mdelder/failover/pkg/helpers" "github.com/openshift/library-go/pkg/controller/controllercmd" "github.com/openshift/library-go/pkg/operator/events" "github.com/spf13/pflag" "github.com/open-cluster-management/registration/pk...
package 数组 import "sort" // ------------------------ 排序解法 ------------------------ // 时间复杂度: O(n * log_n) func canMakeArithmeticProgression(arr []int) bool { sort.Ints(arr) return isArithmeticProgression(arr) } func isArithmeticProgression(arr []int) bool { if len(arr) <= 1 { return true } diff := arr[1] - ar...
// Copyright 2017 The Go Authors. All rights reserved. // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. package benchstat import ( "fmt" "io" "unicode/utf8" ) // FormatText appends a fixed-width text formatting of the tables to w. func FormatText(w io.Writer...
package goSolution func minDistance(word1 string, word2 string) int { n, m := len(word1), len(word2) f := make([][]int, n + 1) for i := 0; i < n + 1; i++ { f[i] = make([]int, m + 1) } for i := 0; i < n; i++ { for j := 0; j < m; j++ { f[i + 1][j + 1] = max(f[i][j + 1], f[i + 1][j]) if word1[i] == word2...
package slice_1 import "testing" func TestSolve(t *testing.T) { arr := []struct{ str string left int expected int } { {"((1)23(45))(aB)", 0, 10}, {"((1)23(45))(aB)", 1, 3}, {"((1)23(45))(aB)", 2, -1}, {"((1)23(45))(aB)", 6, 9}, {"((1)23(45))(aB)", 11, 14}, {"((>)|?(*'))(yZ)", 11, 14}, } for _, ...
package slicerdicer import ( "image" "testing" ) var ( testRect = image.Rect(0, 0, 1000, 1000) testImage = image.NewRGBA(testRect) ) func assert(t *testing.T, val, expected interface{}) { t.Helper() if val != expected { t.Errorf("value (%+v) was not like expected (%+v)", val, expected) } } func TestCrop(...
package model import ( "github.com/astaxie/beego/orm" ) type UserModel struct { Id int64 `json:"id" orm:"column(id);pk;auto;unique"` Phone string `json:"phone" orm:"column(phone);unique;size(11)"` Nickname string `json:"nickname" orm:"column(nickname);unique;size(40);"` Password string `j...
package main import ( "crypto/tls" "flag" "fmt" "io" "io/ioutil" "log" "math" "net" "net/http" "net/url" "os" "path" "strconv" "strings" "sync" "time" "gonum.org/v1/gonum/mat" "gonum.org/v1/gonum/optimize" ) // `http-max-rps` is designed to tell you the maximum rps that // either an http server or ...
package controllers import ( "github.com/astaxie/beego" "gowechatsubscribe/models" "strconv" "gowechatsubscribe/dblite" ) type PoetryController struct { beego.Controller } func (c *PoetryController) Get() { login := checkAccount(c.Ctx) c.Data["IsLogin"] = login if !login { c.Redirect("/mis/login", 302) r...
package iowriter import ( "fmt" "io" "os" "github.com/popodidi/log" "github.com/popodidi/log/handlers" "github.com/popodidi/log/handlers/codec" ) // Config defines the writer handler config. type Config struct { Codec handlers.Codec Writer io.Writer } // Stdout returns a handler that encodes with default c...
package blob import ( "io/ioutil" "os" "strings" "github.com/iotaledger/wasp/packages/hashing" "github.com/iotaledger/wasp/tools/wasp-cli/config" "github.com/iotaledger/wasp/tools/wasp-cli/log" "github.com/spf13/pflag" ) func InitCommands(commands map[string]func([]string), flags *pflag.FlagSet) { commands["...
package main import ( "manager" "manager/stmanager" "flag" "fmt" ) func main() { t := flag.Int("t", 0, "stock list type") flag.Parse() switch (*t) { case 0: fmt.Println("Get all the stock list") m := manager.NewStockListManager() m.Process()...
/* Copyright 2019 Cornelius Weig. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software...
package davepdf import "fmt" func (pdf *Pdf) ImportPage(sourceFile string, pageno int, box string) int { var tplid int pdf.fpdi.SetSourceFile(sourceFile) pdf.fpdi.SetNextObjectID(pdf.n + 1) tplid = pdf.fpdi.ImportPage(pageno, box) // write imported objects for tplName, objId := range pdf.fpdi.PutFormXobjects...
package main import ( "daemon" "errors" "fmt" "log" "net" "os" ) func parseCommand(str string) (int, error) { if str == "get" { return daemon.CMD_GET, nil } else if str == "put" { return daemon.CMD_PUT, nil } else if str == "pin" { return daemon.CMD_PIN, nil } else if str == "unpin" { return daemon....
package main import ( "fmt" ) func main() { //if x:= 42;x==2 { Didn't run because x not the same // fmt.Println("007") //} if x := 42; x == 42 { fmt.Println("009") } }
package main import ( "encoding/csv" "fmt" "os" "sort" "sync" "time" ) // doing hw 4.6 of CS215 // made good headway learned the csv package, bufio // bunch of other file opening, manipulations etc // gonna try to make it rly good with go's concurrency // This is represent the bipartite graph type Graph map[st...
package gfuns import ( "bytes" "encoding/json" "fmt" "log" "os" "os/exec" "path/filepath" "strconv" ) func Split(url string, ffprobe FFprobe) ([]string, string, error) { dir, _ := createDir(ffprobe.Format.Filename) message, err := ffmpeg("-y", "-v", "error", "-i", url, "-f", "segment", "-codec:", "copy", "-...
package main import ( "fmt" "log" "time" tm "github.com/buger/goterm" "github.com/goburrow/modbus" ) var normal chan bool func main() { normal = make(chan bool, 1) SlaveId := byte(1) addr := uint16(0x59) // handler := modbus.NewTCPClientHandler("127.0.0.1:502") handler := modbus.NewRTUClientHandler("/dev/...
package main import ( "os" "fmt" "path/filepath" ) type Student struct { Age int Name string } type my_string string func fs(str string) (r_str string) { str+=str+"sh" r_str=str+"ce" return r_str } func main(){ fmt.Println(os.Args) fmt.Println(len(os.Args)) fmt.Println(filepath.Base(os.Args[0]...
/* * Copyright 2017 StreamSets Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed...
package segtree /* Verified: RMQ: https://onlinejudge.u-aizu.ac.jp/solutions/problem/DSL_2_A/review/5807307/numacci/Go RSQ: https://onlinejudge.u-aizu.ac.jp/solutions/problem/DSL_2_B/review/5805828/numacci/Go */ // SegTree can be used for RMQ and RSQ with Update operation, not Add. // So if we need to add x to...
package output type Outputs []*Output func (Outputs Outputs) Params() (params []string) { for _, output := range Outputs { params = append(params, output.Params()...) } return }
//go:generate mockgen -destination=./mock/types_mock.go os FileInfo package os
/* * Copyright (c) 2020. Ant Group. All rights reserved. * * SPDX-License-Identifier: Apache-2.0 */ package stargz import "testing" func Test_digest_Sha256(t *testing.T) { tests := []struct { name string d digest want string }{ { name: "testdigest", d: digest("sha256:12345"), want: "1234...
package crypto_test import ( "crypto-performance-compare/crypto" "crypto-performance-compare/fakes" "crypto-performance-compare/utils" "fmt" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" "net/http" "net/http/httptest" "os" "testing" ) func TestUpdater(t *testing.T) { ts := http...
package attacher import ( "errors" "fmt" "net" "strings" "github.com/Huawei/eSDK_K8S_Plugin/src/proto" "github.com/Huawei/eSDK_K8S_Plugin/src/storage/oceanstor/client" "github.com/Huawei/eSDK_K8S_Plugin/src/utils" "github.com/Huawei/eSDK_K8S_Plugin/src/utils/log" ) type AttacherPlugin interface { Controller...
package goSolution func minCostClimbingStairs(cost []int) int { cost0 := cost[0] cost1 := cost[1] for _, c := range cost[2:] { t := cost1 cost1 = c + min(t, cost0) cost0 = t } return min(cost1, cost0) }
package manifestgen import ( "github.com/iLLeniumStudios/FiveMCarsMerger/pkg/dft" "github.com/iLLeniumStudios/FiveMCarsMerger/pkg/flags" log "github.com/sirupsen/logrus" "io/ioutil" "os" "strings" "text/template" ) type Manifest struct { HasCarcols bool HasCarvariations bool HasContentUnlocks ...
package util import ( "go_web/pkg/logger" "strconv" ) func Int64ToString(num int64) string { return strconv.FormatInt(num, 10) } func StringToInt64(str string) int64 { i, err := strconv.ParseInt(str, 10, 64) if err != nil { logger.LogError(err) } return i }
package main import ( "context" "encoding/json" "fmt" "log" "net/http" "time" "go.mongodb.org/mongo-driver/bson" ) func GetPeopleEndpoint(response http.ResponseWriter, request *http.Request) { fmt.Println("GetPeopleEndpoint - start") response.Header().Set("content-type", "application/json") var people []P...
package dalmodel import ( "context" "github.com/gremlinsapps/avocado_server/session" "github.com/jinzhu/gorm" ) type Hashtag struct { gorm.Model AuditModel Name string `gorm:"not null;unique_index"` } type AuditModel struct { CreatedBy User `gorm:"foreignkey:CreatedByID;association_foreignkey:ID"` CreatedB...
package main import ( "log" "net/http" "github.com/Khamliuk/testsCI/controller" "github.com/Khamliuk/testsCI/handler" "github.com/Khamliuk/testsCI/mongo" ) func main() { db, err := mongo.New() if err != nil { log.Fatalf("could not create new db connection: %v", err) } service := controller.New(db) api :=...
package server import ( "context" "log" "time" "github.com/asishshaji/startup/apps/auth/controller" "github.com/asishshaji/startup/apps/auth/delivery" "github.com/asishshaji/startup/apps/auth/repository" "github.com/asishshaji/startup/apps/auth/usecase" "go.mongodb.org/mongo-driver/mongo" "go.mongodb.org/mon...
package zfs // #include <stdlib.h> // #include <libzfs.h> // #include "common.h" // #include "zpool.h" // #include "zfs.h" import "C" import ( "encoding/json" "fmt" "strconv" "time" "errors" ) var stringToDatasetPropDic = make(map[string]DatasetProp) var stringToPoolPropDic = make(map[string]PoolProp) var zfsMax...
package match import ( mesh_proto "github.com/kumahq/kuma/api/mesh/v1alpha1" "github.com/kumahq/kuma/pkg/core/policy" "github.com/kumahq/kuma/pkg/core/resources/model" ) // ToConnectionPolicies casts a ResourceList to a slice of ConnectionPolicy. func ToConnectionPolicies(policies model.ResourceList) []policy.Conn...
package collectors import ( "encoding/json" "os" "sync" "time" cclog "github.com/ClusterCockpit/cc-metric-collector/pkg/ccLogger" lp "github.com/ClusterCockpit/cc-metric-collector/pkg/ccMetric" mct "github.com/ClusterCockpit/cc-metric-collector/pkg/multiChanTicker" ) // Map of all available metric collectors ...
package abstract_factory_test import ( "design_pattern/creational/abstract_factory" "testing" ) func TestAdidas(t *testing.T) { adidasFactory, _ := abstract_factory.GetSportsFactory("adidas") adidasShoe := adidasFactory.MakeShoe() logo := adidasShoe.GetLogo() if logo == "adidas" { t.Logf("adidas shoe logo = %...