text
stringlengths
11
4.05M
package gen import ( "context" "errors" ) // ErrContinue can be returned from a Planner if there is no match. Other planners may then be tried. var ErrContinue = errors.New("continue") // Plan is the contract that must be filled for a type to be rendered. type Plan interface { // Type returns the TypeInfo for the...
// This file contains Protobuf and JSON serialization/deserialization methods for peer IDs. package peer import ( "encoding/json" ) // Interface assertions commented out to avoid introducing hard dependencies to protobuf. // var _ proto.Marshaler = (*ID)(nil) // var _ proto.Unmarshaler = (*ID)(nil) var _ json.Marsha...
package main import "fmt" type person struct { id int name string age int } func main2401() { //初始化 var per person =person{101,"李宁",40} //fmt.Println(per) //fmt.Printf("%p\n",&per) //定义指针接收结构体变量地址 //p := &per var p *person = &per fmt.Printf("%T\n",p) //*person 类型 //通过指针间接修改结构体成员的值 (*p).age = 50 ...
package db import ( _ "github.com/Go-SQL-Driver/MySQL" //"time" "fmt" ) func Search (keyword string) interface{}{ rows, err := db.Query("SELECT * FROM video WHERE `title` like \"%"+keyword+"%\" ;" ) checkErr(err) var a [] map[string]interface{} for rows.Next() { var id int var title string var path str...
package main import ( "chat/codec" "encoding/json" "strings" "time" ) type Message struct { From string //发送者 Time int64 //发送时间 Text string //消息内容 isGm bool //是否为GM命令 gmOrder []string //GM命令参数 } // NewMessage 新消息 func NewMessage(from string, text string) *Message { return &Message{ ...
package printer import ( "encoding/json" "github.com/davyxu/tabtoy/v2/i18n" "github.com/davyxu/tabtoy/v2/model" ) type typePrinter struct { } // 一个列字段 type typeFieldModel struct { Name string Type string Kind string IsRepeated bool Meta map[string]interface{} Comment string Val...
package router import ( "github.com/astaxie/beego" "beegoApi/controller" "beegoApi/middleware" ) func init(){ ns := beego.NewNamespace("/v1", beego.NSRouter("/user", &controller.IndexController{}, "Get:Get"), ) beego.Router("/user", &controller.IndexController{}, "Get:Get") beego.InsertFilter("/v1/*",beego...
package trie import ( "fmt" "github.com/openacid/slim/encode" ) func ExampleSlimTrie_RangeGet() { // To index a map of key range to value with SlimTrie is very simple: // // Gives a set of key the same value, and use RangeGet() instead of Get(). // SlimTrie does not store branches for adjacent leaves with the...
package controllers import ( "encoding/json" "fmt" "net/http" "strconv" "github.com/gorilla/websocket" "github.com/astaxie/beego" ) //默认beego的controller type IndexController struct { beego.Controller } //储存当前每个房间的人数 var Room = make(map[int64]int) //记录房间id以及人数 方便给前端传递数据 type Roomlist struct { Roomid int64 ...
package main import ( "context" "log" ) func main() { ctx := context.TODO() routes, err := injectRoutes(ctx) if err != nil { log.Fatalln("inject routes failed") } if err := routes.Run(":8080"); err != nil { log.Fatalln("start server failed") } }
package client import ( "fmt" "github.com/33cn/chain33/common" "github.com/33cn/chain33/types" "math/rand" "strconv" "testing" "time" ) func TestJSONClient_GetPeerList(t *testing.T) { jsonclient := NewJSONClient("", "http://123.60.25.80:8801") peerList, err := jsonclient.GetPeerList() if err != nil { t.Er...
package user import ( "context" "encoding/base64" "encoding/json" "net/http" "time" "github.com/damocles217/server/models" "github.com/damocles217/server/router/user/config" "go.mongodb.org/mongo-driver/bson" "go.mongodb.org/mongo-driver/bson/primitive" "go.mongodb.org/mongo-driver/mongo" ) func MakeUser( ...
package sdk import ( "context" "encoding/json" "fmt" "io/ioutil" "net/http" "net/http/httptest" "testing" rmTesting "github.com/brigadecore/brigade/sdk/v3/internal/restmachinery/testing" // nolint: lll metaTesting "github.com/brigadecore/brigade/sdk/v3/meta/testing" "github.com/stretchr/testify/require" ) ...
// Copyright 2016 Google Inc. All rights reserved. // Use of this source code is governed by the Apache 2.0 // license that can be found in the LICENSE file. package main import ( "io/ioutil" "log" "os" "testing" "time" "golang.org/x/net/context" "github.com/GoogleCloudPlatform/golang-samples/internal/testut...
// Package main implements the ledger backed oasis-node signer plugin. package main import ( "flag" "fmt" "strconv" "strings" "github.com/oasisprotocol/oasis-core/go/common/crypto/signature" pluginSigner "github.com/oasisprotocol/oasis-core/go/common/crypto/signature/signers/plugin" "github.com/oasisprotocol/...
package sol import ( "testing" ) func TestSol(t *testing.T) { testcases := []struct { s string induces []int want string }{ {s: "codeleet", induces: []int{4, 5, 6, 7, 0, 2, 1, 3}, want: "leetcode"}, {s: "abc", induces: []int{0, 1, 2}, want: "abc"}, {s: "art", induces: []int{1, 0, 2}, want: "ra...
package users import ( "admigo/common" "admigo/model" "admigo/model/roles" "errors" "fmt" "time" ) type userRequest struct { Name string `json:"name"` Email string `json:"email"` Password string `json:"password"` Cpassword string `json:"cpassword"` } type UserModel struct { Id int ...
package main import ( "fmt" ) const ( USERS_TOTAL_AND_STRAVA = "Users: %d (unique strava users: %d)" USERS_TOTAL = "Users: %d" USERS_UNLOCKED = "Unlocked users: %d" TEAMS_TOTAL_AND_MONITORED = "Teams: %d (monitored: %d)" TEAMS_TOTAL = "Teams: %d" CLUBS_TOTAL ...
package main import ( "encoding/json" _ "fmt" "net/http" "time" "github.com/prometheus/client_golang/prometheus" "github.com/prometheus/common/log" "github.com/prometheus/common/version" "gopkg.in/alecthomas/kingpin.v2" ) type clouderaOpts struct { uri string username string password string clusterNa...
package main /** This app will contain multilevel bootstrap event */ import ( "context" "fmt" "log" "net/http" "os" "os/signal" "syscall" "time" "github.com/gin-gonic/gin" ) var Modloc string = "" var Libloc string = "" var Routers *gin.Engine func main() { BootstrapAll() // r := SetupRouter() srv := &...
package main import "fmt" func printMap(cityMap map[string]string) { // 引用传递 for key, value := range cityMap { fmt.Println("key =", key, "value =", value) } } func changeValue(cityMap map[string]string) { cityMap["England"] = "London" } func main() { cityMap := make(map[string]string) // 添加key,value cityM...
package sim import ( "time" ) type Portfolio struct { *Simulacrum speculative float64 aggressive float64 moderate float64 conservative float64 lastDate *time.Time lastRet *float64 } func NewPortfolio(sim *Simulation, speculative, aggressive, moderate, conservative float64) *Portfolio { return &Portfolio{ ...
package server import ( "fmt" "github.com/asaskevich/govalidator" "github.com/go-chi/chi/v5" "github.com/go-chi/render" "github.com/profiralex/go-bootstrap-redis/pkg/bl" "net/http" ) // swagger:model type entityResponse struct { UUID string `json:"uuid"` Field1 string `json:"field_1"` Field2 int `json:"...
package go_ntskem import ( "testing" ) func TestGenerateKey(t *testing.T) { nts := NTSKEM{} nts.New(12) nts.GenerateKey() } func TestEncapsulate(t *testing.T) { } func TestDecapsulate(t *testing.T) { }
package main import ( "fmt" ) var arr [5]int = [5]int{1, 2, 3, 4, 5} var slc []int = []int{1, 2, 3, 4, 5} func main() { fmt.Println(arr) fmt.Println(slc) slc := append(slc, 6) fmt.Println(slc) // slc[20] = 19 // error }
package main import "fmt" type Suite int const ( Spades Suite = iota Hearts Diamonds Clubs ) func (s Suite) String() string { return [...]string{"Spades", "Hearts", "Diamonds", "Clubs"}[s] } /** * created: 2019/7/15 13:01 * By Will Fan */ func main() { s := Hearts fmt.Print(s) switch s { case Spades: ...
package printer import ( "github.com/davyxu/tabtoy/util" "github.com/davyxu/tabtoy/v2/i18n" "github.com/davyxu/tabtoy/v2/model" ) func valueWrapperPbt(t model.FieldType, node *model.Node) string { switch t { case model.FieldType_String: return util.StringEscape(node.Value) } return node.Value } type pbtPr...
package runner import ( "context" ) // Runner interface defines method to start running type Runner interface { Run(context.Context) Result }
package render import ( "github.com/tanema/amore/gfx" ) const increment float32 = 1 type Fake3D struct { img *gfx.Image quads []*gfx.Quad ox, oy float32 } func New(filepath string, frameWidth, frameHeight int32) (*Fake3D, error) { img, err := gfx.NewImage(filepath) if err != nil { return nil, err } i...
package main import "fmt" // ListNode 19. //给你一个链表,删除链表的倒数第 n 个结点,并且返回链表的头结点。 // // // // 示例 1: // // //输入:head = [1,2,3,4,5], n = 2 //输出:[1,2,3,5] // // // 示例 2: // // //输入:head = [1], n = 1 //输出:[] // // // 示例 3: // // //输入:head = [1,2], n = 1 //输出:[1] // // // // // 提示: // // // 链表中结点的数目为 sz // 1 <= sz <= 30 // 0 ...
package compose import ( "fmt" "strconv" "github.com/kudrykv/latex-yearly-planner/app/components/calendar" "github.com/kudrykv/latex-yearly-planner/app/components/header" "github.com/kudrykv/latex-yearly-planner/app/components/page" "github.com/kudrykv/latex-yearly-planner/app/config" ) func HeaderTodosIndexed...
package test2 import ( "fmt" _ "fmt" ) type Human struct { Age int Name string } func (h *Human) Say() { fmt.Println("humam " + h.Name + " is say") } func (h *Student) Say() { fmt.Println("Student " + h.Name + " is say") } type Student struct { Human int Name string Value string Score int Id strin...
package test import ( "fmt" "log" "net/http" ) //test form x-www-form-urlencode func ValidateUserLogin(w http.ResponseWriter, r *http.Request) { err := r.ParseForm() if err != nil { w.Write([]byte(err.Error())) } log.Println(r.Form.Get("hello")) log.Println(r.Form.Get("post")) log.Println(r.PostForm.Get("...
package modA import ( "testing" ) func TestA(t *testing.T) { t.Log(A) }
package main import ( "encoding/json" "log" "net/http" "html/template" "gopkg.in/mgo.v2/bson" "fmt" //"io" //"strings" "github.com/gorilla/mux" . "github.com/cboornaz17/pallas/src/config" . "github.com/cboornaz17/pallas/src/dao" . "github.com/cboornaz17/pallas/src/models" ) var c...
// +build !linux package mptcp import "testing" // TestOthers_checkMPTCP verifies that checkMPTCP is not implemented on // platforms other than Linux. func TestOthers_checkMPTCP(t *testing.T) { ok, err := checkMPTCP("localhost", 8080) if ok || err != ErrNotImplemented { t.Fatalf("checkMPTCP is not implemented, b...
package api import ( "fmt" "log" //"time" "net/http" //"strconv" "github.com/gorilla/mux" //"github.com/robfig/cron" "github.com/acmakhoa/smsapp/db" "github.com/acmakhoa/smsapp/worker" ) type ListSmsAPI struct{} func (_ *ListSmsAPI) FindAllHandler(w http.ResponseWriter, r *http.Request){ ...
package processor type Processor3 struct { } func NewProcessor3() Processor3 { return Processor3{} } func (p3 Processor3) Process() string { return "Processing 3" }
package dcp import ( "fmt" "strings" ) // Given the root to a binary tree, implement serialize(root), which serializes the tree into a string, and deserialize(s), which deserializes the string back into the tree. // For example, given the following Node class // class Node: // def __init__(self, val, left=None...
package nats import ( "github.com/atymkiv/echo_frame_learning/blog/pkg/utl/config" "github.com/nats-io/go-nats" ) func New(cfg *config.Nats) (*nats.Conn, error) { natsClient, err := nats.Connect(cfg.Host) return natsClient, err }
package main import ( "bufio" "encoding/json" "flag" "fmt" "log" "net/url" "os" "strconv" "strings" "time" "github.com/JustAdam/streamingtwitter" "github.com/tg/gosortmap" "menteslibres.net/gosexy/redis" ) const STOPWORDS_FILE_NAME = "stopwords.txt" const TOPWORDS_FILE_NAME = "topwords.json" const TOKEN...
package main import "fmt" func main() { messages := make(chan string) signals := make(chan bool) // use select with a default clause to implement non-blocking sends. // message and signals have not any value so default case will immediately take. select { case msg := <-messages: fmt.Println("received message...
package main type Certificate struct { SerialNumber string `json:"serialNumber"` RegistrationNumber int `json:"registrationNumber"` RegistrationDate string `json:"registrationDate"` CertificateHash string `json:"certificateHash"` MetaDataHash string `json:"metaDataHash"` PublicationDate st...
package dbserver import ( "database/sql" _ "github.com/go-sql-driver/mysql" "github.com/labstack/echo" "net/http" ) func CreateDb(c echo.Context) error { dbName := c.QueryParam("dbname") sqlQuery := "create database " + dbName + ";" db, err := sql.Open("mysql", "root:lei123@/lei") if err != nil { panic(err....
package main import ( "bytes" "testing" ) var ( usersData = `name,age F1 L1,30 F2 L2,20 F3 L3,30 F4 L4,20 F5 L5,30 F6 L6,20 F7 L7,30 F8 L8,20 F9 L9,70` ) func Test_countRecords(t *testing.T) { cnt, err := countRecords(bytes.NewBufferString(usersData), &UserCounter{}) if err != nil { t.Error(err) } if cnt !=...
//01 go语言关键字 标识符 //程序所属包 package main //import printer "fmt" import (//. "fmt" _ "golangPractice/practice00/learn02" //只初始化 不引用 "fmt" ) //常量定义 首字母用大写 const NAME = "heylink\n" //全局变量 var mainName = "main name\n" //全局变量 var a string = "nihao\n" //一般声明 type myInt int //结构的声明 type Learn struct { } //声明接口 type iLear...
package postgres import ( "context" "fmt" "strings" "github.com/georgysavva/scany/pgxscan" "github.com/jackc/pgx/v4" "github.com/odpf/stencil/models" ) // Repository DB access layer type Store struct { db *DB } func (r *Store) Close() { r.db.Close() } // ListSnapshots returns list of snapshots. func (r *St...
package main import ( "context" "fmt" "os" "os/signal" "syscall" "github.com/pteich/configstruct" "github.com/pteich/elastic-query-export/export" "github.com/pteich/elastic-query-export/flags" ) var Version string func main() { conf := flags.Flags{ ElasticURL: "http://localhost:9200", ElasticVer...
package model import ( "encoding/json" valuetransaction "github.com/iotaledger/goshimmer/dapps/valuetransfers/packages/transaction" ) // ValueTxID is the base58 representation of a transaction ID type ValueTxID string func NewValueTxID(id *valuetransaction.ID) ValueTxID { return ValueTxID(id.String()) } func (i...
package generator import ( "bytes" "fmt" "go/format" "io/ioutil" "log" "path/filepath" "testing" "github.com/frk/compare" "github.com/frk/gosql/internal/analysis" "github.com/frk/gosql/internal/config" "github.com/frk/gosql/internal/postgres" "github.com/frk/gosql/internal/search" ) func TestGenerator(t ...
package fixture import ( "math" "time" ) // @pi const Pi = 3.14 const StringConstant = "qwer" // @dao --asdf "val poi" --qwer 654 // @test -r="q w e r" type X struct { Val int // @field SliceVal []string `gorm:"index"` MapVal map[string]int `json:"map_val"` } // @func --name add func (x *X) Add(y *X) { ...
package main import ( "bufio" "fmt" "io" "os" "regexp" "strconv" "strings" ) type Password struct { min, max int substr string str string } func ReadInput(r io.Reader) ([]Password, error) { scanner := bufio.NewScanner(r) scanner.Split(bufio.ScanLines) var passwords []Password for scanner.Scan() ...
package oidc_test import ( "context" "fmt" "regexp" "testing" "time" "github.com/ory/fosite" "github.com/ory/fosite/token/hmac" "github.com/stretchr/testify/assert" "github.com/authelia/authelia/v4/internal/configuration/schema" "github.com/authelia/authelia/v4/internal/oidc" ) func TestHMACCoreStrategy(t...
package templatecode import ( "fmt" "os" "regexp" "strings" ) // CreateController 创建文件 // name: 文件名称 // path: 文件所在文件夹路径 func CreateController(name, path string) { create(name, path, 1) } // CreateServices 创建文件 // name: 文件名称 // path: 文件所在文件夹路径 func CreateServices(name, path string) { create(name, path, 2) }...
package config import ( "bytes" "os" "github.com/BurntSushi/toml" "github.com/golang/glog" "sub_account_service/finance/lib" ) type zhifubaoConfig struct { AlipayAppID string AlipayUrl string AlipayPrivateKey string AlipayPublicKey string Format string Charset string Sign...
package size import ( "fmt" "strconv" ) // Count in byte(8bits) type Size int64 var Measure = Size(1 << 10) var Precision = 1 var HaveSpace = true // 1TB = 1024 GB = 1024*1024 func (s *Size) String() string { if *s <0 { return "unknown" } p := strconv.Itoa(Precision) sp := "" f := "%ciB" if Measure == 1...
package pack import ( "bytes" "crypto" "crypto/rsa" "crypto/sha256" "encoding/binary" "encoding/json" "fmt" "math" "time" "github.com/syndtr/goleveldb/leveldb" ) const DIFF = 3 // minning block moi func Mine(tran []Transaction, phash [32]byte) Block { var n int64 = 0 Mroot := MakeMRoot(tran) time := ti...
package LinkedList type Node struct { data interface{} next *Node } func (n *Node) Next() *Node { return n.next }
package bom // BOM Mongodb Mongo builder of (go.mongodb.org/mongo-driver) import ( "context" "encoding/json" "fmt" "math" "reflect" "strings" "time" "go.mongodb.org/mongo-driver/bson" "go.mongodb.org/mongo-driver/bson/primitive" "go.mongodb.org/mongo-driver/mongo" "go.mongodb.org/mongo-driver/mongo/option...
// Copyright 2013 Walter Schulze // // 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 resources import ( DaoClusterTypes "github.com/containers-ai/alameda/datahub/pkg/dao/interfaces/clusterstatus/types" "github.com/containers-ai/alameda/datahub/pkg/formatconversion/requests/common" ApiResources "github.com/containers-ai/api/alameda_api/v1alpha1/datahub/resources" ) type CreateNodesRequestEx...
package control import ( "net/http" "encoding/json" "fmt" ) //状态为返回 func CodeReturn(w http.ResponseWriter,httpCode int ){ w.Header().Add("Content-type","text/html;charset=utf-8") w.WriteHeader(httpCode); return; } //json返回 func JsonReturn(w http.ResponseWriter,data interface{}){ w.Header().Add("Content-type","t...
package linkeddata import ( "encoding/json" "github.com/google/uuid" ) type ObjectCapabilityInvocation struct { Id uuid.UUID `json:"id"` Action string `json:"action"` Proof *Proof `json:"proof,omitempty"` } func (d *ObjectCapabilityInvocation) Clone() Signable { b, _ := json.Marshal(d) var clone Di...
package services import ( "github.com/nu7hatch/gouuid" "log" ) type BetService struct { betPublisher BetPublisher } func NewBetService(publisher BetPublisher) *BetService { return &BetService{ betPublisher: publisher, } } // Publisher gives the bet an id and sends bet message to the queue. func (e BetService...
/* * macky - Simple MU* Non-Client * * See README.md for usage * * See LICENSE for licensing info * * Written Sept 2013 Kutani */ package main import ( "bufio" "container/list" "encoding/json" "fmt" "net" "os" "strings" "syscall" ) var sList = list.New() var sListAdd chan *Server = make(chan *Server,...
package services import ( "time" "github.com/ne7ermore/gRBAC/common" "github.com/ne7ermore/gRBAC/plugin" ) type Permission struct { Id string `json:"id"` Name string `json:"name"` Descrip string `json:"descrip"` Sep string `json:"sep"` CreateTime time.Time `json:"createTim...
package printer import ( "fmt" "text/template" "strings" "github.com/davyxu/tabtoy/v2/i18n" "github.com/davyxu/tabtoy/v2/model" ) const cppTemplate = `// Generated by github.com/davyxu/tabtoy // Version: {{.ToolVersion}} // DO NOT EDIT!! #include <vector> #include <map> #include <string> namespace {{.Namespac...
package types import ( sdk "github.com/cosmos/cosmos-sdk/types" ) type Module interface { Handler() sdk.Handler }
package main func displayWidgets() { //Label createWidget("Label", ` Item { Label { anchors.centerIn: parent text: "This Is A Label" } }`) //Text createWidget("Text", ` Item { Text { anchors.centerIn: parent text: "This Is A Text Item" } }`) //Cal...
package backend import ( "context" "fmt" "sync" "sync/atomic" "time" "github.com/Azure/go-autorest/autorest" "github.com/sirupsen/logrus" "github.com/jim-minter/rp/pkg/api" "github.com/jim-minter/rp/pkg/database" "github.com/jim-minter/rp/pkg/env" ) const ( maxWorkers = 100 maxDequeueCount = 5 ) t...
package main import ( "flag" "fmt" "io" "log" "net/url" "os" "strconv" "time" "github.com/gorilla/websocket" ) var ( ip = flag.String("ip", "127.0.0.1", "server IP") connection = flag.Int("conn", 1, "number of socket connections") ) func main() { flag.Usage = func() { io.WriteString(os.Stderr,...
package application import ( "fmt" "github.com/go-gl/glfw/v3.3/glfw" "github.com/go-gl/mathgl/mgl32" ) const ( DEBUG = glfw.KeyH ) type Drawable interface { Draw() DrawWithUniforms(mgl32.Mat4, mgl32.Mat4) Update(float64) Log() string } type Camera interface { Log() string GetViewMatrix() mgl32.Mat4 GetP...
package turnstile import ( "database/sql" "reflect" "testing" "time" _ "github.com/mattn/go-sqlite3" ) type eventWithNulls struct { Time time.Time Type string UserID int64 LanguageCode sql.NullString ChatID sql.NullInt64 ChatType sql.NullString } func scanEvents(rows *sql....
package leetcode import ( "reflect" "sort" "testing" ) type TestCases []struct { Input string Output []string } // Input: "23" // Output: ["ad", "ae", "af", "bd", "be", "bf", "cd", "ce", "cf"]. var testcases = TestCases{ {Input: "23", Output: []string{"ad", "ae", "af", "bd", "be", "bf", "cd", "ce", "cf"}}, } ...
package main import ( "net/http" "github.com/ggalihpp/go-backend-ggalihpp/minio" example "github.com/ggalihpp/go-backend-ggalihpp/route-example" "github.com/labstack/echo" ) func setupHandlers(e *echo.Echo) { e.GET("/ping", func(c echo.Context) error { return c.String(http.StatusOK, "pong") }) exampleRoute...
package main import "fmt" func main() { //1.声明变量 没有初始化 零值 为false var a bool fmt.Println(a) a = false fmt.Println(a) //2.布尔类型不接受其他类型的赋值,不支持自动或强制的类型转换 //a = 1 //a = bool(1) //fmt.Println(a) //3.自动推导类型 var b = true fmt.Println(b) c := false fmt.Println(c) v2 := (1==2) fmt.Println(v2) fmt.Printf("...
// GENERATED BY THE COMMAND ABOVE; DO NOT EDIT // This file was generated by swaggo/swag at // 2019-11-27 11:02:57.290336153 +0100 CET m=+0.082305077 package docs import ( "bytes" "encoding/json" "strings" "github.com/alecthomas/template" "github.com/swaggo/swag" ) var doc = `{ "schemes": {{ marshal .Schem...
/* * Copyright 2018-present Open Networking Foundation * 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 ...
//go:generate go run github.com/alvaroloes/enumer -type InstallationPhase -output zz_generated_installationphase_enumer.go package api
package service type BaseService struct { TrackableLogService } type TrackableLogService struct { LogContext string }
package main import ( "context" "encoding/json" "fmt" "log" "net" "net/http" "net/http/pprof" "os" "os/signal" "path/filepath" "syscall" "time" "github.com/msiebuhr/ucs" "github.com/msiebuhr/ucs/cache" "github.com/msiebuhr/ucs/customflags" "github.com/msiebuhr/ucs/frontend" "github.com/namsral/flag"...
package cpu import "path/filepath" import "testing" func TestParsingInstructions(t *testing.T) { absPath, _ := filepath.Abs("../../test_input.txt") list, err := ParseInstructions(absPath) if err != nil { t.Errorf("Failed to parse test_input.txt :: %q", err) } else { if list.Len() != 4 { t.Errorf...
package main import ( "html/template" "net/http" "fmt" ) var t*template.Template func init(){ t=template.Must(template.ParseFiles("redirect1.gohtml")) } func main() { http.HandleFunc("/",foo) http.HandleFunc("/bar",bar) http.HandleFunc("/barred",barred) http.Handle("/favicon.ico",http.NotFoundHandler()) ...
package testdata import ( "github.com/frk/gosql" "github.com/frk/gosql/internal/testdata/common" ) type UpdateFromblockBasicSingleQuery struct { User *common.User4 `rel:"test_user:u"` From struct { _ gosql.Relation `sql:"test_post:p"` } Where struct { _ gosql.Column `sql:"u.id=p.user_id"` _ gosql.Column `...
package uuid import "github.com/lithammer/shortuuid" func NewString() string { return shortuuid.New() }
package lnroll import ( "testing" "github.com/apg/ln" ) type mockClient struct { C int E int } func (c *mockClient) Critical(err error, extras map[string]string) (uuid string, e error) { c.C++ return } func (c *mockClient) Error(err error, extras map[string]string) (uuid string, e error) { c.E++ return } ...
package prometheuscustomexporter import ( "context" metricspb "github.com/census-instrumentation/opencensus-proto/gen-go/metrics/v1" "github.com/orijtech/prometheus-go-metrics-exporter" commonpb "github.com/census-instrumentation/opencensus-proto/gen-go/agent/common/v1" resourcepb "github.com/census-instrumenta...
// Copyright 2023 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 upstream import ( "context" "fmt" "strconv" "sync/atomic" "testing" "time" v2 "github.com/envoyproxy/go-control-plane/envoy/api/v2" core "github.com/envoyproxy/go-control-plane/envoy/api/v2/core" corev3 "github.com/envoyproxy/go-control-plane/envoy/config/core/v3" discoveryv3 "github.com/envoyproxy/...
package main func addStrings(num1 string, num2 string) string { sum := make([]byte, 0) i, j, carry := len(num1)-1, len(num2)-1, 0 for i >= 0 || j >= 0 || carry != 0 { if i >= 0 { carry += int(num1[i] - '0') i-- } if j >= 0 { carry += int(num2[j] - '0') j-- } sum = append(sum, byte(carry%10+'0'...
package main import "fmt" func main() { var list1 = ListNode{10, nil} var list2 = ListNode{101, &list1} var list3 = ListNode{110, &list2} var list4 = ListNode{120, &list3} //120 110 101 10 //101 10 120 110 ret := rotateRight(&list4, 3) fmt.Println(ret.Val) fmt.Println(ret.Next.Val) fmt.Println(ret.Next.Nex...
/* * Copyright (c) 2014 Michael Wendland * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal * in the Software without restriction, including without limitation the rights * to use, copy, modify, merge, pu...
package usecase import ( "HttpBigFilesServer/MainApplication/internal/files/model" "HttpBigFilesServer/MainApplication/internal/files/repository" "HttpBigFilesServer/MainApplication/pkg/logger" "io" "os" "time" ) type Interface interface { Download(id uint64, seeker uint64) (model.File, *os.File, error) Uploa...
package main import "fmt" func main() { fmt.Println(isNumber("1.1+") == false) fmt.Println(isNumber(".-4") == false) fmt.Println(isNumber("-1E-16") == true) fmt.Println(isNumber("1+2") == false) fmt.Println(isNumber("3 .") == false) fmt.Println(isNumber(".") == false) fmt.Println(isNumber(". 1") == false) fm...
package main import ( "context" "database/sql" "flag" "log" _ "github.com/lib/pq" ) var ( planFile string ) func main() { flag.StringVar(&planFile, "plan", "plan.yaml", "gosqlbencher plan file") flag.Parse() pl, err := readPlan(planFile) if err != nil { log.Fatalf("failed to read plan: %v", err) } l...
package dingtalk import ( "crypto/hmac" "crypto/sha256" "encoding/base64" "encoding/json" "fmt" "github.com/weiqiang333/infra-skywalking-webhook/configs" "log" "net/http" "net/url" "strings" "time" ) /* [{ "scopeId": 2, "name": "growing-segmentation-pid:15149@seg3", "id0": 47, "id1": 0, "alarmMessage"...
package setgame func MakeSet(a int, b int, c int) bool { if a < 3 && b < 3 && c < 3 { return (a == b && a == c) || (a != b && a != c && b != c) } return MakeSet(a%3, b%3, c%3) && MakeSet(a/3, b/3, c/3) } func getMatch(a int, b int) int { if a < 3 && b < 3 { return (6 - a - b) % 3 } return getMatch(a%3, b%3)...
package 数组 func hanota(A []int, B []int, C []int) []int { move(len(A), &A, &B, &C) return C } // 将 A 上面的 n 个盘子,借助 B,移动到 C 中 (移动的每步要符合汉诺塔规则) func move(n int, A *[]int, B *[]int, C *[]int) { if n == 1 { *C = append(*C, (*A)[len(*A)-1]) *A = (*A)[:len(*A)-1] return } move(n-1, A, C, B) move(1, A, B, C) move...
package pipeline type EchoFunc func([]int) <-chan int type PipeFunc func(<-chan int) <-chan int func pipeline(nums []int, echo EchoFunc, pipeFns ...PipeFunc) <-chan int { ch := echo(nums) for i := range pipeFns { ch = pipeFns[i](ch) } return ch } //var nums = []int{1, 2, 3, 4, 5, 6, 7, 8, 9, 10} //for n := ran...
package main import ( "example.com/ben/primes" "fmt" ) func main() { best := best{} for a := -1000; a <= 1000; a++ { for _, b := range primes.GetPrimes(1000) { n := 0 for { quad := n*n + a*n + b if !primes.IsPrime(quad) { break } //fmt.Printf("a: %v, b: %v, n: %v, quad: %v\n", a, b, ...