text
stringlengths
11
4.05M
package main import ( "errors" // "fmt" termbox "github.com/nsf/termbox-go" // "gopkg.in/mattn/go-runewidth.v0" ) type av struct { tag string /* Tag tools*/ cols []*col // w, h int } type col struct { tag string wins []*win x, w int } type win struct { tag string // body string rows []*row y, h int } ...
package main import ( "fmt" "net" "flag" "strings" "strconv" "os" "bufio" "bytes" "encoding/binary" "github.com/golang/protobuf/proto" identity "./proto_files" ) func main(){ flag.Parse() if flag.NArg() != 1{ fmt.Fprintln(os.Stderr, "missing subcommand 'mode': individual or enterprise") os.Exit(1) }...
// Copyright © 2020. All rights reserved. // Author: Ilya Stroy. // Contacts: qioalice@gmail.com, https://github.com/qioalice // License: https://opensource.org/licenses/MIT package privet import ( "sync/atomic" "unsafe" ) //goland:noinspection GoSnakeCaseUsage const ( /* TODO: comment */ _LLS_STANDBY uint32 =...
package benchmark // 基准测试源文件名称也必须以_test结尾 import ( "fmt" "strconv" "testing" ) // 基准测试函数名必须以Benchmark开头,函数没有返回值 /** int转字符串操作的基准测试,测试了三个函数,具体见一下三个基准测试方法 输出: goos: windows goarch: amd64 BenchmarkSprintf-4 5000000 367 ns/op BenchmarkFormat-4 100000000 18.1 ns/op BenchmarkItoa-4 ...
package main import ( "fmt" "github.com/ethereum/go-ethereum/common" "github.com/sanguohot/medichain/chain" "github.com/sanguohot/medichain/etc" "log" ) func main() { name := etc.ContractAuth if err, hash := chain.SetAddressToCns(name, common.HexToAddress("0x6313917545787e96c22520da87ec0a4bbdc442ad")); err != ...
package main import ( "fmt" "io" "os" "path/filepath" "strings" "time" "gopkg.in/yaml.v3" "git.scc.kit.edu/sdm/lsdf-checksum/scaleadpt" "git.scc.kit.edu/sdm/lsdf-checksum/scaleadpt/filelist" "git.scc.kit.edu/sdm/lsdf-checksum/scaleadpt/options" ) type Spec struct { Filesystems map[string]SpecFilesystem `...
package fcm type response struct { StatusCode int Err string `json:"error,omitempty"` Success int `json:"success"` MultiCastId int64 `json:"multicast_id"` CanonicalIds int `json:"canonical_ids"` Failure int `json:"failure"` Resu...
package client import ( "context" "encoding/json" "os" "os/signal" "syscall" "time" "github.com/asppj/cnbs/net-bridge/auth" "github.com/asppj/cnbs/net-bridge/options" "github.com/asppj/cnbs/log" "github.com/gogf/gf/frame/g" "github.com/gogf/gf/net/gtcp" ) // Client 客户端 type Client struct { running ...
package parser_test import ( "fmt" "syscall" "testing" "github.com/m-lab/etl/parser" ) func TestParseIPFamily(t *testing.T) { if parser.ParseIPFamily("1.2.3.4") != syscall.AF_INET { t.Fatalf("IPv4 address not parsed correctly.") } if parser.ParseIPFamily("2001:db8:0:1:1:1:1:1") != syscall.AF_INET6 { t.Fat...
/* Package tracing provides tracing integration to the project OpenTracing implements a general purpose interface that microservices can program against, and which adapts to all major distributed tracing systems. */ package tracing
package effects import "github.com/faiface/beep" // Doppler simulates a "sound at a distance". If the sound starts at a far distance, // it'll take some time to reach the ears of the listener. // // The distance of the sound can change dynamically. Doppler adjusts the density of // the sound (affecting its speed) to ...
package main import ( "github.com/labstack/echo" "github.com/labstack/echo/middleware" "api/handlers" "controller" ) func main() { e := echo.New() e.Use(middleware.CORSWithConfig(middleware.CORSConfig{ AllowOrigins: []string{"http://localhost:8080","http://localhost:8081","http://localhost:633...
package middleware import ( "bytes" "net/http" "testing" "github.com/gorilla/mux" "github.com/stretchr/testify/require" "github.com/root-gg/plik/server/common" "github.com/root-gg/plik/server/context" ) func TestFileNoUpload(t *testing.T) { ctx := newTestingContext(common.NewConfiguration()) req, err := h...
package main import ( "fmt" "os" "github.com/takatoh/fft" "github.com/takatoh/infr" "github.com/takatoh/seismicwave" ) func main() { csvfile := os.Args[1] w, e := seismicwave.LoadCSV(csvfile) if e != nil { fmt.Println(e) os.Exit(1) } acc := w[0].Data dt := w[0].Dt n := len(acc) v0 := acc[0] * dt n...
package stack import "testing" func TestIsValid(t *testing.T) { s := "[](){}" t.Log(isValid(s)) s = "[()]{}" t.Log(isValid(s)) s = "(" t.Log(isValid(s)) s = "(][]()" t.Log(isValid(s)) s = "]" t.Log(isValid(s)) }
package add /* import ( "io/ioutil" "os" "testing" "github.com/devspace-cloud/devspace/cmd/flags" "github.com/devspace-cloud/devspace/pkg/devspace/config/loader" "github.com/devspace-cloud/devspace/pkg/devspace/config/constants" "github.com/devspace-cloud/devspace/pkg/devspace/config/versions" "github.com/dev...
package inform import ( // Standard library "bytes" "context" "os/exec" "strings" "text/template" // Third-party packages "github.com/go-joe/joe" "github.com/pkg/errors" ) // The prefix used for all keys stored. const keyPrefix = "org.deuill.informbot" type Inform struct { sessions map[string]*Session // ...
package controller import ( _ "bytes" "database/sql" "fmt" //"newproject/gtoken" "newproject/model" "gitee.com/johng/gf/g/encoding/gjson" "gitee.com/johng/gf/g/frame/gmvc" "gitee.com/johng/gf/g/net/ghttp" //"os" "os/exec" "strconv" _ "strings" "github.com/Unknwon/goconfig" _ "golang.org/x/crypto/ssh"...
package utils import ( "bytes" "fmt" "path" "strings" "text/template" ) func sub(left, right int) int { return left - right } func addSuffix(host string, suffix string) string { if !strings.HasSuffix(host, suffix) { host += suffix } return host } // ParseTemp 解析templates func ParseTemp(filePath string, d...
package main import ( "fmt" kernel "mohammedmanssour-events/kernal" "time" ) type User struct { name string email string } func main() { unsubscribe1 := kernel.Subscribe("UserRegistered", func(event kernel.EventInterface) { User := event.(User) fmt.Printf("User Registered with name %s and email %s\n", Us...
package gcp // MachinePool stores the configuration for a machine pool installed on GCP. type MachinePool struct { // Zones is list of availability zones that can be used. // // +optional Zones []string `json:"zones,omitempty"` // InstanceType defines the GCP instance type. // eg. n1-standard-4 // // +optiona...
package auth import ( "fmt" "github.com/astaxie/beego" "github.com/astaxie/beego/logs" "github.com/astaxie/beego/orm" "ions_zhiliao/models/auth" "ions_zhiliao/utils" "math" "time" ) type AuthController struct { beego.Controller } func (a *AuthController) List() { //每页显示的条数 o := orm.NewOrm() qs := o.Quer...
package entrypoint import ( "os" "testing" "github.com/stretchr/testify/assert" "github.com/urfave/cli" ) func TestStringFlagRequiredOnMissingFlag(t *testing.T) { t.Parallel() app := createSampleAppWithRequiredFlag() app.Action = func(cliContext *cli.Context) error { value, err := StringFlagRequiredE(cliCo...
package main import ( "encoding/binary" "errors" "github.com/g-xianhui/crypt" "io" "net" ) var _ = io.EOF const MAX_CLIENT_BUF = 1 << 16 func Readn(conn io.Reader, count int) ([]byte, int, error) { data := make([]byte, count) n := 0 for { i, err := conn.Read(data[n:]) if i > 0 { n += i } if n ==...
package main import ( "log" ) //node定义 type Node struct { Data interface{} //数据域 next *Node //指针域 belong *SingelChain //Node归属链 } type SingelChain struct { root Node //存储头结点 length int //存储当前长度 } func (l *SingelChain) Init() *SingelChain { l.root.next = nil l.length = 0 return l } //返回链表的...
package userinterface import ( "unicode" "unicode/utf8" ui "github.com/gizak/termui/v3" "github.com/gizak/termui/v3/widgets" ) var ( text string ) func inputWidgetInit(width, height int) *widgets.Paragraph { p := widgets.NewParagraph() p.Text = prettyPrint("") p.SetRect(0, 0, width, 3) ui.Render(p) return...
package fmc import ( "fmt" "os" "strconv" "strings" "github.com/mattn/go-isatty" ) // Base attributes const ( reset attribute = iota bold faint italic underline blinkSlow blinkRapid reverseVideo concealed crossedOut ) // Foreground text colors const ( fgBlack attribute = iota + 30 fgRed fgGreen f...
package utils import ( "os" "testing" "github.com/stretchr/testify/require" ) func TestNewAuthorizer(t *testing.T) { t.Cleanup(func() { os.RemoveAll("testDir") }) require.NoError(t, os.MkdirAll("testDir", os.ModePerm)) acct, err := NewKeyFile("testDir", "password123") require.NoError(t, err) _, err = NewA...
package main import "fmt" var x, y int = 12, 13 var ( xa int = 12 xb string = "ok" ) func main() { var a string = "Runoob" fmt.Println(a) var b, c int = 1, 2 fmt.Println(b, c) fmt.Println(x, y) fmt.Println(xa, xb) zeroVariable() multiDefine() valueAdnReference() } func zeroVariable() { var a strin...
/* * @lc app=leetcode.cn id=11 lang=golang * * [11] 盛最多水的容器 */ package main import "fmt" // @lc code=start func min(a, b int) int { if a < b { return a } else { return b } } func maxArea(height []int) int { heightLen := len(height) res := 0 area := 0 for i, j := 0, heightLen-1; i != j; { left, right...
package main import ( "fmt" "strings" "encoding/json" "log" "net/http" "github.com/gorilla/mux" "github.com/gorilla/handlers" ) type Media struct { Audio string `json:"audio"` Wave string `json:"wave"` Duration string `json:"duration"` } func main() { fmt.Println("Listening on port 8080") h...
package resolvers import ( "context" "github.com/syncromatics/kafmesh/internal/graph/generated" ) //go:generate mockgen -source=./resolver.go -destination=./resolver_mock_test.go -package=resolvers_test // DataLoaders provides data loaders for models from the context type DataLoaders interface { ComponentLoader(...
package timer import ( "fmt" "time" "github.com/sirupsen/logrus" ) // Timer is the struct that keeps track of each of the sections. type Timer struct { listOfStages []string stageTimes map[string]time.Duration startTimes map[string]time.Time } const ( // TotalTimeElapsed is a constant string value to de...
package osbuild1 type GroupsStageOptions struct { Groups map[string]GroupsStageOptionsGroup `json:"groups"` } func (GroupsStageOptions) isStageOptions() {} type GroupsStageOptionsGroup struct { Name string `json:"name"` GID *int `json:"gid,omitempty"` } func NewGroupsStage(options *GroupsStageOptions) *Stage ...
package converter // Converter 转换器接口 type Converter interface { Convert(ConversionSource, <-chan struct{}) ([]byte, error) UploadAWSS3([]byte) (bool, error) UploadQiniu([]byte) (bool, string, error) }
// Copyright 2018 Andrew Bates // // 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 wri...
package faterpg // Aspect are phrases that describe some sig- // nificant detail about a character. They are // the reasons why your character matters, why // we’re interested in seeing your character in // the game. Aspects can cover a wide range of // elements, such as personality or descriptive // traits, beliefs, ...
package controllers import ( "app/forms" "app/models" "net/http" "strconv" "github.com/gin-gonic/gin" ) type PersonController struct{} var personModel = new(models.Person) func (p PersonController) List(ctx *gin.Context) { people := personModel.GetAll() ctx.HTML(http.StatusOK, "index.tmpl", gin.H{ "people...
package main import ( "context" "errors" "github.com/hashicorp/terraform-plugin-sdk/helper/schema" pb "github.com/karmab/terraform-provider-kcli/kcli-proto" "google.golang.org/grpc" "io/ioutil" "log" "os" "time" ) func (kcli *Kcli) CreateVm(vmprofile *pb.Vmprofile) *pb.Result { conn, err := grpc.Dial(kcli.U...
package authentication import ( "errors" "golang.org/x/text/encoding/unicode" ) const ( ldapSupportedExtensionAttribute = "supportedExtension" // LDAP Extension OID: Password Modify Extended Operation. // // RFC3062: https://datatracker.ietf.org/doc/html/rfc3062 // // OID Reference: http://oidref.com/1.3.6....
package sig type Sig struct { listerner []*chan string Close chan string } func NewStringSig() *Sig { return &Sig{ Close: make(chan string, 1), } } func (sig *Sig) Send(control string) { for _, i := range sig.listerner { *i <- control } } func (sig *Sig) Recv() *chan string { ch := make(chan string, ...
package main import ( "context" "github.com/spf13/cobra" ) var rootCmd = &cobra.Command{ Use: "vault-sidecar", Short: "vault server auto unseal, plugin register & ctl", } func execute(ctx context.Context) error { return rootCmd.ExecuteContext(ctx) } func init() { rootCmd.CompletionOptions.DisableDefaultCmd...
package main import ( "time" "fmt" ) // anggap saja fungsi ini prosesnya mirip mengambil data dari database func ambilData(banyak_pesan int) (hasil []string) { for x := 0; x < banyak_pesan; x++ { waktu := time.Now(); hasil = append(hasil, fmt.Sprintf("[%v:%v:%v] go routine. %v \n ", waktu.Hour(), waktu....
package line_login import ( "github.com/5hields/line-login/linethrift" "crypto/rsa" "encoding/hex" "log" "math/big" "strconv" ) func rsaKeyGen(key *linethrift.RSAKey) rsa.PublicKey { decN, err := hex.DecodeString(key.Nvalue) if err != nil { log.Fatal(err) } n := big.NewInt(0) n.SetBytes(decN) eVal, err...
/* * Copyright (c) 2020, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. * * WSO2 Inc. licenses this file to you 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/li...
package main /* @Time : 2020-04-04 10:57 @Author : audiRStony @File : 03_反射ValueOf.go @Software: GoLand */ import ( "fmt" "reflect" ) func reflectValueOf(x interface{}) { v := reflect.ValueOf(x) // 获取接口的值信息 k := v.Kind() // 拿到值对应的种类 switch k { case reflect.Int64: fmt.Printf...
package parser import "log" func Parse(buffer string) { astro := &Astro{Buffer: string(buffer)} astro.Init() if err := astro.Parse(); err != nil { log.Fatal(err) } astro.PrintSyntaxTree() }
package scraper import ( "bytes" "errors" "net/url" "text/template" . "github.com/cstockton/go-conv" ) var ErrNoNextURL = errors.New("no next url") var ErrNoRows = errors.New("no rows") var ErrNoData = errors.New("no data") type EchoData struct { data []byte } func (e *EchoData) Get(path s...
package main import ( "bytes" "fmt" "log" "net/http" "os" "gopl/ch1" "gopl/ch12" "gopl/ch3" "gopl/ch4" "gopl/ch5" "gopl/ch6" "gopl/ch7" "gopl/ch8" "gopl/ch9" ) func main() { chapter1() Server() // 读取输入到params这个slice中 //params := make([]string, 0) // //in := bufio.NewScanner(os.Stdin) // //for i...
package main import ( "fmt" "sync/atomic" "time" ) func main() { // 通过使用全局变量count来判断是否执行匿名函数fn // 从而达到控制打印输出顺序的结果。 var count uint32 trigger := func(i uint32, fn func()) { for { // LoadUint32 atomically loads *addr. if n := atomic.LoadUint32(&count); n == i { fn() // AddUint32 atomically adds de...
package pkg1; type MapStruct map[int]string
package handler import ( "log" . "github.com/cleslley/api-rest-go/model" mgo "gopkg.in/mgo.v2" "gopkg.in/mgo.v2/bson" ) //MoviesDB armazena os dados do BD type MoviesDB struct { Server string Database string } var db *mgo.Database //Collection armazena o nome da coleção const Collection ...
package model import "time" type Title struct { PublisherId string `json:"publisher_id"` TitleId string `json:"title_id"` FullTitleId string `gorm:"primary_key" json:"id"` TitleName string `json:"name"` CreatedAt time.Time `json:"created_at"` UpdatedAt time.Time `json:"updated_at"` ...
package mhfpacket import ( "errors" "github.com/Andoryuuta/Erupe/network" "github.com/Andoryuuta/Erupe/network/clientctx" "github.com/Andoryuuta/byteframe" ) // MsgSysGetUserBinary represents the MSG_SYS_GET_USER_BINARY type MsgSysGetUserBinary struct { AckHandle uint32 CharID uint32 BinaryType uint8 } ...
package detectcoll import ( "crypto/rand" "crypto/sha1" "crypto/subtle" "encoding/hex" "testing" ) func TestSHA1(t *testing.T) { var h Hash = NewSHA1() var ret []byte ret = h.Sum(nil) if subtle.ConstantTimeCompare(ret, []byte{0xda, 0x39, 0xa3, 0xee, 0x5e, 0x6b, 0x4b, 0x0d, 0x32, 0x55, 0xbf, 0xef, 0x95, 0x6...
package main import "fmt" func main() { // 声明一个变量 保存接受用户输入的选项 key := "" // 控制是否退出for loop := true balance := 1000.0 // 收支金额 money := 0.0 // 收支说明 note := "" // 是否有收支的行为 flag := false // 收支的详情使用字符串来记录 // 当有收支时,只需要对 details 进行拼接处理即可 details := "收支\t账户金额\t收支金额\t说 明" forloop: for { fmt.Println("\n-...
package main import ( "fmt" "log" "os" "os/exec" ) func runShell(script string) error { cmd := exec.Command("sh", "-c", script) cmd.Stdin = os.Stdin cmd.Stdout = os.Stdout cmd.Stderr = os.Stderr cmd.Env = os.Environ() log.Println(cmd.String()) return cmd.Run() } func linkDo(source, target string) error { ...
package main import ( "encoding/json" "fmt" "net/http" "os" "time" "github.com/senslabs/alpha/sens/errors" "github.com/senslabs/alpha/sens/httpclient" "github.com/senslabs/alpha/sens/logger" ) type Device struct { DeviceId string `json:",omitempty"` DeviceName string `json:",omitempty"` OrgId ...
package api import ( "encoding/json" "io/ioutil" "net/http" "strings" "../services" "github.com/go-chi/chi" "github.com/go-chi/render" ) type podcontrollerhandler struct { kubeService services.IKubeService } func (h *podcontrollerhandler) router() chi.Router { r := chi.NewRouter() r.R...
package generator import ( "bytes" "fmt" "io" "log" "os" "os/exec" "strings" "text/template" "github.com/getkin/kin-openapi/openapi3" ) func curled(s string) string { return "{" + s + "}" } func renderTemplateToString(templateString string, funcMap template.FuncMap, data interface{}) (string, error) { b ...
package httputil import ( "github.com/pomerium/pomerium/internal/log" ) // CanonicalHeaderKey re-exports the log.CanonicalHeaderKey function to avoid an import cycle. var CanonicalHeaderKey = log.CanonicalHeaderKey
package main // type stateFunc func(m *Memory) type stateFunc func(*lexer) stateFunc type Token struct { Raw string Jump int // Index of corresponding jump } func (t Token) String() string { return t.Raw } var ( RShiftToken = Token{Raw: ">"} LShiftToken = Token{Raw: "<"} IncToken = Token{Raw: "+"} DecTok...
package ldclient import ( "errors" "log" "os" "strings" "time" ) const Version string = "0.0.3" // The LaunchDarkly client. Client instances are thread-safe. // Applications should instantiate a single instance for the lifetime // of their application. type LDClient struct { apiKey string config ...
package redisgraph import ( "fmt" "strings" ) // Node represents a node within a graph. type Node struct { ID uint64 Label string Alias string Properties map[string]interface{} graph *Graph } func NodeNew(label string, alias string, properties map[string]interface{}) *Node { p := prop...
// Copyright 2020 Akamai Technologies, 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...
package main import ( "bufio" "fmt" "io" "log" "strconv" "strings" ) func main() { r := strings.NewReader(input) ints := extractIntArr(r) for i := 0; i < len(ints); i++ { a := ints[i] for j := i + 1; j < len(ints); j++ { b := ints[j] for k := j + 1; k < len(ints); k++ { c := ints[k] if a+b+...
package pkg import ( "net" "github.com/google/gopacket/layers" ) // @EthernetInterface is the name of the ethernet interface of system. // ServerAddr is the address provided by the NAT. // @LocalInterface is the name of the local interface of system. // @WireLessInterface is the name of the wireless interfac...
package controllers import ( "context" "encoding/json" "errors" "fmt" "github.com/anshap1719/authentication/controllers/gen/twitter" "github.com/anshap1719/authentication/database" "github.com/anshap1719/authentication/models" "github.com/anshap1719/authentication/utils/auth" . "github.com/anshap1719/authenti...
package main import ( "testing" "github.com/stretchr/testify/assert" ) func Test__sphere_rayIntersect_inside(t *testing.T) { s := sphere{10, vector{0, 0, 0}, material{}} d, ok := s.rayIntersect(vector{0, 0, 0}, vector{1, 1, 1}) assert.True(t, ok) assert.Equal(t, float64(10), d) }
package services import ( "models" "net" "strconv" "errors" "log" ) // Just used to wrap the actual Peer from models.Peer here to use it as caller type UDPConnection struct { UCPConnObject *models.UDPConnection } // When Creating Initial (despite first element in tunnel), always set writer for left side >> Wri...
package greeter import ( "github.com/hashrs/blockchain/framework/chain-starter" "github.com/spf13/cobra" "github.com/hashrs/blockchain/chain/x/greeter/client/cli" gtypes "github.com/hashrs/blockchain/chain/x/greeter/internal/types" "github.com/hashrs/blockchain/framework/chain-app/codec" sdk "github.com/hashrs/...
package main import "fmt" import m "golang-book/chapter11/math" // Directory must be in $GOPATH func main() { xs := []float64{1, 2, 3, 4} avg := m.Average(xs) fmt.Println(avg) } // Inside ./math, run `go install` to create a linkable object file // Then, go to ./chapter11 and run `go run main.go`
package types // OrderedSet represents an ordered set. type OrderedSet struct { filter map[string]bool Values []string } // Init creates a new OrderedSet instance, and adds any given items into this set. func (o *OrderedSet) Init(items ...string) { o.filter = make(map[string]bool) for _, item := range items { o...
package download import ( "io" "github.com/gobuffalo/buffalo" "github.com/gobuffalo/buffalo/render" "github.com/gomods/athens/pkg/errors" "github.com/gomods/athens/pkg/log" ) // PathVersionZip URL. const PathVersionZip = "/{module:.+}/@v/{version}.zip" // VersionZipHandler implements GET baseURL/module/@v/vers...
package main import "errors" func main() { panic(errors.New("where is zhong?")) }
package hdfs import ( "context" "net/http" "github.com/colinmarc/hdfs/v2" "github.com/sirupsen/logrus" "gopkg.in/yaml.v2" "github.com/yunify/qscamel/constants" "github.com/yunify/qscamel/model" ) // Client is the struct for HDFS endpoint. type Client struct { Address string `yaml:"address"` Path string ...
// Copyright 2019 The Android Open Source Project // // 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 collection import "github.com/shopspring/decimal" type BaseCollection struct { value interface{} length int } func (c BaseCollection) Value() interface{} { return c.value } func (c BaseCollection) All() []interface{} { panic("not implement") } func (c BaseCollection) Avg(key ...string) decimal.Decimal...
/* ** description("get the name and line number of the calling file hook"). ** copyright('tuoyun,www.tuoyun.net'). ** author("fg,Gordon@tuoyun.net"). ** time(2021/3/16 11:26). */ package log import ( "fmt" "github.com/sirupsen/logrus" "runtime" "strings" ) type fileHook struct{} func newFileHook() *fileHook { ...
package main import ( "archive/zip" "fmt" "io" "io/ioutil" "net/http" "os" "path/filepath" "strings" "github.com/GoAdminGroup/go-admin/modules/utils" ) func getThemeTemplate(moduleName, themeName string) { downloadTo("http://file.go-admin.cn/go_admin/template/template.zip", "tmp.zip") checkError(unzipDi...
package sol import "testing" func TestBasic(t *testing.T) { t.Log(longestCommonSubsequence("ezupkr", "ubmrapg")) }
package ds import ( "reflect" "testing" ) func TestTreeNode_Find(t *testing.T) { type fields struct { Val int Left *TreeNode Right *TreeNode } type args struct { val int } tests := []struct { name string fields fields args args want bool }{ { "Find a node", fields{5, NewTreeNo...
package models type User struct { Id int Username string `orm:"size(100)"` Password string `orm:"size(200)"` Img string `orm:"size(200)"` IsAdmin int `orm:"size(1)"` CreateTime int64 `orm:"size(20)"` }
package main import ( "encoding/hex" "log" "net" "os" "os/signal" "syscall" "time" "github.com/go-gl/glfw/v3.2/glfw" ) var ( messageRate = 25 * time.Millisecond power = float32(0.3) // steering values will by multiplied by this stopSteering = false // All data without checksum. Will be calculate...
package leetcode import "testing" func TestLJJS(t *testing.T) { lj := make([][]bool, 8) for i := 0; i < 8; i++ { lj[i] = make([]bool, 8) } lj[1][2] = true lj[1][6] = true lj[2][4] = true lj[3][0] = true lj[3][2] = true lj[3][5] = true lj[4][2] = true lj[5][3] = true lj[5][4] = true lj[5][6] = true lj[...
package cache import ( "testing" eventpkg "github.com/serverless/event-gateway/event" "github.com/serverless/event-gateway/function" "github.com/serverless/event-gateway/libkv" "github.com/stretchr/testify/assert" "go.uber.org/zap" ) func TestSubscriptionCacheModified(t *testing.T) { t.Run("async added", fun...
package rest import ( "fmt" "github.com/jinmukeji/jiujiantang-services/pkg/rest" proto "github.com/jinmukeji/proto/v3/gen/micro/idl/partner/xima/user/v1" "github.com/kataras/iris/v12" ) // SetSigninPhoneBody 设置登录电话的body type SetSigninPhoneBody struct { Phone string `json:"phone"` ...
package filter import ( "log" "opentsp.org/internal/tsdb" ) type series struct { series tsdb.Series filter *Filter } func (s series) Next() *tsdb.Point { for { point := s.series.Next() pass, err := s.filter.Eval(point) if err != nil { log.Printf("tsdb: filter error: %v", err) point.Free() contin...
package store import ( "errors" "fmt" "log" "net" "os" "path/filepath" "sync" "time" "github.com/hashicorp/raft" raftboltdb "github.com/hashicorp/raft-boltdb" ) var ( ErrNotLeader = errors.New("This node does not leader") ErrLockAlreadyAcquired = errors.New("The lock had already acquired") Err...
// Copyright (c) 2020 Blockwatch Data Inc. // Author: alex@blockwatch.cc package micheline import ( "bytes" "encoding/json" "fmt" "io" "strconv" "strings" ) type BigMapValue struct { Type *Prim Value *Prim } func NewBigMapValue() *BigMapValue { return &BigMapValue{ Type: &Prim{}, Value: &Prim{}, } }...
package main import ( "context" "fmt" "os" "github.com/antihax/optional" "github.com/outscale/osc-sdk-go/osc" ) func main() { client := osc.NewAPIClient(osc.NewConfiguration()) auth := context.WithValue(context.Background(), osc.ContextAWSv4, osc.AWSv4{ AccessKey: os.Getenv("OSC_ACCESS_KEY"), SecretKey: o...
package mails import ( "database/sql" "fmt" "log" "os" "sync" "github.com/aws/aws-sdk-go/aws" "github.com/aws/aws-sdk-go/aws/credentials" "github.com/aws/aws-sdk-go/aws/session" "github.com/aws/aws-sdk-go/service/ses" "github.com/toomore/mailbox/campaign" ) var svc *ses.SES var ql chan struct{} func init(...
package data_test import ( "bufio" "encoding/json" "io/ioutil" "log" "os" "testing" data "github.com/bgokden/veri/data" "github.com/stretchr/testify/assert" pb "github.com/bgokden/veri/veriservice" ) func TestData(t *testing.T) { dir, err := ioutil.TempDir("", "veri-test") if err != nil { log.Fatal(err...
package native import ( "os" "path" "sync" "github.com/baidu/openedge/logger" "github.com/baidu/openedge/master/engine" "github.com/baidu/openedge/sdk-go/openedge" "github.com/orcaman/concurrent-map" ) const packageConfigPath = "package.yml" type packageConfig struct { Entry string `yaml:"entry" json:"entry...
package logic import ( "log" "path/filepath" ) // NewFilter creates new filter func NewFilter(include string, exclude string) Filter { return &filter{ incl: newIncluder(include), excl: newExcluder(exclude), } } // Skip filters file specified if necessary func (f *filter) Skip(file string) bool { return !f.i...
package controllers import ( "database/sql" "encoding/json" "fmt" "html/template" "io/ioutil" "math/rand" "net/http" "sesi11/models" _ "github.com/go-sql-driver/mysql" ) func Login(w http.ResponseWriter, r *http.Request) { request := models.LoginRequest{} response := models.LoginResponse{} reqbyte, _ := ...
package main import "fmt" func kthSmallest(root *TreeNode, k int) int { finder := &kthSmalletFinder{k: k, smallest: nil, n: 0} finder.Traverse(root) return finder.smallest.Val } type kthSmalletFinder struct { k int smallest *TreeNode n int } func (k *kthSmalletFinder) Traverse(t *TreeNode) bool ...
package routers import ( "github.com/astaxie/beego" "github.com/astaxie/beego/context" "quickstart/controllers" ) func init() { beego.Get("/myrouter",func(ctx *context.Context){ ctx.Output.Body([]byte("hello world myrouter")) }) beego.Router("/deny",&controllers.RController{}) }
/* Given five points on a straight line such that their pairwise distances are 1,2,4, ..., 14,18,20 (after ordering), find the respective positions of the five points (relative to the furthest point on the left). */ package main import ( "fmt" "math/rand" "sort" ) func main() { x := solve() d := sd(x[:]) fmt...
package pubsub import ( "testing" pb "gx/ipfs/QmWL6MKfes1HuSiRUNzGmwy9YyQDwcZF9V1NaA2keYKhtE/go-libp2p-pubsub/pb" crypto "gx/ipfs/QmNiJiXwWE3kRhZrC5ej3kSjWHm337pYfhjLGSCDNKJP2s/go-libp2p-crypto" peer "gx/ipfs/QmPJxxDsX2UbchSHobbYuvz7qnyJTFKvaKMzE2rZWJ4x5B/go-libp2p-peer" ) func TestSigning(t *testing.T) { priv...