text
stringlengths
11
4.05M
package packagen import ( "bytes" "io/ioutil" "path/filepath" "testing" qt "github.com/frankban/quicktest" ) func TestExtendStruct(t *testing.T) { for _, tc := range []ExtendOption{ { SrcPkg: "./testdata/extend/src", Src: "Data", DstPkg: "./testdata/extend/dst", Dst: ...
package main import ( "bytes" "flag" "io/ioutil" "log" "os" "path/filepath" "text/template" ) func main() { var ( flRoot = flag.String( "root", "", "Package the entire contents of the directory tree at root-path, typically a destination root created by xcodebuild(1).", ) flIdentifier = flag.Str...
package main import "fmt" func main() { var nums []int = []int{3, 2, 4} results := twoSumBest(nums, 6) fmt.Println(results) } func twoSumBest(nums []int, target int) []int { if len(nums) < 2 { return nil } var m map[int]int = make(map[int]int, len(nums)) for i, v := range nums { if j, ok := m[v]; ok { ...
/** * @Author: XiaoLongBao * @Description: 对interface的了解学习 * @File: interface_test * @Program: hello world * @Date: 2021-03-17 09:27 */ package _interface import ( "reflect" "testing" ) /* * Go interface 的一个 “坑” 及原理分析 https://mp.weixin.qq.com/s/vNACbdSDxC9S0LOAr7ngLQ * 针对 interface 使用疑惑。 */ // todo: 事例1 ...
package main import ( "context" "errors" "flag" "fmt" "net/url" "os" "sync" "github.com/folbricht/desync" ) const cacheUsage = `desync cache [options] <caibx> [<caibx>..] Read chunk IDs in caibx files from one or more stores without creating a blob. Can be used to pre-populate a local cache.` func cache(ct...
package model import ( "database/sql" "strconv" "time" "github.com/tribalmedia/vista/setting" ) //Team is ... type Team struct { ID int `db:"id"` Name string `db:"name"` PictureURL sql.NullString `db:"picture_url"` Description sql.NullString `db:"description"` Created ...
package json import ( "encoding/json" "fmt" "io/ioutil" "log" ) type Foo struct { Name string Body string Time int64 } func WriteJsonToFile() { filename := "a_foo.json" fooBar := Foo{"Bar", "Hello", 1294706395881547000} fmt.Println("\nWriting json ", fooBar, "to file: ", filename) marshalledFooBar, err :...
// Copyright 2021 The Cockroach Authors. // // Use of this software is governed by the Business Source License // included in the file licenses/BSL.txt. // // As of the Change Date specified in that file, in accordance with // the Business Source License, use of this software will be governed // by the Apache License, ...
package p2pv2 import ( "context" "errors" "fmt" "github.com/golang/protobuf/proto" prom "github.com/prometheus/client_golang/prometheus" "github.com/xuperchain/xupercore/lib/metrics" "time" "github.com/xuperchain/xupercore/kernel/common/xaddress" knet "github.com/xuperchain/xupercore/kernel/network" "github...
package server import ( "context" "github.com/parulraich/grpcAssignment/calculatorpb/proto" "io" "log" "time" ) type CalculatorHandler struct{} func (ch *CalculatorHandler) Square(ctx context.Context, request *calculatorpb.CalculatorRequest) (*calculatorpb.CalculatorResponse, error) { response := &calculatorpb...
// This Source Code Form is subject to the terms of the MIT License. // If a copy of the MIT License was not distributed with this // file, you can obtain one at https://opensource.org/licenses/MIT. // // Copyright (c) DUSK NETWORK. All rights reserved. package legacy_test import ( "context" "encoding/binary" "os"...
package main import ( "bufio" "fmt" "io" "math" "os" "strconv" "strings" ) func main() { fmt.Printf("The total meal cost is %d dollars.\n", response(os.Stdin)) } func response(input io.Reader) int64 { in := bufio.NewReader(input) mealC, _ := in.ReadString('\n') tipP, _ := in.ReadString('\n') taxP, _ := i...
// Copyright (c) 2017 Kuguar <licenses@kuguar.io> Author: Adrian P.K. <apk@kuguar.io> // // MIT License // // Permission is hereby granted, free of charge, to any person obtaining // a copy of this software and associated documentation files (the // "Software"), to deal in the Software without restriction, including //...
package entity import ( "time" ) const ( ATAd = 1 // 广告图片 ATHk = 2 // 关键词 ATSg = 3 // 标语 ) //应用参数 type AppParams struct { Id int64 `json:"id"` Name string `json:"name"` Value string `json:"value"` Type int `json:"type"` Data string `json:"data"` //扩展信息 CreatedAt time.Time `xorm:"created" json:"created...
package main import ( "bufio" "io" "os" ) const ( null = byte('\000') ) func collectFiles(filepath string) ([]string, error) { fin := os.Stdin if filepath != "-" { // 从其他文件读取 f, err := os.Open(filepath) if err != nil { return nil, err } fin = f } return readFiles(fin) } func readFiles(reader io...
package v3 func init() { registerXform(selectToIndexScan{}) } type selectToIndexScan struct { xformImplementation } func (selectToIndexScan) id() xformID { return xformSelectToIndexScanID } func (selectToIndexScan) pattern() *expr { return &expr{ op: selectOp, children: []*expr{ &expr{ // left op: sc...
package main import ( "bufio" "fmt" "os" "strconv" "strings" ) //func main() { // var nums []int // input := bufio.NewScanner(os.Stdin) // input.Scan() // //str=strings.Split(input.Text(),",") // str := strings.ReplaceAll(input.Text(), " ", "") // newstr := strings.ReplaceAll(str, ",", "") // //fmt.Printf("%c",n...
package main import ( "bytes" "fmt" "io/ioutil" "log" "os" "github.com/BurntSushi/toml" "github.com/spf13/cobra" "github.com/HalalChain/qitmeer-cli/rpc/client" ) // Config cli config file type Config struct { ConfigFile string SimNet bool TestNet bool RPC *client.Config } var cfg = &Config{ RPC: &c...
// Copyright (C) 2017 Google 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 t...
package main import "fmt" func main() { //i := 0 //j := 1 flag := true k := 1 ^ 1 fmt.Println(k) fmt.Println(flag) }
package set type Elem int // Set implements a basic set data structure. type Set struct { data map[Elem]struct{} } func (s *Set) init() { if s.data == nil { s.data = make(map[Elem]struct{}) } } // Len returns the number of elements in the set. func (s *Set) Len() int { return len(s.data) } // Add adds the el...
package email import ( "fmt" "regexp" "strings" ) var ( isHTMLRgx = regexp.MustCompile(`.*<html.*>.*`) lineBreak = "\r\n" ) type EmailMessage struct { Recipients []string BCC []string CC []string SenderEmail string Subject string Content string } func (msg *EmailMessage) GetCont...
package peer import ( "fmt" "math/rand" "os" "sync" "time" "code.cloudfoundry.org/lager" ) type peerClient interface { ReadLeader(logger lager.Logger, leader string) ([]Glimpse, error) PostAndReadSnapshot(logger lager.Logger, host string) ([]Glimpse, error) } type Heartbeat struct { Leader string P...
package editorapi import ( "editorApi/init/mgdb" "editorApi/init/qmlog" "editorApi/mdbmodel/editor" "fmt" "runtime" "sync" "time" "github.com/mongodb/mongo-go-driver/mongo" "go.mongodb.org/mongo-driver/bson" ) var toClient *mongo.Client var ( onLineJobsCollection string catalogCollection string...
// Copyright 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved. // // Licensed under the Apache License, Version 2.0 (the "License"). You // may not use this file except in compliance with the License. A copy of // the License is located at // // http://aws.amazon.com/apache2.0/ // // or in the "license" fil...
// Copyright 2020 The Cockroach Authors. // // Use of this software is governed by the Business Source License // included in the file licenses/BSL.txt. // // As of the Change Date specified in that file, in accordance with // the Business Source License, use of this software will be governed // by the Apache License, ...
package headlysis type Output struct { Headlysis []UrlAnalysisOutput `json:"headlysis"` } type UrlAnalysisOutput struct { Url string `json:"target_url"` PresentHeaders []PresentHeader `json:"present_security_headers"` NotPresentHeaders []NotPresentHeader `json:"not_present_security...
package static // sheetFileName: cfg_battle_npc.xlsx const ( BattleNpcTypeSystem = 1 // 系统NPC BattleNpcTypePlayer = 2 // 玩家NPC )
package parser import "fmt" type TypeLit struct { pos posRange } func (t TypeLit) Pos() Position { return t.pos } func (t TypeLit) String() string { return "Type" } type StructLit struct { pos posRange } func (t StructLit) Pos() Position { return t.pos } func (t StructLit) String() string { return "Struct" } ...
package routes import ( "bytes" "encoding/json" "github.com/labstack/echo/v4" "github.com/labstack/echo/v4/middleware" "hero/configs" "hero/pkg/db/mysql" "hero/pkg/logger" "hero/utils" "io/ioutil" "os" ) func Run() error { port := configs.Get("server.port") e := echo.New() e.Use(middleware.Logger()) e....
package main import ( "fmt" "encoding/csv" "os" "database/sql" _ "github.com/go-sql-driver/mysql" "strconv" ) type Usermove struct { utctime int `json:"utctime"` idfa string `json:"idfa"` geohash string `json:"geohash"` latitude float64 `json:"latitude"` longitude float64 `json:"longitude"` horizontal flo...
package dao import ( "errors" "go-blogs-webapp/main/models" "io/ioutil" "log" "time" mgo "gopkg.in/mgo.v2" "gopkg.in/mgo.v2/bson" ) type BlogsDAO struct { Server string Database string } var db *mgo.Database const ( COLLECTION = "blogs" ) // Establish a connection to database func (m *BlogsDAO) Connec...
package validator import ( "net/http" "github.com/gtongy/demo-echo-app/errors" "github.com/gtongy/demo-echo-app/models" "github.com/gtongy/demo-echo-app/mysql" "github.com/labstack/echo" validator "gopkg.in/go-playground/validator.v9" ) type CustomValidator struct { Validator *validator.Validate } func (cv *...
// Licensed to Elasticsearch B.V. under one or more contributor // license agreements. See the NOTICE file distributed with // this work for additional information regarding copyright // ownership. Elasticsearch B.V. licenses this file to you under // the Apache License, Version 2.0 (the "License"); you may // not use ...
package e2e import ( "encoding/json" "net/http" . "github.com/onsi/ginkgo" . "github.com/onsi/gomega" "github.com/tommy351/kubenvoy/test/echo" ) func decodeResponse(r *http.Response) (*echo.Response, error) { var res echo.Response decoder := json.NewDecoder(r.Body) if err := decoder.Decode(&res); err != nil...
package search import ( "fmt" "testing" ) func TestBsearch(t *testing.T) { s := []int{0, 1, 2, 3, 4, 5, 6, 7, 8, 9} index, err := Bsearch(s, 8) if err != nil { fmt.Println(err) } fmt.Println("查找的数的index为:", index) index, err = Bsearch(s, 10) if err != nil { fmt.Println(err) } } func TestBM(t *testing....
package main import ( "fmt" "io/ioutil" "log" "github.com/jroimartin/gocui" "regexp" ) func cursorDown(g *gocui.Gui, v *gocui.View) error { if v != nil { cx, cy := v.Cursor() if err := v.SetCursor(cx, cy+1); err != nil { ox, oy := v.Origin() if err := v.SetOrigin(ox, oy+1); err != nil { return er...
package azure import ( "bufio" "bytes" "context" "encoding/base64" "encoding/binary" "io" "io/ioutil" "path" "strings" blob "github.com/Azure/azure-storage-blob-go/azblob" "github.com/opentracing/opentracing-go" "github.com/pkg/errors" "github.com/grafana/tempo/tempodb/backend" ) const ( // dir repres...
// Copyright 2020 The ChromiumOS Authors // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. package wifi import ( "context" "time" "github.com/google/gopacket" "github.com/google/gopacket/layers" "chromiumos/tast/common/network/ping" "chromiumos/tast/ctxuti...
/* @Time : 2020/4/9 4:43 PM */ package main import ( "fmt" "log" "net/http" "time" "workerqueue/workerqueue" ) func main() { workerQueue := workerqueue.New(10) workerQueue.Start() // for i in {1..4096}; do curl localhost:8000/submit-work -d name=$USER -d delay=$(expr $i % 11)s; done http.HandleFunc("/submit...
package hivesql import ( "crypto/tls" "crypto/x509" "net" ) type config struct { addr string user string password string dbName string auth string hiveConfig map[string]string tlsConfig *tls.Config } func (c *config) turnTLS() { if c.tlsConfig == nil { c.tlsConfig = new(tls.Config) rootCA...
/* * Copyright (c) 2016, Randy Westlund. All rights reserved. * This code is under the BSD-2-Clause license. * * This file contains HTTP handlers for the application. */ package router import ( "bytes" "database/sql" "encoding/json" "image" "image/jpeg" "image/png" "log" "mime/multipart" "net/http" "ne...
package router import "sync" type IRunnable interface { Run() error OnError(err error) } type RunnerQueue struct { started bool statusMutex *sync.Mutex n int queueLen int queue chan IRunnable } func NewRunnerQueue(n, queueLen int) (r RunnerQueue) { r.n = n r.queueLen = queueLen r.started = false r.statu...
package Graph import ( GE "GoGraph/Edge" GV "GoGraph/Vertex" "fmt" ) type Graph struct { AdjList []*GV.Vertex AdjMatr [][]float32 UndirectedEdges []*GE.UndirectedEdge } //This method adds vertex to graph. //The vertex is just an isolated vertex. func (graph *Graph) AddVertex(v *...
package main import ( "testing" ) func TestSmoke(t *testing.T) { if false { t.Errorf("smoke test") } } func TestFirstNumber(t *testing.T) { numbers := fizzbuzz() got := numbers[0] expected := "1" if expected != got { t.Errorf("expected:%s got:%s", expected, got) } } func TestThreeIsFizz(t *testing.T) ...
package main import ( "encoding/json" "fmt" "io/ioutil" "log" "net/http" "net/http/httputil" "os" "strings" "time" "github.com/gin-gonic/gin" ) // 全局配置信息 var ( droneScheme = os.Getenv("DRONE_SCHEME") droneHost = os.Getenv("DRONE_HOST") droneToken = os.Getenv("DRONE_TOKEN") apiPrefix = os.Getenv("A...
package text import ( "io/ioutil" "os" "testing" "github.com/aevea/quoad" "github.com/stretchr/testify/assert" ) func TestReleaseNotes(t *testing.T) { notes := ReleaseNotes{Complex: true} file, err := os.Open("../../expected-output.md") assert.NoError(t, err) defer file.Close() b, err := ioutil.ReadAll(...
package jtlr import ( "testing" ) func TestPrettyPrint(t *testing.T) { type args struct { input string } tests := []struct { name string args args }{ { name: "a", args: args{ input: `{"a": [134, 2], "b": {"a":1, "b":2}}`, }, }, { name: "b", args: args{ input: `{"a": [134, {"a":...
package url_hash import ( "github.com/gopherjs/gopherjs/js" "github.com/winded/tyomaa/frontend/js/dom" ) func Get() string { hash := js.Global.Get("window").Get("location").Get("hash").String() if len(hash) > 0 { return hash[1:] } else { return "" } } func Set(value string) { js.Global.Get("window").Get("...
// Go 提供了对 base64 编解码的内建支持 package main // 这个语法引入了 encoding/base64 包, 并使用别名 b64 代替默认的 base64。 // 这样可以节省点空间 import ( b64 "encoding/base64" "fmt" ) func main() { // 这是要编解码的字符串 data := "abc123!?$*&()'-=@~" // Go 同时支持标准 base64 以及 URL 兼容 base64。 // 这是使用标准编码器进行编码的方法。 // 编码器需要一个 []byte,因此我们将 string 转换为该类型 sEnc := b...
// Package bot provides the implementation of the IRC bot. package bot import ( "fmt" "log" "regexp" "github.com/caiofilipini/got/irc" ) const ( // Action is the command that triggers the bot. Action = "!got" // WelcomeMsg is the message to be printed out when the bot is online. WelcomeMsg = "OHAI" // Hel...
package schema import ( "github.com/facebookincubator/ent" "github.com/facebookincubator/ent/schema/edge" ) // CourseItem holds the schema definition for the CourseItem entity. type CourseItem struct { ent.Schema } // Fields of the CourseItem. func (CourseItem) Fields() []ent.Field { return nil } // Edges of th...
package odoo import ( "fmt" ) // StockReturnPicking represents stock.return.picking model. type StockReturnPicking struct { LastUpdate *Time `xmlrpc:"__last_update,omptempty"` CreateDate *Time `xmlrpc:"create_date,omptempty"` CreateUid *Many2One `xmlrpc:"create_uid,omptempty"` Di...
/* Copyright 2021 The KodeRover 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, s...
// Copyright 2020 Comcast Cable Communications Management, LLC // // 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 ...
package struct_utils import ( "reflect" "go-corm/errorHandle" "strings" "time" ) func Analysis(o interface{}) (mapField, mapTag ReflectFieldMap, mapFieldToTag map[string]string, pk []string, err error) { defer errorHandle.CatchLoadDataError(&err) mapField, mapTag, mapFieldToTag = NewReflectFieldMap(), NewRefl...
package cloudformation // AWSAutoScalingAutoScalingGroup_LaunchTemplateSpecification AWS CloudFormation Resource (AWS::AutoScaling::AutoScalingGroup.LaunchTemplateSpecification) // See: http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-autoscaling-autoscalinggroup-launchtemplatespecification...
// Copyright (c) Jeevanandam M. (https://github.com/jeevatkm) // go-aah/aah source code and usage is governed by a MIT style // license that can be found in the LICENSE file. package aah import ( "errors" "fmt" "net/http" "net/url" "reflect" "strings" "aahframework.org/ahttp.v0" "aahframework.org/essentials....
package main import ( "context" "path" "regexp" "strconv" "time" "github.com/guitarrapc/watchdog-symlinker/directory" "github.com/guitarrapc/watchdog-symlinker/filewatch" ) type fileWatcher struct { directoryPattern string symlinkName string option fileWatcherOption } type fileWatcherOption...
// Copyright 2020 The ChromiumOS Authors // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. package crash import ( "context" "os" "golang.org/x/sys/unix" "chromiumos/tast/local/crash" "chromiumos/tast/testing" ) func init() { testing.AddTest(&testing.Test{...
// Copyright 2014 Aller Media AS. All rights reserved. // License: GPL3 // Package command provides runnable commands for the cli interface. // Command unlock provides unlocking options for hanging jobs. package notifications import ( "fmt" log "github.com/Sirupsen/logrus" "github.com/tbruyelle/hipchat-go/hipchat...
package kafka import ( "log" "fmt" "gopkg.in/confluentinc/confluent-kafka-go.v1/kafka" ) func logPartitions(s string, prts []kafka.TopicPartition) { for _, p := range prts { s = fmt.Sprintf("%v | %v", s, p.Partition) } log.Println(s) }
package moni import ( "github.com/AsynkronIT/protoactor-go/actor" "github.com/golang/protobuf/proto" "github.com/saintEvol/go-rigger/rigger" ) const mainApplicationName = "main_application" const mainApplicationSupName = "main_application_sup" const userManagerSupName = "user_manager_sup" const userManagerServerNa...
package render import ( "image" "image/draw" "github.com/oakmound/oak/physics" ) // The Compound type is intended for use to easily swap between multiple // renderables that are drawn at the same position on the same layer. // A common use case for this would be a character entitiy who switches // their animation...
package bob // package name must match the package name in bob_test.go import ( "strings" "unicode" ) const ( fine = "Fine. Be that way!" sure = "Sure." whatever = "Whatever." chill = "Whoa, chill out!" testVersion = 2 ) // Hey is what bob says, the lazy bastard func Hey(phrase string) s...
// Copyright 2020 Ye Zi Jie. All Rights Reserved. // // 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 ...
package config import ( "encoding/json" "io/ioutil" ) type GlobalConfig struct { /* Server configuration */ ServerName string ServerHost string ServerPort int MaxPackageSize int /* Log configuration */ EnableLog bool LogToConsole bool LogPath string /* Database configuration */ DBType string DBHost st...
package list import ( "errors" "github.com/mah0x211/github-release-admin/github" "github.com/mah0x211/github-release-admin/log" ) type Option struct { ItemsPerPage int MaxItems uint64 BranchExists bool Branch string } const ( flgReleaseOnly = 0x0 flgDraftRelease = 0x1 flgPreRelease = 0x2 flg...
package server import ( "bytes" "context" "fmt" "testing" "time" "github.com/golang/protobuf/jsonpb" "github.com/stretchr/testify/assert" "github.com/tilt-dev/tilt/internal/testutils/bufsync" "github.com/tilt-dev/tilt/internal/testutils" proto_webview "github.com/tilt-dev/tilt/pkg/webview" ) func TestVie...
package unc import ( "bytes" "go/ast" "go/format" "log" "golang.org/x/tools/go/analysis" "golang.org/x/tools/go/analysis/passes/inspect" "golang.org/x/tools/go/ast/inspector" ) // Analyser reports c-style nil checks. var Analyzer = &analysis.Analyzer{ Name: "unc", Doc: "Reports c style nil checks."...
package command import ( "fmt" "net/http" "os" "os/exec" "path/filepath" "strings" "github.com/BlackCodes/logbud/flag" "github.com/rs/zerolog/log" ) type Build struct { projectDir string buildDir string } func NewBuild(buildDir, projectDir string) *Build { return &Build{projectDir: projectDir, buildDir...
package main import "fmt" type Person struct { First string Last string Age int } type DoubleZero struct { Person First string LicenseToKill bool } func main() { p1 := DoubleZero{ Person: Person{ First: "Denis", Last: "John", Age: 30, }, First: "Denison", LicenseToKill:...
package swagger import ( "fmt" "net/http" "strings" "github.com/gorilla/mux" ) type Route struct { Name string Method string Pattern string HandlerFunc http.HandlerFunc } type Routes []Route func NewRouter() *mux.Router { router := mux.NewRouter().StrictSlash(true) for _, route := range r...
package main import ( "fmt" "runtime" "sync" ) func init() { fmt.Println("this is init function. I'm learning about mutex") } var wgGlobal sync.WaitGroup var wgF sync.WaitGroup var wgB sync.WaitGroup func main() { fmt.Printf("Go Routines:\t %v\n", runtime.NumGoroutine()) wgGlobal.Add(2) wgB.Add(1) go foo(...
// Copyright (c) KwanJunWen // This source code is licensed under the MIT license found in the // LICENSE file in the root directory of this source tree. package estemplate import "fmt" // DatatypeMapperMurmur3 (Plugin) Specialised Datatype to compute hashes of values at index-time // and store them in the index. Ty...
package dynakube import ( "context" "net/http" "os" "time" dynatracev1beta1 "github.com/Dynatrace/dynatrace-operator/src/api/v1beta1" "github.com/Dynatrace/dynatrace-operator/src/controllers/dynakube/activegate" "github.com/Dynatrace/dynatrace-operator/src/controllers/dynakube/apimonitoring" "github.com/Dynat...
package models import ( "decept-defense/controllers/comm" "fmt" "strings" ) type Baits struct { ID int64 `gorm:"primary_key;AUTO_INCREMENT;not null;unique;column:id" json:"id"` CreateTime string `gorm:"not null"` Creator string ...
// Copyright 2014 Aller Media AS. All rights reserved. // License: GPL3 package command import ( "github.com/jwaldrip/odin/cli" ) func ExampleVersionRun() { GitTag = "unknown" GitCommit = "unknown" GitBranch = "unknown" v := &Version{} var c cli.Command v.Run(c) // Output: // miniETL version unknown (unkn...
package _map import "testing" func TestMapWithFunValue(t *testing.T) { m := map[int]func(op int) int{} m[1] = func(op int) int { return op } m[2] = func(op int) int { return op * op } m[3] = func(op int) int { return op * op * op } t.Log(m[1](2), m[2](3), m[3](5)) }
package uploadbills import ( "encoding/json" "fmt" "net/http" "time" godrej "main.go/godrej" itc "main.go/itc" marico "main.go/marico" rb "main.go/rb" "main.go/utils" ) // gcloud config set project dropshop-5cbbf // gcloud functions deploy UploadCreditNoteAPI --runtime go113 --trigger-http --allow-unauth...
package main import ( "fmt" "os" "github.com/LEW21/siren/imagectl" ) func main() { args := os.Args[1:] allCommands := []imagectl.CommandGroup{ {"Image", imagectl.Commands}, } if len(args) == 0 || args[0] == "-h" || args[0] == "--help" { imagectl.PrintHelp("Image manager for systemd-machined.", allComman...
package net import ( "encoding/json" "fmt" "log" "net/http" "serverskeleton/parser" "github.com/gorilla/websocket" ) type WSServer struct { MethodMap map[string]*parser.MethodInfo } func (w *WSServer) RegisterMethod(v interface{}) { parser.RegisterMethod(w.MethodMap, v) } type WSConnection struct { Send...
package main // //import ( // "fmt" // "os" // "runtime" // "strconv" // "time" // // "github.com/eatonphil/gosql" //) // //var inserts = 0 //var lastId = 0 //var firstId = 0 // //func doInsert(mb gosql.Backend) { // parser := gosql.Parser{} // for i := 0; i < inserts; i++ { // lastId = i // if i == 0 { // firstId...
package lesson01 import ( "io" "github.com/dtamura/opentracing-tutorial-go/lib/log" opentracing "github.com/opentracing/opentracing-go" spanLog "github.com/opentracing/opentracing-go/log" ) // Client 構造体 type Client struct { tracer opentracing.Tracer logger log.Factory closer io.Closer } // ConfigOptions オプシ...
package main import ( "log" "os" "github.com/sirupsen/logrus" "github.com/spf13/cobra" cfsservice "gitlab.com/cfs-service" "gitlab.com/cfs-service/server" "gitlab.com/cfs-service/service" "gitlab.com/cfs-service/store" ) func init() { } func main() { config := &cfsservice.RuntimeConfig{} var rootCmd = &...
package main import ( "bufio" "fmt" "log" "os" "sort" "strings" ) func nextPermu(s string) (string, bool) { k, l := -1, 0 for i := len(s) - 2; i >= 0; i-- { if s[i] < s[i+1] { k = i break } } if k == -1 { return s, true } for i := len(s) - 1; i > 0; i-- { if s[i] > s[k] { l = i break ...
package main; import ( "fmt" "github.com/rajeshpachar/hellomod/hellotest" "github.com/rajeshpachar/hellomod/child" ) func main(){ fmt.Println("we are inside main func now"); hellotest.SayHello("my main calling me"); fmt.Println("now main is running child###"); child.HelloChild() }
package resource import ( "fmt" "io" "net/url" "strings" "github.com/mebyus/ffd/resource/archiveofourown" "github.com/mebyus/ffd/resource/fanfiction" "github.com/mebyus/ffd/resource/ficbook" "github.com/mebyus/ffd/resource/fiction" "github.com/mebyus/ffd/resource/royalroad" "github.com/mebyus/ffd/resource/s...
// Package client implements a lightweight bandwidth estimation using a modified UDP // implementation of ping. // // Example usage from golang/bin/ // # Runs a basic client *locally* that sends UDP packets of varying size. // # See white paper for details. // ./client // // # Specify ports to receive and send on and...
package server import ( "github.com/bugscatcher/cache-service/configs" "github.com/go-redis/redis" ) type GRPCHandler struct { Redis *redis.Client Conf configs.Config }
package main import ( "math" "fmt" ) /* Given two integers dividend and divisor, divide two integers without using multiplication, division and mod operator. Return the quotient after dividing dividend by divisor. The integer division should truncate toward zero. Example 1: Input: dividend = 10, divisor =...
// 经营体检 package elemeOpenApi // 根据商户ID查询商户经营体检信息 // shopId 店铺ID // date 体检日期(最多查到7天内的体检数据) func (diagnosis *Diagnosis) GetShopDiagnosis(shopId_ int64, date_ string) (interface{}, error) { params := make(map[string]interface{}) params["shopId"] = shopId_ params["date"] = date_ return APIInterface(diagnosis.config,...
package closing_channels func ExampleClosingChannels() { closingChannels() //Output: //Sent job 1 //Received job 1 //Sent job 2 //Received job 2 //Sent job 3 //Sent all jobs //Received job 3 //Received all jobs }
package main import ( "fmt" "math/big" "reflect" "strconv" ) type SMC struct { E map[string]EnviromentValue S GenericStack M map[string]Var C Stack T GenericStack } //Função que converte booleanos em String func BtoA(boolValue bool) string { resultStr := "" if boolValue { resultStr = "true" } else { ...
package cmd import ( "os/exec" "path/filepath" "github.com/brainicorn/skelp/generator" "github.com/spf13/cobra" ) const ( defaultCompletionDir = "/etc/bash_completion.d/" ) var ( completionDir string noSudo bool ) func newBashmeCommand() *cobra.Command { cmd := &cobra.Command{ Use: "bashme", S...
package main import "fmt" // OCP - Type should be open for extension but close for modification // Color defines Color as an int type Color int // Color = iota assign 0 to Color and increment by 1 down the color list const ( brown Color = iota // so brown is type Color and has value of 0 red // r...
package leetcode import "testing" func Test_alienOrder(t *testing.T) { type args struct { words []string } tests := []struct { name string args args want string }{ { name: "test_alienOrder01", args: args{words: []string{"wrt", "wrf", "er", "ett", "rftt"}}, want: "wertf", }, { name: "test...
// Copyright 2022 The ChromiumOS Authors // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. package policy import ( "context" "time" "chromiumos/tast/common/fixture" "chromiumos/tast/common/pci" "chromiumos/tast/common/policy" "chromiumos/tast/common/policy/...
package parser import ( "errors" "strings" "github.com/DataDrake/cuppa/version" "github.com/autamus/go-parspack/pkg" ) // ParseVersion returns the value of a version tuple. func (p *Parser) ParseVersion() (result pkg.Version, err error) { // Watch for the end of the version. end := false token := p.scnr.Peak(...
package exec import ( "errors" "fmt" "github.com/pgavlin/warp/wasm" ) // ErrDataSegmentDoesNotFit should be returned by Instantiate if a data segment attempts to write outside of // its target memory's bounds. var ErrDataSegmentDoesNotFit = errors.New("data segment does not fit") // ErrElementSegmentDoesNotFit s...