text
stringlengths
11
4.05M
package slice func Reduce[I, V any](slice []I, initReduceValue V, f func(reduceValue V, index int, value I) V) (reduceValue V) { reduceValue = initReduceValue for i, v := range slice { reduceValue = f(reduceValue, i, v) } return }
// 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 ...
package iris import ( "fmt" "github.com/midtrans/midtrans-go" assert "github.com/stretchr/testify/require" "math/rand" "strconv" "testing" "time" ) var irisCreatorKeySandbox = "IRIS-330198f0-e49d-493f-baae-585cfded355d" var irisApproverKeySandbox = "IRIS-1595c12b-6814-4e5a-bbbb-9bc18193f47b" func random() str...
package fakes import ( "fmt" "net/http" "github.com/cloudfoundry-incubator/notifications/cf" ) type CloudController struct { CurrentToken string GetUsersBySpaceGuidError error GetUsersByOrganizationGuidError error LoadSpaceError error LoadOrg...
package services // import ( // "errors" // "time" // "github.com/dgrijalva/jwt-go" // ) // // Set our secret. // // TODO: Use generated key from README // var mySigningKey = []byte("secret") // // Token defines a token for our application // type Token string // // TokenService provides a token // type TokenSe...
package pubsub import ( "context" "errors" "fmt" "sync" "github.com/siatris/go-pubsub-ws/pkg/websocket" "github.com/go-redis/redis/v8" ) type Middleware func(websocket.WSMessage) websocket.WSMessage type Subscription interface { Subscriber() websocket.WSConn Use(Middleware) Namespaces() []string Handle(w...
package main import ( "log" "net/http" _ "net/http/pprof" "os" "os/signal" "syscall" "time" ) func simple_deadlock() { c := make(chan bool) // c <- true // fatal error: all goroutines are asleep - deadlock! --> goroutine 1 [chan send]: <-c // fatal error: all goroutines are asleep - deadlock! --> goroutine ...
package main import "fmt" func main() { fmt.Println(maxSumTwoNoOverlap([]int{ 2, 1, 5, 6, 0, 9, 5, 0, 3, 8, }, 4, 2)) } // 0,6,5,2,2,5,1,9,4 func maxSumTwoNoOverlap(nums []int, firstLen int, secondLen int) int { n := len(nums) max := func(a, b int) int { if a > b { return a } return b } s := make...
package server import ( "fmt" "net/http" ) type RequestHandler func(http.ResponseWriter, *http.Request) bool type RequestBroker struct { Routers map[string][]RequestHandler HttpMethodNotSupported RequestHandler NoRouterServedRequest RequestHandler } func (r *RequestBroker) serveOrRejectWithRout...
package main import ( "bufio" "context" "encoding/json" "errors" "flag" "fmt" "os" "sync" "github.com/amenzhinsky/iothub/cmd/internal" "github.com/amenzhinsky/iothub/iotdevice" "github.com/amenzhinsky/iothub/iotdevice/transport" "github.com/amenzhinsky/iothub/iotdevice/transport/mqtt" ) var transports = ...
package benchmark /* func Test_Use_reflectvalue_deepcopy(t *testing.T) { dst := testDataDst{} deepcopy.Copy(&dst, &td).Do() assert.Equal(t, td, dst) dst.Slice[0] = "aaa" fmt.Println("deepcopy:", td.Slice) } func Test_Use_Ptr_coven(t *testing.T) { c, err := coven.NewConverter(testDataDst{}, testDataSrc{}) ass...
package main import f "fmt" func main() { a := make(map[string]int) a["age"] = 27 a["height"] = 175 f.Println(a) b := map[string]float64{ "pi": 3.141592, "sqrt2": 1.41421356, } f.Println(b["pi"], b["sqrt2"]) f.Println("-------------------") capacityUnit := make(map[string]string) capacityUnit[...
package p_test import ( "testing" pp "github.com/Kretech/xgo/p" "github.com/Kretech/xgo/test" ) func TestArgsNameWithAlias(t *testing.T) { as := test.A(t) a := 3 b := 4 a1 := pp.VarName(a, b) as.Equal(a1, []string{`a`, `b`}) }
package dep import "testing" func TestListen(t *testing.T) { // todo }
package memrepo import ( "github.com/scjalliance/drivestream/commit" "github.com/scjalliance/drivestream/resource" ) // FileEntry holds version history for a file. type FileEntry struct { Versions map[resource.Version]resource.FileData Views map[resource.ID]map[commit.SeqNum]resource.Version } func newFileEnt...
package domain const ( // Title Errors TaskErrorTitleEmptyCode = iota // Invalid Task ID Error TaskErrorIDInvalidCode // Description Errors TaskErrorDescriptionEmptyCode // Date Errors TaskErrorDueDateEmptyCode TaskErrorDueDateInvalidCode // Priority Errors TaskErrorPriorityEmptyCode TaskErrorInvalidPr...
package handlers import ( "fmt" "net/url" "github.com/authelia/authelia/v4/internal/authentication" "github.com/authelia/authelia/v4/internal/authorization" "github.com/authelia/authelia/v4/internal/middlewares" "github.com/authelia/authelia/v4/internal/session" "github.com/authelia/authelia/v4/internal/utils"...
package game import ( "encoding/json" "errors" "fmt" ) type ResultType string const ( Ones ResultType = "ones" Twos = "twos" Threes = "threes" Fours = "fours" Fives = "fives" Sixes = "sixes" ThreeOfAKind...
package main import ( "fmt" "io/ioutil" "os" "encoding/json" "github.com/buger/jsonparser" "strings" "YJparser/yamlparser" "text/template" ) type Swagger struct{ SwagVersion string `json:"swagger"` ObjectsFlag bool ApiTypeFlag bool Package string Paths json.RawMessage Definitions json.RawMessage ...
// Go program to illustrate // the concept of Goroutine package main import "fmt" func display(str string) { for w := 0; w < 6; w++ { fmt.Println(str) } } func main() { // Calling Goroutine go display("Welcome") // Calling normal function display("GeeksforGeeks") } /* In the above written program, We si...
package main import "fmt" func main() { // n := 2548 y := "browsing under an umbrella" // fmt.Printf("%x", n) fmt.Printf("%b", y) }
package controllers import ( "{{.PackageName}}/helpers" "{{.PackageName}}/models" "github.com/labstack/echo" ) func find{{.ModelName}}ByID(c echo.Context) (*models.{{.ModelName}}, *helpers.ResponseError) { c.Request().ParseForm() {{.InstanceName}}, _ := models.FindOne{{.ModelName}}ByID(c.Param("{{.InstanceName ...
package service import ( "github.com/goscaffold/logger" "github.com/goscaffold/snowflake" micro "github.com/micro/go-micro" "github.com/micro/go-micro/client" "github.com/micro/go-micro/server" tracingWrapper "github.com/micro/go-plugins/wrapper/trace/opentracing" opentracing "github.com/opentracing/opentracin...
package main /* * @lc app=leetcode.cn id=189 lang=golang * * [189] 轮转数组 */ /* 1. 最基础实现,暴力解 2. 空间复杂度O(1) 3. 时间复杂度O(k * n) 4. 提交最后一个case 超时。说明逻辑没有问题,执行时间需要优化 */ // @lc code=start func rotate(nums []int, k int) { for i := 0; i < k; i++ { tmp := nums[len(nums)-1] for j := len(nums) - 2; j > -1; j-- { nums[...
package main import ( "encoding/base64" "encoding/json" "github.com/google/uuid" "github.com/googollee/go-socket.io" "github.com/gorilla/mux" "github.com/gorilla/securecookie" "golang.org/x/crypto/bcrypt" _ "golang.org/x/oauth2" "gopkg.in/mgo.v2" "gopkg.in/mgo.v2/bson" "html/template" _ "io" "io/ioutil" ...
package v1 import ( "context" "reflect" "github.com/aws/aws-sdk-go/service/ec2" "github.o-in.dwango.co.jp/naari3/ingress-sg-validator/pkg/aws/services" ) type mockEC2 struct { services.EC2 store []*ec2.SecurityGroup } // Only support 'GroupIds' and part of 'Filter' func (c *mockEC2) DescribeSecurityGroupsAsLi...
package gcs_proxy import ( "testing" "github.com/stretchr/testify/assert" "net/http/httptest" "net/http" "errors" ) type StubRepository struct { getObjects func(path string) ([]Object, error) getObject func(path string) ([]byte, error) isFile func(path string) (bool, error) } func (s StubRepository) Get...
package problem0239 func maxSlidingWindow(nums []int, k int) []int { deque := &Deque{} result := make([]int, len(nums)-k+1) for i := 0; i < len(nums); i++ { for !deque.IsEmpty() && i-deque.First() >= k { deque.Shift() } for !deque.IsEmpty() && nums[i] > nums[deque.Last()] { deque.Pop() } deque.Push(...
package example import ( "github.com/GoAdminGroup/go-admin/context" "github.com/GoAdminGroup/go-admin/modules/auth" "github.com/GoAdminGroup/go-admin/modules/db" "github.com/GoAdminGroup/go-admin/modules/service" ) func (e *Example) initRouter(prefix string, srv service.List) *context.App { app := context.NewAp...
package main import "fmt" func main() { b := 255 a := &b fmt.Printf("%T and %v\n", a, a) var c *int if c == nil { fmt.Println("Zero value is:", c) c = &b fmt.Println("New value is:", c) } intPntr := new(int) fmt.Printf("Type %T val %v Type pntr value %T Ptr Value %v\n", intPntr, intPntr, *intPntr, *i...
// Package eskip-match provides a cli tool and utilities to // helps you test Skipper (https://github.com/zalando/skipper) // `.eskip` files routing matching logic. package main import ( "log" "os" "github.com/rbarilani/eskip-match/cli" ) var logFatal = log.Fatal func main() { app := cli.NewApp() app.Version =...
/* Copyright 2021. The KubeVela Authors. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writ...
package main import ( "log" "time" "github.com/garyburd/redigo/redis" ) type Worker struct { Name string Address string conn redis.Conn } func NewWorker(name string, addr string) *Worker { return &Worker{Name: name, Address: addr} } func (w *Worker) Connect() { c, err := NewConn() if err != nil { ...
package rpc import ( "context" "gate/config" "google.golang.org/grpc" "log" "message" "time" ) var GateToClusterClient *GateToCluster var connect grpc.ClientConnInterface var client message.ServerServiceClient //连接cluster type GateToCluster struct { connect grpc.ClientConnInterface } func (g *GateToCluster) ...
package gsm7bit import "unicode" func init() { for index, r := range reverseLookup { forwardLookup[r] = byte(index) } for r, b := range forwardEscapes { reverseEscapes[b] = r } } const esc, cr byte = 0x1B, 0x0D var forwardLookup = map[rune]byte{} var reverseLookup = [256]rune{ 0x40, 0xA3, 0x24, 0xA5, 0xE8...
package r2 import ( "net/http" "net/url" ) // PostForm sets the request post form and the content type. func PostForm(postForm url.Values) Option { return func(r *Request) { if r.Header == nil { r.Header = http.Header{} } r.Header.Set(HeaderContentType, ContentTypeApplicationFormEncoded) r.PostForm = po...
package utils /** RPC通信配置 */ const RPCURL = "http://127.0.0.1:8332" const RPCUSER = "user" const RPCPASSSWORD = "pwd" const RPCBERSION = "2.0"
package main import ( "fmt" "math" ) var XX = 200 const YY = 300 //常量不会分配地址 func main() { const ( x uint16 = 120 y s s1 = "abc" z ) println(x, " ", y, " ", s, " ", s1, " ", z) const ( a = iota a1 b float32 = iota c ) println(a, " ", a1, " ", b, " ", c) // println(&XX, &YY) // error ...
package hash import ( "crypto/hmac" "crypto/md5" "crypto/sha1" "crypto/sha256" "crypto/sha512" "github.com/vlorc/lua-vm/base" "hash" ) type SHA1Factory struct{} type SHA256Factory struct{} type SHA512Factory struct{} type MD5Factory struct{} type HMACFactory struct{} func __sum(h hash.Hash, buf ...base.Buffer...
package handlers import ( "github.com/kkurahar/go-gin-lightweight/helpers/log" "github.com/kkurahar/go-gin-lightweight/resources" ) var ( tagResource = resources.NewResourceTag() logger = log.NewLogger() )
package generated //go:generate dataloaden ServiceLoader int *github.com/syncromatics/kafmesh/internal/graph/model.Service //go:generate dataloaden ServiceSliceLoader int []*github.com/syncromatics/kafmesh/internal/graph/model.Service //go:generate dataloaden ProcessorLoader int *github.com/syncromatics/kafmesh/inter...
// 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 ( "errors" "io/ioutil" "os" "path/filepath" "strings" "github.com/jinzhu/configor" log "github.com/sirupsen/logrus" yaml "gopkg.in/yaml.v2" ) /** * ConfigurationLoader contains all methods to load/save configuration files */ type ConfigurationLoader struct { } /** * The Project Config...
// Copyright 2018 The gitsync authors. All rights reserved. // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. package hook_test import ( "context" "testing" "github.com/seibert-media/gitsync/pkg/hook" . "github.com/onsi/ginkgo" . "github.com/onsi/gomega" ) ...
package cookiejar2 import ( "net/http" "net/url" ) type ImmutableCookieJar struct { Inner http.CookieJar } func (i *ImmutableCookieJar) SetCookies(u *url.URL, cookies []*http.Cookie) { // Immutable, prevent set cookies } func (i *ImmutableCookieJar) Cookies(u *url.URL) []*http.Cookie { return i.Inner.Cookies(u...
package rules import ( "github.com/bonjourmalware/melody/internal/filters" "github.com/bonjourmalware/melody/internal/logging" ) // Rules abstracts an array of Rule type Rules []Rule // Rule describes a parsed Rule object, used to match against a byte array type Rule struct { Name string ID string Tags map[st...
package marketdata import "time" type MarketData struct { MarketName string `json:"marketname"` High float64 `json:"high"` Low float64 `json:"low"` Volume float64 `json:"volume"` Created time.Time `json:"created"` Timestamp time.Time `json:"timestamp"` }
/* Copyright 2019 The Kubernetes Authors. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, ...
/* Copyright 2021 CodeNotary, 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 law or agreed to i...
package main import ( "fmt" "sync" ) // 定义一个协程计数器 var wg sync.WaitGroup func test() { // 这是主进程执行的 for i := 0; i < 1000; i++ { fmt.Println("test1 你好golang", i) //time.Sleep(time.Millisecond * 100) } // 协程计数器减1 wg.Done() } func test2() { // 这是主进程执行的 for i := 0; i < 1000; i++ { fmt.Println("test2 你好go...
package service import ( "context" "fmt" "net/http" "github.com/gofrs/uuid" "github.com/go-ocf/cloud/cloud2cloud-connector/store" "golang.org/x/oauth2" ) func (rh *RequestHandler) HandleLinkedAccount(ctx context.Context, data LinkedAccountData, authCode string) (LinkedAccountData, error) { var oauth oauth2.C...
package main import "fmt" func main() { fmt.Println("Printing all even numbers from 1 to 100") for i := 1; i <= 100; i++ { if i % 2 == 0 { fmt.Print("\t", i) } } fmt.Println() fmt.Println("Printing all odd numbers from 1 to 100") for i := 1; i <= 100; i++ { if i % 2 != 0 { fmt.Print("\t", i) } } ...
package ansi_test import ( "fmt" "testing" "unicode/utf8" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" "github.com/jcorbin/anansi/ansi" ) func TestDecodeEscape(t *testing.T) { type anRead struct { e ansi.Escape a []byte n int } type utRead struct { r rune m int } t...
package main_test import "testing" func TestVeri(t *testing.T) { }
package controllers import ( "encoding/json" "fmt" "reflect" "strings" "github.com/mitchellh/mapstructure" "github.com/gophergala2016/source/core/config" "github.com/gophergala2016/source/core/foundation" "github.com/gophergala2016/source/core/infra/database" "github.com/gophergala2016/source/core/net/conte...
// Copyright 2021 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 main import ( "fmt" "time" "github.com/olebedev/when" "github.com/olebedev/when/rules/common" "github.com/olebedev/when/rules/en" ) func main() { fmt.Println("vim-go") w := when.New(nil) w.Add(en.All...) w.Add(common.All...) text := "drop me a line in next wednesday at 2:25 p.m" text = "December ...
package main import "golang_normal_study/go_log/loginit" /* var logger *log.Logger var logFile *os.File func init() { var err error logFile,err=os.OpenFile("./testlog.log",os.O_RDWR|os.O_CREATE|os.O_APPEND,0644) if err!=nil{ panic(err) } //defer logFile.Close() logger=log.New(logFile,"\r\n",log.Ldate|log....
package main func spiralMatrixIII(R int, C int, r0 int, c0 int) [][]int { leftBound, rightBound := c0, c0 upBound, downBound := r0, r0 result := make([][]int, 0) for len(result) < R*C { for i := leftBound; i <= rightBound; i++ { if isValidCoordinate(upBound, i, R, C) { result = append(result, []int{upBoun...
package services import "errors" var errInvalidUserData = errors.New("invalid username or password") var errUserAlreadyExists = errors.New("this login or email is already used")
package main import ( "encoding/json" "errors" "flag" "fmt" "io" "os" "os/exec" yaml "gopkg.in/yaml.v3" ) type jqFlags struct { compact bool nullAsSingleInputValue bool exitStatusCodeBasedOnOutput bool slurp bool raw bool rawString ...
package sese import ( "encoding/xml" "github.com/thought-machine/finance-messaging/iso20022" ) type Document03600104 struct { XMLName xml.Name `xml:"urn:iso:std:iso:20022:tech:xsd:sese.036.001.04 Document"` Message *SecuritiesFinancingModificationInstructionV04 `xml:"SctiesF...
package demoinfocs import ( "github.com/ghostanalysis/demoinfocs-golang/common" ) type demoCommand byte const ( maxEntities = (1 << common.MaxEditctBits) maxPlayers = 64 maxWeapons = 64 ) const ( dc_Signon demoCommand = iota + 1 dc_Packet dc_Synctick dc_ConsoleCommand dc_UserCommand dc_DataTables dc_St...
package command import ( "os/exec" "github.com/satori/go.uuid" "os" "fmt" "bufio" "log" "bytes" ) type Output struct { Content string `json:"content"` } type LogsCommand struct { StackName string `json:"stackName"` ServiceName string `json:serviceName` Instance string `json:instance` } type RunComman...
package main import ( "bufio" "fmt" "io" "io/ioutil" "log" "os" ) /* @Time : 2021/1/18 10:40 下午 @Author : audiRS7 @File : find4.go @Software: GoLand */ //文件目录树形结构节点 type dirTreeNode struct { name string child []dirTreeNode } var iCount int = 0 //递归遍历文件目录 func getDirTree(pathName string) (dirTreeNode, error...
// Copyright 2020 PingCAP, Inc. Licensed under Apache-2.0. package storage import ( "bytes" "context" "fmt" "os" "os/exec" "path/filepath" "github.com/pingcap/errors" berrors "github.com/pingcap/tidb/br/pkg/errors" ) // HDFSStorage represents HDFS storage. type HDFSStorage struct { remote string } // NewH...
//Copyright 2015 gsgo Author. All Rights Reserved. package logs import ( "fmt" "strings" "sync" ) //日志等级常量 const ( LevelTrace = iota LevelDebug LevelInfo LevelWarn LevelError ) var levelPrefix = []string{"[T]", "[D]", "[I]", "[W]", "[E]"} func getLoggerLevel(level string) int { level = strings.ToLower(leve...
package cmd import ( "errors" "fmt" "github.com/spf13/cobra" "github.com/wish/ctl/cmd/util/parsing" "github.com/wish/ctl/pkg/client" "strings" ) var supportedGetTypes = [][]string{ {"pods", "pod", "po"}, {"jobs", "job"}, {"configmaps", "configmap", "cm"}, {"deployments", "deployment", "deploy"}, {"replicas...
package config import ( "strings" "github.com/spf13/viper" ) // LoadConfig for func LoadConfig() { viper.AddConfigPath("./conf") // 如果没有指定配置文件,则解析默认的配置文件 viper.SetConfigName("config") viper.SetConfigType("yaml") // 设置配置文件格式为YAML viper.AutomaticEnv() // 读取匹配的环境变量 viper.SetEnvPrefix("CRAWLAB") // 读取环...
package main import ( "os" "cloud_go/service" "flag" ) const ( PORT string = "8080" ) func main() { port := os.Getenv("PORT")//get custom environment variables if len(port) == 0 { port = PORT } flag.StringVar(&port, "p", PORT, "PORT for httpd listening") flag.Parse() serv...
package main import( "fmt" "time" "math/rand" ) func main() { average := 0 for a := 0; a < 10; a++ { rand.Seed(time.Now().UnixNano()) start := time.Now() fmt.Println(connectDB("Database 1")) fmt.Println(connectDB("Database 2")) average =...
package main import ( "database/sql" "net/http" _ "github.com/lib/pq" ) //ShipmentEnvironmentsByGroupResult ... type ShipmentEnvironmentsByGroupResult struct { Group string `json:"group"` Count int `json:"count"` } func shipmentEnvironmentsByGroup(r *http.Request) *Response { query := ` select "Shipment...
package raft import ( "bytes" "encoding/json" "fmt" "io" "reflect" ) var commandTypes map[string]Command func init() { commandTypes = map[string]Command{} } type Command interface { CommandName() string } type CommandEncoder interface { Encode(w io.Writer) error Decode(r io.Reader) error } // Creates a n...
package cli import ( "fmt" "io/ioutil" "net/http" "strings" "testing" "time" "github.com/10gen/realm-cli/internal/telemetry" "github.com/10gen/realm-cli/internal/utils/api" "github.com/10gen/realm-cli/internal/utils/test/assert" "github.com/10gen/realm-cli/internal/utils/test/mock" ) type capturedEvent str...
package log import ( "Open_IM/pkg/common/config" "bufio" "fmt" nested "github.com/antonfisher/nested-logrus-formatter" rotatelogs "github.com/lestrrat-go/file-rotatelogs" "github.com/rifflock/lfshook" "github.com/sirupsen/logrus" "os" "time" ) var logger *Logger type Logger struct { *logrus.Logger Pid int...
package k8sml import ( "reflect" "strings" ) type ContainerNetworkInterface struct { ID string `yaml:"id"` Kubernetes *Kubernetes } func (cni *ContainerNetworkInterface) GetID() string { return cni.ID } func (cni *ContainerNetworkInterface) GetVariableValue(variable string) interface{} { e := reflect.ValueOf(...
package main import ( "fmt" "time" ByteArkSignerSDK "github.com/byteark/byteark-sdk-go" ) func main() { // Create signer options signerOptions := ByteArkSignerSDK.SignerOptions{ AccessID: "fleet-1320", AccessSecret: "2bpqxHOMUxVmkzA1", } // Create signer createSignerError := ByteArkSignerSDK.CreateS...
/*- * Copyright 2015 Grammarly, 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 agree...
package msg const ( ListStr = "获取列表" DelStr = "删除" GetStr = "获取" CreateStr = "创建" SuccessStr = "成功" ErrorStr = "失败" StateStr = "状态" Had = "已存在" NoHad = "不存在" MastHasOneStr = "至少要有一个" IdCardNumErr = "身份证不合法" ) // 获取操作提示 func GetTodoResMsg(str string, e...
package strings import ( "text/template" ) var FuncMap = template.FuncMap { "add": Add, "dateFormat": DateFormat, "findRe": FindRe, "findSubRe": FindSubRe, "floatToInt": FloatToInt, "inchesToFeet": InchesToFeet, "lower": ToLower, "minify": MinifyCode, "markdown": Markdown, "marshal": Marshal, ...
package run import ( "time" floc "gopkg.in/workanator/go-floc.v1" ) /* Wait waits until the condition is met. The function falls into sleep with the duration given between condition checks. The function does not run any job actually and just repeatedly checks predicate return value. When the predicate returns true...
package DbBase import ( "xwork/Extend/Cache" _ "xwork/Extend/Cache/Memcache" "os" "github.com/sirupsen/logrus" ) func InitCache() { ca := Cache.NewCache("default") if ca == nil { logrus.Error("cache: server connection fail name default") os.Exit(0) } }
// Example Documentation: https://objectrocket.com/docs/redis_go_examples.html // Driver Documentation: https://github.com/garyburd/redigo // TODO: Test this with SSL. Reformat example so it is more consistent with others (i.e. ping instead of adding and removing stuff from DB) package main import "github.com/garyburd...
package cli import ( "context" "os" "os/signal" ) func withTrapCancel(ctx context.Context, ss ...os.Signal) (context.Context, context.CancelFunc) { ret, cancel := context.WithCancel(ctx) ch := make(chan os.Signal, len(ss)) go func() { defer signal.Stop(ch) <-ch cancel() }() signal.Notify(ch, ss...) ret...
package kuu import ( "testing" ) // TestRandCode func TestRandCode(t *testing.T) { t.Log(RandCode(4)) t.Log(RandCode(6)) t.Log(RandCode()) t.Log(RandCode(10)) }
package config const( RpcServiceName = "com.salpadding.srv" )
/* Licensed to the Apache Software Foundation (ASF) under one or more contributor license agreements. See the NOTICE file distributed with this work for additional information regarding copyright ownership. The ASF licenses this file to you under the Apache License, Version 2.0 (the "License"); you may not use this f...
package imagehelper import ( "image" _ "image/jpeg" _ "image/png" "os" ) func GetImageDimension(srcPath string) (width int, height int, err error) { src, err := os.Open(srcPath) if err != nil { return 0, 0, err } defer src.Close() image, _, err := image.DecodeConfig(src) if err != nil { return 0, 0, er...
// 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 t...
package translator import ( "github.com/stretchr/testify/require" "testing" ) func TestTranslateEnglishToKlingon(t *testing.T) { tests := []struct{ input string output string }{ {"Nyota Uhura", "0xF8DB 0xF8E8 0xF8DD 0xF8E3 0xF8D0 0x0020 0xF8E5 0xF8D6 0xF8E5 0xF8E1 0xF8D0"}, {"Data", "0xF8D3 0xF8D0 0xF8E3 ...
//////////////////////////////////////////////////////////////////////////////// // // // Copyright 2019 Dell, Inc. // // ...
package main /* * @lc app=leetcode id=145 lang=golang * * [145] Binary Tree Postorder Traversal */ /** * Definition for a binary tree node. * type TreeNode struct { * Val int * Left *TreeNode * Right *TreeNode * } */ func prepend145(s []int, val int) []int { copied := append(s...
// Copyright 2016 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 internal import ( "errors" ) var ( ErrUserDoesNotExist = errors.New("user does not exist") )
// Package util contains utilities for use in all transport implementations package util
/* # -*- coding: utf-8 -*- # @Author : joker # @Time : 2021/6/3 10:31 下午 # @File : implement_queue_using_stacks.go # @Description : // 栈实现队列 # @Attention : */ package v2 // 用栈实现队列 // 关键是: 一个栈专门用于push,剩下的一个栈,专门用于pop type MyQueue struct { pushStack []int popStack []int } /** Initialize your data structure here. */ ...
package manage_model import ( "ibgame/logs" "ibgame/models/mysql" ) const ( superstar = 1 //"当家球星" allstar = 11 //"全明星" scorer = 2 //"得分手" defender = 3 //"防守者" threer = 4 //"三分手" maker = 5 //"组织者" rebound = 6 //"篮板手" sixer = 7 //"第六人" threeD = 8 //"3d" tibu = 9 //"替补" ...
// Copyright 2022 PingCAP, Inc. Licensed under Apache-2.0. package prealloctableid_test import ( "fmt" "testing" "github.com/pingcap/tidb/br/pkg/metautil" prealloctableid "github.com/pingcap/tidb/br/pkg/restore/prealloc_table_id" "github.com/pingcap/tidb/parser/model" "github.com/stretchr/testify/require" ) t...
// Copyright © 2018 NAME HERE <EMAIL ADDRESS> // // 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 ...
package consts //版本号 const ( VersionV3 = "/v3" ) //host const ( DeviceHost = "https://device.jpush.cn" PushHost = "https://api.jpush.cn" ) //device const ( /** 查询设备的别名和标签 -----分割线----- 设置设备的别名与标签: tags: 支持add, remove 或者空字符串。当tags参数为空字符串的时候,表示清空所有的 tags; add/remove 下是增加或删除指定的 tag; 一次 add/remove tag 的上限...