text
stringlengths
11
4.05M
package sgf import ( "bufio" "bytes" "fmt" "io" "io/ioutil" "os" "strings" ) // SaveCollection creates a new file, and saves each tree given into that file. // It is useful for saving the rarely-used SGF collection format. Note that the // location of the nodes in their trees is irrelevant: in each case, the w...
package main import ( _ "github.com/mattn/go-sqlite3" "github.com/go-xorm/xorm" "fmt" ) var engine *xorm.Engine type U struct { User Count int } type User struct { Id int64 Name string } type Home struct { Id int64 HomeName string UserId int64 } var err error func main() { engine, err = xorm....
package docker_driver import ( "os" "io/ioutil" "github.com/netapp/netappdvp/storage_drivers" "github.com/netapp/netappdvp/storage_drivers/test_driver" "testing" log "github.com/Sirupsen/logrus" ) var ( tempRoot string = "/tmp/root" ) func newNdvpDriverWithPrefix(storage_prefix, snapshot_prefix strin...
package db import ( "database/sql" _ "github.com/go-sql-driver/mysql" "github.com/bradbeam/l1g/config" "strconv" ) func Connect(c config.Config) (*sql.DB, error) { var connectionstring string connectionstring += c["DatabaseUsername"] // Test to see if we actually have a database password if _, ok := c...
package main import "sync" var ( // Apps stores all tracked applications. Apps map[Application]Metric // AppLock guards additions to Apps to ensure thread safety AppLock sync.Mutex ) // Application represts a single version of a particular application. type Application struct { Name string Version string } ...
package udig import ( "crypto/tls" "crypto/x509" "fmt" "net" "net/http" ) ///////////////////////////////////////// // TLS RESOLVER ///////////////////////////////////////// // NewTLSResolver creates a new TLSResolver with sensible defaults. func NewTLSResolver() *TLSResolver { transport := http.DefaultTranspo...
package collect import ( "encoding/json" "dudu/models" "dudu/modules/collector" "github.com/shirou/gopsutil/host" ) // 系统相关 type BootTime struct{} // collect info func (b *BootTime) Collect() (interface{}, error) { return host.BootTime() } func (b *BootTime) Marshal(res interface{}) ([]byte, error) { return...
package som_test import ( "testing" "github.com/voievodin/self-organizing-map/som" ) func TestDataSetReduce(t *testing.T) { dataSet := &som.DataSet{} for i := 0; i < 9; i++ { dataSet.AddRaw(float64(i)) } dataSet.Reduce(3) // 0 1 2 3 4 5 6 7 8 (len = 9) // * ^ * ^ * ^ * // // [0] -> (0 + 3) / 2 =...
package collection // Data holds data about a collection. type Data struct { Type Type `json:"type"` StartToken string `json:"startToken"` }
package kafka import ( "context" "github.com/segmentio/kafka-go" ) // Producer sends messages to the broker type Producer struct { producer *kafka.Writer } // NewProducer creates a producer to send messages to kafka func NewProducer(topic string, brokers []string) *Producer { newProducer := &kafka.Writer{ Add...
package SocksTCP import ( "encoding/binary" "errors" "fmt" socks "github.com/OperatorFoundation/shapeshifter-dispatcher/common/socks5" "io/ioutil" "net" "testing" "time" ) const ( version = 0x05 ) func TestSocksTCPOptimizerFirst(t *testing.T) { negotiateError := negotiateSocks("../../ConfigFiles/OptimizerF...
// 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...
package session import "github.com/lab5e/lmqtt/pkg/entities" // IterateFn is the callback function used by Iterate() // Return false means to stop the iteration. type IterateFn func(session *entities.Session) bool // Store is the session store interface type Store interface { Set(session *entities.Session) error R...
package controllers import ( "encoding/json" "net/http" "time" "github.com/astaxie/beego" "github.com/dockercn/wharf/models" "github.com/dockercn/wharf/utils" ) type OrganizationWebV1Controller struct { beego.Controller } func (this *OrganizationWebV1Controller) URLMapping() { this.Mapping("GetOrgs", this....
/* * @lc app=leetcode.cn id=125 lang=golang * * [125] 验证回文串 */ // @lc code=start // package leetcode import ( "unicode" ) func isPalindrome(s string) bool { r := []rune(s) start := 0 end := len(r) - 1 for { for start < end && !(unicode.IsLetter(r[start]) || unicode.IsDigit(r[start])){ start += 1 } f...
package composition import ( "encoding/json" "errors" "io/ioutil" "net/http" netUrl "net/url" "os" "appengine" "appengine/urlfetch" ) const MercuryURL = "https://mercury.postlight.com/parser?url=" var MercuryToken = os.Getenv("MERCURY_TOKEN") var YoutubeToken = os.Getenv("YOUTUBE_TOKEN") // API Response fo...
package handlers import ( "InkaTry/warehouse-storage-be/internal/http/admin/dtos" "InkaTry/warehouse-storage-be/internal/pkg/errs" "InkaTry/warehouse-storage-be/internal/pkg/stores" "InkaTry/warehouse-storage-be/mocks/mock_mysql" "context" "errors" "github.com/golang/mock/gomock" "github.com/stretchr/testify/a...
package main import ( "flag" "fmt" "log" "os" "runtime" "time" "gopkg.in/mgo.v2" "github.com/michigan-com/brvty-api/brvtyclient" "github.com/michigan-com/brvty-api/mongoqueue" "github.com/michigan-com/gannett-newsfetch/commands" ) func main() { var brvtyTimeout time.Duration var verboseMgo bool flag.Du...
// Copyright 2022 PingCAP, Inc. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // // http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed to i...
package main import ( "fmt" "os" "github.com/adlio/trello" "github.com/underyx/the-gathering/giantbomb" ) type GameMatch struct { Card *trello.Card Game *giantbomb.GameType } func main() { trelloKey := os.Getenv("THEG_TRELLO_KEY") trelloToken := os.Getenv("THEG_TRELLO_TOKEN") trelloBoardID := os.Getenv("TH...
package textbox import ( "net/http" _ "net/http/pprof" ) func init() { go http.ListenAndServe("localhost:6789", nil) }
package main import ( "fmt" "math" ) type Vertex struct { X, Y float64 } /* Go does not have classes. However, you can define methods on types. A method is a function with a special receiver argument. The receiver appears in its own argument list between the func keyword and the method name. In this example, t...
// SysMonitor project doc.go /* SysMonitor document */ package main
// Package manager contains an identity manager responsible for refreshing sessions and creating users. package manager import ( "context" "errors" "time" "github.com/google/btree" "github.com/rs/zerolog" "golang.org/x/oauth2" "golang.org/x/sync/errgroup" "google.golang.org/grpc/codes" "google.golang.org/grp...
// Copyright © 2018 Inanc Gumus // Learn Go Programming Course // License: https://creativecommons.org/licenses/by-nc-sa/4.0/ // // For more tutorials : https://learngoprogramming.com // In-person training : https://www.linkedin.com/in/inancgumus/ // Follow me on twitter: https://twitter.com/inancgumus package main ...
/* # -*- coding: utf-8 -*- # @Author : joker # @Time : 2021/6/17 9:27 上午 # @File : lt_二进制_反转.go # @Description : # @Attention : */ package v2 func reverseBits(num uint32) uint32 { // 核心: // 将1不断的前移 var r uint32 var count = 31 for num > 0 { r += (num & 1) << count count-- num >>= 1 } return r }
package hub import ( "log" "k0s.io/k0s/pkg/hub/config" "k0s.io/k0s/pkg/hub/hub" ) func Run(args []string) (err error) { c := config.Parse(args) log.Println("server is listening on", c.Port()) h := hub.NewHub(c) if c.UseTLS() { err = h.ListenAndServeTLS(c.Cert(), c.Key()) } else { err = h.ListenAndServ...
package main import ( "fmt" "os" "path/filepath" "github.com/spf13/viper" "github.com/tendermint/tendermint/abci/server" "github.com/tendermint/tendermint/libs/cli" cmn "github.com/tendermint/tendermint/libs/common" dbm "github.com/tendermint/tendermint/libs/db" "github.com/tendermint/tendermint/libs/log" ...
package sphere import ( "testing" "github.com/akosgarai/opengl_playground/pkg/primitives/material" "github.com/go-gl/mathgl/mgl32" ) var ( DefaultRadius = float32(2.0) DefaultColor = mgl32.Vec3{0, 0, 1} DefaultCenter = mgl32.Vec3{3, 3, 5} DefaultSpeed = float32(0.0) DefaultDirection = mgl32.Vec...
package main import ( "fmt" ) func main() { ch := make(chan bool) for i := 0; i < 10; i++ { go Go(i) // goroutine运行Go函数 } <-ch } func Go(index int) { // 定一个Go函数,在里面传递进去一个参数,是int类型的 num := 1 // 定义一个参数,把1赋值给num for i := 0; i < 100000000; i++ { // for循环,循环叠加一亿次 num += i // num加等i } ...
package main /* TODO: Implement Build/Deploy */ import ( "fmt" "github.com/ClarityServices/skynet2" "github.com/sbinet/liner" "regexp" "strconv" "strings" "syscall" ) var criteria = new(skynet.Criteria) var configFile = "./build.cfg" /* * CLI Logic */ var SupportedCliCommands = []string{ "exit", "quit", ...
package open_im_sdk import ( "encoding/json" "fmt" "net/http" ) func (u *UserRelated) GetFriendsInfo(callback Base, uidList string) { if callback == nil || uidList == "" { sdkLog("uidList or callback is nil") return } go func() { fList, err := u.getLocalFriendList() if err != nil { sdkLog("getLocalFr...
package readmodel import ( "context" "cloud.google.com/go/firestore" "github.com/dwaynelavon/es-loyalty-program/internal/app/user" ) type userStore struct { firestoreClient *firestore.Client } // NewUserStore instantiates a new instance of the EventRepo func NewUserStore(firestoreClient *firestore.Client) user....
package run import ( "github.com/rs/zerolog/log" "github.com/saucelabs/saucectl/internal/credentials" "github.com/saucelabs/saucectl/internal/docker" "github.com/saucelabs/saucectl/internal/flags" "github.com/saucelabs/saucectl/internal/puppeteer" "github.com/saucelabs/saucectl/internal/region" "github.com/sauc...
// Copyright 2016 Eleme. All rights reserved. // Use of this source code is governed by a MIT // license that can be found in the LICENSE file. package backend import ( "encoding/json" "log" "os" ) const ( VERSION = "0.9.1" ) // Config Configuration file structure type Config struct { Proxy ProxyConfig ...
package main import ( "testing" ) func TestReorderList(t *testing.T) { }
package models type PurchaseParams struct { Purchaser string `json:"Purchaser"` Value string `json:"Value"` Offchain string `json:"Offchain"` ContractAddress string `json:"ContractAddress"` ContractName string `json:"ContractName"` MasterAddr string `json:"MasterAddr"` Err ...
package week12 // 动态规划 func maxSubArray2(nums []int) int { f := make([]int, len(nums)+1) f[0] = nums[0] ans := f[0] for i := 1; i <= len(nums); i++ { f[i] = max(nums[i], nums[i]+f[i-1]) ans = max(ans, f[i]) } return ans }
package service import ( "context" "fmt" "log" "os" "strconv" "testing" "github.com/gdotgordon/fibsrv/store" "github.com/ory/dockertest" "github.com/ory/dockertest/docker" "go.uber.org/zap" ) var ( user = "postgres" password = "secret" db = "fib_db" port = "5433" dialect = "postgres" d...
package main import ( "ms/sun/servises/pusher_service" "time" "runtime" "ms/sun/shared/x" "fmt" "ms/sun/shared/helper" ) func main() { //i := 0 go func() { for i := 1; i < 100; i += 5 { //pusher_service.ServeMockStream(i, os.Stderr) pusher_service.ServeMockStream(i, nil) } }() go ...
/* Package tagsDemand "Every package should have a package comment, a block comment preceding the package clause. For multi-file packages, the package comment only needs to be present in one file, and any one will do. The package comment should introduce the package and provide information relevant to the package as a ...
/* Copyright 2021 RadonDB. 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 distri...
package resource import ( "github.com/scjalliance/drivestream/seqnum" ) // Version is a file or drive version number. type Version int64 // String returns a string representation of the version number. func (number Version) String() string { v := number.Base64() return string(v[:]) } // Base64 returns a base64 r...
package wallet import ( "wx-gin-master/models" "wx-gin-master/models/user" "wx-gin-master/pkg/logging" ) type Wallet struct { models.Model Balance float64 `json:"balance"` // 余额 Coin float64 `json:"coin"` // 平台币 } func (Wallet) TableName() string { return "users" } // TopUpBalance 充值余额 func TopUpBalanc...
// +build linux package system import ( "fmt" "strings" pb_info "github.com/mickep76/grpc-exec-example/info" ) func getOS(s *pb_info.System) error { descr, err := readFile("/etc/redhat-release") if err != nil { return err } s.OsDescription = strings.TrimSpace(string(descr)) a := strings.SplitN(s.OsDescr...
package main import ( "fmt" "log" "os" "image/color" "image" "image/png" ) // Based on: // https://esolangs.org/wiki/Bitwise_Cyclic_Tag func bct(data []int, prog []int, limit int) int { l := len(prog) // Program bit pointer: p := 0 var i int for i = 0; len(data) > 0 && i < limit; i++ { cmd := prog[p] ...
package main import ( "encoding/json" "fmt" "io/ioutil" "os" ) type Server struct { ServerName string ServerIp string } type Serverslice struct { Servers []Server } func main() { file, err := os.Open("file/json/unmarshal/servers.json") if err != nil { fmt.Printf("error: %v", err) return } defer fil...
package historicaldata import ( "bytes" "encoding/json" "io/ioutil" "net/http" "os" "strconv" "strings" "time" // "fmt" "github.com/elastic/beats/libbeat/common" "github.com/elastic/beats/libbeat/common/cfgwarn" "github.com/elastic/beats/metricbeat/mb" ) // init registers the MetricSet with the central r...
package main import ( "fmt" "github.com/google/gopacket" "github.com/google/gopacket/layers" "github.com/google/gopacket/pcap" "github.com/google/gopacket/tcpassembly" "github.com/google/gopacket/tcpassembly/tcpreader" "github.com/sirupsen/logrus" "github.com/urfave/cli/v2" "net/http" "net/http/httputil" "r...
package cloudstorage const ( S3CloudStorage string = "s3" OssCloudStorage string = "oss" ) const ( Xlsx_Dir = "biztransfer" // 存放商家批量转账的xlsx文件 Misc_Dir = "misc" // 存放一下杂项零碎的文件 )
//go:build libvirt // +build libvirt package types import ( "sort" "github.com/openshift/installer/pkg/types/libvirt" ) func init() { PlatformNames = append(PlatformNames, libvirt.Name) sort.Strings(PlatformNames) }
package data import ( "crypto/sha256" "database/sql" "fmt" "os" _ "github.com/go-sql-driver/mysql" "github.com/souhub/wecircles/pkg/logging" ) func init() { db := NewDB() defer db.Close() // Create users table cmd := `CREATE TABLE IF NOT EXISTS users( id INT AUTO_INCREMENT PRIMARY KEY, name VARCHAR(255...
package logger import ( "fmt" "io" "log" "os" "strings" ) type Flags int const ( USUAL Flags = log.Ldate | log.Ltime | log.Lshortfile ) type Level int const ( DEBUG Level = iota INFO WARN ERROR FATAL ) type LevelLogger struct { logger *log.Logger level Level context string } var logs LevelLogger...
package compose import ( "fmt" "time" "github.com/kudrykv/latex-yearly-planner/app/components/calendar" "github.com/kudrykv/latex-yearly-planner/app/components/page" "github.com/kudrykv/latex-yearly-planner/app/config" ) func Quarterly(cfg config.Config, tpls []string) (page.Modules, error) { if len(tpls) != 1...
package main import "fmt" func main() { c :=fanin(str("ice"),str("fire")) //c:=one(c,c) for i:=0;i<13;i++{ fmt.Println(<-c) } } func str(s string) chan string{ c :=make(chan string) go func(){ for i:=0;i<8;i++{ c<-fmt.Sprintln(s,"is good",i) } }() return c } func fanin(c1,c2 chan string) chan str...
package main func countSegments(s string) int { wordFlag := false // 单词标志 ans := 0 for i := 0; i < len(s); i++ { // 空格则跳过 if s[i] == ' ' { wordFlag = false continue } // 遇见单词首字母则进行计数 if wordFlag == false { ans++ wordFlag = true } } return ans }
package main import ( "fmt" "time" ) type Clock struct { hour int min int sec int } var h, m, s int func main() { fmt.Println("inserisci tempo con ore minuti e secondi divisi da uno spazio:") fmt.Scan(&h, &m, &s) tempo := new(Clock) tempo.hour = h tempo.min = m tempo.sec = s Countdown(*tempo) } fun...
package main import ( "context" "os" "gx/ipfs/QmR77mMvvh8mJBBWQmBfQBu8oD38NUN4KE9SL2gDgAQNc6/go-ipfs-cmds/examples/adder" //cmdkit "github.com/ipfs/go-ipfs-cmdkit" cmds "gx/ipfs/QmR77mMvvh8mJBBWQmBfQBu8oD38NUN4KE9SL2gDgAQNc6/go-ipfs-cmds" cli "gx/ipfs/QmR77mMvvh8mJBBWQmBfQBu8oD38NUN4KE9SL2gDgAQNc6/go-ipfs-cmds...
package main import ( "fmt" "math/rand" "time" ) type Game struct { worldTurnNumber int } type Human struct { id string name string satiety int } func runMainLoop(game *Game) { for { interval := time.Microsecond * 16666 time.Sleep(interval) game.worldTurnNumber = game.worldTurnNumber + 1 f...
package main import ( "flag" "fmt" "io" "io/ioutil" "log" "net/http" "os" "os/exec" "path/filepath" "runtime" "strconv" "strings" "time" "github.com/dustin/go-humanize" "github.com/m7shapan/njson" ) var ( yearsBack int path string currYear int fetchYears []int only int platform ...
package compute import ( "encoding/json" "fmt" "net/http" "net/url" ) // Virtual listener types const ( // VirtualListenerTypeStandard represents a standard virtual listener. VirtualListenerTypeStandard = "STANDARD" // VirtualListenerTypePerformanceLayer4 represents a high-performance (layer 4) virtual listen...
package soapboxd import ( "testing" pb "github.com/adhocteam/soapbox/proto" ) // TODO probably most this out into another test package type CloudSuccess struct{} func (c *CloudSuccess) UploadFile(bucket string, key string, filename string) error { return nil } func (c *CloudSuccess) GetConfigVars(appSlug string,...
package driveview import ( "fmt" "github.com/scjalliance/drivestream/commit" "github.com/scjalliance/drivestream/resource" ) // NotFound reports that a view of the drive could not be found within // the repository. This typically means that commit 0 for the drive hasn't // been finalized. type NotFound struct { ...
package stockdb import ( "database/sql" "util" _ "github.com/go-sql-driver/mysql" "config" "entity/dbentity" //"fmt" ) type DBBase struct { Dbtype string Dbcon string Logger *util.StockLog } func (s *DBBase) Init(name string) { //dbconfig := config.NewDBConfig("../config/dbcon...
package middlewares import ( "bytes" "os/exec" "fmt" "strings" "io/ioutil" "net/http" ) // 上传ipfs 返回ipfs 地址 func IpfsUpload(path string)(string, error){ var out bytes.Buffer var stderr bytes.Buffer args := []string{"add",path} cmd := exec.Command("ipfs" , args...) cmd.Stdout = &out //结果 cmd.Stderr = &...
package lintcode var array []int /** * @param n: A long integer * @return: An integer, denote the number of trailing zeros in n! */ func trailingZeros(n int64) int64 { if n == 0 { return 0 } var count int64 for i := n; i > 0; { i = i / 5 count += int64(i) } // // 因数5的个数必大于因数2的个数 // for m%5 == 0 && m >...
/********************************** / Sedgewick's algorithm edition 4 / Chapter 1 Weighted Union *********************************/ package weighted_union type Sites struct { id []int weight []int number int } func Init(n int) *Sites { sites := &Sites{make([]int, n), make([]int, n), n} for i := range sites.i...
package main import ( "log" "strings" "unicode" ) func main() { var testCases = []struct { description string input string ok bool }{ { "single digit strings can not be valid", "1", false, }, { "a single zero is invalid", "0", false, }, { "a simple valid SIN th...
/* */ package main import ( "fmt" ) func has23(ints []int) bool { for _, i := range ints { if i == 2 || i == 3 { return true } } return false } func main(){ var status int = 0 if ! has23([]int{5, 6, 7}) { status += 1 } if has23([]int{9, 8, 3}) { status += 1 } if has23([]int{2}) { status += 1 } i...
package cacheservice import ( "encoding/json" "fmt" ) // Example struct type Example struct { Name string Count int } // GetExampleCachedResults gets caching results and unmarshalls into stype model.Example func (cacheService *CacheService) GetExampleCachedResults(key string) (cache Example, err error) { var d...
package periph_gpio import ( "fmt" "os" "strconv" "github.com/sirupsen/logrus" "periph.io/x/periph/conn/gpio/gpioreg" "periph.io/x/periph/host/fs" ) type AtmelGpioPin struct { Number int Name string } type AtmelGpioPins []AtmelGpioPin type AtmelGpioDriver struct { Pins AtmelGpioPins } const ( AtmelGpi...
package git import ( "reflect" "testing" ) func TestBlame(t *testing.T) { t.Parallel() repo := createTestRepo(t) defer cleanupTestRepo(t, repo) commitId1, _ := seedTestRepo(t, repo) commitId2, _ := updateReadme(t, repo, "foo\nbar\nbaz\n") opts := BlameOptions{ NewestCommit: commitId2, OldestCommit: nil,...
package statistics import ( "github.com/emicklei/go-restful" api "github.com/emicklei/go-restful-openapi" . "grm-service/dbcentral/pg" . "grm-service/util" "titan-statistics/dbcentral/etcd" "titan-statistics/dbcentral/pg" . "titan-statistics/types" ) type StatSvc struct { SysDB *pg.SystemDB MetaDB *p...
package api import ( "fmt" "octlink/mirage/src/modules/account" "octlink/mirage/src/modules/session" "octlink/mirage/src/utils" "octlink/mirage/src/utils/merrors" "octlink/mirage/src/utils/octlog" "octlink/mirage/src/utils/uuid" ) func APIAddAccount(paras *ApiParas) *ApiResponse { resp := new(ApiResponse) n...
package main import ( "net/http" "os" docker "github.com/docker/docker/client" "github.com/ubclaunchpad/inertia/daemon/inertiad/containers" "github.com/ubclaunchpad/inertia/daemon/inertiad/log" ) // downHandler tries to take the deployment offline func downHandler(w http.ResponseWriter, r *http.Request) { if d...
// Copyright 2022 PingCAP, Inc. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // // http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed to i...
// Package aws contains AWS-specific structures for installer // configuration and management. package aws // Name is name for the AWS platform. const Name string = "aws"
package main type Problem13B struct { } func (this *Problem13B) Solve() { Log.Info("Problem 13B solver beginning!") grid := IntegerGrid2D{} grid.Init(); scanSize := 100; //offset := 10; offset:= 1362; maxSteps := 50; from := &IntVec2{}; from.X = 1; from.Y = 1; for j := 0; j <= scanSize; j++{ for i ...
package main import "fmt" func main(){ // brackets around condition are not mandatory // flower bracket after condition is mandatory if 5%2==0 { fmt.Println("its true") } // A statement can preceed conditional // it would be available in the else blocks as well. if num:=-10; num>9 { fmt.Println(num," is ...
// Licensed to Elasticsearch B.V. under one or more contributor // license agreements. See the NOTICE file distributed with // this work for additional information regarding copyright // ownership. Elasticsearch B.V. licenses this file to you under // the Apache License, Version 2.0 (the "License"); you may // not use ...
package user import ( "encoding/json" "net/http" "rest_server/pkg/errors" "rest_server/pkg/rest" "github.com/sirupsen/logrus" "golang.org/x/xerrors" "gopkg.in/go-playground/validator.v9" ) type Handler struct { user service } type requestUser struct { Password string `json:"password" validate:"re...
package delta_test import ( "sort" "strings" "testing" "time" "github.com/GeoNet/delta/meta" ) var recorderSamplingRates = []float64{50, 200} var sensorSamplingRates = []float64{0.1, 1, 10, 50, 100, 200} func TestStreams(t *testing.T) { var streams meta.StreamList loadListFile(t, "../install/streams.csv", &...
package frida_go import ( "fmt" "github.com/a97077088/frida-go/cfrida" "unsafe" ) const ( FRIDA_SCRIPT_RUNTIME_DEFAULT = iota FRIDA_SCRIPT_RUNTIME_QJS FRIDA_SCRIPT_RUNTIME_V8 ) type FridaScriptRuntime int type Session struct { CObj } func (s *Session) Pid() int { return cfrida.Frida_session_get_pid(s.instance...
package day23 import ( "testing" "github.com/kdeberk/advent-of-code/2019/internal/utils" ) const part1Answer = 20367 const part2Answer = 15080 func TestPart1(t *testing.T) { program, err := utils.ReadProgram("./../../input/23.txt") if err != nil { t.Fatal(err) } answer, _ := part1(program) if part1Answer ...
package services import ( "librarymanager/authorization/common" "librarymanager/authorization/domain" "testing" "time" "github.com/go-redis/redis" ) func Test_Authorization_CreateToken(t *testing.T) { td, err := CreateToken("somekey") if err != nil { t.Error("Error when creating token details") } if le...
// The requests package contains logic for loading and unmarshalling // data contained within web requests. The most common uses for this // library are as follows: // // params, err := requests.New(request).Params() // // err := requests.New(request).Unmarshal(structPtr) // // Parameters will be loaded from t...
// package api import ( "errors" "fmt" "net/http" "strconv" "strings" "github.com/dgrijalva/jwt-go" "github.com/gin-gonic/gin" "github.com/PeachIceTea/fela/conf" ) // Define errors var ( ErrIDParamMissing = errors.New("id parameter is missing") ErrInvalidID = errors.New("invalid id") ErrNoAudioStre...
package usocksd import ( "errors" "net" "strings" "github.com/BurntSushi/toml" "github.com/cybozu-go/well" ) const ( defaultPort = 1080 defaultMetricsPort = 1081 ) // IncomingConfig is a set of configurations to accept clients. type IncomingConfig struct { Port int MetricsPort int `toml:"me...
// Copyright 2022 PingCAP, Inc. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // // http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed to in wr...
package main import "fmt" // 0,1,···,n-1这n个数字排成一个圆圈,从数字0开始,每次从这个圆圈里删除第m个数字(删除后从下一个数字开始计数)。 // 求出这个圆圈里剩下的最后一个数字。 // 例如,0、1、2、3、4这5个数字组成一个圆圈,从数字0开始每次删除第3个数字,则删除的前4个数字依次是2、0、4、1,因此最后剩下的数字是3。 //输入: n = 5, m = 3 //输出: 3 func main() { fmt.Println(lastRemaining(5, 3)) } func lastRemaining(n int, m int) int { pos := 0 ...
package main import "testing" // This is the "equivalent" benchmark to example.go. // Run with: // go test -bench . -cpu 1 func BenchmarkIntAddInt(b *testing.B) { val := 1 for i := 0; i < b.N; i++ { // Go is not yet clever enough to optimize this loop away. If/when // it becomes clever, this needs to be exte...
package tblfmt import ( "io" "strconv" "unicode/utf8" ) // Builder is the shared builder interface. type Builder func(ResultSet, ...Option) (Encoder, error) // Option is a Encoder option. type Option func(interface{}) error // FromMap creates an encoder for the provided result set, applying the named // options....
package stencil_test import ( "bytes" "fmt" "io/ioutil" "net/http" "net/http/httptest" "os/exec" "path/filepath" "testing" "time" stencil "github.com/odpf/stencil/clients/go" "github.com/stretchr/testify/assert" "google.golang.org/protobuf/proto" "google.golang.org/protobuf/reflect/protoreflect" "google...
package main import ( "fmt" "time" ) func main() { ch3 := make(chan int) select { case num := <-ch3: fmt.Printf("从ch接收 %d\n", num) case <-time.After(time.Second): fmt.Println("超时") } }
package catm import ( "encoding/xml" "github.com/thought-machine/finance-messaging/iso20022" ) type Document00600101 struct { XMLName xml.Name `xml:"urn:iso:std:iso:20022:tech:xsd:catm.006.001.01 Document"` Message *MaintenanceDelegationResponseV01 `xml:"MntncDlgtnRspn"` } func (d *Docu...
package iterator import ( "errors" "github.com/yulyulyharuka/todo2/model" ) type todoIterator struct { index int32 todos map[int32]model.Todo } func (o todoIterator) HasNext() bool { if o.index < int32(len(o.todos)) { return true } return false } func (o todoIterator) GetNext() (model.Todo, error) { if o...
package main import "fmt" func main() { girlMap := map[string]int{"yp": 0, "sy": 1} for key, value := range girlMap { fmt.Printf("name: %s, %d\n", key, value) } }
package context1 import ( "context" "fmt" "time" ) func context1() { /* 创建一个可以随时取消的上下文 在上下文里可以创建键值对 */ ctx, _ := context.WithCancel(context.Background()) key := "key1" valueCtx := context.WithValue(ctx, key, "add value") go watch(valueCtx) time.Sleep(10 * time.Second) /* cancel和ctx.done都是结束上下文 */...
package notice import ( "github.com/devfeel/dotweb" "master/define" "master/api" "strconv" "strings" "master/utils" ) func SendNoticeHander(ctx dotweb.Context)error{ defer ctx.End() token:=ctx.FormValue("token") title:=ctx.FormValue("noticeTitle") info:=ctx.FormValue("noticeContent") channel,_:= strconv...
package omigad import ( "encoding/json" "log" "net/http" "net/url" "os" "strings" "github.com/astaxie/beego" "github.com/astaxie/beego/logs" "github.com/wst-libs/wst-sdk/conf" "github.com/wst-libs/wst-sdk/sdk/manager" "github.com/wst-libs/wst-sdk/utils" ) var filechan chan FileInfo = make(chan FileInfo, 1...