text
stringlengths
11
4.05M
package chess type SquareSet struct { mask uint64 } func NewSquareSet(mask uint64) *SquareSet { return &SquareSet{mask} } func (s *SquareSet) Iter() <-chan int { ch := make(chan int) go func() { square := bitScan(s.mask, 0) for square != -1 { ch <- square square = bitScan(...
package gopbox import ( "net/url" "unicode" "github.com/polluxxx/goauth2" ) const ( AuthUrl = "https://www.dropbox.com/1/oauth2/authorize" TokenUrl = "https://api.dropbox.com/1/oauth2/token" MetaUrl = "https://api.dropbox.com/1/" ContentUrl = "https://api-content.dropbox.com/1/" ) type DropboxApi str...
package main import "fmt" func main() { x := []int{1, 2, 3, 4, 5} for i, v := range x[2:] { fmt.Println(i, v) } } func minArray(numbers []int) int { for i, v := range numbers[1:] { i = v * i con } return 0 }
package object import ( "ganymede/vector" ) // NewRectangleObject creates a new rectangle func NewRectangleObject(w float64, h float64, mass float64, position vector.Vector) Rectangle { return Rectangle{ vector.NewVector(w, h), NewGenericObject(mass, position, collisionBoundingBox), } } // Rectangle is an obj...
package tree import ( "fmt" "math/rand" "testing" "time" ) func TestCreateTree(t *testing.T) { r := rand.New(rand.NewSource(10)) r.Seed(time.Now().UnixNano()) a := r.Perm(30) fmt.Println("create a slice:", a) var tree *AvlNode for _, v := range a { tree = Insert(tree, ElementType(v)) } ...
// 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 load import ( "github.com/skudasov/loadgen" ) func CheckFromName(name string) loadgen.RuntimeCh...
package main import ( "bufio" "bytes" "flag" "io/ioutil" "path/filepath" "testing" ) var update = flag.Bool("update", false, "update .golden files") func TestToJSON(t *testing.T) { testtable := []struct { tname string }{ { tname: "ok", }, } for _, tc := range testtable { t.Run(tc.tname, func(t *...
// Package log contains simple leveled logging implementation on top of stdlib logger. // NOTE: without "only stdlib" constraint I would use github.com/uber-go/zap for logging. package log import ( "encoding/json" "errors" "fmt" "io" "log" "os" "strconv" "strings" ) // Logger interface is subset of github.com...
package controller import ( "api/models" "api/utils/inject" ) var BaseModel = &models.BaseModels{} type Controllers struct { Hello *HelloController `auto:"helloController"` Test *TestController `auto:"testController"` } func (ctx *Controllers) New() { BaseModel.New() inject.Register("baseController", ctx) ...
package main import ( "fmt" "./lexer" "./parser" ) func main() { //const ( // RLPL = iota // lex // RPPL // parse // REPL // evalutate //) //replType := REPL //var input io.Reader // //if len(os.Args) >= 2 { // input, _ = os.Open(os.Args[1]) //} else { // input = os.Stdin //} // //f...
package repository import ( "encoding/csv" "errors" "fmt" "io" "log" "time" "github.com/jesus-mata/academy-go-q12021/application/repository" "github.com/jesus-mata/academy-go-q12021/domain" "github.com/jesus-mata/academy-go-q12021/infrastructure" "github.com/jesus-mata/academy-go-q12021/infrastructure/newsa...
// Copyright (C) 2019 Storj Labs, Inc. // See LICENSE for copying information. package fpath import ( "os" "path/filepath" "github.com/zeebo/errs" ) // AtomicWriteFile is a helper to atomically write the data to the outfile. func AtomicWriteFile(outfile string, data []byte, _ os.FileMode) (err error) { // TODO:...
package logger_test import ( "context" "testing" "github.com/jonbodner/proteus/logger" ) func TestLogging(t *testing.T) { logger.Log(logger.WithLevel(context.Background(), logger.DEBUG), logger.DEBUG, "this is a message", []logger.Pair{ {"Foo", "Bar"}, {"int", 1}, {"bool", true}, {"float", 3.14}, {"str...
package main import ( "fmt" "os" "github.com/smartcontractkit/substrate-adapter/adapter" ) func main() { fmt.Println("Starting Substrate adapter") privkey := os.Getenv("SA_PRIVATE_KEY") txType := os.Getenv("SA_TX_TYPE") endpoint := os.Getenv("SA_ENDPOINT") port := os.Getenv("SA_PORT") adapterClient, err :...
package leetcode func lengthOfLongestSubstring(s string) int { length := len(s) var norepeat int for i := range s { smap := make(map[byte]bool) var tmp int for j := i; j < length; j++ { _, ok := smap[s[j]] if ok { tmp = j - i break } else { smap[s[j]] = true } tmp = j + 1 - i } ...
// 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 users import ( "RBStask/app/models/entity" "RBStask/app/models/mappers" "database/sql" "fmt" // "RBStask/app/controllers" // _ "github.com/lib/pq" ) type UserProvider struct { db *sql.DB users *mappers.UserMapper } func (p *UserProvider) Init() error { connStr := "host=localho...
// Copyright 2021 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, ...
// Copyright 2021 The CUE 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 aggregation contains the GalleryAggregator for Google+ event pictures. package aggregation import ( "encoding/base64" "encoding/json" "fmt" "net/http" "net/http/httptest" "strings" timepkg "time" "github.com/PuerkitoBio/goquery" "github.com/sourcegraph/webloop" "code...
package main import ( "fmt" ) func main() { var a, k, p, ans int fmt.Scan(&a) k = 0 p = 0 f := []int{} if a == 1 { fmt.Println("1") } else { for i := 1; i <= a+1; i++ { k = k + i p = p + k if p == a { ans = i } if p > a { f = append(f, i) break } } for _, j := range f { ...
package main import ( "encoding/hex" "fmt" "net/http" ) var stuff []byte var out []byte var out2 []byte func handler1(w http.ResponseWriter, r *http.Request) { n, err := w.Write(out) if n != len(out) { fmt.Println("Short write!") } if err != nil { fmt.Println(err) } } func handler2(w http.ResponseWriter...
package main import ( "encoding/json" "flag" "github.com/gorilla/mux" "github.com/wilsonfv/todolist/app/controller" "github.com/wilsonfv/todolist/app/dao" "github.com/wilsonfv/todolist/app/model" "log" "net/http" ) var td = dao.TaskDao{} func ListTask(w http.ResponseWriter, r *http.Request) { log.Println("L...
package main import ( "fmt" ) func test() { // var x float64 = 3.4 // var x = 3.4 // var y string = "abc" // var y = "abc" // var a uint8 = 10 // var b uint16 = 10 // var c int = 100 // var c = 100 // fmt.Println("x's type:", reflect.TypeOf(x)) // fmt.Println("y's type:", reflect.TypeOf(y)) // fmt.Printl...
package main import ( "context" "fmt" "time" "github.com/bketelsen/microclass/module4/userservice/proto/account" "github.com/micro/go-micro/client" "github.com/micro/profile-srv/proto/record" ) func main() { cl := account.NewAccountClient("go.micro.srv.user", client.DefaultClient) req := &account.LoginReques...
package main import ( "os" "github.com/ray-g/dnsproxy/dnsproxy" "github.com/ray-g/dnsproxy/utils" ) func main() { dnsproxy.Serve(os.Args[1]) utils.WaitSysSignal() }
package day02 import ( "testing" "github.com/wistler/aoc-2020/internal/io" ) func TestWithSampleData(t *testing.T) { input := []string{ "1-3 a: abcde", "1-3 b: cdefg", "2-9 c: ccccccccc", } part1Ans := 2 part2Ans := 1 got, err := part1(input) check(err) if got != part1Ans { t.Fatalf(`Part 1: got %v...
package nan import ( "log" "math" ) // START OMIT func Log(x float64) float64 { if x <= 0.0 { log.Panicf("x (%v) <= 0", x) } return math.Log(x) } // END OMIT
// Common methods for Expiry packages package expiry import ( "fmt" "time" ) type clock interface { Now() time.Time } type realClock struct{} func (r realClock) Now() time.Time { return time.Now() } // Handles tracking of expiration times. // This is intentionally _not_ an interface // The way the Expiry packag...
package main import ( "encoding/json" "fmt" "os" ) func main() { var i interface{} dec := json.NewDecoder(os.Stdin) if err := dec.Decode(&i); err != nil { fmt.Fprintf(os.Stderr, "Error parsing json: %v\n", err) os.Exit(1) } enc := json.NewEncoder(os.Stdout) enc.SetIndent("", " ") if err := enc.Encode(i...
/* Copyright © 2021 Author : mehtaarn000 Email : arnavm834@gmail.com */ package utils import ( "os" "path/filepath" "strings" ) // Create creates files and directories recursively (and returns a write object) func Create(p string) (*os.File, error) { if err := os.MkdirAll(filepath.Dir(p), 777); err != nil { re...
package acmetool import kingpin "gopkg.in/alecthomas/kingpin.v2" type App struct { CommandLine *kingpin.Application Commands map[string]func(Ctx) }
package todotxt import ( "fmt" "sort" ) // TaskSegmentType represents type of segment in task string. //go:generate stringer -type TaskSegmentType -trimprefix Segment -output segment_type.go type TaskSegmentType uint8 // Flags for indicating type of segment in task string. const ( SegmentIsCompleted TaskSegmentTy...
// 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 appsplatform import ( "context" "time" "chromiumos/tast/ctxutil" "chromiumos/tast/local/chrome/uiauto/faillog" "chromiumos/tast/local/playbilling/dgapi2" "chr...
package fileUtil import ( "archive/tar" "compress/gzip" "fmt" "io" "os" "path" "path/filepath" ) // Tar压缩(不支持压缩目录哦) // 参数: // sourceList:需要压缩的文件路径列表 //targetPath:压缩到目标路径 // 返回值: // 1.错误对象 func Tar(sourceList []string, targetPath string) error { targetFile, err := os.Create(targetPath) if err != nil { retur...
// Copyright 2018 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...
package retry import ( "context" "testing" "time" ) func immediateTimeAfter(time.Duration) <-chan time.Time { c := make(chan time.Time, 1) c <- time.Now() return c } func TestBackoffRetries(t *testing.T) { // make backoff return immediately Clock.After = immediateTimeAfter ctx := context.Background() backo...
package services import ( "github.com/devmaufh/golang-api-rest/models" ) //ModuleServiceInteface build and interface for access to service implementation type ModuleServiceInteface interface { Save(models.Module) models.Module FindAll() []models.Module } type moduleService struct { modules []models.Module } //N...
// +build linux package smnet import ( "bufio" "fmt" "github.com/safchain/ethtool" "log" "net" "os/exec" "regexp" "strconv" "strings" "github.com/influxdata/telegraf" "github.com/influxdata/telegraf/filter" "github.com/influxdata/telegraf/plugins/inputs" "github.com/influxdata/telegraf/plugins/inputs/sy...
package cli import ( "fmt" "os" "runtime" "strings" "testing" "github.com/alessio/shellescape" "github.com/stretchr/testify/require" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/apimachinery/pkg/types" "k8s.io/cli-runtime/pkg/genericclioptions" "github.com/tilt-dev/tilt/pkg/apis/core/v1alpha1" "...
package main import ( "fmt" "log" "os" ) func main() { file, err := os.Create("index.jsp") if err != nil { log.Fatal("Cannot create file", err) } defer file.Close() v := os.Getenv("name") s := `<html> <body> <h2>Hello `+ v +` the Server x2 is running!</h2> <h1>Test to put the artifact on Bitbucket reposit...
package app import ( "fmt" "go.uber.org/dig" ) type ( // @ctor SomeStruct struct{} // @ctor SomeInterface interface{} ) // Start the application which invoked from main() function in cmd package. func Start(di *dig.Container, text string) { // "text" is provided by dependency-injection fmt.Println(text) /...
package template_validator import ( "fmt" admission "k8s.io/api/admissionregistration/v1" apps "k8s.io/api/apps/v1" v1 "k8s.io/api/core/v1" rbac "k8s.io/api/rbac/v1" "k8s.io/apimachinery/pkg/api/errors" "k8s.io/apimachinery/pkg/runtime" lifecycleapi "kubevirt.io/controller-lifecycle-operator-sdk/pkg/sdk/api" ...
package main import ( "encoding/gob" "fmt" "net" "os" ) type Person struct { Name Name Email []Email } type Name struct { Family string Last string } type Email struct { Kind string Address string } func (p Person) String() string { s := p.Name.Last + " " + p.Name.Family for _, v := range p.Email...
package stack // simpleStack implements a non-thread safe Stack. type simpleStack[T any] []T // newSimpleStack returns a new non-thread safe Stack. func newSimpleStack[T any]() *simpleStack[T] { return new(simpleStack[T]) } // Push pushes an element onto the top of this Stack. func (s *simpleStack[T]) Push(element ...
package main import ( "strings" "testing" ) const testData = `1, 1 1, 6 8, 3 3, 4 5, 5 8, 9` func TestTask1(t *testing.T) { points := loadData(strings.Split(testData, "\n")) if calculateLargestArea(points) != 17 { t.Fail() } } func TestTask2(t *testing.T) { points := loadData(strings.Split(testData, "\n")) ...
package balancer import ( "github.com/fufuok/load-balancer/internal/doublejump" "github.com/fufuok/load-balancer/utils" ) // JumpConsistentHash type consistentHash struct { count int h *doublejump.Hash } func NewConsistentHash(choices ...*Choice) (lb *consistentHash) { lb = &consistentHash{} lb.Update(choi...
package main import "fmt" const INT_MAX = int(^uint(0) >> 1) const INT_MIN = ^INT_MAX func (t *BST) isValid() bool { if t.root != nil { return t.root.left._isValid(INT_MIN, t.root.data) && t.root.right._isValid(t.root.data, INT_MAX) } // empty tree is valid, right? return true } func (n *Node) _isValid(min,...
package storage import ( "fmt" "github.com/jinzhu/gorm" _ "github.com/jinzhu/gorm/dialects/sqlite" "keysiron/config" ) func connectMySQL() (db *gorm.DB, err error) { var connStr = fmt.Sprintf( "%s:%s@tcp(%s:%d)/%s?charset=utf8&parseTime=True&loc=Local", config.KeysironConfigVar.Database.User, config.Keysir...
package main import ( "github.com/g3force/go-blink1" "github.com/g3force/qaBlink/config" "github.com/g3force/qaBlink/watcher" "log" "os" "sort" "strings" "time" ) var CONFIG_LOCATIONS = []string{"config.json", os.Getenv("HOME") + "/.qaBlink.json"} type QaBlinkSlot struct { Id string Jobs []watcher.QaBlin...
package parser import ( "github.com/antlr/antlr4/runtime/Go/antlr" "github.com/colinking/go-sqlite3-native/internal/parser/generated" "github.com/colinking/go-sqlite3-native/internal/vm" ) //go:generate antlr -Dlanguage=Go -o generated -package generated SQL.g4 func Parse(query string) ([]vm.Instruction, error) {...
/* Copyright 2019 The Skaffold 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, sof...
package main import "github.com/alidevjimmy/go-echo-train/app" func main() { app.StartApplocation(":8080") }
package main import ( "strings" "testing" ) func TestPangram(t *testing.T) { for k, v := range map[string]string{ "A quick brown fox jumps over the lazy dog": "NULL", "A slow Yellow fox crawls Under the proactive dog": "bjkmqz"} { if r := pangram(k); r != v { t.Errorf("failed: pangram %s is %s, got...
package config import ( "fmt" "path/filepath" "strings" log "github.com/sirupsen/logrus" homedir "github.com/mitchellh/go-homedir" "github.com/spf13/viper" ) // DSN stores all the database connection and driver information type DSN struct { Driver string Host string Port ...
package main import ( "time" ) // START1 OMIT func FooArgs( strict bool, // HL message string, // HL delay time.Duration, // HL onSuccess func(), // HL onError func(error), // HL ) error { // Do the work ... return nil } // END1 OMIT func main() { // START2 OMIT err := FooArgs(false, "some...
package main import ( "fmt" "myRPC/limit/base" "time" ) func main() { limitBase.InitLimit() limiter,_ := limitBase.GetLimitMgr().NewLimiter("counter", map[interface{}]interface{}{}) m := make(map[int]bool) for i := 0; i < 1000; i++ { allow := limiter.Allow() if allow { m[i] = true } else { m[i] = f...
package main import ( "fmt" "io/ioutil" "os" "gopkg.in/yaml.v2" ) type Config struct { Hosts []struct { HostName string `yaml:"name"` Connection string `yaml:"connection"` UserName string `yaml:"username"` PassWord string `yaml:"password"` Commands []struct { Name string `yaml:"name"`...
package core import ( "github.com/cadmium-im/zirconium-go/core/models" "github.com/cadmium-im/zirconium-go/core/utils" "github.com/fatih/structs" "github.com/google/logger" ) type Router struct { appContext *AppContext handlers map[string][]C2SMessageHandler } type C2SMessageHandler interface { HandleMessag...
package h2mux import ( "testing" "time" "github.com/stretchr/testify/assert" ) func assertEmpty(t *testing.T, rl *ReadyList) { select { case <-rl.ReadyChannel(): t.Fatal("Spurious wakeup") default: } } func assertClosed(t *testing.T, rl *ReadyList) { select { case _, ok := <-rl.ReadyChannel(): assert.F...
package api const ( RecordPrefix = "/record" ReviewPrefix = "/review" )
package service import ( "strconv" "time" "github.com/dgrijalva/jwt-go" meetupmanager "github.com/lucas-dev-it/62252aee-9d11-4149-a0ea-de587cbcd233" "github.com/lucas-dev-it/62252aee-9d11-4149-a0ea-de587cbcd233/business" "github.com/lucas-dev-it/62252aee-9d11-4149-a0ea-de587cbcd233/business/model" "github.com/...
package main import ( "html/template" "github.com/yuriizinets/go-ssc" ) type PageIndex struct { ComponentHttpbinUUID ssc.Component ComponentCounter ssc.Component ComponentSampleBinding ssc.Component ComponentSampleParent ssc.Component } func (*PageIndex) Template() *template.Template { return templa...
package repositories import ( "context" "go.mongodb.org/mongo-driver/bson" "go.mongodb.org/mongo-driver/bson/primitive" "go.mongodb.org/mongo-driver/mongo" "headless-todo-tasks-service/internal/entities" "headless-todo-tasks-service/internal/services/repositories" ) const TasksCollection = "tasks" type TasksRe...
package model import ( "github.com/jinzhu/gorm" ) type TypeInfo struct { Type string } type BookInLocal struct { gorm.Model Title string Type string }
// Package reader contains various meteo.Reader implementations using different sensors. package reader
package serverFunctionality import ( "context" "database/sql" "fmt" "log" "time" _ "github.com/denisenkom/go-mssqldb" models "github.com/mtapp/MeetingTrackingApp/model" ) // Replace with your own connection parameters var server = "BWEBDB01" //"localhost" var port = 1433 var user = "sa" var p...
// 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 firmware import ( "context" "strings" "chromiumos/tast/local/firmware" "chromiumos/tast/testing" "chromiumos/tast/testing/hwdep" ) func init() { testing.AddT...
package main import ( . "fmt" // 调用函数,无序通过报名 operatorSystem "os" // 给包起别名 _ "wovert/09_func/other" // _ 表示仅调用包的init 函数 ) func main() { // 接受用户的参数,字符串方式传递 list := operatorSystem.Args n := len(list) Println("n=", n) for i := 0; i < n; i++ { Printf("%d=%s\n", i, list[i]) } }
/* Copyright 2015 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 in writing, soft...
package cncscraper import ( "time" ) type Topic struct { CrawlDate time.Time `bson:"crawl_datetime"` CreatedDate time.Time `bson:"topic_datetime"` ForumId int `bson:"forum_id"` Id int `bson:"topic_id"` IsArchived bool `bson:"is_archived"` PollOptions []PollOption...
package column_test import ( "context" "fmt" "os" "testing" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" "github.com/vahid-sohrabloo/chconn/v2" "github.com/vahid-sohrabloo/chconn/v2/column" "github.com/vahid-sohrabloo/chconn/v2/types" ) func TestTuples(t *testing.T) { tableNam...
package testflow import ( tmv1beta1 "github.com/gardener/test-infra/pkg/apis/testmachinery/v1beta1" "github.com/gardener/test-infra/pkg/testmachinery/config" "github.com/gardener/test-infra/pkg/testmachinery/locations" "github.com/gardener/test-infra/pkg/testmachinery/testdefinition" "github.com/gardener/test-inf...
package models import( "encoding/json" ) /** * Type definition for AlertSeverityListEnum enum */ type AlertSeverityListEnum int /** * Value collection for AlertSeverityListEnum enum */ const ( AlertSeverityList_KCRITICAL AlertSeverityListEnum = 1 + iota AlertSeverityList_KWARNING ...
package task import ( "context" "fmt" "os" "os/signal" "path/filepath" "strings" "syscall" "time" "github.com/radovskyb/watcher" "github.com/go-task/task/v3/errors" "github.com/go-task/task/v3/internal/fingerprint" "github.com/go-task/task/v3/internal/logger" "github.com/go-task/task/v3/taskfile" ) con...
package rtda /** * 帧 */ type Frame struct { lower *Frame //用来实现链表数据结构 localVars LocalVars //局部变量表指针 operandStack *OperandStack //操作数栈指针 } func NewFrame(maxLocals, maxStack uint) *Frame { return &Frame{ localVars: newLocalVars(maxLocals), operandStack: newOperandStack(maxStack), // 执行方法所需的局部变量表大小和操作数栈深度是由编...
// cancellation context can be seen as a convenience without which a data sink // routine often ends up having to store away what coomes out of a channel // input as a result of a negative close poll // // after introducing cancellation context it becomes possible for source to // block on a buffered channel if sink is...
package daemonset import ( "testing" dynatracev1beta1 "github.com/Dynatrace/dynatrace-operator/src/api/v1beta1" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" corev1 "k8s.io/apimachinery/pkg/apis/meta/v1" ) func TestPrepareVolumes(t *testing.T) { t.Run("has defaults if instance is n...
// 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...
/* Copyright 2022 The Skaffold 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, sof...
package catalog type ActionScope string const ( ActionScopeProject ActionScope = "project" ActionScopeModule ActionScope = "module" ) type ActionType string const ( ActionTypeContainer ActionType = "container" ActionTypeGitHubAction ActionType = "githubaction" ) type ActionAccess struct { Env []string `ya...
package main import ( "net/http" "os" "testing" "io/ioutil" "github.com/bandwidthcom/go-bandwidth" "github.com/gin-gonic/gin" "github.com/stretchr/testify/assert" ) func TestNewCatapultApi(t *testing.T) { os.Setenv("CATAPULT_USER_ID", "UserID") os.Setenv("CATAPULT_API_TOKEN", "Token") os.Setenv("CATAPULT_...
package sass import ( "net/http" "net/http/httptest" "strings" "testing" "time" "github.com/thatguystone/acrylic/internal" "github.com/thatguystone/acrylic/internal/testutil" "github.com/thatguystone/acrylic/watch" "github.com/thatguystone/cog/check" ) func hit(h http.Handler) *httptest.ResponseRecorder { ...
// dockerns は Docker コンテナーへの接続な名前解決を行う HTTP / SOCKS v5 プロキシーサーバー及び DNS サーバー。 // // ルーティングに関する設定は etcd 上に保存して使用する。 // // # 「ホスト名が ^.*\.my-service\.com$ の正規表現に一致したら my_container_name へ接続する」というルーティング情報を master アカウントに追加する。 // # 0.regexp_name の 0 は優先順位で、複数のルーティング情報がある場合に値が大きいほど優先される。regexp_name は管理上の設定名なので何でも構わない。 // cur...
// Copyright 2018 SixUnDeuxZero // // 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...
// +build !debug package cache func (q *queue) checkInvariants() {} func (c *lru) checkInvariants() {}
package controller import ( "antalk-go/internal/common" proto "antalk-go/internal/proto/pb" "antalk-go/internal/push/service" "context" ) type Controller struct { push *service.Push } func New(c *common.Config) (*Controller, error) { s := &Controller{} return s, nil } func (c *Controller) Cmd(ctx context.Con...
package odoo import ( "fmt" ) // IrActionsClient represents ir.actions.client model. type IrActionsClient struct { LastUpdate *Time `xmlrpc:"__last_update,omptempty"` BindingModelId *Many2One `xmlrpc:"binding_model_id,omptempty"` BindingType *Selection `xmlrpc:"binding_type,omptempty"` Context ...
package main // Pomodoro! // References: // - [Wikipedia: Pomodoro Technique](https://en.wikipedia.org/wiki/Pomodoro_Technique) // - [List of colors for prompt](https://wiki.archlinux.org/index.php/Color_Bash_Prompt#List_of_colors_for_prompt_and_Bash) // - [CMD in Python and Go](http://www.darkcoding.net/softwar...
package middleware import ( "net/http" "github.com/winded/tyomaa/backend/util" ) func AccessControl(next http.Handler) http.Handler { return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { w.Header().Set("Access-Control-Allow-Origin", util.EnvOrDefault("ALLOW_ORIGIN", "*")) next.ServeHTTP(w, r...
package controller import ( "encoding/json" "net/http" "strconv" "time" "github.com/simplejia/clog/api" "github.com/simplejia/namesrv/model" ) var AddNameStatFunc = func() func(string, string) error { fun := "AddNameStatFunc" ch := make(chan [2]string, 1e6) go func() { m := make(map[string]time.Time) n...
// Copyright 2018 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...
package database import ( "gorm.io/driver/sqlite" "gorm.io/gorm" "os" ) func newSQLite() gorm.Dialector { fn := os.Getenv("SQLITE_FILENAME") return sqlite.Open(fn) }
package provider import ( "bytes" "chaplapp/core" "encoding/json" "os" "testing" "time" ) func TestProvidesChairmanListCorrectly(testing *testing.T) { chairmen := Chairmen{[]string{"John Doe", "Jane Doe", "Foobius Bar"}} src, _ := json.Marshal(chairmen) os.Stdout.Write(src) reader := bytes.NewReader(src) r...
package r30_test import ( "testing" "go.lukeharris.dev/r30" "go.lukeharris.dev/testUtils" ) func TestStep(t *testing.T) { utils := testUtils.Setup(t) t1 := []byte{0b00000001, 0b01000000} t1Expect := []byte{0b00000011, 0b01100000} t1Got := r30.Step(t1) utils.BytesEq(t1Got, t1Expect) t2 := []byte{0b00000001...
// Copyright 2016 Attic Labs, Inc. All rights reserved. // Licensed under the Apache License, version 2.0: // http://www.apache.org/licenses/LICENSE-2.0 package types import "github.com/attic-labs/noms/go/d" type listLeafSequence struct { leafSequence values []Value } func newListLeafSequence(vrw ValueReadWriter,...
package main //634. 寻找数组的错位排列 //在组合数学中,如果一个排列中所有元素都不在原先的位置上,那么这个排列就被称为错位排列。 // //给定一个从1 到 n升序排列的数组,你可以计算出总共有多少个不同的错位排列吗? // //由于答案可能非常大,你只需要将答案对 109+7 取余输出即可。 // // // //样例 1: // //输入: 3 //输出: 2 //解释: 原始的数组为 [1,2,3]。两个错位排列的数组为 [2,3,1] 和 [3,1,2]。 // // //注释: //n 的范围是 [1, 106]。 // 动态规划 // 当 n (1,n) ,当x跟 1 互换时,问题可以分解为...
package main import ( "BeegoDemo/blockchain" "BeegoDemo/db_mysql" "BeegoDemo/models" _ "BeegoDemo/routers" "encoding/json" "encoding/xml" "fmt" "github.com/astaxie/beego" ) func main() { user1 := models.User{ Id:1, Phone:"", Password: "", } fmt.Println("内存中的数据User1:",user1) //json /** * {"Id":1 ...
package libbpf type Packet []byte type libbpfAfxdpRunner interface { Read() <-chan Packet Pass(data Packet) New(data Packet) Drop() Close() }
package main import ( "cloud.google.com/go/profiler" "github.com/chidakiyo/benkyo/go-memleak-check/lib" "github.com/gin-gonic/gin" "log" "net/http" "os" ) func main() { StartProfiler("leak-01", "0.0.2") route := gin.Default() http.Handle("/", route) route.GET("ds", lib.MercariDatastoreCreate) route.GET("...