text
stringlengths
11
4.05M
package stub import ( "fmt" operatorsv1api "github.com/openshift/api/operator/v1" v1 "github.com/openshift/api/samples/v1" "github.com/openshift/cluster-samples-operator/pkg/cache" "github.com/openshift/cluster-samples-operator/pkg/util" "github.com/sirupsen/logrus" corev1 "k8s.io/api/core/v1" kerrors "k8s.io...
package buffer import ( "errors" "fmt" ) // A Queue is used to manage a set of commands. type Queue struct { push chan interface{} reset chan chan []interface{} filter chan queueFilterReq unshift chan interface{} items chan interface{} data chan string len chan int byteLen cha...
package main import ( "context" "log" "github.com/spotinst/spotinst-sdk-go/service/elastigroup" "github.com/spotinst/spotinst-sdk-go/service/elastigroup/providers/aws" "github.com/spotinst/spotinst-sdk-go/spotinst" "github.com/spotinst/spotinst-sdk-go/spotinst/session" "github.com/spotinst/spotinst-sdk-go/spot...
package customer type ReceiptTypeTree struct { ID int64 `description:"ID"` Name string `description:"名称"` Children []*ReceiptTypeTree `description:"子类" json:"children,omitempty"` } type ReceiptTypeAdd struct { ParentID int64 `description:"父级ID"` Name string `description:"名...
package main import ( "fmt" "math" "sort" ) func main() { fmt.Println(matrixSum([][]int{ {7, 2, 1}, {6, 4, 2}, {6, 5, 3}, {3, 2, 1}, })) fmt.Println(matrixSum([][]int{{}})) } func matrixSum(nums [][]int) int { if len(nums) == 0 { return 0 } if len(nums[0]) == 0 { return 0 } for i := 0; i <...
package db import ( "database/sql" _ "github.com/go-sql-driver/mysql" "github.com/op/go-logging" ) var ( log = logging.MustGetLogger("db") MySQL *sql.DB ) // 连接到 MySQL 数据库使用 config.MYSQL_DATA_SOURCE_NAME // 可以设置环境变量 MYSQL_DATA_SOURCE_NAME 来更改 dataSourceName // http://godoc.org/github.com/go-sql-driver/mysql /...
package config import ( "flag" "tcc_transaction/store/data" ) var ( // 数据库连接 C data.DataClient // email EmailUsername = flag.String("email-username", "", "") EmailTo = flag.String("email-to", "", "email receiver, if have many please use ',' split.") EmailPassword = flag.String("email-pas...
package e2e import ( "context" . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" "github.com/sirupsen/logrus" corev1 "k8s.io/api/core/v1" apierrors "k8s.io/apimachinery/pkg/api/errors" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/apimachinery/pkg/runtime/schema" "k8s.io/client-go/rest" "git...
package models import "time" // models collections var ( UserCollectionName = "users" ) type User struct { ID string `bson:"_id,omitempty" json:"_id,omitempty"` FullName string `bson:"full_name" validate:"required,min=2,max=100" json:"full_name"` Email ...
package main import ( "fmt" "sort" ) func main() { ss := []string{"banana", "abacaxi", "pêra", "laranja", "banana"} si := []int{7, 5, 2, 5, 8, 5, 1, 7, 9, 2, 4, 6, 1, 2} fmt.Println(ss) fmt.Println(si) fmt.Println(sort.IntsAreSorted(si)) sort.Strings(ss) sort.Ints(si) fmt.Println(ss) fmt.Println(si) f...
package handler import ( "context" "github.com/jinmukeji/ae-v1/core" "github.com/jinmukeji/jiujiantang-services/service/auth" proto "github.com/jinmukeji/proto/v3/gen/micro/idl/partner/xima/core/v1" ) const ( // dengyunClient 登云的client dengyunClient = "dengyun-10001" // moaiClient 摩爱的client moaiClient = "moa...
// Package scenariolib handles everything need to execute a scenario and send all // information to the usage analytics endpoint package scenariolib import ( "errors" "github.com/k0kubun/pp" ) // ============== TAB CHANGE EVENT ====================== // ====================================================== // Ta...
package graph_test import ( "reflect" "testing" ) import "github.com/nfisher/daywalker/graph" func Test_Graph_Contains_Added_Node(t *testing.T) { g := graph.New() actual := g.Contains("b") if actual { t.Errorf("want g.Contains(a) = false, got %v", actual) } actual = g.Contains(graph.Root) if actual != tr...
/* GETTING USER INPUT := -------------------------------- it is defined as short-hand assignment operator it is used to assign values to variables without using var keyword . it will not reassign values to already defined var and if you do so it will throw an error. it can not be used outside a function but can be use...
package main import ( "bytes" "fmt" "os/exec" "strings" "github.com/bwmarrin/discordgo" ) // TODO: use $PLAN9, I guess var fortunes = map[string]string{ "dougfacts": "/usr/src/os/plan9front/lib/dougfacts", "ken": "/usr/src/os/plan9front/lib/ken", "rob": "/usr/src/os/plan9front/lib/rob", "rsc": ...
// DRUNKWATER TEMPLATE(add description and prototypes) // Question Title and Description on leetcode.com // Function Declaration and Function Prototypes on leetcode.com //483. Smallest Good Base //For an integer n, we call k>=2 a good base of n, if all digits of n base k are 1. //Now given a string representing n, you ...
// Tideland GoText - String Extensions // // Copyright (C) 2018 Frank Mueller / Tideland / Oldenburg / Germany // // All rights reserved. Use of this source code valuePos governed // by the new BSD license. package stringex //-------------------- // IMPORTS //-------------------- import ( "strings" "unicode" ) //...
package logger import ( "fmt" "net/http" _ "net/http/pprof" "os" "runtime" "runtime/pprof" "strings" "time" ) var ( pid int progname string ) func init() { pid = os.Getpid() paths := strings.Split(os.Args[0], "/") paths = strings.Split(paths[len(paths)-1], string(os.PathSeparator)) progname = path...
package main import ( "fmt" s "leyservNext/fiddle/fiddle2" "reflect" ) func init() { } func main() { fmt.Println("hello guy.") var per s.Person result := reflect.ValueOf(&per).MethodByName("GetName").Call([]reflect.Value{}) fmt.Println(result) reflect.ty //structName := "fiddle2.Person" //funcName := "GetNa...
// (C) Copyright 2012, Jeramey Crawford <jeramey@antihe.ro>. All // rights reserved. Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. package md5_crypt import "testing" var md5Crypt = New() func TestGenerate(t *testing.T) { data := []struct { salt []byte key ...
package domain type User struct { Name string `json:"name"` Email string `json:"email"` } type MailMessage struct { Sender User `json:"sender"` To []User `json:"to"` Subject string `json:"subject"` HtmlContent string `json:"htmlContent"` }
package simulation import ( "math/rand" "github.com/cosmos/cosmos-sdk/baseapp" "github.com/cosmos/cosmos-sdk/simapp/helpers" simappparams "github.com/cosmos/cosmos-sdk/simapp/params" sdk "github.com/cosmos/cosmos-sdk/types" simtypes "github.com/cosmos/cosmos-sdk/types/simulation" "github.com/cosmos/cosmos-sdk/...
package entity type ComponentType struct { ID string `json:"id"` Name string `json:"Title"` Description string `json:"Text"` }
package pegasus2 import ( "context" "errors" "fmt" "sync" "time" "github.com/XiaoMi/pegasus-go-client/idl/base" "github.com/XiaoMi/pegasus-go-client/pegalog" "github.com/XiaoMi/pegasus-go-client/rpc" "github.com/XiaoMi/pegasus-go-client/session" ) type nodeSession struct { logger pegalog.Logger addr str...
package sessionmapper import ( "bytes" "context" "fmt" "net/http" "net/http/httptest" "testing" ) func TestClient(t *testing.T) { ts := httptest.NewServer( http.HandlerFunc( func(w http.ResponseWriter, r *http.Request) { fmt.Fprintf(w, `{"upstream":{"me": "too"}}`) })) defer ts.Close() c := ts....
package dto import ( entity "mix/test/entity/core/transaction" transaction "mix/test/pb/core/transaction" ) func ToAccountOutput(item *entity.Account, output *transaction.AccountOutput) { output.Id = item.Id output.MerchantId = item.MerchantId output.OpenId = item.OpenId output.Status = item.Status output.Lock...
package Map import "../Event" type Map struct { Title string Map []string Events []*Event.Event }
package prepare import ( "github.com/KubeOperator/KubeOperator/pkg/service/cluster/adm/phases" "github.com/KubeOperator/KubeOperator/pkg/util/kobe" "io" ) const ( playbookNameContainerRuntime = "02-runtime.yml" ) type ContainerRuntimePhase struct { } func (s ContainerRuntimePhase) Name() string { return "Insta...
package sorts import ( "reflect" ) type Result struct { Info reflect.Value less func(x, y reflect.Value) bool Count int } func (r Result) Len() int { return r.Info.Len() } func (r Result) Less(i, j int) bool { return r.less(r.Info.Index(i), r.Info.Index(j)) } func (r Result) Swap(i, j int) { var a = r.Info....
package main import ( "fmt" "sort" "strconv" ) func main() { n := 45553333 tempStr := "" //tempNum := 0 numStr := strconv.Itoa(n) var numArray []int //try using a nested loop for i := 0; i < len(numStr); i++ { for j := 0; j < len(numStr); j++ { if j == i { continue } tempStr += string(num...
package repos import ( "../entity" ) type PostRepo interface { Save(post *entity.Post)(*entity.Post, error) FindAll() ([]entity.Post, error) }
package lib import ( "bytes" "fmt" "io/ioutil" "net/http" "time" ) // ResponseError indicates an error while fetching a HTTP response. type ResponseError struct { code int s string } func (e *ResponseError) Error() string { return fmt.Sprintf("ResponseError: Response('%d', '%s')", e.code, e.s) } var clie...
package lessgo import ( "encoding/json" "errors" "github.com/lessgo/lessgo/pongo2" "io" "sync" "time" ) type ( Tpl struct { template *pongo2.Template modTime time.Time } // Pongo2Render is a custom lessgo template renderer using Pongo2. Pongo2Render struct { set *pongo2.TemplateSet caching bo...
package user import ( "camp/lib" "camp/week2/model" "camp/week2/util" "github.com/globalsign/mgo/bson" ) func (userService *UserService) SubUser(base lib.IBase, subUid bson.ObjectId) (err error) { // 获取 token 中的 uid uid, err := util.TokenToUid(base) if err != nil { return } return model.NewUser().SubUser(...
package main import ( "fmt" "html/template" "io" "log" "net/http" "os" ) var templates = template.Must(template.ParseFiles("project-file-converter.html", "index.html", "about.html", "contact.html", "designer.html")) func index(w http.ResponseWriter, r *http.Request) { if r.Method == "GET" { templates.Execut...
/* Create a function that takes an array of strings and returns an array with only the strings that have numbers in them. If there are no strings containing numbers, return an empty array. Examples numInStr(["1a", "a", "2b", "b"]) ➞ ["1a", "2b"] numInStr(["abc", "abc10"]) ➞ ["abc10"] numInStr(["abc", "ab10c", "a10...
package easy053 import "math" func maxSubArray(nums []int) int { max, sum := math.MinInt64, 0 for _, v := range nums { sum += v if max < sum { max = sum } if sum < 0 { sum = 0 } } return max }
package main import ( "io/ioutil" "log" "os" "strconv" "github.com/tarm/serial" ) // this used for turn off logging in console func turnoff() { log.SetOutput(ioutil.Discard) } // this function used for scanning available serial port in computer func scanserial() string { log.Println("scanning available seria...
package main /** 回文数 判断一个整数是否是回文数。回文数是指正序(从左向右)和倒序(从右向左)读都是一样的整数。 示例1: ``` 输入: 121 输出: true ``` 示例2: ``` 输入: -121 输出: false 解释: 从左向右读, 为 -121 。 从右向左读, 为 121- 。因此它不是一个回文数。 ``` 示例2: ``` 输入: 10 输出: false 解释: 从右向左读, 为 01 。因此它不是一个回文数。 ``` 进阶: 你能不将整数转为字符串来解决这个问题吗? ``` */ /** 之前做过这题 */ func IsPalindrome(x int) bool { ...
package githuberrordialog import ( "fmt" "net/url" "runtime" "github.com/gotk3/gotk3/gtk" ) var ( //Repository defines the repository that the errordialog should offer a report-issue link to. Repository string //IssueTemplateEnabled decides wether a prefilled issue template will be included in the report-issu...
package layer import ( "bufio" "crypto/sha1" "fmt" "io" "os" "strings" "github.com/giantswarm/conair/btrfs" ) type layer struct { Hash string Verb string Payload string ParentId string ParentPath string Path string Exists bool fs *btrfs.Driver } func Create(fs *btrf...
package manager import ( "bytes" "encoding/json" "github.com/golang/glog" "math/rand" "net/http" "strconv" "sync" "testing" "time" "znfz/three_server/lib" "znfz/three_server/models" ) type ts struct { lock sync.RWMutex count int sumTime int64 } var huangAddr = "0x759D4c2E15587Fae036f183202F36CA3C6...
//package main package piscine //import "fmt" func SortIntegerTable(table []int) { arr_len := len(table) for i := 0; i < arr_len; i++ { for j := 0; j < (arr_len - 1 - i); j++ { if table[j] > table[j+1] { table[j], table[j+1] = table[j+1], table[j] } } } } // func main() { // s := []int{7, 89, 9, 10...
package game import ( "fmt" "math/rand" "strings" "time" ) const ( OVER = -1 RUNNING = 2 //to leave room for player 0 and 1 ) type Game struct { Board *Board Turn int Status int Winner int Update chan int Timeout chan struct{} } func (g *Game) Killswitch() { t := time.NewTimer(time.Minute * ...
package proxy import ( "fmt" "github.com/nokamoto/grpc-proxy/codec" "github.com/nokamoto/grpc-proxy/descriptor" "github.com/nokamoto/grpc-proxy/route" "github.com/nokamoto/grpc-proxy/yaml" "google.golang.org/grpc" "net" ) // Server represents a gRPC server combined all routes. type Server struct { srv *grp...
package data_postgres import ( . "github.com/nogio/noggo/base" "github.com/nogio/noggo/driver" "database/sql" "errors" ) type ( //数据库连接 PostgresConnect struct { config Map //数据库对象 db *sql.DB //连接串 url string //模型 models map[string]Map } ) //打开连接 func (conn *PostgresConnect) Open() error { db...
package main import ( "crypto/rand" "encoding/base64" "encoding/json" "errors" "flag" "fmt" "io/ioutil" "log" "net/http" "os" "path/filepath" "strings" "sync" "time" "github.com/boltdb/bolt" "github.com/fsnotify/fsnotify" ) type conf struct { ListenPort string `json:"listenPort"` Roo...
package trie import ( "fmt" "sort" "strings" "testing" "unicode/utf8" ) func use() { fmt.Println("") strings.Compare("", "") utf8.Valid([]byte("")) sort.Ints(make([]int, 0)) } func testRemoveSpaceAndTolower() { word := "i 你好 歪 歪 love yy 歪歪 and yo abc ukuabcaaaabcde" fmt.Println((word)) wc := NewTrie("wor...
// SPDX-License-Identifier: Apache-2.0 // Copyright (c) 2019 Intel Corporation package oam import ( "encoding/json" "github.com/gorilla/mux" "io/ioutil" "net/http" "path/filepath" "strconv" ) // AllRecords store all the AFService var AllRecords []AFService // NewRecordAFServiceID is id to allocate var NewReco...
package policymaker import ( "io" "os" "os/exec" "runtime" "github.com/armon/circbuf" ) func execCmd(command string) string { const maxBufSize = 16 * 1024 // Execute the command using a shell var shell, flag string if runtime.GOOS == "windows" { shell = "cmd" flag = "/C" } else { shell = "/bin/sh" ...
package main import ( "io/ioutil" "net" "net/http" "time" "github.com/aws/aws-sdk-go/aws/session" "github.com/aws/aws-sdk-go/service/cloudwatch" "github.com/gogo/protobuf/proto" "github.com/golang/snappy" "github.com/heptio/workgroup" "github.com/prometheus/client_golang/prometheus/promhttp" "github.com/pr...
package Problem0492 import ( "math" ) func constructRectangle(area int) []int { for i := int(math.Sqrt(float64(area))); i > 1; i-- { if area%i == 0 { return []int{area / i, i} } } return []int{area, 1} }
package env import ( "context" "fmt" mathrand "math/rand" "os" "strings" "sync" "testing" "time" "github.com/google/uuid" "github.com/dollarshaveclub/acyl/pkg/eventlogger" "github.com/dollarshaveclub/acyl/pkg/ghclient" "github.com/dollarshaveclub/acyl/pkg/locker" "github.com/dollarshaveclub/acyl/pkg/mem...
// Copyright 2020 MongoDB 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...
// Copyright 2017 The LUCI 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...
package ghook import ( "bytes" "crypto/hmac" "crypto/sha1" "encoding/hex" "fmt" "io/ioutil" "net/http" "net/http/httptest" "testing" ) var ( secret1 = []byte("d696f82431664d9ea93483789db0116c") secret2 = []byte("e177b4e2ce1d2604d05e79a8375031b6") ) func testHookReq(url string, secret []byte) error { body...
package actions func (as *ActionSuite) Test_ProspectsResource_List() { as.Fail("Not Implemented!") } func (as *ActionSuite) Test_ProspectsResource_Show() { as.Fail("Not Implemented!") } func (as *ActionSuite) Test_ProspectsResource_New() { as.Fail("Not Implemented!") } func (as *ActionSuite) Test_ProspectsResour...
package ntwk import ( "gx/ipfs/QmTu65MVbemtUxJEWgsTtzv9Zv9P8rvmqNA4eG9TrTRGYc/go-libp2p-peer" "gx/ipfs/Qmd52WKRSwrBK5gUaJKawryZQ5by6UbNB8KVW2Zy6JtbyW/go-libp2p-host" "github.com/filecoin-project/go-filecoin/pubsub" ) // Network is a unified interface for dealing with libp2p type Network struct { host host.Host ...
// Copyright 2014 David Persson. All rights reserved. // // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. package main import ( "flag" "fmt" "os" "os/signal" "strconv" "strings" "time" "github.com/kr/beanstalk" "github.com/peterh/liner" ) var ( // Use...
package repositories import ( "context" "github.com/itsmeadi/cart/src/entities/models" ) type Product interface { GetProductDetailById(ctx context.Context, id int64) (models.Product, error) }
package easyorm import ( "fmt" "log" "reflect" "testing" ) type UserInfo struct { Name string `easyorm:",index"` Phone string Mail string } type User struct { Id int64 `easyorm:"id,primary"` Info UserInfo `easyorm:"info"` } func ExamplePrintSFTree() { tree, err := typeSFTree(reflect.TypeOf(&User{}))...
package gonba import ( "time" ) const endpointSchedule = "scoreboardv2" const scheduleDateFormat = "2006-01-02" func (c *Client) GetSchedule(date time.Time) (Schedule, int) { var scheduleResponse scheduleResponse params := map[string]string { "GameDate": date.Format(scheduleDateFormat), "LeagueId": "00", "D...
// navermusicInfo package DaeseongLib import ( "bufio" "flag" "fmt" "io" "io/ioutil" "log" "net/http" "os" "regexp" "strings" ) type tagMusic struct { Level string Name string Title string } var mMusic = make(map[string]tagMusic) func selectMusicPage() string { sSelectPage := flag.Int("page", 1, "pag...
package file import "fmt" type Size int const ( Byte Size = 1 KByte = 1024 * Byte MByte = 1024 * KByte GByte = 1024 * MByte TByte = 1024 * GByte ) func ParseSize(s string) (size Size, err error) { oneSize := 0 unit := Size(1) for i := 0; i < len(s); i++ { if s[i] >= '0' && s[i] <= ...
package transport type Connection struct { Hostname string `json:"hostname" yaml:"hostname"` Port int `json:"port" yaml:"port"` } type Identity struct { Nick []string `json:"nick" yaml:"nick"` RealName string `json:"real_name" yaml:"real_name"` } type Config struct { Protocol string `json:"p...
package main import "fmt" func main() { //firstExample() //secondExample() thirdExample() } func firstExample() { c := make(chan string) c <- "first example" msg := <- c fmt.Println(msg) } func secondExample() { c := make(chan string, 1) c <- "second example" msg := <- c fmt.Println(msg) } func thir...
package tritondb import ( "database/sql" "fmt" "github.com/tada3/triton/weather/model" ) const ( sqlSelectPoiCity1 = "SELECT cityName from poi_city WHERE (name = ? OR name2 = ?) AND countryCode = ? ORDER BY precedence DESC" sqlSelectPoiCity2 = "SELECT cityName, countryCode from poi_city WHERE (name = ? OR name2...
package eightball import ( "math/rand" "github.com/gadget-bot/gadget/router" "github.com/slack-go/slack" "github.com/slack-go/slack/slackevents" ) func getEightballAnswer() string { answers := []string{ "It is certain", "It is decidedly so", "Without a doubt", "Yes - definitely", "You may rely on it"...
// DRUNKWATER TEMPLATE(add description and prototypes) // Question Title and Description on leetcode.com // Function Declaration and Function Prototypes on leetcode.com //93. Restore IP Addresses //Given a string containing only digits, restore it by returning all possible valid IP address combinations. //Example: //In...
package command import ( "os" "github.com/jclem/graphsh/types" ) // Exit exits the shell type Exit struct{} func testExit(input string) (Command, error) { if input == "exit" { return &Exit{}, nil } return nil, nil } // Execute implements the Command interface func (c Exit) Execute(s types.Session) error { ...
package x86 import ( "reflect" "github.com/MovingtoMars/ssvm/ir" ) func (v *gen) genIntDiv(instr *ir.Instr, signed, remainder bool, alloc *allocator) { numBytes := v.target.TypeSize(instr.Type()) if v.target.TypeSizeInBits(instr.Type())%8 != 0 { panic("unsupported int size for div") } alloc.valToReg(v, "@ea...
package controller import ( "github.com/ThomasJunk/demo/pkg/configuration" "github.com/alexedwards/scs/v2" "go.uber.org/zap" ) //Handler for controllers type Handler struct { Session *scs.SessionManager Configuration *configuration.Environment Log *zap.Logger } //New generates a new Handler fun...
// Copyright 2023 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 main import ( "fmt" "os" ) func main() { var allArgs, seq string for index, args := range os.Args[1:] { fmt.Printf("%d is %s \n", index, args) seq = " " allArgs += seq + args } fmt.Printf("All args is %s", allArgs) }
package main import ( "fmt" ) func Ping(ping chan<- string, message string){ ping<- message } func PingPong(ping <-chan string, pong chan<- string){ message := <-ping pong<- message } func main(){ ping := make(chan string, 1) pong := make(chan string, 1) Ping(ping, "Ping Pong") PingPong(ping, pong) fmt....
package gherkin import ( re "regexp" "strings" "fmt" "io" "io/ioutil" "path/filepath" "os" "reflect" matchers "github.com/tychofreeman/go-matchers" ) type Runner struct { steps []stepdef background Scenario isExample bool setUp interface{} tearDown interface{} ...
package main import ( "context" "encoding/json" "fmt" "log" "net/http" "path/filepath" "github.com/gorilla/mux" "github.com/roasbeef/btcutil" "github.com/waltonseymour/bard/lnrpc" "google.golang.org/grpc" "google.golang.org/grpc/credentials" ) const address = "localhost:10009" const ( defaultTLSCertFile...
/* Description You are a intrepid 2-dimensional explorer located at the northern polar reaches of a distant 2-dimensional planet. Unfortunately, you have been assigned to explore the most boring planet in the known universe (due primarily to your lack of social skills and aggressive body odor). Having a perfectly cir...
package main import ( "encoding/base64" "fmt" "log" ) func main() { input := []byte("Password1") // 演示base64编码 encodeString := base64.StdEncoding.EncodeToString(input) fmt.Println(encodeString) // 对上面的编码结果进行base64解码 decodeBytes, err := base64.StdEncoding.DecodeStrin...
package memcache import ( "bytes" "fmt" "log" "math" "sort" "strconv" "strings" "time" ) // Scheduler: route request to nodes type Scheduler interface { Feedback(host *Host, key string, adjust float64, in_check bool) // feedback for auto routing GetHostsByKey(key string) []*Host ...
package models import ( "fmt" "time" "github.com/reechou/holmes" ) type RobotGroup struct { ID int64 `xorm:"pk autoincr"` RobotId int64 `xorm:"not null default 0 int index" json:"robotId"` RobotWx string `xorm:"not null default '' varchar(128) index" json:"robotWx"` UserName ...
package agent import ( "net" ) type udpClient struct { conn *net.UDPAddr token string readChan chan []byte writeChan chan []byte } func (u udpClient) Token() string { return u.token } func (u udpClient) GetReadChan() chan []byte { return u.readChan } func (u udpClient) GetWriteChan() chan []byte {...
package api import ( "net/http" "strings" ) const ( originAddress = "http://localhost:8080" supportedHeaders = "Content-Type, Authorization" ) // optionsHandler sets CORS headers and returns 200 -- used for OPTIONS requests // TODO: This should be applied in an adapter func optionsHandler(ctx apiContext, w ht...
package duck type Duck interface { Swim() Display() }
package postgresql import ( "context" "fmt" "time" "github.com/google/uuid" "github.com/Mindslave/skade/backend/internal/entities" ) //CreateUser is the Endpoint used to create new users func (r *Repo) CreateUser(ctx context.Context, arg entities.DbCreateUserParams) (entities.User, error) { var u entities.Use...
package main import ( "fmt" "time" _ "github.com/go-sql-driver/mysql" "github.com/jinzhu/gorm" ) type HouseCancel struct { Recordid int64 `gorm:"primary_key;type:int(11) auto_increment;not null"` Customerid int64 `gorm:"type:int(11)"` Houseid int64 `gorm:"type:int(11)"` Reason string `gor...
package main import ( "encoding/json" "io/ioutil" "log" "net/http" "os" "strconv" "github.com/aws/aws-sdk-go/aws" "github.com/aws/aws-sdk-go/aws/session" "github.com/aws/aws-sdk-go/service/dynamodb" "github.com/aws/aws-sdk-go/service/dynamodb/dynamodbattribute" "github.com/google/uuid" ) const SERVICE_VER...
package main import ( "flag" "os" "time" ) var ( options struct { ifdev string port string rawfile string mute bool max int } startedAt time.Time lines []string = make([]string, 0, 1<<20) ) func init() { flag.StringVar(&options.ifdev, "i", "eth0", "device") flag.StringVar(&options.po...
package main import ( "fmt" "github.com/codegangsta/cli" "os" "strings" ) var vulcanUrl string func main() { url, args, err := findVulcanUrl(os.Args) if err != nil { fmt.Println(err) os.Exit(2) } vulcanUrl = url app := cli.NewApp() app.Name = "vulcanctl" app.Usage = "Command line interface to a runni...
package controllers import ( "businessense/models" u "businessense/utils" "encoding/json" "fmt" "net/http" "github.com/gorilla/mux" ) //CreateIndustry HandlerFunc var CreateIndustry = func(w http.ResponseWriter, r *http.Request) { industry := &models.Industry{} err := json.NewDecoder(r.Body).Decode(industry...
// Package match implements branch matching package match import ( "fmt" nitroerrors "github.com/dollarshaveclub/acyl/pkg/nitro/errors" ) // BranchInfo includes the information about a specific branch of a git repo type BranchInfo struct { Name string SHA string } // RepoInfo models the information about paren...
// Copyright 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved. // SPDX-License-Identifier: Apache-2.0 package describe import ( "fmt" "github.com/aws/amazon-ecs-cli-v2/internal/pkg/archer" "github.com/aws/amazon-ecs-cli-v2/internal/pkg/aws/session" "github.com/aws/amazon-ecs-cli-v2/internal/pkg/deplo...
/* Given a list of phone numbers, determine if it is consistent in the sense that no number is the prefix of another. Let’s say the phone catalogue listed these numbers: Emergency 911 Alice 97 625 999 Bob 91 12 54 26 In this case, it’s not possible to call Bob, because the central would direct your cal...
package repository import ( "context" "time" "github.com/YAWAL/ERP-common-lib/logging" "github.com/YAWAL/ERP-common-lib/models" "go.mongodb.org/mongo-driver/bson" "go.mongodb.org/mongo-driver/bson/primitive" "go.mongodb.org/mongo-driver/mongo" ) const ( employeesDB = "hr" employeesCollection = "emp...
func twoSum(nums []int, target int) []int { r:=[]int{0,0}; for i:=0; i<len(nums); i++ { // n2 := ; s_nums := nums[i+1:] //found := findinslice(s_nums, n2) found := findinslice(s_nums, target - nums[i]); if(found != -1){ found = found+i+1; r=[]int{...
package main // dbConfig represents DB configuration of the bot. type dbConfig struct { User string `json:"user"` Password string `json:"password"` Protocol string `json:"protocol"` Host string `json:"host"` Port int `json:"port"` Database string `json:"database"` }
//Package forms provides a set of types and interfaces for specifying form loading and validation. /* */ package forms
v, ok := <-intChan
package output import ( "io" ) type Interleaved struct{} func (Interleaved) WrapWriter(w io.Writer, _ string) io.Writer { return w }
package main import ( "github.com/urfave/cli" "log" "os" "path/filepath" "fmt" ) func main() { app := cli.NewApp() app.Name = "ggit" app.Usage = "Git - Implemented in GoLang!" app.Commands = []cli.Command{ // Plumbing Commands { Name: "hash-object", Usage: "Compute hash ID and optionally create a ...