text
stringlengths
11
4.05M
package commands import ( "fmt" "io" cmds "gx/ipfs/QmQtQrtNioesAWtrx8csBvfY37gTe94d6wQ3VikZUjxD39/go-ipfs-cmds" cmdkit "gx/ipfs/Qmde5VP1qUkyQXKCfmEUA7bP64V2HAptbJ7phuPp7jXWwg/go-ipfs-cmdkit" "github.com/filecoin-project/go-filecoin/api" ) var versionCmd = &cmds.Command{ Helptext: cmdkit.HelpText{ Tagline: "...
package ipfs import ( "os" shell "github.com/ipfs/go-ipfs-api" ) type IpfsClient struct { api string gateway string sh *shell.Shell } var _ipfsClient *IpfsClient = &IpfsClient{} func Initialize(api string, gateway string) { _ipfsClient.api = api _ipfsClient.gateway = gateway _ipfsClient.sh = shell...
package components import ( "github.com/fananchong/go-xserver/common" "github.com/fananchong/go-xserver/common/utils" "github.com/fananchong/gotcp" ) // TCPServer : TCP Server 组件 type TCPServer struct { ctx *common.Context } // NewTCPServer : 实例化 func NewTCPServer(ctx *common.Context) *TCPServer { server := &TC...
/* * Copyright 2019 Banco Bilbao Vizcaya Argentaria, S.A. * * 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 ap...
// Copyright (C) 2018 Storj Labs, Inc. // See LICENSE for copying information. package telemetry import ( "context" "net" "os" "time" "github.com/zeebo/admission/admmonkit" "github.com/zeebo/admission/admproto" "go.uber.org/zap" monkit "gopkg.in/spacemonkeygo/monkit.v2" ) const ( // DefaultInterval is the ...
package benchutil import ( "fmt" "github.com/graphql-go/graphql" ) func WideSchemaWithXFieldsAndYItems(x int, y int) graphql.Schema { wide := graphql.NewObject(graphql.ObjectConfig{ Name: "Wide", Description: "An object", Fields: generateXWideFields(x), }) queryType := graphql.NewObject(graph...
package aoc2015 import ( "fmt" "image" "strconv" "strings" aoc "github.com/janreggie/aoc/internal" "github.com/pkg/errors" ) // lights represents a 1000x1000 grid of lights (Day 6) type lights [1000][1000]struct { status bool // on/off? brightness uint64 } // turnOn turns on all points in a rectangular ...
package main import ( "crypto/aes" "encoding/hex" "errors" "fmt" "net/http" "time" ) func generatePadding(numBytes int) []byte { padding := make([]byte, aes.BlockSize) for i := 0; i < numBytes; i++ { padding[aes.BlockSize-i-1] = byte(numBytes) } return padding } func xorSlices(a, b []byte) ([]byte, erro...
package more import ( "fmt" "strings" "golang.org/x/tour/pic" "golang.org/x/tour/wc" ) //DoTest DoTest func DoTest() { froballTest() } //Go 函数可以是一个闭包。闭包是一个函数值,它引用了其函数体之外的变量。该函数可以访问并赋予其引用的变量的值,换句话说,该函数被“绑定”在了这些变量上。 func fibonacci() func() int { x, y := 0, 1 return func() int { x, y = y, x+y return y } } ...
package seev import ( "encoding/xml" "github.com/thought-machine/finance-messaging/iso20022" ) type Document04000101 struct { XMLName xml.Name `xml:"urn:iso:std:iso:20022:tech:xsd:seev.040.001.01 Document"` Message *CorporateActionInstructionCancellationRequestV01 `xml:"C...
package controllers import ( "context" "fmt" "strconv" "time" "github.com/pkg/errors" "golang.org/x/sync/errgroup" "github.com/containers-ai/alameda/datahub/pkg/entities" "github.com/containers-ai/alameda/internal/pkg/database/prometheus" "github.com/containers-ai/alameda/internal/pkg/message-queue/kafka" ...
package gotf import "github.com/kniren/gota/dataframe" type difficultyType uint8 var difficultyMap = map[string]int{ "Access Road/Trail": 1, "Easy / Green Circle": 2, "Intermediate / Blue Square": 3, "Advanced: Grade 4": 4, "Very Diffi...
package settings // ApplicationSettings db情報など type ApplicationSettings struct { DB string Cache string IsDebug bool } // NewApplicationSettings 設定項目を含めたstructの作成 func NewApplicationSettings() *ApplicationSettings { // flagかファイルなどから取ってくると良いかもね return &ApplicationSettings{ DB: "mysql", Cache: "m...
package stateful import ( "context" "fmt" aliceapi "github.com/yandex-cloud/examples/serverless/alice-shareable-todolist/app/alice/api" "github.com/yandex-cloud/examples/serverless/alice-shareable-todolist/app/errors" "github.com/yandex-cloud/examples/serverless/alice-shareable-todolist/app/model" "github.com/y...
package main import "fmt" func main() { defer fmt.Println("mine") defer fmt.Println("is") fmt.Println("world") }
package main import ( "fmt" "net" "os" "time" ) const timeFormat = "15:04:05.999" func main() { address := os.Args[1] last := "" ticker := time.NewTicker(time.Millisecond * 100) t := time.Now() fmt.Printf("%s: === %s\n", t.Format(timeFormat), address) for { conn, err := net.DialTimeout("tcp", address, ti...
package planets import ( "context" "errors" ) type SuccessRepository struct { } func (r SuccessRepository) Add(ctx context.Context, planet Planet) error { return nil } func (r SuccessRepository) GetAll(ctx context.Context) ([]Planet, error) { return []Planet{{"XXXX", "Tatooine", "Hot", "Desert", 5}}, nil } fun...
package main import ( "strings" ) func recalcPars() { for id, gld := range glds { for _, elem := range starters { gld.Finished[strings.ToLower(elem)] = empty{} } changed := -1 for changed != 0 { changed = 0 newfinished := make(map[string]empty) for _, comb := range gld.Combos { // Lowercase...
package logging import ( "fmt" "github.com/feast-dev/feast/go/internal/feast/model" "github.com/feast-dev/feast/go/protos/feast/types" ) type FeatureServiceSchema struct { JoinKeys []string Features []string RequestData []string JoinKeysTypes map[string]types.ValueType_Enum FeaturesTypes map[str...
package wiki import ( "net/http" ) type wikiView struct { } func NewWikiView() *wikiView { v := new(wikiView) return v } func (v *wikiView) Render(responseWriter http.ResponseWriter) error { var err error _, err = responseWriter.Write([]byte("<html><head></head><body>")) if err != nil { return err } _, er...
package main import ( "fmt" ) func twoSum(numbers []int, target int) []int { for i := 0; i < len(numbers)-1; i++ { j := i + 1 for j < len(numbers) { if numbers[i]+numbers[j] < target { j++ } else if numbers[i]+numbers[j] == target { return []int{i + 1, j + 1} } else { break } } } re...
package main import ( "fmt" ) func somar(x int, y int) int { return x + y } func main() { x := 10 y:= 32 fmt.Println("Somando", x, "+", y, "=", somar(x, y)) }
package localdriver_test import ( "context" "errors" "fmt" "io/ioutil" "os" "path/filepath" "code.cloudfoundry.org/dockerdriver" "code.cloudfoundry.org/dockerdriver/driverhttp" dockerdriverutils "code.cloudfoundry.org/dockerdriver/utils" "code.cloudfoundry.org/goshims/filepathshim" "code.cloudfoundry.org/g...
package vo import ( "strings" "github.com/mirzaakhena/danarisan/application/apperror" ) type UndanganState string const ( NganggurUndanganStateEnum UndanganState = "NGANGGUR" DitawarkanUndanganStateEnum UndanganState = "DITAWARKAN" TerimaUndanganStateEnum UndanganState = "TERIMA" TolakUndanganStateEnum ...
package main import ( "fmt" ) func GetMax(first int, second int) int { max := first if max < second { max = second } return max } func LongestIncreasingSequence(numbers []int) (int, []int) { if len(numbers) == 0 { return 0,nil } status := make([]int, len(numbers)) for i := 0; i < len(numbers); i++ { ...
package gosseract_test import "github.com/otiai10/gosseract" import "testing" import "fmt" import "os" func assert(t *testing.T, actual interface{}, expected interface{}) { if expected != actual { fmt.Printf("`%+v` expected, but `%+v` actual.\n", expected, actual) t.Fail() os.Exit(1) } } func TestGosseract_G...
package gofiler import ( "fmt" "regexp" "strconv" "strings" ) // Profile maps unkown OCR token in a profiled document to the // according interpreations of the profiler. type Profile map[string]Interpretation // GlobalHistPatterns returns all global historical patterns with // their according probabilities. func...
package httputils import ( "bytes" "crypto/tls" "fmt" "io" "net" "net/http" "net/url" "os" "path" "stayreal/osutils" "strconv" "strings" "time" "github.com/gorilla/mux" ftp "github.com/jlaffaye/ftp" "github.com/urfave/negroni" ) func SimpleFileServer(listen, root string) { m := mux.NewRouter() m.Pa...
package mmysql import ( "bytes" "context" sql2 "database/sql" "fmt" "github.com/jinzhu/gorm" _ "github.com/jinzhu/gorm/dialects/mysql" cat2 "github.com/owenliang/myf-go-cat/cat" "github.com/owenliang/myf-go/client/cat" "reflect" "strings" "time" ) // 单个Mysql连接 type DBConn struct { gorm *gorm.DB tx bool...
package hydrator import ( "testing" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/mock" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "github.com/argoproj/argo/persist/sqldb" sqldbmocks "github.com/argoproj/argo/persist/sqldb/mocks" wfv1 "github.com/argoproj/argo/pkg/apis/workflow/v1alpha1...
// Create a program that uses a switch statement with the switch expression specified as a variable of TYPE string with the IDENTIFIER “favSport”. package main import "fmt" func main() { favSport := "Dota" switch favSport { case "Dota": fmt.Println("Go to download DOTA on Steam") case "Soccer": fmt.Println(...
/* Copyright 2023 The KubeVela Authors. 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, so...
package main import "fmt" import "crypto/sha256" import "math/rand" import "encoding/binary" import "bytes" import "time" import "os" import "net" import "bufio" /*import "math/big" import "crypto/elliptic" import "crypto/ecdsa" import "io/ioutil"*/ const hashSize = 32 //blocks, chains type block ...
package config import ( "time" ) // 数据库连接参数 type ConnParam struct { Driver string Host string Port string Username string Password string Database string } // 模型基础 type Model struct { ID uint `gorm:"primarykey" json:"id"` CreatedAt time.Time `json:"created_at"` UpdatedAt time.Time `js...
// GENERATED BY THE COMMAND ABOVE; DO NOT EDIT // This file was generated by swaggo/swag at // 2018-09-01 21:58:06.43941915 +0530 IST m=+0.045875770 package docs import ( "github.com/swaggo/swag" ) var doc = `{ "swagger": "2.0", "info": { "contact": {}, "license": {} }, "paths": { ...
package fishbone import ( "context" "fmt" "strings" "testing" "github.com/MakeNowJust/heredoc/v2" "go.mercari.io/datastore/v2" "go.mercari.io/datastore/v2/dsmiddleware/dslog" "go.mercari.io/datastore/v2/internal/testutils" "google.golang.org/api/iterator" ) func TestFishBone_QueryWithoutTx(t *testing.T) { ...
package main import ( "encoding/json" "fmt" "log" "net/http" "github.com/gorilla/mux" ) type Employee struct { ID string `json:"id"` Isbn string `json:"isbn"` Firstname string `json:"fname"` Lastname string `json:"lname"` } var employees []Employee func getEmployees(w http...
package pgsql import ( "database/sql" "time" ) // TimetzToString returns an sql.Scanner that converts a PostgreSQL timetz into a Go string and sets it to val. func TimetzToString(val *string) sql.Scanner { return timetzToString{val: val} } // TimetzToByteSlice returns an sql.Scanner that converts a PostgreSQL tim...
package cmd import ( "os" "fmt" gdn "code.cloudfoundry.org/cfdev/garden" "code.cloudfoundry.org/garden/client" "code.cloudfoundry.org/garden/client/connection" "code.cloudfoundry.org/cfdev/shell" "code.cloudfoundry.org/cfdev/config" ) type Bosh struct{ Exit chan struct{} UI UI Config config.Config } func(b...
package core import ( "Perekoter/controllers" "net/http" "strings" "github.com/gin-gonic/gin" ) func GetRouter() *gin.Engine { gin.SetMode(gin.ReleaseMode) router := gin.Default() router.LoadHTMLGlob("client/page.html") router.Static("/src", "./client/front/files/") router.Static("/covers", "./covers/") ...
package main import ( "fmt" "io/ioutil" "regexp" "runtime" "strconv" "strings" "time" ) func checkErr(error error) { if error != nil { panic(error) } } func getFileContent(path string) string { _, currentPath, _, _ := runtime.Caller(1) dat, err := ioutil.ReadFile(currentPath + path) checkErr(err) re...
package main import ( "context" "github.com/saskaradit/kafka-go-consume-produce.git/messagebus" ) func main() { // Creates a new context ctx := context.Background() // produce messages in a new go routine // so that produce and consume does not block go messagebus.Produce(ctx) messagebus.Consume(ctx) }
package main import ( "bufio" "fmt" "io" "os" "sort" "strconv" ) func ReadInput(r io.Reader) ([]int, error) { scanner := bufio.NewScanner(r) scanner.Split(bufio.ScanWords) var result []int for scanner.Scan() { x, err := strconv.Atoi(scanner.Text()) if err != nil { return result, err } result = a...
package converter import ( "testing" ) func TestInput1ShouldGetI(t *testing.T) { result := roman(1) errorCheck(t, result, "I") } func TestInput3ShoudGetIII(t *testing.T) { result := roman(3) errorCheck(t, result, "III") } func Test4ShouldGetIX(t *testing.T) { result := roman(4) errorCheck(t, result, "IV") } ...
package main import ( "math" ) type RunningLight struct { Effect Position float64 IntervalPar float64 delta float64 Bounce bool Direction bool ModePar int } func NewRunningLight(disp Display) *RunningLight { ef := NewEffect(disp, 0.5, 0.0) r := &RunningLight{ Effect: ef, Inter...
package gateway import ( "fmt" log "github.com/sirupsen/logrus" ) // Hub maintains the set of active clients and broadcasts messages to the // clients. type Hub struct { // Registered clients. clients map[string]*Client // Register requests from the clients. register chan *Client // Unregister requests from...
// SPDX-License-Identifier: Unlicense OR MIT // Package system contains events usually handled at the top-level // program level. package system import ( "image" "time" "github.com/gop9/olt/gio/op" "github.com/gop9/olt/gio/unit" ) // A FrameEvent asks for a new frame in the form of a list of // operations. type...
package 二叉树 import "github.com/Lxy417165709/LeetCode-Golang/新刷题/util/math_util" // maxDepth 获取二叉树深度。 func maxDepth(root *TreeNode) int { if root == nil { return 0 } return math_util.Max(maxDepth(root.Left), maxDepth(root.Right)) + 1 }
package main import ( "crypto/md5" "fmt" ) func main() { src := "abcde" h := md5.New() h.Write([]byte(src)) degist := h.Sum(nil) fmt.Println(degist) fmt.Println(len(degist)) fmt.Println(string(degist)) d := md5.New() d.Write(degist) s := d.Sum(nil) fmt.Println(s) fmt.Println(len(s)) fmt.Println(string...
package test import ( "time" ) type LampController struct { currentLamp *Lamp } //var currentLamp *Lamp func (this *LampController) Init() { this.currentLamp = LampMap["S2N"] this.currentLamp.light() //每隔10s就变换红绿灯 ticker := time.NewTicker(time.Second * 10) go func() { for _ = range ticker.C { this.curr...
package native import ( "errors" "runtime" "github.com/toy80/debug" ) func init() { // many system call have poor multi-thread support, we stick the "main" // goroutine to the thread that invoke init functions runtime.LockOSThread() initNative() } const ( WinHintResizable = 1 << iota WinHintFullScreen Wi...
package tree import ( "fmt" ) // Accept func ExampleAcceptDuplicates() { tree := NewTree(2, false) for i := 1; i < 7; i++ { tree.AddLeaf(i) } for i := 1; i < 7; i++ { tree.AddLeaf(i) } fmt.Println(tree) // Output: // 0 // 0/0 // 0/0/0 // 0/0/0/0 // 0/0/0/0/0/1 // 0/0/0/0/1/2 // 0/0/0/1 // 0/0/0/1/...
package stringunpack import ( "fmt" "strings" ) const ( symTypeUndefined = iota symTypeChar symTypeNum symTypeBackslash ) const ( symZero = 48 symNine = symZero + 9 ) var ( builder strings.Builder currentSymbol, nextPrintSymbol, prevSymbol rune currentPosition...
package main import ( "encoding/json" "errors" "fmt" "io/ioutil" "log" "net" "net/http" "os" "regexp" "runtime" "strings" "time" "github.com/gorilla/mux" ) const AllMatches = -1 const AutoRuVendorsUrl = "http://moto.auto.ru/motorcycle/" const AvitoMoscowUrl = "https://www.avito.ru/moskva/mototsikly_i_m...
package main import ( "fmt" ) func fibTailRec(n int) int { var accumulator func(index int, last int, previousToLast int) int accumulator = func(index int, last int, previousToLast int) int { if index >= n { return last } else { return accumulator(index+1, last+previousToLast, last) } } if n <= 2 {...
package datacenter import ( "reflect" "testing" "github.com/ethereum/go-ethereum/common" ) func TestUploadToBigDataCenter(t *testing.T) { type args struct { fileBytes []byte } tests := []struct { name string args args wantErr bool }{ // TODO: Add test cases. {"", args{nil}, true}, } for _,...
package runit import ( "fmt" "io/ioutil" "os" "path/filepath" "reflect" "strings" "testing" . "github.com/anthonybishopric/gotcha" "gopkg.in/yaml.v2" ) func fakeTemplate(restartPolicy RestartPolicy) map[string]ServiceTemplate { return map[string]ServiceTemplate{"foo": { Run: []string{"foo", "on...
package leetcode func preorderTraversal(root *TreeNode) []int { if root == nil { return []int{} } return deepinM(root) } func deepinM(root *TreeNode) []int { if root == nil { return []int{} } num := make([]int, 0) num = append(num, root.Val) if root.Left != nil { num = append(num, deepinM(root.Left)...)...
package controllers import ( "encoding/json" "net/http" "github.com/raykanavheti/LetsworkBackend/controllers/util" "github.com/raykanavheti/LetsworkBackend/models" ) //SkillController interface type SkillController struct{} // CreateSkills creates a new Skill for a skill func (catCntrl *SkillController) CreateSk...
package main import ( "github.com/hajimehoshi/ebiten/v2" "github.com/justjoeyuk/chip8-go/pkg/chip8" "github.com/justjoeyuk/chip8-go/pkg/game" "io/ioutil" "os" ) func main() { if len(os.Args) < 2 { panic("Not enough arguments. Please select a ROM to load.") } ebiten.SetWindowSize(640, 320) ebiten.SetWindow...
package ecr import ( "encoding/base64" "strings" "github.com/aws/aws-sdk-go/aws" "github.com/aws/aws-sdk-go/aws/session" "github.com/aws/aws-sdk-go/service/ecr" "github.com/aws/aws-sdk-go/service/ecr/ecriface" ) // Registry provides the ECR API client to make ECR operational calls, as well as, credentials // f...
package main import ( "bytes" "context" "fmt" "io" "net/http" "net/url" "os" "strconv" "strings" "time" "github.com/Comcast/kuberhealthy/v2/pkg/checks/external/checkclient" "github.com/jenkins-x/jx-helpers/v3/pkg/kube/services" "github.com/jenkins-x/jx-helpers/v3/pkg/stringhelpers" "github.com/jenkins-x...
package api import ( "net/url" "github.com/pkg/errors" ) // Validate validates the config file is correct func (c *Config) Validate() error { if _, err := url.ParseRequestURI(c.Source.Repo.Url); err != nil { return errors.Errorf(`"source.repo.url" should be a valid URL: %v`, err) } if _, err := url.ParseReque...
package configdb import ( "github.com/jasonish/evebox/core" "github.com/stretchr/testify/assert" "testing" ) func Setup(t *testing.T) *UserStore { db, err := NewConfigDB(":memory:") if err != nil { t.Fatal(err) } userstore := &UserStore{db.DB} return userstore } func TestUserNotExist(t *testing.T) { user...
package main import ( "fmt" ) func main() { // Get the directory from the user fmt.Print("Enter the full path of the parent directory where you want to create your new directories: ") var userDir string fmt.Scanf("%s", &userDir) // Prompt the user to enter how many dirs they want to make f...
package store import ( "fmt" "os" "testing" "time" _ "github.com/mattn/go-sqlite3" "github.com/stretchr/testify/assert" ) func TestNewStore(t *testing.T) { assert := assert.New(t) testDir := fmt.Sprintf("test_dir_%x", time.Now().Unix()) err := os.MkdirAll(testDir, os.ModePerm) assert.Nil(err) s, err := ...
package dbsrv import ( "gopkg.in/doug-martin/goqu.v3" "github.com/empirefox/esecend/cerr" "github.com/empirefox/esecend/front" "github.com/empirefox/esecend/models" "github.com/empirefox/reform" ) func (dbs *DbService) EvalSave( order *front.Order, ra *uint, tokUsr *models.User, orderId, itemId uint, payload *...
package basic import ( "errors" "fmt" "log" ) var errv = errors.New("errors.New 提示信息") type TYPE1 struct { x, y int } /* 定义了自己的errorr类型 */ func (TYPE1) Error() string { return "TYPE1 ERROR" } func div(x int, y int) (int, error) { if y == 0 { /* 对自己error类型的引用 */ return 0, TYPE1{x, y} } return x ...
package main import ( "fmt" ) func exp1() { done := make(chan bool) mapper := make(map[int]int) //mutex := sync.Mutex{} go func() { //mutex.Lock() mapper[1] = 1 //mutex.Unlock() done <- true }() //mutex.Lock() mapper[2] = 2 //mutex.Unlock() <-done for k, v := range mapper { fmt.Printf("k: %v v: ...
package signers import ( "fmt" "sync" "github.com/choria-io/aaasvc/auditors" "github.com/choria-io/aaasvc/authorizers" "github.com/choria-io/aaasvc/api/gen/models" "github.com/choria-io/aaasvc/api/gen/restapi/operations" "github.com/go-openapi/runtime/middleware" ) var signer Signer var mu = &sync.Mutex{} /...
package dynamo import ( "github.com/aws/aws-sdk-go/service/dynamodb" "github.com/aws/aws-sdk-go/service/dynamodb/dynamodbattribute" ) type Decoder struct { Decoder *dynamodbattribute.Decoder } func (c Decoder) UnmarshalList(l []*dynamodb.AttributeValue, out interface{}) error { return c.Decoder.Decode(&dynamodb....
package edit import ( "bytes" "testing" "github.com/MakeNowJust/heredoc" "github.com/cli/cli/pkg/iostreams" "github.com/heaths/gh-label/internal/github" "github.com/heaths/gh-label/internal/options" ) func Test_edit(t *testing.T) { tests := []struct { name string rename string tty bool want str...
package middleware import ( "net/http" md "github.com/ebikode/eLearning-core/model" tr "github.com/ebikode/eLearning-core/translation" ut "github.com/ebikode/eLearning-core/utils" ) // Check if Admin IP has changee func CheckAdminIPAddress() func(next http.Handler) http.Handler { return func(next http.Handler)...
package redis import ( "time" "github.com/go-redis/redis" ) // RClient ... type RClient struct { client *redis.Client } // NewClient .... func NewClient(addr string) (*RClient, error) { client := redis.NewClient(&redis.Options{ Addr: addr, Password: "", // no password set DB: 0, // use default ...
package config import ( "encoding/json" "io/ioutil" "os" "reflect" "testing" "github.com/SIGBlockchain/project_aurum/internal/constants" ) func TestLoadConfigurationFile(t *testing.T) { cfg := Config{1, 20, "5000", "40s", false, ""} marshalledCfg, err := json.Marshal(cfg) if err != nil { t.Errorf("failed ...
package config import ( "fmt" "github.com/spf13/viper" "os" ) func LoadConfig() { viper.SetConfigType("yaml") configFile := "./config.yaml" if len(os.Getenv("configFile")) != 0{ configFile = os.Getenv("configFile") } viper.SetConfigFile(configFile) err := viper.ReadInConfig() if err != nil { panic(fmt...
package main import ( "fmt" "os" "strconv" "strings" "gotrading/core" "gotrading/exchanges" "gotrading/graph" "gotrading/reporting" "gotrading/strategies/arbitrage" "github.com/spf13/viper" ) func main() { viper.SetConfigName("config") viper.AddConfigPath(".") err := viper.ReadInConfig() if err != n...
adityabhasin@Adityas-MacBook-Pro.local.2917
package main import ( "bufio" "fmt" "os" "strconv" "strings" ) func main() { // 소지금액 입력 받는 기능 fmt.Println("소지금액 입력.") reader := bufio.NewReader(os.Stdin) str, _ := reader.ReadString('\n') str = strings.TrimSpace(str) cost, _ := strconv.Atoi(str) // 메뉴 보여주는 기능 fmt.Println("------------------------------"...
package gov import ( sdk "github.com/irisnet/irishub/types" ) type ProposalResult string const ( PASS ProposalResult = "pass" REJECT ProposalResult = "reject" REJECTVETO ProposalResult = "reject-veto" ) // validatorGovInfo used for tallying type validatorGovInfo struct { Address sdk.ValAddress // add...
/* Package datastore has utility functions to use with queries. */ package datastore import ( "google.golang.org/appengine/datastore" ) // FilterMulti applays multiple filter operations on same property. func FilterMulti(q *datastore.Query, str string, slc interface{}) *datastore.Query { switch s := slc.(type) { c...
package models type Topic struct { ID string `json:"id"` AuthorID string `json:"author_id"` Tab *string `json:"tab"` Content *string `json:"content"` Title string `json:"title"` LastReplyAt *string `json:"last_reply_at"` Good *bool `json:"good"` Top *bool `js...
// Copyright 2019-present PingCAP, 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 agr...
package pgsql import ( "testing" ) func TestBool(t *testing.T) { testlist2{{ data: []testdata{ {input: bool(true), output: bool(true)}, {input: bool(false), output: bool(false)}, }, }, { data: []testdata{ {input: string("true"), output: string(`true`)}, {input: string("false"), output: string(`fa...
package main import "fmt" // ------------------------- Arrival ------------------------- type Arrival struct { StationName string TimeStamp int } func NewArrival(stationName string, timeStamp int) *Arrival { return &Arrival{stationName, timeStamp} } // ------------------------- Trip ------------------------- t...
package contacts import ( "encoding/xml" . "gopkg.in/check.v1" "regexp" "testing" ) type ErrorSuite struct{} var _ = Suite(new(ErrorSuite)) func TestError(t *testing.T) { TestingT(t) } func (s *ErrorSuite) TestMarshal(c *C) { resp := new(jsonErrorResponse) resp.Errors = []*jsonError{{ Domain: "GDat...
package main import ( "fmt" "runtime" "sync" ) const MAX int = 10 var ( counter int = 0 wg sync.WaitGroup ) func Count() { defer wg.Done() value := counter runtime.Gosched() value ++ counter = value } func main() { wg.Add(MAX) for i:=0; i<MAX; i++ { go Count...
package main import ( "go/ast" "go/parser" "go/token" "io/ioutil" "log" ) func main() { src, err := ioutil.ReadFile("main.go") if err != nil{ log.Fatal(err) } fset := token.NewFileSet() file, err := parser.ParseFile(fset, "main.go", src, 0) if err != nil { log.Fatal(err) } ast.Print(fset, file) }
package main import "fmt" // checkError checks for an error and panics (stops execution) // if one is found. func checkError(e error) { if e != nil { panic(e) } } func printHeader(fd FileData) { smallWord, smallWordCount, err := fd.GetMostFrequentSmallWord() checkError(err) medWord, medWordCount, err := fd.Ge...
package context import "context" type key string const ( timeoutKey key = "TimeoutKey" deadlineKey key = "DeadlineKey" ) //Setup 함수는 몇 가지 값을 설정한다. func Setup(ctx context.Context) context.Context { ctx = context.WithValue(ctx, timeoutKey, "timeout exceeded") ctx = context.WithValue(ctx, deadlineKey, "deadline e...
package main import ( "fmt" "log" "os" "plugin" "github.com/tevino/go-plugin-demo/pinger" ) func main() { if len(os.Args) < 2 { fmt.Printf("Usage: %s [plugin binary]\n", os.Args[0]) os.Exit(1) } pluginPath := os.Args[1] // load plugin p, err := plugin.Open(pluginPath) if err != nil { log.Fatalf("Er...
package awskinesis import ( . "github.com/onsi/ginkgo" . "github.com/onsi/gomega" "github.com/batchcorp/plumber/types" "github.com/batchcorp/plumber/validate" "github.com/batchcorp/plumber-schemas/build/go/protos/args" "github.com/batchcorp/plumber-schemas/build/go/protos/opts" ) var _ = Describe("AWS Kinesis...
package datastore import ( "context" "database/sql" "time" "github.com/amanbolat/furutsu/internal/discount" "github.com/georgysavva/scany/pgxscan" ) type DbDiscount struct { Id string Name string Rule map[string]interface{} Percent int CreatedAt time.Time UpdatedAt time.Time } func (d ...
package database import ( "fmt" "strings" "unicode" "unicode/utf8" ) // Pos represents a byte position in the original input text from which // this template was parsed. //type Pos int type ItemType int // Item represents a token or text string returned from the scanner. type Item struct { Typ ItemType // The...
package main import ( "bufio" "fmt" "os" "sort" "strconv" "strings" ) func main() { filePath := os.Args[1] file, _ := os.Open(filePath) defer file.Close() reader := bufio.NewReader(file) scanner := bufio.NewScanner(reader) scanner.Split(bufio.ScanLines) total := 0 for scanner.Scan() { //parse o...
package main import ( "bufio" "log" "os" "strings" "sync" "github.com/gocql/gocql" "github.com/google/flatbuffers/go" cli "gopkg.in/urfave/cli.v1" "github.com/transactional-cloud-serving-benchmark/tcsb/serialization_util" "github.com/transactional-cloud-serving-benchmark/tcsb/serialized_messages" ) func m...
package main import ( "fmt" "reflect" ) // http://techblog.raccoon.ne.jp/archives/38280316.html func main() { b := true fmt.Println(reflect.TypeOf(b)) ui8 := uint8(100) fmt.Println(reflect.TypeOf(ui8)) n := 100 fmt.Println(reflect.TypeOf(n)) c := 'A' fmt.Println(reflect.TypeOf(c)) r := 'あ' fmt.Println...
// Copyright 2018 Diego Bernardes. All rights reserved. // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. package repository type errMemory struct { message string alreadyExists bool notFound bool } func (e *errMemory) Error() string { return ...
package matching_test import ( "testing" . "github.com/onsi/ginkgo" "github.com/kumahq/kuma/pkg/test" "github.com/kumahq/kuma/test/e2e/matching" "github.com/kumahq/kuma/test/framework" ) var _ = Describe("Test Matching on Universal", matching.Universal) func TestE2EMatching(t *testing.T) { if framework.IsK8s...
/* Package grayscale8 implements DVID support for 8-bit grayscale images. It simply wraps the voxels package, setting NumChannels (1) and BytesPerVoxel(1). */ package grayscale8 import ( "github.com/janelia-flyem/dvid/datastore" "github.com/janelia-flyem/dvid/datatype/voxels" "github.com/janelia-flyem/dvid/dvid"...