text
stringlengths
11
4.05M
package main import ( "errors" "fmt" "math" ) func main() { // 命名 var a = "Hello" b := "Gail" var c string c = "!" fmt.Println(a, b, c) // 变量一般用驼峰命名,但是要注意跟函数名区分开 roundArea := RoundArea(1.0) fmt.Print(roundArea) // 普通的for循环 sum := 0 for i := 0; i < 10; i++ { sum += 1 } fmt.Print(sum) // Go 中的普通...
package window import ( "github.com/galaco/lambda-client/engine" "github.com/galaco/tinygametools" "github.com/go-gl/glfw/v3.2/glfw" ) // Manager is responsible for managing this games window. Understand // that there is a distinction between the window and the renderer. // This manager provides a window that a re...
package conv import "net/mail" func ToEmailAddress(s string) (string, error) { addr, err := mail.ParseAddress(s) if err != nil { return "", err } return addr.String(), nil } func IsEmailAddress(s string) bool { addr, _ := ToEmailAddress(s) return addr != "" }
package contexts import ( "github.com/daiguadaidai/haechi/config" ) type HttpContext struct { ServerConfig *config.StartConfig RuleConfig *config.RuleConfig } func NewHttpContext(sc *config.StartConfig) *HttpContext { return &HttpContext{ ServerConfig: sc, RuleConfig: sc.RuleConfig, } }
package service import ( "fmt" "snippetBox-microservice/news/api/controller" "snippetBox-microservice/news/pkg/domain" "snippetBox-microservice/news/pkg/validator" "time" ) type news struct { repo NewsRepositoryInterface } type NewsRepositoryInterface interface { Insert(title, content string, expires time.Tim...
package tool import ( "fmt" "testing" "time" ) func TestRandom(t *testing.T) { fmt.Printf("letterBytes:[%v] \n", letterBytes) fmt.Printf("letterIdxBits [%v] [%b] \n", letterIdxBits, letterIdxBits) fmt.Printf("letterIdxMask [%v] [%b] \n", letterIdxMask, letterIdxMask) fmt.Printf("letterIdxMax [%v] [%b] \n", let...
// Copyright 2022 The ChromiumOS Authors // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. package ui import ( "context" "fmt" "strings" "time" "github.com/godbus/dbus/v5" "chromiumos/tast/ctxutil" "chromiumos/tast/errors" "chromiumos/tast/local/chrome" ...
// SPDX-License-Identifier: ISC // Copyright (c) 2014-2020 Bitmark Inc. // Use of this source code is governed by an ISC // license that can be found in the LICENSE file. package domain import ( "net" "time" "github.com/miekg/dns" "github.com/bitmark-inc/bitmarkd/announce/receptor" "github.com/bitmark-inc/bitm...
package handlers import ( "encoding/json" "fmt" "github.com/gin-gonic/gin" "github.com/sagaraglawe/miniProject/inits" "github.com/sagaraglawe/miniProject/migrations" "io/ioutil" "log" "mime/multipart" "net/http" "sync" ) func AdminShow(c *gin.Context){ //getting the parameter value user with the key name in...
package main import ( "fmt" ) type describe interface { description() string } func printDescription(d describe) { fmt.Printf("Description: %s\n", d.description()) } type Product struct { id uint name string price uint PR PRStatement } type PRStatement func() string // PRStatemen...
package main import ( "fmt" "io" "net/http" "os" "path/filepath" ) func checkFatalError(err error) { if err != nil { fmt.Fprintf(os.Stderr, "error is %v\n", err) os.Exit(1) } } func main() { fmt.Println("hello wget") url := "https://www.baidu.com/img/bd_logo1.png" // url := "https://mirrors.tuna.tsing...
package util import ( "log" "os" ) func CreateLogger(prefix, logfile string) *log.Logger{ if logfile == "" { return log.New(os.Stdout, prefix, log.LstdFlags) } else { file, _ := os.Open(logfile) return log.New(file, prefix, log.LstdFlags) } }
package util import ( "bufio" "fmt" "io" "os" "strings" ) var path = "/Users/novalagung/Documents/temp/test.txt" func createFile() { // detect if file exists var _, err = os.Stat(path) // create file if not exists if os.IsNotExist(err) { var file, err = os.Create(path) if isError(err) { return } ...
package test import ( "github.com/orbs-network/orbs-network-javascript-plugin/test" . "github.com/orbs-network/orbs-network-javascript-plugin/worker" "github.com/stretchr/testify/require" "testing" ) func TestNewV8Worker_MethodNotFound(t *testing.T) { sdkHandler := test.AFakeSdkFor([]byte("signer"), []byte("call...
package main import ( "fmt" "time" "github.com/liasece/micchaos/ccmd" "github.com/liasece/micchaos/testclient/client" ) func run(ch chan struct{}, i int) { defer func() { ch <- struct{}{} }() c := &client.Client{} c.Init(fmt.Sprintf("Jansen%d", i+1), "testpsw99876") err := c.Dial(":11002") if err != nil...
// Copyright 2020 The VectorSQL Authors. // // Code is licensed under Apache License, Version 2.0. package datablocks import ( "fmt" "sync" "base/errors" "columns" "datavalues" ) type DataBlock struct { mu sync.RWMutex seqs []int info *DataBlockInfo values []*DataBlockValue totalBy...
package main import ( "flag" "fmt" "log" "os" "path/filepath" "time" "github.com/fasthall/kubeprof/client" "github.com/fasthall/kubeprof/util" _ "k8s.io/client-go/plugin/pkg/client/auth/gcp" ) var tool string var kubeConfig string var sshKey string var stageDir string var outputDir string var jobFile string...
// Copyright 2015 The Cockroach Authors. // // Use of this software is governed by the Business Source License // included in the file licenses/BSL.txt. // // As of the Change Date specified in that file, in accordance with // the Business Source License, use of this software will be governed // by the Apache License, ...
package admin_models import ( "github.com/astaxie/beego/orm" ) func (df *DataFile) TableName() string { return "data_file" } func (df *DataFile) Insert() error { if _, err := orm.NewOrm().Insert(df); err != nil { return err } return nil } func (df *DataFile) Read(fields ...string) error { if err := orm.N...
package auth /* Creation Time: 2019 - Sep - 21 Created by: (ehsan) Maintainers: 1. Ehsan N. Moosa (E2) Auditor: Ehsan N. Moosa (E2) Copyright Ronak Software Group 2018 */ // easyjson:json type CreateAccessToken struct { Permissions []string `json:"permissions"` Period int64 `json:"per...
package server import ( "fmt" "log" fiber "github.com/gofiber/fiber/v2" "gitlab.com/cfs-service/server/handlers" "gitlab.com/cfs-service/server/middleware" "gitlab.com/cfs-service/store" ) func Start(port uint64, s store.IStore) error { // Initilize handlers handlers.Initialize(s) app := fiber.New() app....
package convoso import ( "net/http" "net/url" "strings" ) func postFormRequest(route string, body url.Values) (*http.Response, error) { body.Add("auth_token", apiKEY) log.Info("POST: "+route, " POSTBODY: "+body.Encode()) request, err := http.NewRequest("POST", route, strings.NewReader(body.Encode())) if err !...
package main import ( "fmt" "net/http" ) type String string type Struct struct { Greeting string Punct string Who string } type Hello struct{} func (h Hello) ServeHTTP( w http.ResponseWriter, r *http.Request) { fmt.Fprint(w, "Hello!") } func main() { var h Hello u := String("Hellow World") http...
package ast import ( "github.com/OlegSchwann/GoDao/internal/flag" "go/ast" "go/parser" "go/token" ) func ParseFile(config flag.Config) (*ast.File, error) { var maybeTrace parser.Mode // no effect by default if config.Verbose { maybeTrace = parser.Trace } return parser.ParseFile(token.NewFileSet(), config.I...
package t1 // Copyright 2016-2017 MediaMath // // 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 o...
package datetime import ( "github.com/project-flogo/core/data" "github.com/project-flogo/core/support/log" "time" "github.com/project-flogo/core/data/expression/function" ) const DateFormatDefault = "2006-01-02-07:00" type CurrentDate struct { } func init() { function.Register(&CurrentDate{}) } func (s *Curr...
package sync // // Copyright (c) 2019 ARM Limited. // // SPDX-License-Identifier: MIT // // Permission is hereby granted, free of charge, to any person obtaining a copy // of this software and associated documentation files (the "Software"), to // deal in the Software without restriction, including without limit...
package testing import ( "reflect" "testing" "github.com/kr/pretty" ) // DiffVisible is a flag which dictates whether the diff message should be shown failed assertions var DiffVisible = true // Testable is an interface that other structs can implement to aid in testing type Testable interface { Title() string ...
// Copyright 2020 The ChromiumOS Authors // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. package health import ( "context" "time" "chromiumos/tast/errors" "chromiumos/tast/local/croshealthd" "chromiumos/tast/local/jsontypes" "chromiumos/tast/testing" ) t...
package gateway import "github.com/gobjserver/gobjserver/core/entity" // ObjectGateway . type ObjectGateway interface { FindAll() ([]string, error) Insert(objectName string, instance interface{}) (*entity.Object, error) Find(objectName string) []*entity.Object FindByID(objectName string, objectID string) (*entity...
package integration_test import ( "fmt" "time" . "github.com/onsi/ginkgo" . "github.com/onsi/gomega" "k8s.io/apimachinery/pkg/util/wait" "k8s.io/client-go/kubernetes" qstsv1a1 "code.cloudfoundry.org/quarks-operator/pkg/kube/apis/quarksstatefulset/v1alpha1" utils "code.cloudfoundry.org/quarks-utils/testing/in...
package api import ( "net/http" "github.com/gin-gonic/gin" "github.com/gin-gonic/gin/binding" "github.com/pegasus-cloud/iam_client/iam" "github.com/pegasus-cloud/iam_client/protos" "github.com/pegasus-cloud/iam_client/utility" ) type ( listGroupsOutput struct { Groups []group `json:"groups"` Total int ...
package texdata import ( "github.com/go-gl/mathgl/mgl32" ) type TexData struct { Reflectivity mgl32.Vec3 NameStringTableID int32 Width int32 Height int32 ViewWidth int32 ViewHeight int32 }
/* Copyright © 2020 Doppler <support@doppler.com> 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 w...
package main import ( "bufio" "encoding/json" "fmt" "net" "net/http" ) func main() { var address string network := "tcp" host := "google.com" port := "80" address = net.JoinHostPort(host, port) conn, err := net.Dial(network, address) if err != nil { fmt.Printf("Failed to connect.") } else { fmt.Fpr...
package sim import ( "github.com/faiface/pixel" "math/rand" "sync" "time" ) const Partcount = 12 * 60 const Species = 12 const Radius = 8 const Threads = 12 const Friction = 0.88 const AttractionPrescaler = 0.0011 const AttractionScaler = 0.015 const CollisionEnabled = false type Particle struct { Position pixe...
package cryptopal import ( "encoding/base64" "encoding/hex" "fmt" "sort" "strings" "unicode" "unicode/utf8" ) // HexIn is a struct for taking a hex encoded byte slice as src type HexIn struct { Src []byte // a hex encoded byte slice } // ToBase64 converts a hex to base64 (bytes) which can be cast as a string...
// Package printmailer contains an implementation of the mailer interface that // prints package printmailer import ( "fmt" mailer "github.com/Nivl/go-mailer" ) // Makes sure Mailer implements mailer.Mailer var _ mailer.Mailer = (*Mailer)(nil) // Mailer is a mailer that just print emails type Mailer struct { } /...
package keeper import ( "math/big" "github.com/cosmos/cosmos-sdk/codec" sdk "github.com/cosmos/cosmos-sdk/types" paramtypes "github.com/cosmos/cosmos-sdk/x/params/types" "github.com/tendermint/tendermint/libs/log" "github.com/tharsis/ethermint/x/feemarket/types" ) // Keeper grants access to the Fee Market mod...
package test import ( "bytes" log "github.com/sirupsen/logrus" "golang.org/x/crypto/ssh" "net" "testing" ) func TestShell(t *testing.T) { var ( client *ssh.Client session *ssh.Session err error ) addr := "106.52.6.144:22" if client, err = ssh.Dial("tcp", addr, &ssh.ClientConfig{ User: "root", Auth:...
package flushqueues import ( "sync" "github.com/prometheus/client_golang/prometheus" "github.com/uber-go/atomic" ) type ExclusiveQueues struct { queues []*PriorityQueue index *atomic.Int32 activeKeys sync.Map stopped bool } // New creates a new set of flush queues with a prom gauge to track curre...
package worker import ( "os" "time" gocontext "context" "github.com/mitchellh/multistep" "github.com/pkg/errors" "github.com/sirupsen/logrus" "github.com/travis-ci/worker/backend" "github.com/travis-ci/worker/context" "github.com/travis-ci/worker/metrics" "go.opencensus.io/trace" ) type stepDownloadTrace ...
package parser // P collects input matchers. type P struct { IMakeMatchers Comprehensions } func NewParser(m IMakeMatchers) P { return P{m, make(Comprehensions)} } // ParseInput to generate a matching command. // Returns the command found regardless of error. func (parser P) ParseInput(input string) (p *Pattern, ...
package request import ( "encoding/json" "fmt" "io" "strings" "github.com/dema501/randomjoke/internal/pkg/request" ) // FakeSuperAgent has been build for unit tests purpose type FakeSuperAgent struct { body io.Reader } // Constructor.. func New(b *strings.Reader) request.Maker { return &FakeSuperAgent{ bod...
package commands import ( "fmt" "os" "github.com/BSidesSF/ctf-2019/challenges/rsaos/sessions" ) type PublicKeyCommand struct{} func (ec *PublicKeyCommand) GetName() string { return "get-publickey" } func (ec *PublicKeyCommand) GetDescription() string { return "Retrieve the Public Key" } func (ec *PublicKeyCo...
package users import ( "bytes" "net/http" "net/http/httptest" "testing" "github.com/gin-gonic/gin" "github.com/joho/godotenv" "github.com/stretchr/testify/assert" ) var initialized = false var router *gin.Engine func prepareTest() *gin.Engine { if !initialized { initialized = true godotenv.Load("./../.....
// Copyright 2018 The ChromiumOS Authors // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. package input import ( "context" "fmt" "math" "math/big" "os" "time" "unsafe" "chromiumos/tast/errors" "chromiumos/tast/local/coords" "chromiumos/tast/testing" ) ...
package zhash import ( "bytes" "encoding/json" "errors" "io" "io/ioutil" ) type Unmarshaller func([]byte, interface{}) error type Marshaller func(interface{}) ([]byte, error) // Sets function for marshalling via Hash.WriteHash(fd) func (h *Hash) SetMarshallerFunc(fu Marshaller) { h.marshal = fu } // Set funct...
package v2 import ( "fmt" "log" "sort" "gopkg.in/yaml.v2" "github.com/cyberark/secretless-broker/pkg/secretless/plugin" "github.com/cyberark/secretless-broker/pkg/secretless/plugin/sharedobj" ) // Config represents a full configuration of Secretless, which is just a list of // individual Service configuration...
package sej import ( "fmt" "path" "runtime" "sort" "testing" "time" ) func TestWatch(t *testing.T) { dir := newTestPath(t) shardChan := make(chan string) go func() { if err := WatchRootDir(dir, time.Millisecond, func(dir string) { go func() { shardChan <- dir }() }); err != nil { t.Fatal(er...
package api import ( "context" "fmt" "net/http" "github.com/porter-dev/porter/internal/models" ) func (c *Client) ListTemplates( ctx context.Context, ) ([]*models.PorterChartList, error) { req, err := http.NewRequest( "GET", fmt.Sprintf("%s/templates", c.BaseURL), nil, ) if err != nil { return nil, ...
// Fonctions d'utilité courant tel que Panic et Exit. package tools import ( "fmt" "log" "os" "time" ) const ( LogFileName = "log" // Le prefix du fichier de log que nous produisons. ) var ( logfile *os.File = nil // Le handle du fichier de log ouvert. ) // Permet le détournement du logging dans un fichier sé...
package fastdb import ( "bytes" "fastdb/index" "fastdb/storage" "sync" ) type StrIndex struct { mu sync.RWMutex idxList *index.SkipList } func NewStrIdx() *StrIndex { return &StrIndex{idxList: index.NewSkipList()} } func (db *FastDB) Set(key, value []byte) error { return db.doSet(key, value) } func (d...
// Copyright 2020 The ChromiumOS Authors // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. // Package arcappcompat will have tast tests for android apps on Chromebooks. package arcappcompat import ( "context" "time" "chromiumos/tast/common/android/ui" "chromi...
package authnsvc import ( "net/http" "github.com/gin-gonic/gin" "go.uber.org/zap" "github.com/alextanhongpin/go-microservice/api" "github.com/alextanhongpin/go-microservice/pkg/logger" ) type ( Controller struct { service } ) func NewController(svc service) *Controller { return &Controller{svc} } func (...
// Package token holds the lexical token types for use in lexing and parsing, // and functions for accessing them. // // Sample token types include IDENT for an identifier, TRUE for the keyword // "true", and FUNCTION for the keyword "fn". // // A Token represents a particular lexical token. It has a type and a literal...
package main import "fmt" func main() { res1, res2 := rectangle(6, 4) fmt.Println("zhouchang: ", res1, "mianji:", res2) } func rectangle(len, wid float64) (float64, float64) { perimeter := (len + wid) * 2 area := len * wid return perimeter, area }
// Copyright 2020 The ChromiumOS Authors // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. package cuj import ( "context" "os" "path" "path/filepath" "time" "chromiumos/tast/common/fixture" "chromiumos/tast/common/testexec" "chromiumos/tast/errors" "chro...
package main import ( "bytes" "fmt" "net/http" "time" ) func home(w http.ResponseWriter, r *http.Request) { fmt.Fprintf(w, "%s", "<h2>Welcome to the home Page</h2>") fmt.Fprintf(w, "%s", "How are you doing today?") } func work(w http.ResponseWriter, r *http.Request) { fmt.Fprintf(w, "[ %s", time.Now()) fmt.F...
package main import ( "bytes" "crypto/hmac" "crypto/sha256" ) // concatBuf concatenates two strings inside a byte buffer func concatBuf(a, b string) bytes.Buffer { var buf bytes.Buffer buf.WriteString(a) buf.WriteString(b) return buf } // hash returns the HMAC hash of the provided slice of bytes using SHA-256...
package shape import "github.com/gregoryv/draw/xy" // Aligner type aligns multiple shapes type Aligner struct{} // HAlignCenter aligns shape[1:] to shape[0] center coordinates horizontally func (Aligner) HAlignCenter(shapes ...Shape) { hAlign(Center, shapes...) } // HAlignTop aligns shape[1:] to shape[0] top coordi...
package skelplate import ( "encoding/json" "io" "io/ioutil" "os" "strings" "testing" "github.com/AlecAivazis/survey/terminal" ) var tmplErrTests = []struct { tmpl string prefill map[string]interface{} expected string }{ { `{ "author": "brainicorn", "variables":[{"name":"{{.SomeVar", "default"...
package main import ( "encoding/json" "encoding/xml" "fmt" "io" "io/ioutil" "log" "net/http" "net/http/httptest" "os" "reflect" "sort" "strconv" "strings" "testing" "time" ) var users []User func init() { type Сlient struct { FirstName string `xml:"first_name"` LastName string `xml:"last_name"` ...
package main import ( "fmt" "math" ) type Geometrica interface { area() float64 } type Quadrado struct { lado float64 } // area = lado ^ 2 (lado * lado) func (q Quadrado) area() float64 { return q.lado * q.lado } type Circulo struct { raio float64 } // area = pi * (raio ^ 2) (raio * raio) ...
package main import "sync" func main() { } type stack struct { lock sync.Mutex data []item size int } func (s *stack) push(t item) { s.lock.Lock() defer s.lock.Unlock() s.data = append(s.data, t) s.size++ } func (s *stack) pop() (item, bool) { s.lock.Lock() defer s.lock.Unlock() if s.size == 0 { ret...
package exchange import ( "fmt" ) type Bittrex struct { Exchange Pairs []*Pair } type BittrexTicker struct { Volume string `json:"volume"` LastPrice string `json:"last_price"` } type BittrexMarket struct { MarketCurrency string `json:"MarketCurrency"` BaseCurrency string `json:"BaseCurrency"` } type Bi...
package controllers import ( "context" "fmt" "strconv" "github.com/ACER/app/ent" "github.com/ACER/app/ent/course" "github.com/ACER/app/ent/courseitem" "github.com/ACER/app/ent/subject" "github.com/ACER/app/ent/subjecttype" "github.com/gin-gonic/gin" ) // CourseItemController defines the struct for the cours...
/* * @Author: Sy. * @Create: 2019-11-01 20:54:15 * @LastTime: 2019-11-16 17:09:31 * @LastEdit: Sy. * @FilePath: \server\controllers\admin_controllers\admin_auth_controller.go * @Description: 权限因子 */ package admin_controllers import ( "encoding/json" "fmt" "time" "vue-typescript-beego-admin/server/utils" ...
package timer import "time" func NewRealTimer(resetTime time.Duration)(*realTimer) { return &realTimer{ timer:time.NewTimer(resetTime), resetTime:resetTime, } } func (t *realTimer)Until(f func(), stopCh <-chan struct{}) { defer func() { t.timer.Stop() }() for { select { case <-stopCh: return defa...
// Copyright (C) 2017 Google 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 sfAuth import ( "fmt" "net/http" "sync" ) type SfAuth struct { SvcPath string AuthPlugin []Plugin AuthType AuthType Next http.Handler Mu sync.Mutex } type UserInfo struct { Token string UserName string ExpireTime int64 Tenant string } func...
package ontap import "encoding/xml" type NetappVolume struct { XMLName xml.Name `xml:"netapp"` Text string `xml:",chardata"` Version string `xml:"version,attr"` Xmlns string `xml:"xmlns,attr"` Results struct { Text string `xml:",chardata"` Status string `xml:"status,attr"` Attr...
package logger import ( "fmt" "github.com/sirupsen/logrus" "os" "runtime" ) // Logger is an alias to the logrus logger that provides additional // methods for bundle manipulation and reflection type Logger struct { *logrus.Logger } // Fields type-aliases the logrus.Fields so the package can be skipped within //...
package main import ( "fmt" "log" "net/http" ) type myMux struct{} func (mux *myMux) ServeHTTP(w http.ResponseWriter, r *http.Request) { if r.URL.Path == "/hello" { sayHello(w, r) return } http.NotFound(w, r) return } func sayHello(w http.ResponseWriter, r *http.Request) { fmt.Println("=============URL=...
package main import ( "reflect" "testing" "exeTwo.devThree/functions" ) func TestSortMain(t *testing.T) { var check = make(map[int][]string) check[1] = []string{"6. Iota June 3. Gamma March 5. Epsilon May 4. Delta April 2. Beta February 1. Alfa January"} for _, correctResult := range check { letTest := fun...
package database import ( "github.com/jinzhu/gorm" _ "github.com/jinzhu/gorm/dialects/postgres" ) func SetupDatabase(conn string) Database { db, err := gorm.Open("postgres", conn) if err != nil { panic("failed to connect database") } db.LogMode(true) // Migrate the schema if err := db.AutoMigrate(&Propert...
package main import ( log "github.com/cihub/seelog" "fmt" "github.com/yoheiMune/MyGoProject/002_logging/sub" ) func main() { /** SeeLogの調査. # 参照 https://github.com/cihub/seelog # インストール go get -u github.com/cihub/seelog */ defer log.Flush() // デフォルトで出力. log.Info("Hello from SeeLog!") // フォ...
package main import ( "context" "log" "google.golang.org/grpc" ) // implementing the gRPC Unary Interceptor func logger(ctx context.Context, req interface{}, info *grpc.UnaryServerInfo, handler grpc.UnaryHandler) (resp interface{}, err error) { log.Printf("---> Unary interceptor: %v\n", info.FullMethod) return ...
// Copyright 2017 The EvAlgo 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 evhtml import ( "errors" "testing" ) func Test_New(t *testing.T) { form := NewForm() if form.Name == "" { t.Log("Test_New passed!") } else ...
package algorithm import ( "fmt" "testing" ) // 描述 // 模拟筛选出把可以淘汰的服务器 // 用二维数组表示当前服务器的依赖关系 // 用一维数组表示提供需要淘汰的服务器 // 通过算法淘汰可以淘汰的服务器序列 // 规则:如果提供淘汰服务器之外还存在一定依赖关系则无法删除 // 例如:依赖服务器序列号:[[0,1,2], [0,4], [5,6]] 说明:0,1,2相互依赖,同时 0,4号机器也相互依赖,5,6也相互依赖 // 此时提供待淘汰服务器序列数组:[0,1,2,5,6] 因 0,1,2,4 相互依赖而 4 并非在淘汰列表中 所以 0,1,2 无法直接淘汰,5,6...
package currency import ( "golang.org/x/text/currency" ) // ConstantRates doesn't do any currency conversions and accepts only conversions where // both currencies (from and to) are the same. // If not the same currencies, it returns an error. type ConstantRates struct{} // NewConstantRates creates a new ConstantRa...
package main import ( "compiler/evaluator" "compiler/lexer" "compiler/object" "compiler/parser" "fmt" "io" "io/ioutil" "os" ) func main() { content, e := ioutil.ReadFile(os.Args[1]) if e != nil { io.WriteString(os.Stdout, fmt.Sprintf("Error: %q", e.Error()) ) } sourceCode := string(content) l := lexe...
package dto import ( "github.com/shopspring/decimal" "go-resk/src/entity/service_flag" "time" ) //账户创建对象 type AccountCreatedDTO struct { UserId string `validate:"required"` Username string `validate:"required"` AccountName string `validate:"required"` AccountType int CurrencyCode service_flag.Curr...
package abios import ( "net/url" "sync" "time" ) // Default values for the outgoing rate and size of request buffer. const ( default_requests_per_second uint = 5 default_requests_per_minute uint = 300 // Buffer one minutes worth of requests (this can not be changed at runtime) default_request_buffer_size = de...
package types import ( "github.com/irisnet/irishub/modules/auth" "github.com/irisnet/irishub/types" ) type AccountInfo struct { LocalAccountName string `json:"name"` Password string `json:"password"` AccountNumber string `json:"account_number"` Sequence string `json:"sequence"` Address ...
package def const ( SubModName = "network" BlockChain = "xuper" )
package agent import ( "encoding/json" "fmt" "os" "testing" "github.com/buildkite/agent/env" "github.com/stretchr/testify/assert" ) func TestPipelineParserParsesYaml(t *testing.T) { environ := env.FromSlice([]string{`ENV_VAR_FRIEND="friend"`}) result, err := PipelineParser{ Filename: "awesome.yml", Pipe...
/* Fetch a file from Google Cloud Storage Usage: gcs-fetch gs://bucket/object output-file */ package main import ( "fmt" "github.com/marksmithson/gcs-export/internal/pkg/gcsexport" "log" "os" ) func main() { if len(os.Args) < 3 { printUsage() os.Exit(1) } inputFilename := os.Args[1] gsObject := os.Arg...
package main import ( "bufio" "errors" "fmt" "github.com/slasyz/wundercli/api" "os" "strings" ) // Gets list object by its short name. // Works like shell tab completion. func getListByShortName(listName string) (list api.List, err error) { lists, err := api.GetLists() if err != nil { return } var sel []...
package main //1669. 合并两个链表 //给你两个链表 list1 和 list2 ,它们包含的元素分别为 n 个和 m 个。 // //请你将 list1 中下标从 a 到 b 的全部节点都删除,并将list2 接在被删除节点的位置。 // //下图中蓝色边和节点展示了操作后的结果: // // //请你返回结果链表的头指针。 // // // //示例 1: // // // //输入:list1 = [0,1,2,3,4,5], a = 3, b = 4, list2 = [1000000,1000001,1000002] //输出:[0,1,2,1000000,1000001,1000002,5] //解...
package base import ( "github.com/stretchr/testify/assert" "testing" ) func TestParams_Copy(t *testing.T) { // Create parameters a := Params{ NFactors: 1, Lr: 0.1, Type: Baseline, RandomState: 0, UserBased: true, } // Create copy b := a.Copy() b[NFactors] = 2 b[Lr] = 0.2 b[Typ...
// Copyright 2018 The Cockroach Authors. // // Use of this software is governed by the Business Source License // included in the file licenses/BSL.txt. // // As of the Change Date specified in that file, in accordance with // the Business Source License, use of this software will be governed // by the Apache License, ...
package log import ( "github.com/lestrrat-go/file-rotatelogs" "github.com/rifflock/lfshook" log "github.com/sirupsen/logrus" "time" ) func newLfsHook(logLevel int, maxRemainCnt uint) log.Hook { logName := "logs/peipei2" writer, err := rotatelogs.New( logName+".%Y%m%d", // WithLinkName为最新的日志建立软连接,以方便随着找到当前日志...
package main import ( "testing" ) var runDaemon RunDaemon func Test_runMysql(t *testing.T) { runDaemon.runMysql() } func Test_runRedis(t *testing.T) { runDaemon.runRedis() } func Test_runWeb(t *testing.T) { runDaemon.runWeb() } func Test_runWeb1(t *testing.T) { runDaemon.runWeb1() } func Test_runWeb2...
// Copyright (c) 2020 Tailscale Inc & 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 safesocket import ( "context" "fmt" "net" "syscall" ) func connect(path string, port uint16) (net.Conn, error) { pipe, err := net.Dia...
package patcher import ( "bufio" "encoding/json" "fmt" "github.com/phips4/discord-update-patcher/zip" "io/ioutil" "log" "os" "os/exec" "path" "path/filepath" "runtime" "strconv" "strings" "time" ) type Discord struct { dir string Version string modulesDir string } type DiscordModules map[s...
package snailframe func Welcome(r *RData) { m,_ := r.Query("aa") //re,_ := r.dbconn.Find("SELECT * FROM shici_info where id=?",m) //fmt.Println(re) re2 := map[string]interface{}{ "a":m, } r.ExecTpl("aaa",re2) }
package tips import ( "encoding/csv" "fmt" "io" "io/ioutil" "os" "reflect" "strconv" "testing" ) func readCSVFromFile(path string) (persons []person, err error) { f, err := os.Open(path) if err != nil { return nil, fmt.Errorf("Failed to open %s: %v", path, err) } defer func() { if cerr := f.Close(); e...
package main func main() { type num int var a = num(0) a = 5 }
package env import ( "sync" "github.com/kelseyhightower/envconfig" ) var ( env Env once sync.Once ) type Env struct { HttpUrl string `envconfig:"HTTP_URL" default:"localhost:8080"` MongoUrl string `envconfig:"MONGO_URL" default:"mongodb://localhost:27017"` KafkaBrokers []string `envconfig:"KAFK...