text
stringlengths
11
4.05M
package main import ( "net/http" "github.com/alecaivazis/maestro/api/mutations" "github.com/alecaivazis/maestro/api/objectTypes" "github.com/graphql-go/graphql" "github.com/nautilus/events" "github.com/nautilus/services/graphql" ) // MaestroAPI is the service that acts as the interface between the // various c...
package main import "fmt" func main () { hello := func(greeting string) { fmt.Println(greeting) } hello("Good Morning!") }
package main import ( "bufio" "fmt" "os" ) type manualDnsResponder struct { records map[string]string } func newManualDnsResponder() *manualDnsResponder { return &manualDnsResponder{records: make(map[string]string)} } func (r *manualDnsResponder) Cleanup() { for fqdn := range r.records { fmt.Fprintf(os.Stde...
package bitcoin import ( . "ftnox.com/common" . "ftnox.com/config" "ftnox.com/db" "ftnox.com/bitcoin/rpc" ) // GENERAL // The total blocks returned are at most Coins[coin].TotConf blocks. // Returns two arrays based on the current blockchain info from rpc.GetBlocks(). // (NOT based on the status of t...
package model //MsIdcaid 测试PG ltree性能 type MsIdcaid struct { Id int `xorm:"not null pk INT(4) autoincr"` Name string `xorm:"NVARCHAR(4000)"` Cardno string `xorm:"NVARCHAR(4000)"` Descriot string `xorm:"NVARCHAR(4000)"` Ctftp string `xorm:"NVARCHAR(4000)"` Ctfid string `xorm:"NVARCHAR(4...
package pkggraph import ( "encoding/json" "sort" "golang.org/x/tools/go/packages" "golang.org/x/tools/go/vcs" "github.com/loov/goda/internal/stat" ) type Graph struct { Packages map[string]*Node Sorted []*Node stat.Stat } func (g *Graph) AddNode(n *Node) { g.Packages[n.ID] = n n.Graph = g } type Node ...
package cmd import ( "bytes" "fmt" "io" "os" "github.com/spf13/cobra" "github.com/lets-cli/lets/commands/command" "github.com/lets-cli/lets/config" "github.com/lets-cli/lets/runner" ) // cut all elements before command name func prepareArgs(cmd command.Command, originalArgs []string) []string { nameIdx := ...
// Copyright 2018 Saferwall. All rights reserved. // Use of this source code is governed by Apache v2 license // license that can be found in the LICENSE file. package aggregator import ( "bytes" "context" "encoding/json" "errors" store "github.com/saferwall/saferwall/internal/db" "github.com/saferwall/saferwa...
package server import ( "github.com/astaxie/beego" "net" "strings" "github.com/jxufeliujj/tcp-server/core" "github.com/jxufeliujj/tcp-server/socket" "time" ) func StartTCP() { go start_843Port() tcpAddr, errAddr := net.ResolveTCPAddr("tcp4", beego.AppConfig.String("bind")) if errAddr != nil { panic(errAddr...
package main import ( "fmt" "sort" "strings" ) func main() { testCase := []string{"eat", "tea", "tan", "ate", "nat", "bat"} sortWords := make([]string, 0) for i :=0; i < len(testCase); i++ { slice := strings.Split(testCase[i], "") sort.Strings(slice) sortWords = append(sortWords, strings.Join(slice, "")...
package main import "fmt" func main() { // String values var a = "Avijit" fmt.Println(a) // Integer values var b, c int = 1, 2 fmt.Println(b, c) // Boolean value var d = true fmt.Println(d) // Default value var e int fmt.Println(e) // String value f := "apple" fmt.Println(f) }
package main import ( "fmt" "log" "os" "strconv" "github.com/brotherlogic/goserver/utils" "google.golang.org/grpc" pb "github.com/brotherlogic/tracer/proto" //Needed to pull in gzip encoding init _ "google.golang.org/grpc/encoding/gzip" ) func main() { host, port, err := utils.Resolve("tracer", "tracer-c...
package cache import ( "path" "sync" pub "github.com/go-ap/activitypub" h "github.com/go-ap/handlers" ) type ( iriMap map[pub.IRI]pub.Item store struct { enabled bool w sync.RWMutex c iriMap } CanStore interface { Set(iri pub.IRI, it pub.Item) Get(iri pub.IRI) pub.Item Remove(iris .....
package main import ( "fmt" // "golang.org/x/net/http2" "io/ioutil" // "log" "net/http" "net/url" // "os" "strings" "time" // "mtime.com/framework/schedule" // "mtime.com/framework/utility/convert" // "strconv" ) // var ( // BUILD_TIME string // ) // func main() { // d := new(daemon.Daemon) // d.SetV...
package response import ( pb "github.com/LILILIhuahuahua/ustc_tencent_game/api/proto" "github.com/LILILIhuahuahua/ustc_tencent_game/framework" "github.com/LILILIhuahuahua/ustc_tencent_game/framework/event" ) type EnterGameResponse struct { framework.BaseEvent Result bool HeroId int32 } func (e *EnterGameRespon...
package main import ( "github.com/user/aggtodo/controller" "log" "net/http" ) func main() { /* Serve up the home page */ http.HandleFunc("/", controller.HttpHomeHandler) /* Serve up the list page */ http.HandleFunc("/my-list", controller.HttpListHandler) /* URL to handle OAuth2 responses */ ht...
package api import ( "./app" "github.com/gorilla/mux" ) var api *mux.Router = nil func Route(router *mux.Router) { app.Route(router.PathPrefix("/api").Subrouter()) }
package internal import "github.com/onsi/gomega" func CoerceToMatcher(i interface{}) gomega.OmegaMatcher { if m, ok := i.(gomega.OmegaMatcher); ok { return m } return gomega.Equal(i) }
package internal import commentpb "github.com/tomasbasham/blunderlist-comment/blunderlist_comment_v1" // Repository provides the storage requirements through which to access // comments. type Repository interface { GetComments(uint) []*commentpb.CommentResponse GetComment(uint) (*commentpb.CommentResponse, error) ...
package main // import "github.com/nix-community/vgo2nix" import ( "bytes" "encoding/json" "flag" "fmt" "io" "math" "os" "os/exec" "regexp" "sort" "strings" "golang.org/x/mod/module" "golang.org/x/mod/semver" "golang.org/x/tools/go/vcs" ) type Package struct { GoPackagePath string URL strin...
package secretless import "fmt" // Version field is a SemVer that should indicate the baked-in version // of the broker var Version = "1.7.14" // Tag field denotes the specific build type for the broker. It may // be replaced by compile-time variables if needed to provide the git // commit information in the final b...
package model import ( "time" "encoding/json" "log" "fmt" "errors" ) type User struct { Id int `json:"id" gorm:"id;AUTO_INCREMENT"` UserName string `json:"userName" gorm:"user_name"` Password string `json:"-" gorm:"password"` CreateTime time.Time `json:"createTime" ...
package greet var emoji = "👋" func English() string { return "Hi " + emoji } func Italian() string { return "Ciao " + emoji }
package superscan import ( _ "net/http/pprof" "testing" ) func Test_Scan(t *testing.T) { } func Test_pingNet(t *testing.T) { }
// Unless explicitly stated otherwise all files in this repository are licensed // under the Apache License Version 2.0. // This product includes software developed at Datadog (https://www.datadoghq.com/). // Copyright 2016-present Datadog, Inc. package merger import ( "errors" "fmt" ) var errMergeAttempted = fmt....
// Copyright (C) 2021 Storj Labs, Inc. // See LICENSE for copying information. package grant import ( "strings" "testing" "github.com/stretchr/testify/require" "storj.io/common/macaroon" "storj.io/common/paths" "storj.io/common/storj" ) func TestLimitTo(t *testing.T) { // these strings can be of the form <b...
/* 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...
package main func main() { funcMui(1,2) } // 在函数有多个返回值时,只要有一个返回值有命名,其他的也必须命名。如果有多个返回值必须加上括 号();如果只有一个返回值且命名也需要加上括号()。这里的第一个返回值有命名sum,第二个没有命名 func funcMui(x,y int) (sum int,error) { return x+y,nil }
//go:build 386 || amd64 || amd64p32 || arm || arm64 || mipsle || mips64le || mips64p32le || ppc64le || riscv || riscv64 // +build 386 amd64 amd64p32 arm arm64 mipsle mips64le mips64p32le ppc64le riscv riscv64 package column import ( "io" "unsafe" ) func (c *Base[T]) readyBufferHook() { } // slice is the runtime r...
//go:build integration // +build integration package integration import ( "context" "fmt" "strconv" "testing" "time" "github.com/stretchr/testify/require" ) func TestDisableK8s(t *testing.T) { f := newK8sFixture(t, "disable") f.TiltUp() ctx, cancel := context.WithTimeout(f.ctx, time.Minute) defer cancel...
package main import ( "api-documentos/bd" "api-documentos/controladores" "log" "net/http" "github.com/gorilla/mux" "github.com/rs/cors" ) func main() { log.Println("El servidor se encuentra corriendo sin problema") rout() } func rout() { bd.NuevaConexionBD() defer bd.CerrarBD() gori...
package main import ( "path/filepath" "io/ioutil" "gopkg.in/yaml.v2" // "github.com/davecgh/go-spew/spew" ) // Yaml Structures for Defaults and Elasticsearch configs type BlitzferConfigs struct { Configs map[string] Options } // Config yaml structure. type Options struct { Blitzfer struct ...
package utils import ( "math/rand" "sync" "time" ) // Rand return an random number between [min, max) func Rand(min, max int) int { return rand.Intn(max-min) + min } const ( AlphaNumber = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789" Number = "0123456789" Alpha = "abcdefghijklmno...
package tiltfile import ( "bytes" "context" "fmt" "path/filepath" "reflect" "strconv" "testing" "time" "github.com/pkg/errors" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/apimachinery/pkg/types" "k8s.io/client-go/util/w...
package standalone import ( "fmt" "os" "strconv" "strings" "github.com/Dynatrace/dynatrace-operator/src/arch" "github.com/Dynatrace/dynatrace-operator/src/config" "github.com/pkg/errors" ) type containerInfo struct { Name string `json:"name"` Image string `json:"image"` } type environment struct { Mode ...
package auth import ( "context" "encoding/json" "fmt" "net/http" "github.com/morikuni/failure" "github.com/nerocrux/webauthn/domain" "github.com/nerocrux/webauthn/errors" ) type loginRequest struct { Username string } func (s *Server) LoginEndpoint(rw http.ResponseWriter, req *http.Request) error { ctx := ...
// 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 video import ( "context" "io/ioutil" "os" "path/filepath" "regexp" "time" "chromiumos/tast/common/testexec" "chromiumos/tast/local/upstart" "chromiumos/tas...
package dynamic_programming import ( "testing" ) //目标和 sum(P)-sum(N)=target sum(P)+sum(N)+sum(P)-sum(N)=sum(P)+sum(N)+target 2*sum(P)=target+sum(N) func findTargetSumWays(nums []int, S int) int { sum := 0 for i := 0; i < len(nums); i++ { sum += nums[i] } //和小于S sum+S其实就是2*sum(P) if sum < S || (sum+S)&1...
// 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 score import ( "context" "github.com/dusk-network/dus...
/* * Copyright 2021 American Express * * 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...
//nolint package recursive import ( "fmt" "math/rand" "testing" "github.com/slonegd/structstringer/examples/simple" "github.com/stretchr/testify/assert" ) func TestAString(t *testing.T) { tests := []struct { a A want string fmtWant string }{ { a: A{i: 42, flag: true, b: B{i: 43}}, want:...
package models import ( "github.com/jinzhu/gorm" ) // Services defines the shape of the service struct type Services struct { db *gorm.DB User UserService } // NewServices is used to define the service shape func NewServices(connectionString string) (*Services, error) { db, err := gorm.Open("postgres", connect...
// Copyright 2018 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 stealth import ( "bytes" "fmt" "net/http" "net/url" "strconv" ) const googleBaseURL = "http://www.google.com/search?" // TODO: Repleace this global var with something var googleSearchTypes = map[string]string{ "shopping": "tbm=shop", "image": "tbm=isch", "news": "tbm=nws", "video": "tbm=vi...
package main import "fmt" func main() { x := 0 y := 3 // goにwhileはなくループは全てfor for x < y { x++ fmt.Println(x) } // いつものfor for n := 0; n < 5; n++ { fmt.Println(n) } // 無限ループ m := 0 for { m++ if m > 10 { break } else if m%2 == 1 { continue } else { fmt.Println(m) } } // 配列やスライスな...
package Utill import ( "../../../bin/amqp" "../DTO" "../DataBase" "fmt" "log" ) func GetRabbitConnection() (*amqp.Connection) { conn, err := amqp.Dial("amqp://guest@localhost:5672") failOnError(err, "Failed to connect to RabbitMQ") return conn } func CreateChannel(conn *amqp.Connection) (channel *amqp.Cha...
// 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 bios import ( "testing" pb "chromiumos/tast/services/cros/firmware" ) func TestCalcGBB(t *testing.T) { // 1 bit m := calcGBBMask([]pb.GBBFlag{pb.GBBFlag_DEV_SC...
package ferry import ( "net" ) type Tunnel struct { net.Conn priority int index int } func (self *Tunnel) Send(data []byte) (n int, err error) { // 加密一下发送 return self.Write(data) } func (self *Tunnel) Read(buffer []byte) (n int, err error) { // 解密 n, err = self.Conn.Read(buffer) return } type TunnelHea...
package iteration func Contain(str, substr string) bool { for i := 0; i <= len(str)-len(substr); i++ { if substr == str[i:i+len(substr)] { return true } } return false }
// Copyright 2020 Trey Dockendorf // 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 wri...
package request type EventSource struct { UserID string `json:"userId"` SourceType string `json:"type"` GroupID string `json:"groupId"` RoomID string `json:"roomId"` } type EmojiMessage struct { Index int `json:"index"` Length int `json:"lenght"` ProductID string `json:"productId"` Emo...
package models import ( "encoding/json" "time" ) type Routine struct { RoutineId int `json:"routine_id"` Title string `json:"title"` TotalDuration int `json:"total_duration"` Character string `json:"character"` OriginalCreatorId int `json:"original_creato...
package cmd import ( "log" "os" "workflow/stream" "workflow/task" ) const OSEXIT2 = 2 type config struct { attr01 map[string]int attr02 int } func Run() { log.SetPrefix("[work flow]") arg := parse() _, err := stream.NewStream(). Next(task.Task01). Next(task.Task02). Go(arg) if err != nil { log.Pri...
package cmd import ( "bufio" "context" "fmt" "io" "strings" "sync" "github.com/jonboulle/clockwork" apierrors "k8s.io/apimachinery/pkg/api/errors" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/apimachinery/pkg/runtime" "k8s.io/apimachinery/pkg/types" ctrl "sigs.k8s.io/controller-runtime" "sigs.k8...
// fibonacciClosure project main.go package main import ( "fmt" ) func fibonacci() func() int { first := 0 second := 0 third := 1 return func() int { first, second, third = second, third, second+third return first } } func main() { f := fibonacci() for i := 0; i < 10; i++ { fmt.Println(f()) } }
package v1 import ( "github.com/gin-gonic/gin" "github.com/gomodule/redigo/redis" "user/controller" ) func SetV1Route(r *gin.Engine, pool *redis.Pool) { userSvc := controller.NewUserService(pool) userGroup := r.Group("/v1/user") userGroup.GET("/", userSvc.GetUserList) userGroup.POST("/", userSvc.AddUser) use...
// 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 models import( "encoding/json" ) /** * Type definition for Type6Enum enum */ type Type6Enum int /** * Value collection for Type6Enum enum */ const ( Type6_KFILESHARE Type6Enum = 1 + iota Type6_KVOLUME ) func (r Type6Enum) MarshalJSON() ([]byte, error) { s := Type6Enu...
package loader import ( "testing" "github.com/lukaszbudnik/migrator/config" "github.com/stretchr/testify/assert" ) func TestDiskReadDiskMigrationsNonExistingBaseDirError(t *testing.T) { var config config.Config config.BaseDir = "xyzabc" loader := NewLoader(&config) _, err := loader.GetDiskMigrations() ass...
package cmd import ( "github.com/spf13/cobra" "github.com/guumaster/hostctl/pkg/host" ) // enableCmd represents the enable command var enableCmd = &cobra.Command{ Use: "enable", Short: "Enable a profile on your hosts file.", Long: ` Enables an existing profile. It will be listed as "on" while it is enabled. `...
// project euler (projecteuler.net) problem 70 // solution by Kevin Retzke (retzkek@gmail.com), May 2012 package main import ( "fmt" "math" ) type Primes struct { Primes []int Last int } // Init initializes a Primes struct with the first two primes. func (p *Primes) Init() { p.Primes = []int{2,...
package storage import ( "fmt" "io/ioutil" "path" "path/filepath" "github.com/syndtr/goleveldb/leveldb" "github.com/syndtr/goleveldb/leveldb/opt" "context" "github.com/twcclan/goback/backup" "github.com/twcclan/goback/proto" ) func NewSimpleObjectStore(base string) *SimpleChunkStore { return &SimpleChunk...
package main import "fmt" var table [][]int func loadTable(a *[]int) { table = make([][]int, len(*a)) for _, e := range *a { h := hash(e, len(*a)) fmt.Printf(" value is %d and the hash is %d\n", e, h) if table[h] == nil { table[h] = make([]int, 0) } tabl...
package main import "fmt" // Dependency Inversion Principle // HLM should not depend on LLM // Both should depend on abstractions type Relationship int const ( Parent Relationship = iota Child Silbling ) // Info struct type Info struct { from *Person relationship Relationship to *Person } ...
package viz import ( "github.com/nsf/termbox-go" ) type TitleView struct { win *Window title string bold bool } func MakeTitleView(win *Window) *TitleView { me := &TitleView{ win: win, } win.SetPainter(me) return me } func (me *TitleView) SetTitle(title string) { me.title = title // TODO: Uncomment t...
package main import ( "bufio" "errors" "log" "net/url" "os" "strings" "vim-swp-exp/settings" "vim-swp-exp/watcher" mapset "github.com/deckarep/golang-set" cli "github.com/urfave/cli/v2" ) func main() { app := &cli.App{ Name: "vim-swp-exp", Usage: "vim swp file exploit", UsageText: "vim-swp-...
package c37pb //go:generate protoc -I/usr/local/include -I. --go_out=plugins=grpc:. messages.proto
package cmdimages import ( "github.com/tilt-dev/tilt/internal/store" ) func HandleCmdImageUpsertAction(state *store.EngineState, action CmdImageUpsertAction) { obj := action.CmdImage n := obj.Name state.CmdImages[n] = obj } func HandleCmdImageDeleteAction(state *store.EngineState, action CmdImageDeleteAction) { ...
package models import ( "gorm.io/gorm" "time" ) type Session struct { gorm.Model Uuid string `gorm:"index:,unique;not null"` UserId uint ExpiresAt time.Time RefreshCode string `gorm:"index;not null"` User User `gorm:"foreignKey:UserId"` }
package impl_test import ( "encoding/json" "testing" "github.com/stretchr/testify/require" "github.com/bgildson/ifood_backend_challenge/base" "github.com/bgildson/ifood_backend_challenge/impl" ) func TestJSONPlaylistSerializerDecode(t *testing.T) { serializer := impl.JSONPlaylistSerializer{} // success pla...
package chroma import ( "compress/gzip" "encoding/xml" "errors" "fmt" "io" "io/fs" "math" "path/filepath" "reflect" "regexp" "strings" "github.com/dlclark/regexp2" ) // Serialisation of Chroma rules to XML. The format is: // // <rules> // <state name="$STATE"> // <rule [pattern="$PATTERN"]> // ...
package main import ( "fmt" "math/rand" ) type node struct { ch [2]*node priority int val int } func (o *node) cmp(b int) int { switch { case b < o.val: return 0 case b > o.val: return 1 default: return -1 } } func (o *node) rotate(d int) *node { x := o.ch[d^1] o.ch[d^1] = x.ch[d] x.ch...
package generator import ( "io/ioutil" "os" "path/filepath" "github.com/pkg/errors" yaml "gopkg.in/yaml.v2" ) type ImportedPluginsConfigs struct { Path string PluginsConfigs PluginsConfigs } type PluginsConfigs map[string]interface{} type GenerateConfig struct { GenerateTraces bool `yam...
package main import ( "fmt" "log" "net/http" "os" "github.com/line/line-bot-sdk-go/linebot" ) func main() { // create Handler handler, err := newHandler() if err != nil { log.Fatal(err) } // set handler (Routing = /callback) http.HandleFunc("/callback", handler.HandleEvent) // LISTEN PORT if err := ht...
package main import "fmt" import "./vec" func main() { mesh := Cube(1) // a unit cube ray := Ray{vec.Make(1, 1, 2), vec.Make(0, 0, -1)} fmt.Printf("%v\n", ray.IntersectsMesh(mesh)) } func Cube(radius float64) *Mesh { sides := make([]*Mesh, 6) i := 0 for _, r := range []float64{radius, -radius} { // top sid...
package handlers import ( "net/http" "peribahasa/app/models" "peribahasa/web/utils" "strconv" "strings" "github.com/gorilla/mux" ) // EditAsalPage controller var EditAsalPage = func(w http.ResponseWriter, r *http.Request) { var tmpl = utils.ParseTemplates("web/templates/admin/asal/edit.html") vars := mux.Var...
package main import ( "crypto/rsa" "crypto/x509" "encoding/pem" "errors" "github.com/dlintw/goconf" . "github.com/wikiocracy/cryptoballot/cryptoballot" "io/ioutil" "strconv" ) type Config struct { configFile string database struct { host string port int user ...
package queue_list import ( "encoding/xml" "github.com/tmconsulting/amadeus-ws-go/formats" ) type QueueList struct { XMLName xml.Name `xml:"http://xml.amadeus.com/QDQLRQ_11_1_1A Queue_List"` // presence implies that this is a follow up scrolling entry to a previous entry. Absence implies start of a new search ...
// Copyright 2019 Yunion // // 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...
// Copyright 2019 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 lc import "fmt" // Time: O(n) // Benchmark: 0ms 2.2mb | 100% func getHint(secret string, guess string) string { tally := make([]int, 10) for _, ch := range guess { tally[ch-'0']++ } var bulls, cows int for i, ch := range secret { if ch == rune(guess[i]) { bulls++ } if tally[ch-'0'] > 0 { ...
package controllers import ( "fmt" "log" "net/http" "strconv" "time" restful "github.com/emicklei/go-restful" "github.com/tipounet/go-bank/dao" "github.com/tipounet/go-bank/model" "github.com/tipounet/go-bank/service" ) var ( userService service.UserService jwt service.JWTService ) func init() {...
package mirror import ( "context" "crypto/tls" "crypto/x509" "fmt" "net" "net/http" "os" "path" "path/filepath" "time" "github.com/google/go-containerregistry/pkg/authn" "github.com/google/go-containerregistry/pkg/crane" "github.com/google/go-containerregistry/pkg/name" "github.com/google/go-containerre...
package array import ( "fmt" "github.com/project-flogo/core/data" "github.com/project-flogo/core/data/coerce" "github.com/project-flogo/core/data/expression/function" "github.com/project-flogo/core/support/log" ) type sumFunc struct { } func init() { function.Register(&sumFunc{}) } func (a *sumFunc) Name() st...
// 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 network import ( "context" "time" "chromiumos/tast/common/shillconst" "chromiumos/tast/ctxutil" "chromiumos/tast/local/bundles/cros/network/veth" "chromiumos/...
package main import "container/heap" import "strconv" // Leetcode 230. (medium) func kthSmallest(root *TreeNode, k int) int { _, res := recursiveKthSmallest(root, 0, k, -1) return res } func recursiveKthSmallest(root *TreeNode, i, k, res int) (int, int) { if root == nil || i >= k { return i, res } i, res = re...
package msfapi import ( "bytes" "errors" "fmt" "gopkg.in/vmihailenco/msgpack.v2" "io/ioutil" "net/http" ) type API struct { Token string URL string } func New(url string) *API { // TODO ensure url responds before continuing api := new(API) api.URL = url return api } func (api *API) ensureToken() error...
package LeetCode func Code83() { l1 := InitSingleList([]int{1, 1, 2, 2}) PrintSingleList(deleteDuplicates1(l1)) } /** 给定一个排序链表,删除所有重复的元素,使得每个元素只出现一次。 示例 1: 输入: 1->1->2 输出: 1->2 示例 2: 输入: 1->1->2->3->3 输出: 1->2->3 */ /** * Definition for singly-linked list. * type ListNode struct { * Val int * Next *...
package validator import ( "encoding/json" "fmt" "reflect" "strconv" "strings" ) // 1. int, bool 类型声明的时候必须用指针 // 2. 如果是嵌入对象,那么必须是required,不然会panic // 4. 类似链表嵌套 // set default value in array/slice is not support now func ValidateJson(in []byte, v interface{}) error { err := json.Unmarshal(in, v) if err != nil...
package client import ( "bytes" "io" "math/rand" "reflect" "sync" "testing" "time" ) func TestOffsetReaderRead(t *testing.T) { buf := []byte("testData") reader := &offsetReader{buf: bytes.NewReader(buf)} tempBuf := make([]byte, len(buf)) n, err := reader.Read(tempBuf) if err != nil { t.Fatal(err) } ...
package miner import ( "bytes" "encoding/binary" "errors" "time" "unsafe" "github.com/NebulousLabs/Sia/crypto" "github.com/NebulousLabs/Sia/modules" "github.com/NebulousLabs/Sia/types" ) // increaseAttempts is the miner's way of guaging it's own hashrate. After it's // made 100 attempts to find a block, it c...
package Controllers import ( "TaibaiSupport/Models" "encoding/json" "fmt" "github.com/streadway/amqp" "log" "os" ) func failOnError(err error, msg string) { if err != nil { log.Fatalf("%s: %s", msg, err) } } // 不断消费mq的消息 var RabbitmqEventReceivedChan chan Models.TaibaiClassroomEvent var RabbitmqEventTob...
package api import ( "fmt" "net/http" "net/http/httptest" "testing" ) // TestFixer_GetRate to test getting the rate from fixer data. func TestFixer_GetRate(t *testing.T) { f := Fixer{ Base: "EUR", Date: "2017-10-26", Rates: map[string]float32{ "AUD": 1.5248, "BGN": 1.9558, "BRL": 3.803, "CAD": 1.5041, "...
package main import ( "errors" "fmt" ) func main() { f1 := func(i int) (int, error) { if i == 100 { return -1, errors.New("overload") } else { return i - 1, nil } } var r, e = f1(100) if e != nil { fmt.Println("error:", e) } else { fmt.Println("success:", r) } r, e = f1(99) if e != nil { ...
package nebula import ( "encoding/binary" "errors" "fmt" "time" "github.com/flynn/noise" "github.com/sirupsen/logrus" "github.com/slackhq/nebula/cert" "github.com/slackhq/nebula/firewall" "github.com/slackhq/nebula/header" "github.com/slackhq/nebula/iputil" "github.com/slackhq/nebula/udp" "golang.org/x/ne...
// Copyright © 2017 stripe-proxy 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 ag...
package main import ( // "bytes" "context" "encoding/json" "fmt" "net" "net/http" "os" "time" "github.com/containernetworking/cni/pkg/skel" "github.com/containernetworking/cni/pkg/types" "github.com/containernetworking/cni/pkg/types/current" "github.com/containernetworking/cni/pkg/version" ) const ( logP...
package main //Invalid //Checks the validity of assigment of one defined type var to anohter whcih are resolvable to same base type func main() { type num int type num1 num var a num var b num1 a = b }
// Copyright (c) 2019 VMware, Inc. All Rights Reserved. // SPDX-License-Identifier: Apache-2.0 package k8s import ( corev1 "k8s.io/api/core/v1" "k8s.io/cli-runtime/pkg/printers" "k8s.io/client-go/discovery" "k8s.io/client-go/dynamic" "k8s.io/client-go/kubernetes/scheme" "k8s.io/client-go/rest" "k8s.io/client-g...
package notifier import ( "time" "github.com/void616/gm.mint.sender/internal/watcher/db/types" "github.com/void616/gotask" ) // Task loop func (n *Notifier) Task(token *gotask.Token) { for !token.Stopped() { // get list list, err := n.dao.ListUnnotifiedIncomings(itemsPerShot) if err != nil { n.logger....