text
stringlengths
11
4.05M
package pilgrims type Players [4]Player type GameState struct { Players Cards Board } type Cards struct { Resources DevelopmentCards SpecialCards } type SpecialCards struct { LongestRoad byte LargestArmy byte } type Resources struct { Brick byte Wool byte Ore byte Grain byte Lumber byte } type...
package module // 权限 type Privilege struct { BaseTable // 展示名称 Label string `json:"label"` // path Path string `json:"path"` // 功能名 Name string `json:"name"` // 图标 Icon string `json:"icon"` // 是否是叶子节点(0:不是,1:是) IsLeaf uint `json:"is_leaf"` // 是否禁用(0:未禁用,1:禁用) IsForbidden uint `json:"is_forbidden"` // 父级节...
package api import ( "encoding/json" "strconv" "time" "github.com/cloudfly/ecenter/tools" "github.com/cloudfly/mowa" log "github.com/sirupsen/logrus" "github.com/valyala/fasthttp" ) func init() { registerRoute("GET", "/v1/blocks", GetBlocks, 0) registerRoute("POST", "/v1/blocks", AddBlock, 0) registerRoute...
package main import ( "log" "os" "os/signal" "github.com/gorilla/websocket" ) // catchSig cleans up our websocket conenction if we kill the program // with a ctrl-c func catchSig(ch chan os.Signal, c *websocket.Conn) { // block on waiting for a signal <-ch err := c.WriteMessage(websocket.CloseMessage, websock...
// DO NOT EDIT. This file was generated by "github.com/frk/gosql". package testdata import ( "github.com/frk/gosql" ) func (q *InsertOnConflictIgnoreSliceQuery) Exec(c gosql.Conn) error { var queryString = `INSERT INTO "test_onconflict" AS k ( "key" , "name" , "fruit" , "value" ) VALUES ` // ` params :=...
package admin import ( "firstProject/app/dto" "firstProject/app/models" "firstProject/database" ) //CreateUser 创建用户 func CreateAdmin(dto dto.AdminDto) error { admin := models.Admin{} admin.Username = dto.Username admin.Password = dto.Password admin.Name = dto.Name admin.Phone = dto.Phone err := database.DB.C...
package cloudconfig import ( "context" "fmt" "strings" "testing" "github.com/giantswarm/apiextensions/pkg/apis/provider/v1alpha1" "github.com/giantswarm/certs" ignition "github.com/giantswarm/k8scloudconfig/ignition/v_2_2_0" k8scloudconfig "github.com/giantswarm/k8scloudconfig/v_4_4_0" "github.com/giantswarm...
package cryptographic import ( "crypto/aes" "crypto/cipher" "crypto/rand" "io/ioutil" "log" "io" ) // encrypt file with aes and save to another file. func EncryptFile(src, dest, key string) error { plaintext, err := ioutil.ReadFile(src) if err != nil { log.Println("Read file failed.") return err } bloc...
package envoyconfig import ( envoy_config_accesslog_v3 "github.com/envoyproxy/go-control-plane/envoy/config/accesslog/v3" envoy_config_core_v3 "github.com/envoyproxy/go-control-plane/envoy/config/core/v3" envoy_config_route_v3 "github.com/envoyproxy/go-control-plane/envoy/config/route/v3" envoy_http_connection_man...
package server func (h *httpInteractor) routes() { //regular endpoints h.router.HandleFunc("/", h.indexPage()).Methods("GET") h.router.HandleFunc("/upload", h.uploadEndpoint()).Methods("POST") //static files h.router.HandleFunc("/static/css/bulma.min.css", h.bulmaCss()).Methods("GET") h.router.HandleFunc...
/** Merge two sorted linked lists and return it as a sorted list. The list should be made by splicing together the nodes of the first two lists. **/ /** * Definition for singly-linked list. * type ListNode struct { * Val int * Next *ListNode * } */ func mergeTwoLists(l1 *ListNode, l2 *ListNode) *ListNo...
package minilock import ( "github.com/sycamoreone/base58" "os" "testing" ) func TestID(t *testing.T) { idBase58 := "radFxzH6yDYDyHiaZpvUr8UhqbpEzjQdfSF3XeZi9Py72" idBytes, err := base58.Decode(idBase58) if err != nil { t.Fatal(err) } if len(idBytes) != 33 { t.Logf("minilock ID should have 33 bytes, but ha...
package handlers import ( "net/http" "net/http/httptest" "strings" "testing" . "github.com/smartystreets/goconvey/convey" "github.com/stellar/gateway/bridge/config" "github.com/stellar/gateway/horizon" "github.com/stellar/gateway/mocks" "github.com/stellar/gateway/net" "github.com/stellar/gateway/test" "gi...
package podprocess import ( "database/sql" "time" "github.com/square/p2/pkg/launch" "github.com/square/p2/pkg/logging" "github.com/square/p2/pkg/types" "github.com/square/p2/pkg/util" _ "github.com/mattn/go-sqlite3" ) type FinishService interface { // Closes any resources such as database connection Close(...
package tzdb import ( "testing" "time" ) const ( baseURL = "http://api.timezonedb.com" apiKey = "Q34227MHXHAF" spath = "v2.1/get-time-zone" ) func Test_GetTimezone(t *testing.T) { now := time.Now().Unix() t.Logf("now: %d", now) client, err := NewTzdbClient(baseURL, apiKey, 3) if err != nil { t.Fatal(er...
/* Given what is supposed to be typed and what is actually typed, write a function that returns the broken key(s). The function looks like: findBrokenKeys(correct phrase, what you actually typed) Examples findBrokenKeys("happy birthday", "hawwy birthday") ➞ ["p"] findBrokenKeys("starry night", "starrq light") ➞ ["...
package osbuild2 import ( "encoding/json" "fmt" ) // Single stage of a pipeline executing one step type Stage struct { // Well-known name in reverse domain-name notation, uniquely identifying // the stage type. Type string `json:"type"` // Stage-type specific options fully determining the operations of the In...
package main import ( "context" _ "github.com/lib/pq" "github.com/the-gigi/delinkcious/pkg/db_util" "github.com/the-gigi/delinkcious/pkg/link_manager_client" om "github.com/the-gigi/delinkcious/pkg/object_model" "log" "os" "os/exec" ) func check(err error) { if err != nil { panic(err) } } func initDB() {...
package counters type alertCounter int // New created exported function // type alertCounter func New(value int) alertCounter { return alertCounter(value) }
package main import ( "fmt" "math/big" ) func main() { sum := big.NewInt(1) var x int64 for x = 2; x < 1001; x++ { n := big.NewInt(x) n = n.Exp(n,n,nil) sum = sum.Add(sum,n) } sum_str := sum.String() l := len(sum_str) last_ten := sum_str[l-10:] fmt.Println(last_ten) }
package accesslist import ( "errors" "fmt" "testing" "github.com/10gen/realm-cli/internal/cli" "github.com/10gen/realm-cli/internal/cloud/realm" "github.com/10gen/realm-cli/internal/utils/test/assert" "github.com/10gen/realm-cli/internal/utils/test/mock" "github.com/Netflix/go-expect" ) func TestAllowedIPCr...
package go_workerpool type Dispatcher struct { WorkerPool chan chan Job Len int } func NewDispatcher(n int) *Dispatcher { return &Dispatcher{ WorkerPool: make(chan chan Job, n), Len: n, } } func (d *Dispatcher) Run() { for i := 0; i < d.Len; i++ { worker := NewWorker(d.WorkerPool) worker.S...
package handler import ( "encoding/json" "fmt" "github.com/gorilla/websocket" "github.com/tiagorlampert/CHAOS/client/app/entities" "github.com/tiagorlampert/CHAOS/client/app/environment" "github.com/tiagorlampert/CHAOS/client/app/gateways" ws "github.com/tiagorlampert/CHAOS/client/app/infrastructure/websocket" ...
package main import ( "database/sql" "fmt" "log" _ "github.com/lib/pq" ) const ( dbHost = "localhost" dbPort = "5432" dbUser = "root" dbPassword = "" dbName = "postgres" ) // SQLDB - Books DB Object / Bookshelf type SQLDB struct { db *sql.DB table string } // Book - A book info type B...
// Copyright 2022 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 agreed to i...
package systemed // 重启系统 func Reboot() ([]byte, error) { sys := NewSystemed("systemctl") sys.SetArgs("reboot") rs, err := sys.Exec() return rs, err } // 关闭系统,切断电源 func PowerOff() ([]byte, error) { sys := NewSystemed("systemctl") sys.SetArgs("poweroff") rs, err := sys.Exec() return rs, err } // CPU停止工作 func H...
package PDU import ( "github.com/andrewz1/gosmpp/Data" "github.com/andrewz1/gosmpp/Exception" "github.com/andrewz1/gosmpp/Utils" ) type UnbindResp struct { Response } func NewUnbindResp() *UnbindResp { a := &UnbindResp{} a.Construct() return a } func (c *UnbindResp) Construct() { defer c.SetRealReference(c...
// This file was generated for SObject ContentDocument, API Version v43.0 at 2018-07-30 03:47:59.979096702 -0400 EDT m=+46.323441317 package sobjects import ( "fmt" "strings" ) type ContentDocument struct { BaseSObject ArchivedById string `force:",omitempty"` ArchivedDate string `force:"...
package util_test import ( "testing" "github.com/tvacare/web-crawler/util" ) func TestSliceContains(t *testing.T) { s1 := "pineapple" slice1 := []string{"apple", "banana", "orange", "pear"} b1, p1 := util.SliceContains(s1, slice1) if b1 == false || p1 == "" { t.Errorf("Slice contains should have matched - %...
package files import ( "bufio" "fmt" "io/ioutil" "log" "os" "path/filepath" "strings" ) const ( PROGRAM_HOME = "/.fs_sync/" SYNC_LIST_FILE = "/.fs_sync/.synclist" WHITE_LIST_FILE = "/.fs_sync/.whitelist" ) var SUFFIX_WHITELIST = [...]string{".mod", ".sum"} type FileSyncManager struct { SyncListFile ...
package base import ( "errors" "fmt" "gengine/context" "reflect" "sync" ) type ConcStatement struct { Assignments []*Assignment FunctionCalls []*FunctionCall MethodCalls []*MethodCall } func (cs *ConcStatement) AcceptAssignment(assignment *Assignment) error { cs.Assignments = append(cs.Assignments, assi...
package main import ( "bytes" "errors" "fmt" "io/ioutil" "log" "os" "path/filepath" "strings" "github.com/fatih/color" _ "github.com/go-sql-driver/mysql" "github.com/pingcap/tidiff/config" "github.com/pingcap/tidiff/executor" "github.com/pingcap/tidiff/history" "github.com/pingcap/tidiff/uimode" "githu...
package tasks_test import ( "testing" "github.com/benjlevesque/task/mocks" "github.com/benjlevesque/task/pkg/tasks" "github.com/benjlevesque/task/types" "github.com/stretchr/testify/mock" ) func TestEditMock(t *testing.T) { store := &mocks.TaskEditer{} editor := &mocks.TextEditer{} store.On("GetTask", 1).Ret...
package article_model import ( "go_web/app/http/models" "go_web/pkg/logger" "go_web/pkg/model" "go_web/pkg/util" ) // Article 文章模型 type Article struct { models.BaseModel Title string `json:"title"` Body string `json:"body"` } func Get(idstr string) (Article, error) { var article Article id := util.String...
package engine import ( "context" "errors" "fmt" "log" "sort" "strconv" "strings" "time" "github.com/agext/levenshtein" "github.com/eve-spyglass/spyglass2/feeds" "github.com/sirupsen/logrus" "gonum.org/v1/gonum/graph/simple" ) type ( IntelEngine struct { Galaxy NewEden CurrentMap str...
package catp import ( "encoding/xml" "github.com/thought-machine/finance-messaging/iso20022" ) type Document01500101 struct { XMLName xml.Name `xml:"urn:iso:std:iso:20022:tech:xsd:catp.015.001.01 Document"` Message *ATMDepositCompletionAcknowledgementV01 `xml:"ATMDpstCmpltnAck"` } ...
//https://leetcode-cn.com/problems/3sum/ package main import "fmt" func main() { // nums := []int{-1, 0, 1, 2, -1, -4} // nums := []int{3, -2, 1, 0} // nums := []int{-2, 0, 0, 2, 2} nums := []int{-4, -2, -2, -2, 0, 1, 2, 2, 2, 3, 3, 4, 4, 6, 6} fmt.Println(threeSum(nums)) } //排序 + 双指针 func three...
/* * Pause a server. * * When a virtual machine is paused, its state is frozen (e.g. memory, open applications) * and monitoring ceases. Billing charges for CPU and memory stop. A paused machine can be * quickly brought back to life by issuing the "On" power command. * Any applicable licensing charges continue to...
package cats import ( "context" "encoding/json" "io/ioutil" "net/http" "github.com/NYTimes/marvin" "github.com/golang/protobuf/proto" "google.golang.org/appengine/log" ) func (s *service) addCat(ctx context.Context, r interface{}) (interface{}, error) { // make type conversion to the expected Cat pointer r...
package main import ( "context" "github.com/aws/aws-lambda-go/events" "testing" ) var ctx context.Context = nil var in = events.APIGatewayProxyRequest{ Body: "{\"service\": \"https://graphical.weather.gov/xml/SOAP_server/ndfdXMLserver.php\", \"requestBody\": \"https://graphical.weather.gov/xml/docs/SOAP_Requests...
package model import ( "time" "golang.org/x/oauth2" "google.golang.org/api/calendar/v3" ) type Event struct { Summary string Start calendar.EventDateTime End calendar.EventDateTime } type Event2 struct { Token oauth2.Token `json:"token"` CalendarId string `json:"calendarId"` Summary str...
package graphql_test import ( "testing" "github.com/graphql-go/graphql" "github.com/graphql-go/graphql/gqlerrors" "github.com/graphql-go/graphql/testutil" ) func TestValidate_NoUndefinedVariables_AllVariablesDefined(t *testing.T) { testutil.ExpectPassesRule(t, graphql.NoUndefinedVariablesRule, ` query Foo...
package entity import ( "log" "posthis/storage" "time" "gorm.io/gorm" ) type Reply struct { ID uint `gorm:"primarykey"` CreatedAt time.Time UpdatedAt time.Time Content string `gorm:"default:''"` UserID uint //User.ID PostID uint //Post.ID Media []*Media `gorm:"foreignKey:Reply...
package group import ( "Open_IM/pkg/common/db/mysql_model/im_mysql_model" "Open_IM/pkg/common/log" "Open_IM/pkg/proto/group" "context" ) func (s *groupServer) GetGroupApplicationList(_ context.Context, pb *group.GetGroupApplicationListReq) (*group.GetGroupApplicationListResp, error) { log.Info("", "", "rpc GetGr...
package main import ( "github.com/funkygao/gobench/util" "sync" "testing" ) func main() { b := testing.Benchmark(benchmarkDefer) util.ShowBenchResult("defer", b) b = testing.Benchmark(benchmarkDeferUnlock) util.ShowBenchResult("defer mutex unlock", b) b = testing.Benchmark(benchmarkNodeferUnlock) util.ShowBe...
package accesslist import ( "errors" "strings" "testing" "github.com/10gen/realm-cli/internal/cli" "github.com/10gen/realm-cli/internal/cloud/realm" "github.com/10gen/realm-cli/internal/utils/test/assert" "github.com/10gen/realm-cli/internal/utils/test/mock" ) func TestAllowedIPDeleteHandler(t *testing.T) { ...
package main import ( "fmt" "strings" "os" "image" "image/gif" "image/draw" "golang.org/x/crypto/ssh/terminal" "github.com/nfnt/resize" "github.com/ivolo/go-image-to-ascii" "image/color/palette" "github.com/ivolo/go-giphy" "errors" "net/http" ) func check(err error) { if err != nil { ...
package profile import ( "testing" "reflect" "s3-web-browser/server/go/domain/db" ) func TestTransaction(t *testing.T) { conn, err := db.ConnectionForTest() if err != nil { t.Fatalf("failed test %#v", err) return } defer conn.Close() tx, err := conn.Begin() if err != nil { t.Fatalf("failed test %#v"...
package assert const ASSERT bool = false func Assert(b bool) {}
package grpcutil import ( "fmt" xtr "github.com/brown-csci1380/tracing-framework-go/xtrace/client" "golang.org/x/net/context" "google.golang.org/grpc" "google.golang.org/grpc/metadata" "os" ) // Handles propagation of x-trace metadata around grpc server requests (as the ServerOption to grpc.NewServer) var XTrac...
package pathfileops import ( "errors" "fmt" "os" "time" ) // FileInfoPlus - Conforms to the os.FileInfo interface. This structure will store // os.FileInfo information plus additional information related to a file or directory. // type FileInfoPlus struct { // isFInfoInitialized - Not part of FileInfo inte...
package main import ( "flag" "log" "net/http" "os" "github.com/gorilla/context" "github.com/gorilla/mux" "github.com/matscus/Hamster/Mock/dadata/cache" "github.com/matscus/Hamster/Mock/dadata/handlers" ) func init() { cache.LoadCache() } var ( listenport string mode string ) func main() { flag.St...
package main import ( "flag" "fmt" "github.com/APTrust/exchange/context" "github.com/APTrust/exchange/models" "github.com/APTrust/exchange/workers" "os" ) // apt_fetch receives messages from nsqd describing // items in the S3 receiving buckets. It fetches and and validates // tar files, then queues them for sto...
package protocol import ( "fmt" "testing" "time" "github.com/stretchr/testify/assert" ) var header = &Header{ OpCode: OpCodeQuery, ResponseTo: 1, RequestID: 2, MessageLength: 300, } func TestHeader_Encode(t *testing.T) { totals := 1000000 start := time.Now().UnixNano() for i := 0; i < total...
package olm import ( "testing" opregistry "github.com/operator-framework/operator-registry/pkg/registry" "github.com/stretchr/testify/require" "k8s.io/apiextensions-apiserver/pkg/apis/apiextensions/v1beta1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/apimachinery/pkg/labels" ) func TestLabelSetsFor(t...
package spool import ( "bytes" "context" "crypto/sha256" "fmt" "strings" "time" "cloud.google.com/go/spanner" admin "cloud.google.com/go/spanner/admin/database/apiv1" "github.com/cloudspannerecosystem/spool/model" databasepb "google.golang.org/genproto/googleapis/spanner/admin/database/v1" ) // State repre...
package config type Config struct { DB database `toml:"database"` } type database struct { Server string Port int User string Password string DbName string }
package futures import ( "testing" "github.com/stretchr/testify/suite" ) type accountServiceTestSuite struct { baseTestSuite } func TestAccountService(t *testing.T) { suite.Run(t, new(accountServiceTestSuite)) } func (s *accountServiceTestSuite) TestGetBalance() { data := []byte(`[ { "accountAlias": "Sgs...
// Copyright 2022 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 agreed to in wr...
package blocker import ( "testing" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/suite" ) // UnknownBlockerTestSuite 是 UnknownBlocker 的单元测试的 Test Suite type UnknownBlockerTestSuite struct { suite.Suite blockerPool *BlockerPool } // SetupSuite 设置测试环境 func (suite *UnknownBlockerTestSuite) Set...
package shardkv import ( "sync" "umich.edu/eecs491/proj4/shardmaster" ) type Clerk struct { mu sync.Mutex sm *shardmaster.Clerk impl ClerkImpl } func MakeClerk(shardmasters []string) *Clerk { ck := new(Clerk) ck.sm = shardmaster.MakeClerk(shardmasters) ck.InitImpl() return ck } func (ck *Clerk) ...
package aggregatedrange import ( "fmt" "io/ioutil" "log" "math/rand" "testing" "time" "incognito-chain/common" "incognito-chain/privacy/operation" "github.com/stretchr/testify/assert" ) func TestMain(m *testing.M) { log.SetOutput(ioutil.Discard) m.Run() } var _ = func() (_ struct{}) { fmt.Println("This ...
package main import "fmt" // Runes are just characters. UTF-8 character set is supported func main() { fmt.Println('A') for i := 300; i < 310; i++ { fmt.Println(i, "String value of Rune ", string(i)) } }
package main import ( "context" "encoding/json" "fmt" "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/dynamodb" "github.com/teris-io/shortid" "github.com/wooiliang/aws-lambda-go/events" "github.com/wooiliang/aw...
package main import ( pf "../pathfileops" p2 "../pathfileops/v2" "fmt" "io" "os" fp "path/filepath" "strings" "time" ) /* import ( pf "../pathfileops" "fmt" "io" fp "path/filepath" "strings" ) */ func main() { mainTests{}.mainTests117SortFileMgrsCaseSensitive() } type mainTests str...
package http import ( "net/http" "bytes" "fmt" "encoding/json" "github.com/lygo/health" ) type Registrator interface { Handle(pattern string, handler http.Handler) } // read that docs for understend more params // https://kubernetes.io/docs/tasks/configure-pod-container/configure-liveness-readiness-probes/ ...
// SPDX-License-Identifier: Unlicense OR MIT package gpu import ( "time" "github.com/gop9/olt/gio/app/internal/gl" ) type timers struct { ctx *context timers []*timer } type timer struct { Elapsed time.Duration ctx *context obj gl.Query state timerState } type timerState uint8 const ( timer...
/* Copyright 2017 The Kubernetes 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, ...
package main import ( "fmt" "os" ) func main() { env, ok := os.LookupEnv("NAME") if !ok { fmt.Println(`ENV Variable not found`) os.Exit(1) } fmt.Println(env, "hello, this is working..") }
package compactor import "github.com/golang/snappy" // snappy compress var ( defaultSnappyCompactor Compactor = NewSnappy() ) type Snappy struct{} func NewSnappy() *Snappy { return new(Snappy) } func (s *Snappy) Name() string { return "snappy" } func (s *Snappy) Encode(src []byte) (dst []byte, err error) { ds...
package ibc import ( host "github.com/cosmos/ibc-go/modules/core/24-host" "github.com/gookit/gcli/v3" "github.com/ovrclk/akcmd/cmd/cosmos-sdk/x/ibc/channel" "github.com/ovrclk/akcmd/cmd/cosmos-sdk/x/ibc/client/cli" "github.com/ovrclk/akcmd/cmd/cosmos-sdk/x/ibc/connection" ) // GetQueryCmd returns the cli query c...
// Copyright 2020 Frederik Zipp. All rights reserved. // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. package canvas import ( "image" "image/color" "testing" ) func BenchmarkContext(b *testing.B) { draws := make(chan []byte) go func() { for range draws {...
package testdata import ( "github.com/frk/gosql/internal/testdata/common" ) type FilterBasicRecords struct { User *common.User2 `rel:"test_user"` Filter common.FilterMaker }
package permuter import ( "fmt" "testing" ) func ExamplePermute() { myList := []interface{}{1, 2, 3} Permute(myList, func(l []interface{}) { fmt.Print("[") for index, e := range myList { fmt.Print(e) if index != len(myList) { fmt.Print(",") } } fmt.Print("]") }) //Output:[1,2,3][2,1,3][2,3,...
package ionic import ( "bytes" "encoding/json" "fmt" ) const ( getEntityOverviewEndpoint = "/v1/score/getEntityOverviewForEntity" ) func (ic *IonClient) GetEntityOverview(entity EntityInput, token string) (EntityOverview, error) { b, err := json.Marshal(entity) if err != nil { return EntityOverview{}, fmt.Er...
package cwb import ( "context" "net/http" "github.com/google/go-querystring/query" ) const ( // tide forecasts 1 month Tide1MonthId = "F-A0021-001" ) type TideForecastsService service type TideForecast1MonthOptions struct { Limit int `url:"limit,omitempty"` Offset int `url:"offset,omitemp...
package options import ( "flag" "github.com/spf13/pflag" ) type WebHookOptions struct { Port int KubeConfig string MasterURL string CertDir string SidecarConfig string VerFlag bool } func NewDefaultWebHookOptions() WebHookOptions { return WebHookOptions{ Port: 443, ...
package csvreader import ( "reflect" "strconv" "time" ) func setField(field reflect.Value, valStr string) error { if !field.CanSet() { return nil } switch field.Kind() { case reflect.Bool: if val, err := strconv.ParseBool(valStr); err == nil { field.Set(reflect.ValueOf(val).Convert(field.Type())) } c...
package diffsquares // SquareOfSum calculates square of the sum of numbers to n func SquareOfSum(n int) int { sum := (n * (n + 1) / 2) return sum * sum } // SumOfSquares calculates sum of squares to n func SumOfSquares(n int) int { return n * (n + 1) * (2*n + 1) / 6 } // Difference calculate square of sum minus s...
/* Copyright 2020 The Flux 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, softwar...
package main import ( "fmt" "os" "path" "strings" "github.com/rightscale/rsc/ca" "github.com/rightscale/rsc/cm15" "github.com/rightscale/rsc/cm16" "github.com/rightscale/rsc/cmd" "github.com/rightscale/rsc/policy" "github.com/rightscale/rsc/rl10" "github.com/rightscale/rsc/rsapi" "github.com/rightscale/rs...
package sql import ( "context" "database/sql" "fmt" "reflect" "github.com/opentracing/opentracing-go" "github.com/pkg/errors" "github.com/zdao-pro/sky_blue/pkg/util" ) var ( //ErrNoPtr .. ErrNoPtr = errors.New("noptr") //ErrNoResult .. ErrNoResult = errors.New("noResult") ) //Model .. type Model struct {...
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/todolist" ) type cre...
package main import ( "bufio" "bytes" "fmt" "os" "strconv" "strings" ) func main() { var ( n int arr []int ) fmt.Scanf("%d", &n) s := bufio.NewScanner(os.Stdin) s.Scan() temp := s.Text() for _, x := range strings.Split(temp, " ") { num, _ := strconv.Atoi(x) arr = append(arr, num) } var shift...
// ˅ package main import ( "fmt" "os" ) // ˄ type CommandList struct { // ˅ // ˄ nodes []INode // ˅ // ˄ } func NewCommandList() *CommandList { // ˅ return &CommandList{} // ˄ } func (self *CommandList) Parse(context *Context) { // ˅ for { if context.GetToken() == "" { fmt.Println("Missing 'en...
/* Go Language Raspberry Pi Interface (c) Copyright David Thorpe 2016-2018 All Rights Reserved Documentation http://djthorpe.github.io/gopi/ For Licensing and Usage information, please see LICENSE.md */ // Low Noise Amplifier Settings package rfm69 import "github.com/djthorpe/sensors" func (this *rfm69) LN...
package main import ( "fmt" "os" "github.com/containerd/containerd/pkg/seed" "github.com/docker/buildx/commands" "github.com/docker/buildx/version" "github.com/docker/cli/cli" "github.com/docker/cli/cli-plugins/manager" "github.com/docker/cli/cli-plugins/plugin" "github.com/docker/cli/cli/command" "github.c...
package schema import ( "encoding/json" "fmt" "net/http" "github.com/AlecAivazis/survey/v2" "github.com/MakeNowJust/heredoc" "github.com/loginradius/lr-cli/api" "github.com/loginradius/lr-cli/prompt" "github.com/loginradius/lr-cli/request" "github.com/loginradius/lr-cli/config" "github.com/spf13/cobra" ) ...
package greek // Greek // TODO: These are just lowercase, should probably be a map of maps dividning // upper and lowercase. var Symbols = map[string]map[string]string{ "upper": map[string]string{ "alpha": "Α", "beta": "Β", "gamma": "Γ", "delta": "Δ", "epsilon": "Ε", "zeta": "Ζ", "eta": ...
package router import ( "github.com/labstack/echo" "teachEcho/control" ) //必须要token func AdmRouter(adm *echo.Group) { adm.POST("/class/add", control.ClassAdd) adm.GET("/class/drop/:id", control.ClassDrop) adm.POST("/class/edit", control.ClassEdit) adm.GET("/user/page", control.UserPage) }
package main import ( "bufio" "io" "io/ioutil" "math/rand" "net/http" "net/http/httptest" "os" "strings" "testing" "time" ) var endpoints = []string{"cats", "dogs", "birds", "fish"} var letterBytes = "abcdefghijklmnopqrstuvwxyz" func RandStringBytesTesting(n int) string { b := make([]byte, n+1) rand.See...
package sort import "testing" func TestMaxK(t *testing.T) { nums := []int{2, 2, 1} t.Log(MaxK(nums, 2)) }
package main import ( "gitlab.nordstrom.com/huggin/stacktracker" "github.com/vmware/govmomi" ) func main() { return }
package areamgr import ( _ "pb" "server" "server/libs/log" "server/share" ) var ( App *AreaMgr ) type AreaMgr struct { *server.Server quit chan int Area *Areas } func (app *AreaMgr) OnPrepare() bool { log.LogMessage(app.AppId, " prepared") return true } func (app *AreaMgr) OnEvent(e string, args map[stri...
package libseccomp // Action is seccomp trap action type Action uint32 // Action defines seccomp action to the syscall // default value 0 is invalid const ( ActionAllow Action = iota + 1 ActionErrno ActionTrace ActionKill ) // MsgDisallow, Msghandle defines the action needed when trapped by // seccomp filter con...
package main import "fmt" /* func leftChild(i int) int { return 2*i + 1 } func percDown(nums []int, i, N int) { var ( child, tmp int ) for tmp = nums[i]; leftChild(i) < N; i = child { child = leftChild(i) if child != N-1 && nums[child+1] > nums[child] { child++ } if tmp < nums[child...
/* * Copyright 2018, CS Systemes d'Information, http://www.c-s.fr * * 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 requir...
package main import ( cryptoRand "crypto/rand" "encoding/json" "fmt" "io" "io/fs" "log" "math" "math/big" "os" "path/filepath" "time" "golang.org/x/exp/rand" "gopkg.in/yaml.v3" ) type Config struct { RootDir string `yaml:"root_dir"` Seed uint64 `yaml:"seed,omitempty"` Changers []C...
package lla import ( "fmt" "runtime" "time" ) // log level const ( LogLevelEmpty int = iota LogLevelPanic LogLevelError LogLevelWarn LogLevelInfo LogLevelDebug LogLevelDump LogLevelTrace LogLevelMax ) var logLevelNames = [LogLevelMax]string{ "EMPTY", "PANIC", "ERROR", "WARN ", "INFO ", "DEBUG", "DUMP ",...
package main import ( "bytes" "encoding/binary" "fmt" "github.com/nsf/termbox-go" "net" "time" ) type point struct { X int32 Y int32 N int32 } func main() { adr, err := net.ResolveUDPAddr("udp", "127.0.0.1:5000") if err != nil { fmt.Println(err) return } listener, err := net.ListenUDP("udp", adr) ...