text
stringlengths
11
4.05M
package rmailer import ( "crypto/tls" "fmt" "github.com/dsnezhkov/deepsea/global" "gopkg.in/gomail.v2" thtml "html/template" ttext "html/template" "io" "path/filepath" "strings" ) func GenMail(username string, password string, server string, port int, usetls string, from string, subject string, bodyTextTem...
package main import "fmt" func main() { limit := 5 count := 0 var digit1 int var digit2 int var digit3 int fmt.Println("Три числа.") fmt.Println("Введите первое число:") fmt.Scan(&digit1) fmt.Println("Введите второе число:") fmt.Scan(&digit2) fmt.Println("Введите третье число:") fmt.Scan(&digit3) if di...
package xir type Operator string const ( EQ Operator = "=" LT = "<" LE = "<=" GT = ">" GE = ">=" CHOICE = "?" SELECT = "[]" ) type Constraint struct { Op Operator `json:"constraint__"` Value interface{} `json:"value__"` } func ...
package main import ( "fmt" "log" gecko "github.com/vladivolo/go-gecko/v3" ) func main() { tickers, err := gecko.CoinsIDTickers("bitcoin", 0) if err != nil { log.Fatal(err) } fmt.Println(tickers.Tickers) tickers, err = gecko.CoinsIDTickers("bitcoin", 1) fmt.Println(len(tickers.Tickers)) }
package scale import "strings" var ( chromatics = []string{"A", "A#", "B", "C", "C#", "D", "D#", "E", "F", "F#", "G", "G#"} flats = []string{"A", "Bb", "B", "C", "Db", "D", "Eb", "E", "F", "Gb", "G", "Ab"} ) func gen(t string, interval string, collection []string) []string { res := []string{} tonic := []run...
package clock import "fmt" type Clock struct { hour int minute int } const minutesPerDay = 24 * 60 func New(hour, minute int) Clock { var m int = (60*hour + minute) % minutesPerDay if m < 0 { m += minutesPerDay } return Clock{minute: m} } func (c Clock) String() string { return fmt.Sprintf("%02d:%02d"...
package stack import "testing" func TestStack(t *testing.T) { s := Stack{} size := s.Len for i := 1; i <= 10; i++ { // Test Push s.Push(i) } for i := 10; i >= 1; i-- { // Test Peek item, present := s.Peek() if !present { t.Error("Peek Error: Se...
package main import ( "fmt" "sync" ) /** 对比channel通信 和 指定内存 通信的性能 此为 指定内存 的方式 此程序为同步陷阱的范例 */ func main() { setMem := make(map[int]int) wg := sync.WaitGroup{} lk := sync.RWMutex{} for i := 0; i < 10; i++ { wg.Add(1) go func(wg *sync.WaitGroup) { fmt.Println("i ---- ", i) defer wg.Don...
// 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 main import ( "bufio" "bytes" "flag" "fmt" "log" "math/rand" "net" "os" "strings" "sync" "time" "unicode/utf8" "github.com/caffix/amass/amass" "github.com/domainr/whois" "github.com/miekg/dns" http "github.com/valyala/fasthttp" ) type Options struct { Domain string Wordlist string Th...
package main import "fmt" var a = test() func test() int { fmt.Println("test()") return 90 } func init() { fmt.Println("this is init") } func main() { fmt.Println("this is main") }
package httpgateway import ( "fmt" "time" ) var defaultLogger = Logger{} var CustomerLogger LogInterface = nil func GetLogger() LogInterface { if CustomerLogger == nil { return defaultLogger } else { return CustomerLogger } } // 定义log的接口 type LogInterface interface { Debug(format string) Info(format str...
package visualizer import "board" type NilVisualizer struct{} func (nv *NilVisualizer) Display(b *board.Board) { return }
// Copyright 2023 The gVisor 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 agree...
// Copyright 2021 The gVisor 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 agree...
/* * Neblio REST API Suite * * APIs for Interacting with NTP1 Tokens & The Neblio Blockchain * * API version: 1.3.0 * Generated by: OpenAPI Generator (https://openapi-generator.tech) */ package neblioapi type GetRawTxResponse struct { // Raw hex representing the transaction Rawtx string `json:"rawtx,omitempt...
package scanner import ( "github.com/juanibiapina/marco/tokens" "unicode" ) type stateFn func(*scanner) stateFn func scanNumber(l *scanner) stateFn { l.acceptRune('-') l.accept(unicode.IsDigit) l.emit(tokens.NUMBER) return scanInitial } func scanName(l *scanner) stateFn { l.accept(lexIdentifier) l.emit(tok...
package db import ( "fmt" "github.com/go-pg/pg" "github.com/go-pg/pg/types" log "github.com/sirupsen/logrus" ) type Flight struct { Id int `sql:"id"` Geometry types.Q `sql:"geom"` Latitude float64 `sql:"latitude"` Longitude float64 `sql:"longitude"` Country string `sql:"country"` CallSign s...
package storage import ( "testing" "github.com/twcclan/goback/storage/pack/packtest" "gocloud.dev/blob/fileblob" ) func TestCloudStore(t *testing.T) { dir := t.TempDir() bucket, err := fileblob.OpenBucket(dir, nil) //memblob.OpenBucket(nil) if err != nil { t.Fatal(err) } packtest.TestArchiveStorage(t, N...
// Copyright 2021 The ChromiumOS Authors // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. package cellular import ( "context" "chromiumos/tast/common/mmconst" "chromiumos/tast/local/modemmanager" "chromiumos/tast/testing" ) func init() { testing.AddTest(&t...
// http://sourceforge.net/p/proguard/code/ci/default/tree/src/proguard/retrace package main import ( "./frame" "bufio" "fmt" "log" "os" // "regexp" ) var STACK_TRACE_EXPRESSION = "(?:.*?\\bat\\s+%c\\.%m\\s*\\(%s(?::%l)?\\)\\s*)|(?:(?:.*?[:\"]\\s+)?%c(?::.*)?)" func retrace(mapping string, target string) { fi...
package restore import ( "context" "errors" "fmt" "github.com/go-logr/logr" helmclient "github.com/joelanford/helm-operator/pkg/client" "github.com/joelanford/helm-operator/pkg/hook" "github.com/prometheus/common/log" "helm.sh/helm/v3/pkg/chartutil" "helm.sh/helm/v3/pkg/release" "k8s.io/apimachinery/pkg/api...
package httputil // http返回分页数据结构 type pagination struct { Page int `json:"page"` Size int `json:"size"` Total int `json:"total"` TotalPages int `json:"total_pages"` } // http返回数据结构 type Response struct { Result interface{} `json:"result,omitempty"` Pagination *pagination `json:"pagination,o...
package main import ( "fmt" "time" ) func main() { fmt.Println(time.Now()) sleep(5) fmt.Println(time.Now()) } func sleep(second int) { <-time.After(time.Second * time.Duration(second)) }
package ops import ( "testing" ) func TestOps(t *testing.T) { data := []struct { name string initial []byte expected []byte ops []Op }{ { name: "nil ops", initial: []byte{}, expected: []byte{}, ops: nil, }, { name: "insert 1", initial: []byte{}, expected:...
package main import ( "fmt" "sync" "sync/atomic" ) func main() { var wg sync.WaitGroup var incrementer int64 g := 200 // number of goroutines hold := 0 wg.Add(g) for i := 0; i < g; i++ { go func() { atomic.AddInt64(&incrementer, 1) fmt.Println(atomic.LoadInt64(&incrementer)) wg.Done() }() } ...
package model import "github.com/jinzhu/gorm" type User struct { gorm.Model Name string `form:"Name" json:"Name" xml:"Name" binding:"required"` Id int }
package cmd import ( "fmt" "os" "github.com/spf13/cobra" ) //RootCmd is the base command for the cli var RootCmd = &cobra.Command{ Use: "comet", Short: "Comet is a temporary machine procurement and management system", } // Execute adds all child commands to the root command and sets flags appropriately. func...
package mr import ( "fmt" "log" "net" "net/http" "net/rpc" "os" "sync" "time" ) var mutex sync.Mutex //var finishedMutex sync.Mutex // //var mapTaskMutex sync.Mutex // //var reduceTaskMutex sync.Mutex type TaskStatus int type Phase int type WorkerTaskStatus int const ( NotYetStarted TaskStatus = iota D...
package data type ProcessChain interface { Map(m MappingFunction) ProcessChain Filter(f FilterFunction) ProcessChain Sort(c CompareFunction) ProcessChain WithPool(p ProcessorPool) ProcessChain Unordered() ProcessChain Parallel(n int) ProcessChain Process(data Iterable) ProcessingResult } type chain_operation ...
package govern_token import pb "github.com/xuperchain/xupercore/protos" type GovManager interface { GetGovTokenBalance(accountName string) (*pb.GovernTokenBalance, error) DetermineGovTokenIfInitialized() (bool, error) }
// Copyright 2021 The ChromiumOS Authors // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. // Package hermes provides D-Bus wrappers and utilities for Hermes. // https://chromium.googlesource.com/chromiumos/platform2/+/HEAD/hermes/README.md package hermes import (...
package dashboard import ( "github.com/keptn-contrib/dynatrace-service/internal/adapter" "github.com/keptn-contrib/dynatrace-service/internal/dynatrace" keptncommon "github.com/keptn/go-utils/pkg/lib" keptnv2 "github.com/keptn/go-utils/pkg/lib/v0_2_0" log "github.com/sirupsen/logrus" "time" ) func createDefault...
package motherboard import ( "fmt" "time" "github.com/funsun/peridot/common" ) type busMapper struct { Start, Offset uint16 Target common.Bus Remap bool } type Router struct { mappers []*busMapper } func (r *Router) Init() *Router { r.mappers = []*busMapper{} return r } func (r *Router) Re...
package main import "fmt" func fab(n int) int { if n == 1 || n == 2 { return 1 } else { return fab(n-1) + fab(n-2) } } func main() { var n int n = 6 result := fab(n) fmt.Println(result) }
package main // Leetcode 5753. (hard) func largestPathValue(colors string, edges [][]int) int { in := make([]int, len(colors)) g := make([][]int, len(colors)) for i := range edges { in[edges[i][1]]++ g[edges[i][0]] = append(g[edges[i][0]], edges[i][1]) } q := []int{} for i := range in { if in[i] == 0 { ...
// Copyright 2021 The ChromiumOS Authors // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. package nearbyshare import ( "context" "strings" "time" nearbycommon "chromiumos/tast/common/cros/nearbyshare" "chromiumos/tast/errors" "chromiumos/tast/local/chrome/...
package view import ( "time" "github.com/jinzhu/gorm" "github.com/lib/pq" "github.com/caos/zitadel/internal/errors" token_model "github.com/caos/zitadel/internal/token/model" "github.com/caos/zitadel/internal/token/repository/view/model" "github.com/caos/zitadel/internal/view/repository" ) func TokenByID(db ...
package main import ( "flag" "fmt" "github.com/antonholmquist/jason" "github.com/patrickmn/go-cache" "html" "io/ioutil" "net/http" "path/filepath" "strconv" "strings" "time" "log" ) var type_string = flag.String("type", "http", "Listen type (http or tcp)") var tcp_port_string = flag.String("tcp.port", "80...
package main import ( "testing" ) func TestSplitDockerImageRepository(t *testing.T) { registry, repository, tag := splitDockerImage("ubuntu") if registry != "" { t.Fail() } if repository != "ubuntu" { t.Fail() } if tag != "" { t.Fail() } dockerImage := DockerImage{ Registry: registry, Repositor...
// Copyright 2018 High Fidelity, Inc. // // Distributed under the Apache License, Version 2.0. // See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html package cmd import ( "errors" "log" "github.com/spf13/cobra" "github.com/highfidelity/bens/cnf" "github.com/highfidelity/bens/ke...
/* * Copyright IBM Corporation 2021 * * 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 rundeck import ( "bytes" "encoding/json" "fmt" "io/ioutil" "net/http" "net/http/cookiejar" "net/url" "strings" ) const ( defaultAPIVersion = 30 contentTypeJSON = "application/json" ) type ClientParams struct { APIVersion int ServerUrl, Username, Password string } type Client s...
package main import ( "flag" "fmt" "net/http" "os" "strings" "time" ) func main() { var url = flag.String("url", "http://localhost/", "URL to poll") var responseCode = flag.Int("code", 200, "Response code to wait for") var timeout = flag.Int("timeout", 2000, "Timeout before giving up in ms") var interval = ...
package main import ( "flag" "fmt" "time" "sunteng/commons/confutil/light" gn_adx "gungnir/model/adx" ) func main() { flag.Parse() err := light.LoadIndex() if err != nil { fmt.Println(err) return } gn_adx.InitDict([]int64{20066}, gn_adx.CATEGORY) fmt.Printf("\n\n\n===== Start: get value in golang ...
package message import "errors" //ErrInvalidReply 无效的回复 var ErrInvalidReply = errors.New("无效的回复消息") //ErrUnsupportReply 不支持的回复类型 var ErrUnsupportReply = errors.New("不支持的回复消息") // ReplyScene 返回场景 type ReplyScene string const ( // ReplySceneKefu 客服场景 ReplySceneKefu ReplyScene = "kefu" // ReplySceneOpen 开放平台 Repl...
package agent import ( "encoding/json" "fmt" log "github.com/spf13/jwalterweatherman" "org.openappstack/singularity/api" "org.openappstack/singularity/pluginmanager" store "org.openappstack/singularity/store" "os" "path/filepath" ) // configuration related error type ConfigError string // configuration as lo...
package unchainer import ( "encoding/json" "errors" "io/ioutil" "net/http" "net/url" "os" "time" ) func isPath(path string) bool { fi, err := os.Stat(path) return !os.IsNotExist(err) && !fi.IsDir() } func isURL(path string) bool { _, err := url.ParseRequestURI(path) return err == nil } // Load loads fi...
package main import ( "bufio" "flag" "fmt" "log" "os" "regexp" Aurora "github.com/logrusorgru/aurora" ) func main() { version := "1.0.0" filepath := flag.String("filepath", "", "The file to parse") flag.Parse() if *filepath == "" { fmt.Println(Aurora.Gray(1-1, "Error:").BgRed(), "I need a WordPress sl...
// Copyright 2021 The ChromiumOS Authors // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. package apps import ( "context" "path/filepath" "time" "chromiumos/tast/ctxutil" "chromiumos/tast/errors" "chromiumos/tast/local/apps" "chromiumos/tast/local/chrome"...
package bowling // Score a game of bowling. func Score(rolls []int) int { score := 0 for _, roll := range rolls { if roll < 0 || roll > 10 { // Illegal number of pins. return -1 } } for frame := 1; frame <= 10; frame++ { if len(rolls) < 2 { // Incomplete frame. return -1 } if rolls[0] != 10...
/* Copyright The containerd 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...
package orm import ( "log" base "github.com/jinzhu/gorm" ) type Model base.Model type Settings struct { Driver string Path string } var DB *base.DB var settings Settings func Initialize(driver, path string) { log.Println("Initialize Gorm") if driver == "sqlite" { driver = "sqlite3" } settings = Settin...
package netinterface type IConnector interface { WriteToChan([]byte) error ReadFromChan() ([]byte, error) } type ISvrSocket interface { WriteToChan([]byte) error } type ICliSocket interface { Connect() error }
// Copyright 2021 The ChromiumOS Authors // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. package wilcoextension import ( "context" "encoding/json" "fmt" "time" "chromiumos/tast/errors" "chromiumos/tast/local/chrome" "chromiumos/tast/testing" ) // NewCon...
package controller import ( "reflect" "google.golang.org/protobuf/proto" "gamesvr/manager" "gamesvr/session" "shared/utility/router" ) func NewGameRoute() (*router.Router, error) { gsRouter := router.NewRouter() err := gsRouter.RegisterHandler(&session.Session{}, router.WithConfig(manager.CSV.Protocol.Proto...
// Copyright (C) 2020 Storj Labs, Inc. // See LICENSE for copying information. // Package testcontext implements convenience context for testing. package testcontext import ( "context" "fmt" "os" "path/filepath" "runtime" "runtime/pprof" "strings" "sync" "time" "golang.org/x/sync/errgroup" "storj.io/comm...
package main import ( "math" "runtime" "time" "github.com/h2non/bimg" ) var start = time.Now() // Version stores the current package semantic version const Version = "0.5.1" const MB float64 = 1.0 * 1024 * 1024 // Version represents the supported version type Versions struct { ResizeVersion string `json:"tto...
package aliyun import ( "bytes" "crypto/hmac" "crypto/md5" "crypto/sha1" "demo/lib/uuid" "encoding/base64" "encoding/json" "fmt" "io/ioutil" "net/http" "net/url" "strings" "time" ) type DefaultClient struct { Profile Profile } const host string = "http://green.cn-shanghai.aliyuncs.com" const method str...
/* Copyright 2018 Benjamin Bennett 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 wrapper import ( "testing" "github.com/golang/mock/gomock" ) func TestProxyChargeMeter(t *testing.T) { ctrl := gomock.NewController(t) defer ctrl.Finish() tc := []float64{600, 1000, 2000} m := ChargeMeter{} for _, f := range tc { m.SetPower(f) if p, err := m.CurrentPower(); p != f || err != nil...
/** * Copyright (c) 2018-present, MultiVAC Foundation. * * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. */ // This file defines the relevant interfaces and logic that proxies routing and dispatching work to shards. package controller i...
package functions import ( "fmt" "kubeitcli/httpd" "kubeitcli/httpd/requests" "os" ) func GetResults(name string, rClient *httpd.RequestClient) { status, _, _ := requests.GetStatus("", name, rClient) if status[0].Status != "Succeeded" { fmt.Println("[GET RESULTS] Error: Workflow not finished, status: " + st...
package recursion type TreeNode struct { Val int Left *TreeNode Right *TreeNode } func invertTree(root *TreeNode) *TreeNode { if root == nil { return nil } left := root.Left right := root.Right root.Left = invertTree(right) root.Right = invertTree(left) return root }
// Copyright 2017 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 a...
package entities import ( "errors" "fmt" "time" ) type Task struct { Id string Name string Description string UpdatedAt time.Time } func (task Task) Equal(dst Task) bool { return task.Id == dst.Id && task.Name == dst.Name && task.Description == dst.Description && task.UpdatedAt.Equal(...
package main import ( "io/ioutil" "log" "net/http" "os" "go.bourbon.stream/go-vanityurls-apex/handler" yaml "gopkg.in/yaml.v2" ) func main() { addr := ":" + os.Getenv("PORT") h, err := handler.NewHandler(fileFetcher{path: "vanity.yaml"}) if err != nil { log.Fatal(err) } http.Handle("/", h) if err := h...
package orderController import ( "github.com/gin-gonic/gin" "github.com/thoas/go-funk" "github.com/ulule/deepcopier" productModel2 "hd-mall-ed/packages/admin/models/productModel" "hd-mall-ed/packages/client/models/orderModel" "hd-mall-ed/packages/client/models/productModel" "hd-mall-ed/packages/client/models/sh...
package main import ( "bufio" "fmt" "os" "sync" "time" "github.com/aws/aws-sdk-go/aws" "github.com/aws/aws-sdk-go/aws/session" "github.com/aws/aws-sdk-go/service/s3" ) const ( MIN_CHAN_BUF_SIZE = 8 CHAN_BUF_SIZE = 64 MAX_ITEMS_PER_PAGE = 1000 ) type S3utils struct { svc *s3.S3 } type Stat struct ...
package config func GetConfig(k string) interface{} { configLock.RLock() defer configLock.RUnlock() v := configMap[k] return v }
package api import ( "Backend/cisco" "Backend/resources" "encoding/json" "fmt" "net/http" ) func ServeInterfaces(w http.ResponseWriter, r *http.Request) { if origin := r.Header.Get("Origin"); origin != "" { w.Header().Set("Access-Control-Allow-Origin", origin) w.Header().Set("Access-Control-Allow-Methods",...
package thermal_zone import ( "fmt" "github.com/influxdata/telegraf/plugins/parsers" "io/ioutil" "os" "path/filepath" "strconv" "strings" "sync" "github.com/influxdata/telegraf" "github.com/influxdata/telegraf/plugins/inputs" ) type ThermalZoneItem struct { atype string temp_path string } type Therm...
package server import ( "context" "github.com/pingcap-incubator/tinykv/kv/coprocessor" "github.com/pingcap-incubator/tinykv/kv/raftstore/util" "github.com/pingcap-incubator/tinykv/kv/storage" "github.com/pingcap-incubator/tinykv/kv/storage/raft_storage" "github.com/pingcap-incubator/tinykv/kv/transaction/latches...
// Copyright 2020 Insolar Network Ltd. // All rights reserved. // This material is licensed under the Insolar License version 1.0, // available at https://github.com/insolar/block-explorer/blob/master/LICENSE.md. package configuration import ( "time" "go.opencensus.io/stats/view" ) func init() { // todo fix prob...
package framework import ( "context" "fmt" "time" netv1 "k8s.io/api/networking/v1" apierrors "k8s.io/apimachinery/pkg/api/errors" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/apimachinery/pkg/util/wait" v1net "k8s.io/client-go/kubernetes/typed/networking/v1" "github.com/onsi/gomega" ) // NetworkPo...
// Copyright 2020 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, ...
// +build race package timestr import ( "sync" "time" ) var timeStrMutex = sync.RWMutex{} func init() { UpdateTimeStr() go func() { for range time.NewTicker(1 * time.Second).C { timeStrMutex.Lock() UpdateTimeStr() timeStrMutex.Unlock() } }() } func Now() time.Time { timeStrMutex.RLock() defer t...
package jsonq import ( "encoding/json" "fmt" "strings" "testing" ) const TestData = `{ "foo": 1, "bar": 2, "test": "Hello, world!", "baz": 123.1, "numstring": "42", "floatstring": "42.1", "array": [ {"foo": 1}, {"bar": 2}, {"baz": 3} ], "subobj": { "foo": 1, "subarray": [1,2,3], "subsubobj": ...
/* * @Author: ybc * @Date: 2020-07-22 15:51:25 * @LastEditors: ybc * @LastEditTime: 2020-08-17 15:04:17 * @Description: 工具 */ package services import ( "io/ioutil" "net" "os" "regexp" "strconv" "strings" "sync" ) type FileInfo struct { File os.FileInfo Path string } func PathExists(path string) (os.F...
package game import ( "github.com/gin-gonic/gin" "net/http" "xj_web_server/db" "xj_web_server/httpserver/servermiddleware" "xj_web_server/model" "xj_web_server/module" "xj_web_server/util" ) type GetAllGameVersionReq struct { servermiddleware.BaseReq Platform string `json:"platform" binding:"required"` } f...
package main import ( "github.com/gorilla/websocket" "net/http" "math/rand" "time" "encoding/json" "strconv" "fmt" ) func random(min, max int) int { rand.Seed(time.Now().Unix()) return rand.Intn(max - min) + min } type Hub struct{ clients map[*Client] int broadcast ch...
package main import ( "github.com/stretchr/testify/assert" "testing" ) type Test struct { input string expected1 int expected2 int } func TestSolve(t *testing.T) { assert := assert.New(t) tests := []Test{ Test{input: "2x3x4", expected1: 58, expected2: 34}, Test{input: "1x1x10", expected1: 43, expected...
package mysql import ( "database/sql" "os" "reflect" "strings" "testing" "github.com/db-journey/migrate/v2/direction" "github.com/db-journey/migrate/v2/driver" "github.com/db-journey/migrate/v2/file" ) // TestMigrate runs some additional tests on Migrate(). // Basic testing is already done in migrate_test.go...
package service import ( "github.com/16francs/examin_go/domain/model" "github.com/16francs/examin_go/domain/repository" ) // TTagService - 講師向け タグ モデルの操作 type TTagService interface { CreateTag(tag *model.Tag) (*model.Tag, error) } type tTagService struct { repository repository.TTagRepository } // NewTTagServic...
// 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 cmd import ( "fmt" "log" "os" "os/exec" "path/filepath" "sort" "strings" "github.com/Azure/azure-sdk-for-go/tools/generator/autorest" "github.com/Azure/azure-sdk-for-go/tools/generator/changelog" "github.com/Azure/azure-sdk-for-go/tools/generator/model" "github.com/spf13/cobra" ) const ( defaultO...
package dbModel type Catalog struct { } func (Catalog) tableName() string { return "catalog" } func (t Catalog) TableName() string { return GetGwContribAdminTableName(t.tableName()) }
package product type Product struct { name string canChanged bool } func NewProduct(productManager *ProductManager, name string) *Product { res := &Product{} if productManager.isPermittedCreate { res.name = name res.canChanged = true } return res } func (s *Product)Name() string { return s.name } func...
package models import ( "math/big" lpb "github.com/xuperchain/xupercore/bcs/ledger/xledger/xldgpb" sctx "github.com/xuperchain/xupercore/example/xchain/common/context" xctx "github.com/xuperchain/xupercore/kernel/common/xcontext" ecom "github.com/xuperchain/xupercore/kernel/engines/xuperos/common" "github.com/x...
/** * Copyright 2020 Comcast Cable Communications Management, LLC * * 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 requir...
package states import ( "encoding/json" "log" "net/http" "sort" "strconv" "github.com/go-chi/chi" "github.com/kpurdon/apiresponse" "github.com/kpurdon/locationapi/internal/locationsdb" "github.com/kpurdon/locationapi/models" ) // Routes ... TODO func (h Handler) Routes() chi.Router { r := chi.NewRouter() ...
package jprimego import ( "container/list" "crypto/rand" "math/big" ) // FastGeneratePrime find prime number by finding nearest prime of a large integer func FastGeneratePrime(bitLength int64) *big.Int { var TWO = new(big.Int).SetInt64(2) var THREE = new(big.Int).SetInt64(3) BL := new(big.Int).SetInt64(int64(b...
package controllers import ( "encoding/json" "io" "net/http" ) func RegisterControllers() { uc := newUserController() //in Go, /users and /users/ are treated as if different so we need to // explicitly have both http.Handle("/users", *uc) http.Handle("/users/", *uc) } /** creates an encoder and encore the d...
package dmx import ( "encoding/json" "github.com/prebid/prebid-server/openrtb_ext" "testing" ) func TestValidParams(t *testing.T) { validator, err := openrtb_ext.NewBidderParamsValidator("../../static/bidder-params") if err != nil { t.Fatalf("Failed to fetch the json-schemas. %v", err) } for _, validParam :...
package solver import ( "libRPSO/vector" "math" "math/rand" ) type Bound struct { XUpper float64 XLower float64 VUpper float64 VLower float64 } type Solution struct { position []float64 evalValue float64 velocity []float64 } type InitSolutionFunc func(bound *Bound, dim int) *Solution func NewSolution(p...
package base import ( "gonum.org/v1/gonum/stat" "sync" ) /* Parallel Computing */ // Parallel runs tasks in parallel. func Parallel(nTask int, nJob int, worker func(begin, end int)) { var wg sync.WaitGroup wg.Add(nJob) for j := 0; j < nJob; j++ { go func(jobId int) { begin := nTask * jobId / nJob end :=...
package logic import ( "time" ) type UserId interface { GetIdType() string GEtIdValue() string } type AdOpptunities interface { GetAdOpptunities() []AdOpptunity } type CandidateAds interface { GetCandidateAd() CandidateAd CandidateAds() } //version0.1 we only need to filter // 1.time // 2.location // 3.Platfo...
package stackArrayDynamic type stackArrayDynamic struct { }
package blockchain import ( "blockchain-go/utils" "bytes" "crypto/rand" "encoding/binary" "time" ) func ChooseHolder() { // 每10分钟产生一个新块 time.Sleep(10 * time.Minute) bc = BC() optionPool := make([][]byte, 0) //TODO 加锁 length := len(TmpBlocks) if length > 0 { for _, tmp := range TmpBlocks { //TODO 检查...
package utils import ( "testing" ) func TestSignJWT(t *testing.T) { userID := "1" token, err := SignJWT(&userID) if err != nil { t.Error(err) } t.Log(*token) }