text
stringlengths
11
4.05M
package streams type Ticker struct { CurrencyPair string Last float64 LowestAsk float64 HighestBid float64 PercentChange float64 BaseVolume float64 QuoteVolume float64 IsFrozen bool High float64 Low float64 }
package middleware import ( "github.com/opentracing/opentracing-go" "github.com/opentracing/opentracing-go/ext" "net/http" ) func JaegerMiddleWare(handler http.Handler) http.Handler { return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request){ spanCtx, _ := opentracing.GlobalTracer().Extract(opentraci...
package main import ( "context" "encoding/json" "github.com/gin-gonic/gin" "github.com/opentracing/opentracing-go" "github.com/opentracing/opentracing-go/ext" openlog "github.com/opentracing/opentracing-go/log" "strconv" ) // InitRoutes creates a gin router func InitRoutes() *gin.Engine { r := gin.Default() ...
package honeycombio import ( "context" "errors" "fmt" ) // Triggers describes all the trigger-related methods that the Honeycomb API // supports. // // API docs: https://docs.honeycomb.io/api/triggers/ type Triggers interface { // List all triggers present in this dataset. List(ctx context.Context, dataset strin...
package app import ( "encoding/json" bam "github.com/cosmos/cosmos-sdk/baseapp" "github.com/cosmos/cosmos-sdk/codec" sdk "github.com/cosmos/cosmos-sdk/types" "github.com/cosmos/cosmos-sdk/x/auth" "github.com/cosmos/cosmos-sdk/x/auth/genaccounts" "github.com/cosmos/cosmos-sdk/x/bank" "github.com/cosmos/cosmos-s...
package aoc2020 import ( "testing" aoc "github.com/janreggie/aoc/internal" "github.com/stretchr/testify/assert" ) func TestDay02(t *testing.T) { assert := assert.New(t) testCases := []aoc.TestCase{ { Details: "Y2020D02 sample input", Input: day02sampleInput, Result1: "2", Result2: "1", }, { ...
package main import ( "fmt" ) func test(data map[int]string) { // 删除其中一个元素 delete(data, 3) } func main() { data := map[int]string{1: "go", 2: "java", 3: "javascript"} fmt.Println("调用函数前:data = ", data) // map类型作函数参数 test(data) fmt.Println("调用函数后:data = ", data) // 结果为: // 调用函数前:data = map[1:go 2:java 3:...
package memory import ( "errors" "sync" "time" "github.com/delgus/def-parser/internal/app" ) // Cache struct cache type Cache struct { sync.RWMutex items map[string]Item defaultExpiration time.Duration cleanupInterval time.Duration } // Item struct cache item type Item struct { Value *ap...
--- vendor/github.com/modern-go/reflect2/unsafe_map.go.orig 2022-04-16 22:00:28 UTC +++ vendor/github.com/modern-go/reflect2/unsafe_map.go @@ -107,14 +107,6 @@ func (type2 *UnsafeMapType) Iterate(obj interface{}) M return type2.UnsafeIterate(objEFace.data) } -func (type2 *UnsafeMapType) UnsafeIterate(obj unsafe.Po...
package app import ( "errors" "fmt" "github.com/Mrs4s/MiraiGo/client" "github.com/Mrs4s/MiraiGo/message" "github.com/balrogsxt/xtbot-go/event" "github.com/balrogsxt/xtbot-go/util" "github.com/balrogsxt/xtbot-go/util/cache" "github.com/balrogsxt/xtbot-go/util/entity" "github.com/balrogsxt/xtbot-go/util/logger"...
package chain import "github.com/iotaledger/wasp/tools/wasp-cli/log" func activateCmd(args []string) { log.Check(MultiClient().ActivateChain(GetCurrentChainID())) } func deactivateCmd(args []string) { log.Check(MultiClient().DeactivateChain(GetCurrentChainID())) }
package index1 func Method1(i int) int { num := 0 for j := 0; j <= i; j++ { num += j } return num }
package sctransaction import ( "bytes" "github.com/iotaledger/wasp/packages/coretypes" "github.com/iotaledger/wasp/packages/vm/core/root" "github.com/stretchr/testify/require" "testing" ) func TestWriteRead(t *testing.T) { cid := coretypes.NewContractID(coretypes.ChainID{}, root.Interface.Hname()) rsec := NewR...
package main func main() { } func longestOnes(nums []int, k int) int { left, right := 0, 0 zeroCount := 0 mx := 0 for right < len(nums) { if nums[right] == 0 { zeroCount++ } right++ for zeroCount > k { if nums[left] == 0 { zeroCount-- } left++ } if t := right - left; t > mx { mx ...
package store import ( "encoding/json" "io" "io/ioutil" "log" "net/url" "os" "path/filepath" "strings" "tetra/lib/dbg" "time" ) var ( // writable directory dat = filepath.Clean(detectDataPath()) // readonly directory, can be "" res = filepath.Clean(detectResPath()) logfile io.WriteCloser ) func detec...
package log import ( // _ "github.com/wangfmD/rvs/log" "errors" "log" "testing" ) // TestT1 ... func TestT1(t *testing.T) { log.Println("ddd") } func ExampleNew() { err := errors.New("emit macho dwarf: elf header corrupted") if err != nil { log.Println(err) } }
package main import ( "fmt" "io/ioutil" ) func main() { file, e := ioutil.ReadFile("./mytestgo/gotest/filetest/abc.txt") if e != nil { fmt.Println(e) } else { fmt.Println(string(file)) } }
/* Copyright (c) 2016 Jason Ish * All rights reserved. * * 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...
package blob import ( "golang.org/x/net/context" "time" "github.com/firefirestyle/engine-v01/prop" m "github.com/firefirestyle/engine-v01/prop" "google.golang.org/appengine" "google.golang.org/appengine/blobstore" "google.golang.org/appengine/datastore" "google.golang.org/appengine/memcache" ) func (obj *Bl...
package common import "fmt" /* 将输入的date按照指定的partten格式化 @version 1.0 目前只支持正常的格式,其余变态格式暂不支持 如:yyyy,yyyy-MM,yyyy-MM-dd,yyyy-MM-dd HH,yyyy-MM-dd HH:mm,yyyy-MM-dd HH:mm:ss @date string 要被格式化的日期 @partten stirng 指定格式 @author wangdy return 返回格式化后的日期 */ func TimFormat(date, partten string) string { var ptnLength = le...
package main import ( "fmt" "io" "os" "reflect" "github.com/BurntSushi/toml" ) type ComposerConfigFile struct { Koji struct { AllowedDomains []string `toml:"allowed_domains"` CA string `toml:"ca"` } `toml:"koji"` Worker struct { AllowedDomains []string `toml:"allowed_domains"` CA ...
package lib import ( us "OkonmaV/userstorage" "fmt" "net/http" "time" "github.com/dgrijalva/jwt-go" ) // Claims : fuck type Claims struct { Login string IP string UserAgent string Uid string jwt.StandardClaims } // CreateCookie : < func CreateCookie(w http.ResponseWriter, r *http.Request,...
package main import ( "github.com/spf13/cobra" "k8s-pod-mutator-webhook/internal/logger" "k8s-pod-mutator-webhook/pkg/mutator" "k8s-pod-mutator-webhook/pkg/webhook" "os" "os/signal" "syscall" ) var rootCmd = &cobra.Command{ Use: "k8s-pod-mutator-webhook", Short: "Kubernetes Mutating Admission Webhook for P...
package namelist var Fullname = "shivpratap"
package main import ( "context" "fmt" "io" "log" "net" "./colorspb" "google.golang.org/grpc/reflection" "google.golang.org/grpc" ) type server struct{} func (*server) Color(ctx context.Context, req *colorspb.ColorRequest) (*colorspb.ColorResponse, error) { adjective := req.GetColors().GetAdjective() base...
package main import "fmt" const ( _ = iota // not using the first iota value // kb = 1024 -> 2 ^ 10 -> 1 shifted by 10 bits kb = 1 << (iota * 10) // mb = 1024 * kb -> 2 ^ 20 -> 1 shifted by 20 bits mb = 1 << (iota * 10) // gb = 1034 * mb -> 2 ^ 30 -> 1 shifted by 30 bits gb = 1 << (iota * 10) ) func main() { ...
package stank import ( "mvdan.cc/sh/syntax" "bufio" "log" "os" "os/exec" "path" "path/filepath" "strings" ) // LOWEREXTENSIONS2POSIXyNESS is a fairly exhaustive map of lowercase file extensions to whether or not they represent POSIX shell scripts. // Newly minted extensions can be added by stank contributors...
package responses // DNSZoneResponse represents a DNS zone response. type DNSZoneResponse struct { // Name is the domain name of the zone. Name string // ID is the zone's ID. ID string // InstanceID is the IBM Cloud Resource ID for the service instance where // the DNS zone is managed. InstanceID string // ...
package business import "testing" func TestStringStack_Len(t *testing.T) { stack := newStringStack() stack.push("1") stack.push("20") stack.push("300") expected := 3 result := stack.len() if expected != result { t.Errorf("expected:%d but got instead:%d", expected, result) } } func TestStringStack_Pop(t *te...
package pubsub import ( "fmt" "cloud.google.com/go/pubsub" "golang.org/x/net/context" "google.golang.org/api/option" ) // PubSubInput type PubSubInput struct { CredentialsPath string ProjectID string } // validate func (in PubSubInput) validate() error { messages := []string{} if in.CredentialsPath =...
package core import "strings" // Filter is an interface to filter SQL type Filter interface { Do(sql string, dialect Dialect, table *Table) string } // QuoteFilter filter SQL replace ` to database's own quote character type QuoteFilter struct { } func (s *QuoteFilter) Do(sql string, dialect Dialect, table *Table) ...
package test import ( . "exchange_websocket/okex_websocket" "fmt" "testing" ) func TestSymbol(t *testing.T) { okex := NewOkexSymbol() fmt.Println(okex) }
package repository import ( "fmt" "github.com/jmoiron/sqlx" "github.com/rs/zerolog/log" "sitemap/models/entity" "time" ) func NewSQLdbResumeRepo(Conn *sqlx.DB) *DbResumeRepo { return &DbResumeRepo{ Conn: Conn, } } type DbResumeRepo struct { Conn *sqlx.DB } func (l *DbResumeRepo)Count() (int, error){ t :=...
package handler import ( "fmt" "net/http" "time" "github.com/chonla/oddsvr-api/httpclient" "github.com/labstack/echo" ) func (h *Handler) Gateway(c echo.Context) error { code := c.QueryParam("code") token, e := h.strava.ExchangeToken(code) if e != nil { return c.String(http.StatusInternalServerError, fmt....
package noteset type Noteset struct { id string root int noteWeights []float64 patternId string patternNotes []int } func New(id string, root int, noteWeights []float64, patternId string, patternNotes []int) *Noteset { return &Noteset{ id: id, root: root, noteWe...
package error // NewAPIError creates a new application error object with the provided message and errors func NewAPIError(message string, apiErrorBodyList ...*APIErrorBody) *APIError { return &APIError{ Message: message, Body: apiErrorBodyList, } } // APIError implements error type APIError struct { Message...
package main import ( "fmt" "log" "net/http" "github.com/graphql-go/graphql" "github.com/graphql-go/handler" "github.com/svey/skill-tree/gql" "github.com/svey/skill-tree/postgres" ) func main() { // Initialize our api and return a pointer to our router for http.ListenAndServe // and a pointer to our db to d...
package Person import "Lab1/internal/pgk/model_of_person" type ForRepository interface { Get(*model_of_person.PersonRequest) (uint, int) Read(uint) (*model_of_person.PersonResponse, int) ReadAll() ([]*model_of_person.PersonResponse, int) Update(*model_of_person.PersonRequest) int Delete(uint) int }
package main import "fmt" /* 最长子序列,记录长度为l[i]的子序列的最大值的最小值maxV[l[i]] */ func main() { var n int fmt.Scan(&n) l := make([]int, n) for i:=0; i<n; i++ { fmt.Scan(&l[i]) } fmt.Println(lis(l)) } func lis(l[]int) (max int) { if len(l) == 0 { return } maxV := make([]int, len(l) + 1) maxV[1] = l[0] maxV[0] = mi...
package fondidocit import ( "context" "fmt" "net/http" "strings" "github.com/PuerkitoBio/goquery" "github.com/mmbros/quote/internal/quotegetter" "github.com/mmbros/quote/internal/quotegetter/scrapers" ) // scraper gets stock/fund prices from fondidoc.it type scraper struct { name string client *http.Clien...
package byte_order import ( "bytes" "encoding/binary" ) //func Int64ToBytes(num int64) []byte { // buf := make([]byte, 8) // binary.PutVarint(buf, num) // return buf //} // //func BytesToInt64(bytes []byte) int64 { // ans, _ := binary.Varint(bytes) // return ans //} //func Int64ToBytes(i int64) []byte { // var buf...
package tools import ( "io/ioutil" "os" "github.com/ethereum/go-ethereum/accounts/abi" "github.com/ethereum/go-ethereum/common/hexutil" ) // LoadContract will open and decode a contracts // Application Blockchain Interface and Binary files. func LoadContract(abiPath, binPath string) (abi.ABI, []byte, error) { ...
package lmdb import ( "encoding/binary" "encoding/hex" "os" "github.com/Secured-Finance/dione/blockchain/database" types2 "github.com/Secured-Finance/dione/blockchain/types" "github.com/fxamacker/cbor/v2" "github.com/ledgerwatch/lmdb-go/lmdb" ) const ( DefaultBlockDataPrefix = "blockdata_" DefaultBlockHea...
/* Given a string containing digits from 2-9 inclusive, return all possible letter combinations that the number could represent. A mapping of digit to letters (just like on the telephone buttons) is given below. Note that 1 does not map to any letters. Note: Although the above answer is in lexicographical order, yo...
package appqos // AppQoS API Calls + Marshalling import ( "bytes" "encoding/json" "fmt" "io/ioutil" "k8s.io/apimachinery/pkg/api/errors" "net/http" "strconv" ) const ( poolsEndpoint = "/pools" appsEndpoint = "/apps" powerProfilesEndpoint = "/power_profiles" username = "admin"...
package database import ( "context" "database/sql" "fmt" "time" "boiler/pkg/entity" "boiler/pkg/store" ) // AddEmail insert a new emails in the database func (s *Database) AddEmail(ctx context.Context, tx *sql.Tx, email *entity.Email) error { id, err := Insert(ctx, tx, "INSERT INTO emails (user_id, address,...
package main import ( "context" "flag" "fmt" "net/http" "os" "regexp" "strings" "time" "github.com/google/go-github/github" "github.com/gorilla/mux" log "github.com/sirupsen/logrus" "golang.org/x/oauth2" ) var ( webhookSecretEnvVariable = "RELEASE_BOT_WEBHOOK_SECRET" githubTokenEnvVariable = "RELEASE...
package service import ( "github.com/piotrpersona/saga/broker" ) func NewOrderService(b broker.Broker) *OrderService { return &OrderService{ Broker: b, } }
package Grammar const Number = 0 const LParentheses = 1 const RParentheses = 2 const Plus = 3 const Minus = 4 const Multi = 5 const Divide = 6 const BEGIN = 254 const END = 255
package filter import ( "github.com/comdeng/HapGo/hapgo/app" ) func Execute(filterName string, WebApp *app) { }
package rest import ( "encoding/json" ) type SubscriptionRequest struct { EventFilters []string `json:"eventFilters"` DeliveryMode map[string]string `json:"deliveryMode"` } func (resp SubscriptionRequest) String() string { obj, _ := json.MarshalIndent(resp, "", " ") return string(obj) }
package goroutine import ( "fmt" "math" ) //TestGoroutine5 func TestGoroutine5(n int) { ch1 := make(chan float64) for k := 0; k < n; k++ { go term(ch1, float64(k)) } sum := 0.0 for k := 0; k < n; k++ { sum += <-ch1 } fmt.Println(sum); } func term(ch1 chan float64, k float64) { ch1 <- 4 * ((math.Pow(-1,...
package model //Post - type Post struct { ID int64 UserID int64 Title string Body string }
package model //执行数据迁移 func migration() { // 自动迁移模式 DB.AutoMigrate(&Route{}, &UpstreamInfo{}) DB.AutoMigrate(&User{}) DB.AutoMigrate(&Group{}) DB.AutoMigrate(&Role{}, &Privilege{}) //InitData() //SetPrivilege() } func InitData() { route := Route{ Name: "test", Host: "liya.test.com", Path: "...
package object type Type string // Object is the internal representation of any type in the doggo language. type Object interface { Type() Type Inspect() string }
package controllers import ( "librarymanager/reviews/middlewares" "github.com/gin-gonic/gin" ) //MapUrls map routes to controller func MapUrls(router *gin.Engine, reviewsController Reviews, middleware middlewares.Middleware) *gin.RouterGroup { apiRoutes := router.Group("/api/reviews") { apiRoutes.GET("/books...
package medtronic import ( "time" ) const ( CarbRatios Command = 0x8A ) type Tenths int type CarbRatio struct { Start TimeOfDay CarbRatio Tenths // 10x grams/unit or 100x units/exchange Units CarbUnitsType } type CarbRatioSchedule []CarbRatio func carbRatioStep(newerPump bool) int { if newerPump { ...
package main import ( "database/sql" "fmt" "log" _ "github.com/ziutek/mymysql/godrv" ) const ( DB_HOST = "tcp(127.0.0.1:3306)" DB_NAME = "urlshortner" DB_USER = "root" DB_PASS = "" ) func OpenDB() *sql.DB { db, err := sql.Open("mymysql", fmt.Sprintf("%s/%s/%s", DB_NAME, DB_USER, DB_PASS)) if err != nil {...
package main import ( "github.com/gorilla/websocket" "log" ) type client struct { // このクライアントのためのwebsocket socket *websocket.Conn // メッセージをためておく send chan []byte room *room } // clientがroom.forwardにsocketの保有するメッセージを貯めこむ func (c *client) read() { for { if _, msg, err := c.socket.ReadMessage(); err == nil { ...
package main import ( "archive/zip" "crypto/sha256" "encoding/json" "errors" "fmt" "github.com/otiai10/copy" "io" "io/ioutil" "log" "net/http" "os" "path/filepath" "sort" "strconv" "strings" "time" ) type postsStruct struct { ID string `json:"id"` Date string `json:"date"` Text string `json:"-"` ...
// package main implements plz_diff_graphs, a small utility to take the JSON representation // of two build graphs (as output from 'plz query graph') and produce a list of targets // that have changed between the two. // // Note that the 'ordering' of the two graphs matters, hence their labels 'before' and 'after'; // ...
package nougat import ( "fmt" "net/http" "reflect" "testing" ) func TestDo_onSuccess(t *testing.T) { const expectedText = "Some text" const expectedFavoriteCount int64 = 24 client, mux, server := testServer() defer server.Close() mux.HandleFunc("/success", func(w http.ResponseWriter, r *http.Request) { w....
package parser import ( "bufio" "io" "strings" ) // Comment types. const ( LCommand = "L" CCommand = "C" ACommand = "A" ) // Parser is Hack assembly parser. type Parser struct { currentCommand string s *bufio.Scanner hasMoreCommand bool } // New creates a new Hack assembly parser. func New(r i...
import "strconv" func reversal(s string) string { r := []rune(s) for i, j := 0, len(r)-1; i < len(r)/2; i, j = i+1, j-1 { r[i], r[j] = r[j], r[i] } return string(r) } func reverse(x int) int { sign := 1 if x < 0 { sign = -1 } x *= sign str := strconv.Itoa(x) num, _ := strconv.Atoi(reversal(str)...
package test import ( "fmt" "testing" "time" ) func TestGoRoutine(t *testing.T) { for i := 0; i < 1000; i++ { go func(i int) { for { fmt.Printf("Hello from goroutine %d\n", i) } }(i) } time.Sleep(time.Minute) }
// Copyright (c) 2019 Chair of Applied Cryptography, Technische Universität // Darmstadt, Germany. All rights reserved. This file is part of go-perun. Use // of this source code is governed by a MIT-style license that can be found in // the LICENSE file. // +build race package test // Race tells whether the -race bu...
package repository type repoOption func(options *repoOptions) // WithName ... func WithName(name string) repoOption { return func(options *repoOptions) { options.name = name } } // WithURL repo url func WithURL(url string) repoOption { return func(options *repoOptions) { options.url = url } } // WithUsernam...
package main import ( "ddns/client" "ddns/common" "flag" "log" ) var ( enforcement = flag.Bool("f", false, "强制检查 DNS 解析记录") moreTips = flag.Bool("mt", false, "显示更多的提示") version = flag.Bool("version", false, "查看当前版本并检查更新") initOption = flag.Bool("init", false, "初始化配置文件") confPath = flag.String("con...
// Copyright (c) 2020 Xiaozhe Yao & AICAMP.CO.,LTD // // This software is released under the MIT License. // https://opensource.org/licenses/MIT package runtime import ( "bufio" "io" "os/exec" "reflect" "sync" "testing" "time" ) func TestNewProcess(t *testing.T) { type args struct { command string envs ...
package prettyms import ( "fmt" "math" "strconv" "strings" parsems "github.com/fernandoporazzi/parse-ms" ) // Result holds an array with values, such as year, days, hours and so on... type result struct { Values []string } var options Options func newResult() *result { return &result{} } func pluralize(l s...
package pool import ( "context" "github.com/pkg/errors" log "github.com/sirupsen/logrus" "github.com/mee6aas/kyle/internal/pkg/runtime" runtimesConnected "github.com/mee6aas/kyle/internal/pkg/var/runtimes/connected" runtimesPended "github.com/mee6aas/kyle/internal/pkg/var/runtimes/pended" ) func spawn(ctx con...
package gid import ( "fmt" "github.com/go-redis/redis" "ism.com/common/rediscache" ) type RedisChecker struct { GidCheckerInterface } func (gidChecker *RedisChecker) CheckGID(gid string) bool { println("RedidChecker ...") _, err := rediscache.Get(fmt.Sprint("GID:", gid)) if err != nil { if err == redis.Ni...
package treecmds import ( "sync" "github.com/Nv7-Github/Nv7Haven/eod/base" "github.com/Nv7-Github/Nv7Haven/eod/types" "github.com/bwmarrin/discordgo" ) type TreeCmds struct { lock *sync.RWMutex dat map[string]types.ServerData base *base.Base dg *discordgo.Session } func NewTreeCmds(dat map[string]types.S...
package main import ( "fmt" "strconv" "github.com/Cloud-Foundations/Dominator/lib/log" "github.com/Cloud-Foundations/Dominator/lib/srpc" proto "github.com/Cloud-Foundations/Dominator/proto/logger" ) func setDebugLevelSubcommand(args []string, logger log.DebugLogger) error { level, err := strconv.ParseInt(args[...
// Copyright 2016 Martin Hebnes Pedersen (LA5NTA). All rights reserved. // Use of this source code is governed by the MIT-license that can be // found in the LICENSE file. package cfg import ( "encoding/json" "fmt" "net" "strconv" "strings" "github.com/la5nta/wl2k-go/transport/ardop" ) const ( PlaceholderMyc...
package main import ( "fmt" "golang.org/x/tour/wc" "strings" ) type Vertex struct { Lat, Lon float64 } var m map[string]Vertex func main() { m = make(map[string]Vertex) m["anitha"] = Vertex{ 45.34534, 56.4435, } fmt.Println(m["anitha"]) var mm = map[string]Vertex{ "abc" : Vertex{45.3, 56.7}, "de...
package sheet_logic import ( "hub/framework" "hub/sheet_logic/sheet_logic_types" ) type IntLesser IntComparator func NewIntLesser(name string) *IntLesser { tmp := NewIntComparator( name, sheet_logic_types.IntLesser, func(a int64, b int64) bool { return a < b }) return (*IntLesser)(tmp) } type FloatLesser ...
package blog import ( "fmt" "strconv" "time" "mingchuan.me/util" "github.com/jinzhu/gorm" "mingchuan.me/app/errors" ) // CreatePost - create a new post func (blog *BlogService) CreatePost( title string, content string, initialStatus ArticleStatus, initialPermission ArticlePermission) (Article, *errors.Err...
package main import ( "fmt" "bufio" "log" "net" ) func main() { listener, error := net.Listen("tcp", ":8080") if error != nil { log.Fatalln(error) } defer listener.Close() fmt.Println("Awaiting request...") for { connection, error := listener.Accept() ...
package s3urlupload import ( "errors" "io" "net/http" "strings" "sync" "github.com/rlmcpherson/s3gof3r" ) type Config struct { AwsAccessKey string AwsSecretKey string AwsS3Endpoint string AwsS3Bucket string Workers uint GetFilePath func(string) string } func Init(c Config) *S3UrlUpload { if...
package tx import ( "testing" ) //var gateway *EtherGateway func makeGateway() *EtherGateway { return NewEtherGateway() } func Test_loadConfigs(t *testing.T) { makeGateway() } func Test_NetworkType(t *testing.T) { g := makeGateway() if networkID := g.GetCurrentNetworkType(); networkID == "" { t.Errorf("Empty ...
package tal import ( "github.com/cpusoft/goutil/belogs" "github.com/cpusoft/goutil/ginserver" "github.com/cpusoft/goutil/jsonutil" "github.com/gin-gonic/gin" model "rpstir2-model" ) // func GetTals(c *gin.Context) { belogs.Info("GetTals") talModels, err := getTals() if err != nil { belogs.Error("GetTals():...
// _通道(Channels)_ 是连接多个 Go 协程的管道。你可以从一个 Go 协程 // 将值发送到通道,然后在别的 Go 协程中接收。 package main import "fmt" func main() { // 使用 `make(chan val-type)` 创建一个新的通道。 // 通道类型就是他们需要传递值的类型。 messages := make(chan string) // 使用 `channel <-` 语法 _发送(send)_ 一个新的值到通道中。这里 // 我们在一个新的 Go 协程中发送 `"ping"` 到上面创建的 // `messages` 通道中。 go fu...
package request type LevelPrice struct { RateCardID int `json:"rate_card_id"` Prices []struct { LevelID int `json:"level_id"` Price float64 `json:"price"` } `json:"prices"` }
package cgroups import ( "bufio" "fmt" "os" "path/filepath" "strings" rspec "github.com/opencontainers/runtime-spec/specs-go" ) var ( // AbsCgroupPath is absolute path for container's cgroup mount AbsCgroupPath = "/cgrouptest" // RelCgroupPath is relative path for container's cgroup mount RelCgroupPath = "...
package report import ( "github.com/gin-gonic/gin" "github.com/naggie/dsnet" ) var conf *dsnet.DsnetConfig // Routes sets up endpoints for peers. func Routes(router *gin.RouterGroup, dsConf *dsnet.DsnetConfig) { conf = dsConf router.GET("", handleGetReport) } func handleGetReport(c *gin.Context) { newReport :=...
package main import ( "fmt" "sort" ) func main() { capital, keyboards, usbs, price, j := 0, 0, 0, 0, 0 var kBrands, uBrands []int fmt.Scanf("%d", &capital) fmt.Scanf("%d", &keyboards) fmt.Scanf("%d", &usbs) for i := 0; i < keyboards; i++ { fmt.Scanf("%d", &price) kBrands = append(kBrands, price) } ...
// Copyright 2020 The Matrix.org Foundation C.I.C. // // 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...
package command import ( "jabrok.com/global" "jabrok.com/service" "log" ) func GetCommand() { var cmdstring string if len(global.GetArgs()) > 0 { cmdstring = global.GetArgs()[0] cmd, ok := commandMap()[cmdstring] if !ok { log.Fatal("No command") } cmd() } if cmdstring == "" { var listOfCommands...
package testcontainers import ( "context" "fmt" "net/http" "testing" "time" "database/sql" // Import mysql into the scope of this package (required) _ "github.com/go-sql-driver/mysql" "github.com/docker/docker/api/types" "github.com/docker/docker/api/types/filters" "github.com/docker/docker/client" "gith...
package main import ( "github.com/lxn/walk" "sort" ) type Condom struct { Machineid string //客户端唯一识别码 IP string Name string Whoami string Remark string Terrace string Time string checked bool } type CondomModel struct { walk.TableModelBase walk.SorterBase sortColumn int sortO...
package src import ( "net/url" ) // Mkdir will make specified folder on Yandex Disk func (c *Client) Mkdir(remotePath string) (int, string, error) { values := url.Values{} values.Add("path", remotePath) // only one current folder will be created. Not all the folders in the path. urlPath := "/v1/disk/resources?" ...
package main import "math" const ( controlPI = 0 controlPID = 1 ) type Tuner struct { input, output, outputStart, NoiseBand, OStep, lastTime, refVal, absMin, absMax, kp, ki, kd, ku, pu float64 ControlType, lookbackSec, nLookback, sampleTime int running bool } func (t *Tuner) Cancel() { t.running = false } f...
package dto type MeditationExerciseStarted struct { ExerciseStarted }
// 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 ...
package main import ("log" // "net" // "github.com/grpc-go-course/hello/hellopb" "../grpcpb" "google.golang.org/grpc" "context" ) func main() { opts := grpc.WithInsecure() cc, err := grpc.Dial("localhost:50051", opts) if err != nil { log.Fatal(err) } defer cc.Close() grpcClient := grpcpb.NewSatuatio...
package cliutil import ( "bytes" "crypto/sha256" "encoding/hex" "fmt" "os" "github.com/koinos/koinos-proto-golang/koinos/protocol" util "github.com/koinos/koinos-util-golang" "github.com/minio/sio" ) const ( // Version number (this should probably not live here) Version = "v2.0.0" ) // Hardcoded Koin cont...
package git /* #include <git2.h> extern void _go_git_populate_apply_callbacks(git_apply_options *options); extern int _go_git_diff_foreach(git_diff *diff, int eachFile, int eachHunk, int eachLine, void *payload); extern void _go_git_setup_diff_notify_callbacks(git_diff_options* opts); extern int _go_git_diff_blobs(gi...
package dcmdata import "testing" func TestNewDcmList(t *testing.T) { cases := []struct { want DcmList }{ {DcmList{nil, nil, nil, 0}}, } for _, c := range cases { got := NewDcmList() if *got != c.want { t.Errorf("NewDcmList(), want '%v' got '%v'", c.want, got) } } } func TestNewDcmListNode(t *tes...
package proof import ( // "incognito-chain/common" "incognito-chain/privacy/coin" errhandler "incognito-chain/privacy/errorhandler" // "incognito-chain/privacy/key" "incognito-chain/privacy/proof/agg_interface" ) // Paymentproof type Proof interface { GetVersion() uint8 Init() GetInputCoins() []coin.PlainCoin...