text
stringlengths
11
4.05M
package main import ( "crypto/md5" "crypto/sha512" "encoding/base64" "encoding/xml" "fmt" "log" "os" "strings" "time" ) type PwdConfigLegacy struct { // legacy compatibility XMLName xml.Name `xml:"config"` Salt string `xml:"salt"` Site []struct { Name string `xml:"name,attr"` Url string `...
// Copyright (c) 2013-2014 The btcsuite developers // Use of this source code is governed by an ISC // license that can be found in the LICENSE file. package base58 import ( "crypto/sha256" "errors" "sync" ) var bufPool = &sync.Pool{ New: func() interface{} { return make([]byte, 0) }, } // ErrChecksum indicates...
package wallet import ( "encoding/hex" "testing" "time" "github.com/btcsuite/btcwallet/walletdb" "github.com/btcsuite/btcwallet/wtxmgr" "github.com/btcsuite/btcd/btcutil" ) var ( TstSerializedTx, _ = hex.DecodeString("010000000114d9ff358894c486b4ae11c2a8cf7851b1df64c53d2e511278eff17c22fb7373000000008c4930460...
package main import ( "fmt" "log" "github.com/alaaattya/recipy-admin-api/middlewares" "github.com/alaaattya/recipy-admin-api/requestHandlers" "github.com/gin-gonic/gin" "github.com/go-bongo/bongo" "github.com/spf13/viper" ) func main() { viper.SetConfigType("yaml") viper.SetConfigName("config") // name of ...
package _264_Ugly_Number_2 func nthUglyNumber(n int) int { var ( u = make([]int, n) idx2, idx3, idx5 int k = 1 ) u[0] = 1 for k < n { u[k] = min(u[idx2]*2, u[idx3]*3, u[idx5]*5) if u[idx2]*2 == u[k] { idx2++ } if u[idx3]*3 == u[k] { idx3++ } if u[idx5]*5 == u[...
package robot import ( "github.com/ev3go/ev3dev" ) type Engine struct { motorLeft *ev3dev.TachoMotor motorRight *ev3dev.TachoMotor speedLeft int speedRight int speedLevel int } func (engine *Engine) Turn(correction int) { engine.speedLeft = (engine.speedLevel * engine.motorLeft.MaxSpeed() / 100) + correcti...
package main import "fmt" // 测试方法1 func test01() { fmt.Println("test01...") } // 测试方法2 func test02() { // 显示调用panic函数 panic("test02方法:发生panic异常...") } // 测试方法3 func test03() { fmt.Println("test03...") } // 程序当中,有些异常是致命的异常,出现之后会导致程序的中止运行 // 在go语言当中,panic异常,就是会导致程序的中止运行 func main() { // 调用测试方法 test01() test0...
/* * @lc app=leetcode.cn id=213 lang=golang * * [213] 打家劫舍 II */ // @lc code=start package main import "fmt" func rob(nums []int) int { if len(nums) == 0 { return 0 } if len(nums) == 1 { return nums[0] } if len(nums) == 2 { return max(nums[0], nums[1]) } return max(myRob(nums[1:]), m...
package teamusers import ( "time" ) const ( // TeamsCreateTeamUserEndpoint is a string representation of the current endpoint for creating team user TeamsCreateTeamUserEndpoint = "v1/teamUsers/createTeamUser" // TeamsUpdateTeamUserEndpoint is a string representation of the current endpoint for updating team user ...
/* Taking each four digit number of an array in turn, return the number that you are on when all of the digits 0-9 have been discovered. If not all of the digits can be found, return "Missing digits!". Examples findAllDigits([5175, 4538, 2926, 5057, 6401, 4376, 2280, 6137, 8798, 9083]) ➞ 5057 // digits found: 517- ...
package main import ( "bytes" "context" "fmt" "io/ioutil" "log" "os" "path" "time" "go.mongodb.org/mongo-driver/bson" "go.mongodb.org/mongo-driver/mongo" "go.mongodb.org/mongo-driver/mongo/gridfs" "go.mongodb.org/mongo-driver/mongo/options" ) func InitiateMongoClient() *mongo.Client { var err error var...
package sort // CountSort 计数排序 // maxNumber 最大数,通过 MaxNumber 获取 func CountSort(arr *[]int, maxNumber int) { // 额外数组空间 ext := make([]int, maxNumber+1) // 遍历数组,开始计数 for _, v := range *arr { ext[v]++ } // 排序 var arrIdx int for i, v := range ext { // 如果不为0则存在arr中数i,切共v个i ...
// Copyright 2016 Google Inc. 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 la...
package application import ( "errors" "github.com/charly3pins/eShop/domain" "github.com/charly3pins/eShop/domain/base" "github.com/gofrs/uuid" ) var ( ErrInvalidUserID = errors.New("invalid user id") ErrInvalidOrderID = errors.New("invalid order id") ErrOrderWithEmptyProducts = errors.New("or...
package controller import ( "fmt" "sync" "time" // coreinformer "k8s.io/client-go/informers/core/v1" "k8s.io/api/core/v1" "k8s.io/apimachinery/pkg/api/errors" "k8s.io/apimachinery/pkg/util/wait" // "k8s.io/apimachinery/pkg/types" utilruntime "k8s.io/apimachinery/pkg/util/runtime" // "k8s.io/apimachinery/pkg...
// Copyright 2017 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 etcd import ( "sync" "context" "comm/registry" "github.com/coreos/etcd/client" ) type etcdRegistry struct { kapi client.KeysAPI nodes map[string]*registry.Service name string tag string sync.Mutex } func (r *etcdRegistry) Init() error { } func (r *etcdRegistry) Register(service *registry.Se...
package backend_model import "2021/yunsongcailu/yunsong_server/web/web_model" type BackendMenuModel struct { Id int64 MenuTitle string `xorm:"varchar(30)" json:"menu_title"` MenuIcon string `xorm:"varchar(50)" json:"menu_icon"` MenuSort int `xorm:"int" json:"menu_sort"` MenuPath string `xorm:"varchar(30)" json:"...
package rest import ( "fmt" "net/url" "github.com/jinmukeji/jiujiantang-services/pkg/rest" proto "github.com/jinmukeji/proto/v3/gen/micro/idl/partner/xima/core/v1" "github.com/kataras/iris/v12" ) // SubmitRemarkReq 提交分析报告备注的 Request type SubmitRemarkReq struct { Remark string `json:"remark"` } // SubmitRemark...
package ch05 import "errors" var errFindFirstRepeated = errors.New("not found") // Given a list of n elements, find the first repeated element func FindFirstRepeated(in []int) (int, error) { hmap := make(map[int]bool) for _, val := range in { if hmap[val] == true { return val, nil } else { hmap[val] = ...
package goteleport import ( "fmt" "github.com/parnurzeal/gorequest" "log" "strconv" "net/http" "io/ioutil" "encoding/json" ) func (t *Teleporter) clientListenForOutboundMessageBuffer(){ for { v, ok := <- t.out if !ok { continue } b, err := json.Marshal(v) if err != nil { log.Println(err) } ...
package main import ( "encoding/json" "fmt" "log" "net/http" "github.com/gorilla/mux" ) // Hello just a struct type Hello struct { Hello string } // Version a struct to show the version type Version struct { Version string } // our main function func main() { router := mux.NewRouter() router.HandleFunc("/...
package go_discovery import "fmt" package main import "fmt" func fac(n int) int { if n <= 0 { return 1 } return n * fac(n-1) } func facIter(n int) int { result := 1 for n > 0 { result *= n n-- } return result } func fac2(n int) int { result := 1 for i := 2; i <= n; i++ { fmt.Println("i is : ", i)...
package main import ( "fmt" "time" ) /* Main func is executed by the main goroutine. Adding 'go' before call a func or a method causes the func is executed in a newly created go routine. */ func main() { //fmt.Println(fib(6)) // counter execution on a separate go routine go counter(1 * time.Second) // main go ...
package object // Object represents values from our language in go type Object interface { Type() Type Inspect() string } // Type is used to determine the object variant type Type string const ( INTEGER_OBJ = "INTEGER" BOOLEAN_OBJ = "BOOLEAN" NULL_OBJ = "NULL" )
package error import ( "github.com/gin-gonic/gin" "yj-app/app/yjgframe/response" ) func Unauth(c *gin.Context) { response.BuildTpl(c, "error/unauth").WriteTpl() } func Error(c *gin.Context) { response.BuildTpl(c, "error/500").WriteTpl() } func NotFound(c *gin.Context) { response.BuildTpl(c, "error/404").WriteT...
package kvs import "github.com/stretchr/testify/mock" type MockHaproxy struct { mock.Mock } func (_m *MockHaproxy) DeleteService(name string) error { ret := _m.Called(name) var r0 error if rf, ok := ret.Get(0).(func(string) error); ok { r0 = rf(name) } else { r0 = ret.Error(0) } return r0 } func (_m *Mo...
package api import ( "common/logger" "fmt" "github.com/ant0ine/go-json-rest/rest" "github.com/bitly/go-simplejson" "io/ioutil" ) const ( KEY_OP = "operation" KEY_CLASS = "class" ) //define customize api request type AlcedoApiRequest struct { *rest.Request //匿名字段 operation string class string...
/* * Copyright (c) 2020 - present Kurtosis Technologies LLC. * All Rights Reserved. */ package testsuite import "github.com/kurtosis-tech/kurtosis-client/golang/networks" // Docs available at https://docs.kurtosistech.com/kurtosis-libs/lib-documentation type Test interface { // Docs available at https://docs.kur...
package main import ( "context" "github.com/gocolly/colly/v2" "go.mongodb.org/mongo-driver/bson" "log" "shopify_review_scrapper/config" "shopify_review_scrapper/data" "shopify_review_scrapper/phrasecounter" "strconv" "sync" ) func main() { reviewCollector := createConfiguredReviewCollector() scrapeReviewsT...
// Package errors is a drop-in replacement and extension of the Go standard // library's package [errors]. package errors import ( stderrors "errors" "fmt" "strings" ) // Error is the constant error type. // // See https://dave.cheney.net/2016/04/07/constant-errors. type Error string // Error implements the error...
package processors import ( "context" sdk "github.com/identityOrg/oidcsdk" "github.com/identityOrg/oidcsdk/impl/sdkerror" ) type DefaultAudienceValidationProcessor struct { } func NewDefaultAudienceValidationProcessor() *DefaultAudienceValidationProcessor { return &DefaultAudienceValidationProcessor{} } func (d...
package main import ( "fmt" "github.com/bitmaelum/bitmaelum-suite/cmd/bm-client/pkg/vault" "github.com/bitmaelum/bitmaelum-suite/internal" "github.com/bitmaelum/bitmaelum-suite/internal/config" "github.com/bitmaelum/bitmaelum-suite/pkg/address" "github.com/sirupsen/logrus" ) type options struct { Config stri...
package main import ( "fmt" ) func parameterDataType1(x, y int) { fmt.Println("As x & y have same datatype, we need to declare datatype only once.") } func parameterDataType2(x, y int, z string) { fmt.Println("we can declare params like this as well.") } func main() { parameterDataType1(1, 2) parameterDataType...
package reporter import ( "bytes" "net/http" "net/url" "reflect" "testing" ) func TestNewHTTPReporter(t *testing.T) { type args struct { scheme string host string username string password string } tests := []struct { name string args args want *HTTPReporter }{ // TODO: Add test cases. ...
package apis import ( "github.com/kataras/iris/context" ) func Login(ctx context.Context){ ctx.JSON(context.Map{"message": "Hello iris web framework."}) }
package main import ( sp "github.com/kpkhxlgy0/gs_libs/services" ) func startup() { go sig_handler() // init services discovery sp.Init("game", "snowflake") }
func climbStairs(n int) int { if n < 3 { return n } n1 := 1 n2 := 2 result := n1 + n2 for i := 3; i <= n; i++ { result = result + n2 n2 = n1 + n2 n1 = result - n2 } return n2 }
package main import ( "fmt" "io/ioutil" "log" "net/http" "strings" "github.com/gin-gonic/gin" ) func main() { r := gin.Default() // 指定用户使用GET请求访问/hello时,执行sayGenHello函数 r.GET("/hello", sayGinHello) r.GET("/book", func(c *gin.Context) { c.JSON(200, gin.H{ "method": "GET", }) }) r.POST("/book", fun...
package apiokex var ( BASE_URI = "https://www.okex.com/api/v1" FTRADE_URI = "/future_trade.do" FTRADE_CANCEL_URI = "/future_cancel.do" FTRADE_DEVOLVE_URI = "/future_devolve.do" ) type FutureResult struct { ErrorCode int64 `json:"error_code"` OrderId int64 `json:"order_id"` Result bool ...
package handler import ( "Golang-API-Game/pkg/dcontext" "Golang-API-Game/pkg/repository/characters" "Golang-API-Game/pkg/server/response" "errors" "log" "net/http" ) type UserCharacters struct { UserID string UserCharacterID string CharacterID string } type CharactersResponse struct { UserChar...
package ibmcloud import ( "net/http" "strings" "github.com/IBM/vpc-go-sdk/vpcv1" "github.com/pkg/errors" ) const vpcTypeName = "vpc" // listVPCs lists VPCs func (o *ClusterUninstaller) listVPCs() (cloudResources, error) { o.Logger.Debugf("Listing VPCs") ctx, cancel := o.contextWithTimeout() defer cancel() ...
package weldr import ( "encoding/json" "errors" "time" "github.com/osbuild/osbuild-composer/internal/common" "github.com/osbuild/osbuild-composer/internal/distro" "github.com/google/uuid" "github.com/osbuild/osbuild-composer/internal/target" ) type uploadResponse struct { UUID uuid.UUID ...
package main import ( "fmt" "reflect" ) type Animal struct { Name string } func (a Animal) A() { fmt.Println("A") } func (a Animal) B() { fmt.Println("B") } func main() { a := Animal{ Name: "ganshuoos", } t := reflect.TypeOf(a) fmt.Println(t.Kind(), t.Name(), t.NumMethod()) v := reflect.ValueOf(&a) v...
package conversion // //func ToInterface(slice []interface{}) []interface{} { // data := make([]interface{}, 0) // data = append(data, slice...) // return data //}
package main import ( "github.com/julienschmidt/httprouter" "net/http" "video_server/scheduler/orm" ) func videoDelHandler(writer http.ResponseWriter, request *http.Request, params httprouter.Params) { vid := params.ByName("video_id") if len(vid) == 0 { sendResponse(writer, 400, "video_id is should not be em...
package util /* #include "util.h" */ import "C" import "fmt" func GoSum(a,b int) int { s := C.sum(C.int(a),C.int(b)) fmt.Println(s) return int(s) }
package main import ( "github.com/koeng101/armos/devices/ar3" "log" "github.com/jmoiron/sqlx" _ "modernc.org/sqlite" "net/http/httptest" "os" "strings" "testing" ) var app App func TestMain(m *testing.M) { // Initialize the local sqlite database db, err := sqlx.Open("sqlite", ":memory:") if err != nil { ...
package httpclient import ( "context" "fmt" "net/http" "strings" "github.com/asecurityteam/transport" "github.com/asecurityteam/settings" transportd "github.com/asecurityteam/transportd/pkg" componentsd "github.com/asecurityteam/transportd/pkg/components" ) const ( // TypeDefault is used to select the defa...
// Package redis implements a registry in redis. package redis import ( "context" "fmt" "sort" "strings" "sync" "time" "github.com/cenkalti/backoff/v4" "github.com/go-redis/redis/v8" "google.golang.org/protobuf/proto" "google.golang.org/protobuf/types/known/durationpb" "github.com/pomerium/pomerium/intern...
package pprof import ( "flag" "strings" ) type ( FlagSet struct { *flag.FlagSet input []string usageMsgs []string } ) func NewFlagSet(input []string) *FlagSet { return &FlagSet{ flag.NewFlagSet("", flag.ContinueOnError), input, []string{}, } } func (f *FlagSet) StringList(o, d, c string) *[]*...
package utils import "strings" // This function take a string and returns the string // avoiding special letters func RemoveLetters(word string) string { word = strings.Replace(word, "á", "a", -1) word = strings.Replace(word, "é", "e", -1) word = strings.Replace(word, "í", "i", -1) word = strings.Replac...
/* Copyright 2018 Pressinfra SRL. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software...
package main import ( "fmt" "math/rand" "time" "hawx.me/code/chords" ) var rnd = rand.New(rand.NewSource(time.Now().UnixNano())) func Random(root chords.Note) chords.Chord { i := rnd.Intn(len(chords.Variants)) return chords.Variants[i](root) } func Shuffle(s []chords.Note) { for i := len(s) - 1; i > 0; i-- ...
package pkg import ( "bytes" "context" "crypto/rand" "encoding/base64" "errors" "github.com/SungminSo/qr-generator/models" "github.com/SungminSo/qr-generator/models/qrcode" "github.com/gin-gonic/gin" qr "github.com/skip2/go-qrcode" "go.mongodb.org/mongo-driver/bson" "go.mongodb.org/mongo-driver/mongo/option...
package atomicutil import ( "testing" "github.com/stretchr/testify/assert" ) func TestValue(t *testing.T) { v := NewValue(5) assert.Equal(t, 5, v.Load()) t.Run("nil", func(t *testing.T) { var v *Value[int] assert.Equal(t, 0, v.Load()) }) t.Run("default", func(t *testing.T) { var v Value[int] assert.E...
package hw04_lru_cache //nolint:golint,stylecheck import ( "testing" "github.com/stretchr/testify/require" ) func TestList(t *testing.T) { t.Run("empty list", func(t *testing.T) { l := NewList() require.Equal(t, l.Len(), 0) require.Nil(t, l.Front()) require.Nil(t, l.Back()) }) t.Run("complex", func(t ...
/* Disclaimer: The story told within this question is entirely fictional, and invented solely for the purpose of providing an intro. My boss has gotten a new toy robot, and he wants me to help program it. He wants to be able to enter simple arrow instructions to get it to move. These instructions are: ^ (for move for...
package handlers import ( "crypto/ecdsa" "crypto/elliptic" "crypto/rand" "database/sql" "encoding/hex" "encoding/json" "errors" "net/http" "net/http/httptest" "os" "reflect" "sync" "testing" "time" "github.com/SIGBlockchain/project_aurum/internal/accountstable" "github.com/SIGBlockchain/project_aurum/...
package main import ( "bytes" "flag" "fmt" "os" . "github.com/donnie4w/tfdoc" ) func main() { dir, _ := os.Getwd() tofile := "newfile.thrift" java := "" _go := "" cpp := "" php := "" py := "" flag.StringVar(&dir, "dir", "", "") flag.StringVar(&tofile, "tofile", "newfile.thrift", "") flag.StringVar(&ja...
package ssh import "time" // SSHWorker 可以通过 gossh.SSHWorker 修改 const SSHWorker = 10 // RemoteExec 执行远程命令,需要提供 hosts 列表 func RemoteExec(command string, runUser string, port int, hosts []string, timeOutSecond int64) ([]ExecResult, error) { sshExecAgent := SSHExecAgent{} sshExecAgent.Worker = SSHWorker sshExecAgent....
package main import ( "fmt" "strconv" "texas_real_foods/pkg/utils" relay "texas_real_foods/pkg/mail-relay" ) var ( // create map to house environment variables cfg = utils.NewConfigMapWithValues( map[string]string{ "listen_port": "10785", "listen_address": "0.0...
/* # -*- coding: utf-8 -*- # @Author : joker # @Time : 2021/12/11 9:00 上午 # @File : lt_12_整数转罗马数字_test.go.go # @Description : # @Attention : */ package hot100 import ( "fmt" "testing" ) func Test_intToRoman(t *testing.T) { fmt.Println(intToRoman(1994)) }
package main import ( "errors" ) type user struct { Email string Friends []string QueryStatus bool Subscribers []string } func (u *user) createFriends() error { if len(u.Friends) != 2 { return errors.New("incorrect number of friends") } for _, user := range u.Friends { if !isEmailValid(user) {...
// Copyright 2021 Google LLC. 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 applica...
package present // Entry is a struct which connects the Present and it's Recipient type Entry struct { Present Recipient } // Present represents a present with it's various attributes type Present struct { Brand string Name string Store string Cost float64 } // Recipient represents a Recipient of a present w...
package main import ( "bytes" "encoding/json" "fmt" "github.com/prometheus/common/model" "github.com/neuron-digital/go-prometheus-tgbot/jira" "gopkg.in/alecthomas/kingpin.v2" "gopkg.in/telegram-bot-api.v4" "html/template" "io/ioutil" "log" "net/http" "sort" "strings" "time" "sync" ) var ( host ...
package service import ( "github.com/container-storage-interface/spec/lib/go/csi" "github.com/golang/protobuf/ptypes/wrappers" "github.com/ovirt/csi-driver/internal/ovirt" "golang.org/x/net/context" "google.golang.org/grpc/codes" "google.golang.org/grpc/status" "k8s.io/klog" ) //IdentityService of ovirt-csi-dr...
package main import ( "github.com/stretchr/testify/assert" "log" "testing" ) // //func Test_ConvertString(t *testing.T) { // tcs := []struct { // Width int // N int // Answer string // }{ // {3, 1, "001"}, // } // // for _, tc := range tcs { // t.Run("PASS", func(t *testing.T) { // res := ConvertStrin...
package pgeo import ( "database/sql/driver" "errors" "fmt" "strconv" "strings" ) // Circle is represented by a center point and radius. type Circle struct { Point Radius float64 `json:"radius"` } // Value for the database func (c Circle) Value() (driver.Value, error) { return valueCircle(c) } // Scan from s...
package shared type Source struct { Target string `json:"target"` SonarToken string `json:"sonartoken"` Component string `json:"component"` Metrics string `json:"metrics"` } func (s *Source) Valid() bool { if len(s.Component) == 0 || len(s.Metrics) == 0 || len(s.Target) == 0 || len(s.SonarToken) ==...
package httputil import ( "encoding/json" "errors" "fmt" "io/ioutil" "net/http" "net/url" ) var print = fmt.Print func PostUrlEncodeForm(postUrl string, val url.Values) (map[string]string, error) { resp, err1 := http.PostForm(postUrl, val) if err1 != nil { return nil, err1 } if re...
package middleware import ( "context" "fmt" "github.com/qiniu/qmgo/operator" "testing" "github.com/stretchr/testify/require" ) func TestMiddleware(t *testing.T) { ast := require.New(t) ctx := context.Background() // not register ast.NoError(Do(ctx, "success", operator.BeforeInsert)) // valid register Reg...
package schema import ( "regexp" "sync" ) type Column struct { Schema string `db:"TABLE_SCHEMA"` Table string `db:"TABLE_NAME"` Name string `db:"COLUMN_NAME"` DataType string `db:"DATA_TYPE"` ColumnType string `db:"COLUMN_TYPE"` } type ColumnList []*Column type ColumnMap struct { columns ma...
package aoc2017 import ( "testing" aoc "github.com/janreggie/aoc/internal" "github.com/stretchr/testify/assert" ) func TestDay01(t *testing.T) { assert := assert.New(t) testCases := []aoc.TestCase{ {Input: "1122", Result1: "3", Result2: "0"}, {Input: "1212", Result1: "0", Result2: "6"}, {Input...
package constant const ( EmailFeedbackNotice = "反馈内容:%s <br /> 时间:%s" JWTContextKey = "user" )
package data import ( "database/sql" _ "github.com/lib/pq" ) //個別のタグデータを削除する func DeleteTagData(tagId int) { //データベースと接続 db, err := sql.Open("postgres", "user=trainer password=1111 dbname=imagebbs sslmode=disable") if err != nil { panic(err) } //タグデータを削除するSQL文をセット stmt, err := db.Prepare("delete from tags ...
package main import ( "database/sql" "errors" "fmt" ) type Employee struct { ID int `json:"id,omitempty"` Name string `json:"name"` Department string `json:"department"` Title string `json:"title"` Remuneration float64 `json:"remuneration"` Expenses float64 `json:"expens...
package main import "fmt" //函数可以返回多个值 func test() (a,b,c int) { return 1,2,3 } func main() { //a := 10 //b := 20 //c := 30 //多重赋值 a, b := 10, 20 fmt.Println(a, b) //a = b //b = a //fmt.Println(a, b) var c int c = a a = b b = c fmt.Println(a, b) //i := 10 //j := 20 i, j := 10, 20 //多重赋值 i, j ...
package main import ( "fmt" "github.com/faroukelkholy/myhttp" ) func main() { limit, urls := myhttp.ParseCLI() if err := myhttp.Start(limit,urls); err != nil { fmt.Println(err.Error()) } }
package main import ( "bytes" "compress/gzip" "io" "io/ioutil" "os" "testing" ) var goodOutputGz = `Package: vim-tiny Source: vim Version: 2:7.4.052-1ubuntu3 Architecture: amd64 Maintainer: Ubuntu Developers <ubuntu-devel-discuss@lists.ubuntu.com> Installed-Size: 931 Depends: vim-common (= 2:7.4.052-1ubuntu3), ...
package provider import ( "github.com/operator-framework/operator-lifecycle-manager/pkg/package-server/apis/operators" "k8s.io/apimachinery/pkg/labels" ) type PackageManifestProvider interface { Get(namespace, name string) (*operators.PackageManifest, error) List(namespace string, selector labels.Selector) (*oper...
package go_scout import ( secretsmanager "cloud.google.com/go/secretmanager/apiv1" "cloud.google.com/go/storage" "context" "encoding/json" "errors" "fmt" tgbotapi "github.com/go-telegram-bot-api/telegram-bot-api/v5" secretmanagerpb "google.golang.org/genproto/googleapis/cloud/secretmanager/v1" "log" "net/htt...
package producers import ( "errors" "fmt" "log" "time" c "github.com/pedromss/kafli/config" cst "github.com/pedromss/kafli/config/constants" "github.com/pedromss/kafli/confluent" "github.com/pedromss/kafli/contracts" "github.com/pedromss/kafli/model" "github.com/pedromss/kafli/segmentio" inptils "github.co...
package letter import "sync" type FreqMap map[rune]int var waitGroup sync.WaitGroup var mutex sync.Mutex func Frequency(s string) FreqMap { m := FreqMap{} for _, r := range s { m[r]++ } return m } func ConcurrentFrequency(phrases []string) FreqMap { m := FreqMap{} waitGroup.Add(len(phrases)) for _, word :...
package spi import ( "github.com/BurntSushi/toml" "log" ) type AppConfig struct { Database DatabaseConfig Http HttpConfig } type DatabaseConfig struct { Driver string Url string Host string Port int } type HttpConfig struct { Host string Port int } func Load(file string) (*AppConfig, error) { ...
package types import ( "github.com/irisnet/irishub/codec" ) // Register concrete types on codec func RegisterCodec(cdc *codec.Codec) { cdc.RegisterConcrete(MsgRequestRand{}, "irishub/rand/MsgRequestRand", nil) cdc.RegisterConcrete(&Rand{}, "irishub/rand/Rand", nil) cdc.RegisterConcrete(&Request{}, "irishub/rand/...
package operatorclient import ( "context" "fmt" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/apimachinery/pkg/types" "k8s.io/klog" apiregistrationv1 "k8s.io/kube-aggregator/pkg/apis/apiregistration/v1" ) // CreateAPIService creates the APIService. func (c *Client) CreateAPIService(ig *apiregistrationv...
// Copyright (c) 2019 Aiven, Helsinki, Finland. https://aiven.io/ package aiven import ( "fmt" "github.com/aiven/aiven-go-client" "github.com/hashicorp/terraform-plugin-sdk/helper/schema" ) func datasourceVPCPeeringConnection() *schema.Resource { return &schema.Resource{ Read: datasourceVPCPeeringConnectionR...
package goSolution func findRedundantConnection(edges [][]int) []int { n := len(edges) for i, _ := range edges { edges[i][0]-- edges[i][1]-- } dsu := InitializeDSU(n) for i := n - 1; i >= 0; i-- { foundLoop := false for j := 0; j < n; j++ { if j != i { edge := edges[j] if dsu.FindSet(edge[0]) ...
package route import ( "github.com/gin-gonic/gin" "secKill/controller" ) func InitRouter() (router *gin.Engine) { router = gin.Default() router.POST("/secKill", controller.SecKill) router.POST("/secKillInfo", controller.GetProductInfo) return }
/* * @lc app=leetcode.cn id=541 lang=golang * * [541] 反转字符串 II */ // @lc code=start // package leetcode func reverse(b []byte) { left := 0 right := len(b) - 1 for right > left { b[left], b[right] = b[right], b[left] left++ right-- } } func reverseStr(s string, k int) string { n := len(s) b := []byte(...
/* A matrix is antisymmetric, or skew-symmetric, if its transpose equals its negative. The transpose of a matrix can be obtained by reflecting its elements across the main diagonal. Examples of transpositions can be seen here: 0 2 -1 -2 0 0 1 0 0 All antisymmetric matrices exhibit certain characteristics: Antisym...
// Copyright 2017 Jeff Foley. All rights reserved. // Use of this source code is governed by Apache 2 LICENSE that can be found in the LICENSE file. package amass import ( "bufio" "errors" "io" "io/ioutil" "log" "net" "strings" "time" "github.com/OWASP/Amass/amass/core" "github.com/OWASP/Amass/amass/dnssrv...
// Copyright (c) 2016 Readium Foundation // // Redistribution and use in source and binary forms, with or without modification, // are permitted provided that the following conditions are met: // // 1. Redistributions of source code must retain the above copyright notice, this // list of conditions and the following...
package model import "time" // Woof db struct type Woof struct { ID string `db:"id"` Body string `db:"body"` CreatedAt time.Time `db:"created_at"` } // WoofRequest json struct type WoofRequest struct { Message string `json:"message"` } // WoofResponse json struct type WoofResponse struct { ID...
package response import ( "sort" "sync" "github.com/mayflower/docker-ls/lib" ) type RepositoryL0 string type RepositoryCollectionL0 []RepositoryL0 func (r RepositoryCollectionL0) Len() int { return len(r) } func (r RepositoryCollectionL0) Less(i, j int) bool { return string(r[i]) < string(r[j]) } func (r Re...
package train type TypeOfCarriage int const ( COMPARTMENT TypeOfCarriage = iota BUSINESS ECONOM )
// This file was generated by counterfeiter package fake_routing_table import ( "sync" . "github.com/cloudfoundry-incubator/route-emitter/routing_table" ) type FakeRoutingTable struct { SyncStub func(routes RoutesByProcessGuid, containers ContainersByProcessGuid) MessagesToEmit syncMutex sync.RWMutex...
package service import ( "context" "fmt" "io" "net/http" "time" "github.com/gofrs/uuid" "github.com/patrickmn/go-cache" pbAS "github.com/go-ocf/cloud/authorization/pb" "github.com/go-ocf/cloud/cloud2cloud-connector/events" "github.com/go-ocf/cloud/cloud2cloud-connector/store" projectionRA "github.com/go-o...