text
stringlengths
11
4.05M
package main import ( "fmt" ) func test(cur interface{}) { if cur == nil { fmt.Println("cur is nil") } else { fmt.Println("cur is not nil") } } func main() { var cur interface{} test(cur) }
package main import ( "bufio" "fmt" "io" "os" "strconv" ) func main() { solve(os.Stdin, os.Stdout) } func solve(stdin io.Reader, stdout io.Writer) { sc := bufio.NewScanner(stdin) sc.Scan() m, _ := strconv.Atoi(sc.Text()) sc.Scan() p, _ := strconv.ParseFloat(sc.Text(), 64) sc.Scan() x, _ := strconv.Atoi(...
// 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 graphics import ( "context" "github.com/google/go-cmp/cmp" "chromiumos/tast/errors" "chromiumos/tast/local/chrome" "chromiumos/tast/local/chrome/display" "ch...
package main import ( "io/ioutil" "net/http" "net/url" "strings" ) // FetchList will visit a plaintext URL and extract the list of links // Suggested sources are gists or pastebin func FetchList(source *url.URL) ([]url.URL, error) { resp, err := http.Get(source.String()) if err != nil { return []url.URL{}, er...
package main type ListNode struct { Val int Next *ListNode } func main() { // 测试用例 } func removeNthFromEnd(head *ListNode, n int) *ListNode { // pre指针 pre := &ListNode{} pre.Next = head first, second := pre, pre // 先走n+1步 for i := 0; i <= n; i++ { first = first.Next } // 一起走 for first != nil { first...
package main import ( "encoding/json" "fmt" "github.com/jessevdk/go-flags" "reflect" "sort" "strconv" "time" //"runtime/debug" //"os" "strings" ) //type PrintOutput func(string) type AnyType interface{} func If(condition bool, true AnyType, false AnyType) AnyType { if condition { return true } return...
package models type Location struct { Distance_unit string `json:"distance_unit"` Key string `json:"key"` Name string `json:"name"` Region string `json:"region"` Region_id string `json:"region_id"` Country string `json:"country"` Radius int `json:"radius"` }
package srffwu import ( "errors" "fmt" "math" "strings" "time" ) type state int const ( stateInit state = iota stateWaitingForFirstStatus stateSending ) // Settings stores parameters for the firmware upgrade process. type Settings struct { PortName string FwFileName string Verbose bool } func print...
package main import ( "fmt" "lib/util" ) func main() { done := make(chan bool) fmt.Println("Starting http get...") go util.CallURL(done) <- done fmt.Println("Finished http get...") }
package server import ( "fmt" "github.com/yacen/gong/context" "net/http" ) type serverHandler struct { middlewares []Middleware } func (h *serverHandler) ServeHTTP(res http.ResponseWriter, req *http.Request) { if len(h.middlewares) == 0 { return } else { chain := &RealMiddlewareChain{middlewares: h.middlew...
package http import ( "marketplace/transactions/domain" "marketplace/transactions/internal/request" "marketplace/transactions/internal/usecase" "net/http" "github.com/gin-gonic/gin" "github.com/go-pg/pg/v10" "github.com/sirupsen/logrus" ) func GetMyTransactionsHandler(db *pg.DB, cmd usecase.GetMyTransactionsC...
package admin import ( "errors" "github.com/golang/mock/gomock" "github.com/williamchang80/sea-apd/domain/user" "github.com/williamchang80/sea-apd/dto/request/admin" ) var emptyAdmin = user.User{} var emptyAdminRequest = admin.Admin{} // MockUsecase ... type MockUsecase struct { ctrl *gomock.Controller } // R...
package page_index import ( . "Web/main_definitions" "html/template" "log" "net/http" ) // ------------------------------------------- Types ------------------------------------------- // // // IndexWebPage embeds the *WebPage type // IndexWebPage implements the WebPageInterface via its Init() function // More d...
package exchange import ( "testing" "github.com/prebid/openrtb/v19/openrtb2" "github.com/prebid/prebid-server/exchange/entities" "github.com/prebid/prebid-server/openrtb_ext" "github.com/stretchr/testify/assert" ) func TestSeatNonBidsAdd(t *testing.T) { type fields struct { seatNonBidsMap map[string][]openrt...
package main import ( "bytes" "fmt" "log" "os" "text/template" "time" "github.com/codegangsta/cli" "github.com/nsf/termbox-go" "github.com/yanfali/go-tvdb" ) var ( RowTemplate = `{{.SeriesName | printf "%-40s"}} {{.Language | printf "%-10s"}} {{.FirstAired | printf "%-15s"}} {{.Genre}}` RowCompiled = temp...
package animatedArr import ( "time" ) func (a *AnimArr) InsertionSort() { for i := 1; !a.Sorted && i < len(a.Data); i++ { a.PivotInd = i for j := i; j > 0 && a.Data[j-1] > a.Data[j]; j-- { a.Comparisons++ a.Active = j a.Active2 = j-1 a.ArrayAccesses += 2 // In for loop a.swapElements(j, j-1) t...
package base import ( "log" "net" "time" ) type Server struct { netSrv *NetServer Proc *Processor exit chan bool Manager *SessionManager verifyFunc func(pkt *Packet) bool //检查连接是否合法 } // 实现ConnectHandler接口 func (self *Server) SetNetServer(ns *NetServer) { self.netSrv = ns } // 实现ConnectH...
package requests import ( "encoding/json" "fmt" "net/url" "strings" "github.com/google/go-querystring/query" "github.com/atomicjolt/canvasapi" "github.com/atomicjolt/string_utils" ) // UpdateSingleRubric Returns the rubric with the given id. // // Unfortuantely this endpoint does not return a standard Rubric...
/* * 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 ...
package dvid import ( "reflect" "testing" . "github.com/janelia-flyem/go/gocheck" ) type VolumeTest struct { rles RLEs encoding []byte } var _ = Suite(&VolumeTest{}) func (s *VolumeTest) SetUpSuite(c *C) { s.rles = RLEs{ {Point3d{2, 3, 4}, 20}, {Point3d{4, 4, 4}, 14}, {Point3d{1, 3, 5}, 20}, } va...
package main import ( "bytes" "encoding/json" "github.com/ixchi/foxbot/bot" "github.com/syfaro/haste-client" "github.com/syfaro/telegram-bot-api" "os" "strconv" ) type pluginUtils struct { } func (plugin *pluginUtils) Name() string { return "General utilities" } func (plugin *pluginUtils) displayMyID(handle...
package idservice_test import ( "fmt" "log" "net/http" "gopkg.in/errgo.v1" "gopkg.in/macaroon-bakery.v0/bakery" "gopkg.in/macaroon-bakery.v0/bakery/checkers" "gopkg.in/macaroon-bakery.v0/httpbakery" ) type targetServiceHandler struct { svc *bakery.Service authEndpoint string endpoint string ...
package main import "strings" const ( NONCOMMAND = "non-command" SIGNUP = "signup:" SIGNIN = "signin:" SIGNOUT = "signout" TOUSER = "to user:" TOGROUP = "to group:" CREATEGROUP = "create group:" JOINGROUP = "join group:" INVITEGROUP = "invite group:" RESTORENOTES = "restor...
package main import ( "bytes" "encoding/json" "fmt" "log" "net/http" "github.com/josetom/go-chain/common" "github.com/josetom/go-chain/core" "github.com/josetom/go-chain/node" "github.com/spf13/cobra" ) const flagFrom = "from" const flagTo = "to" const flagValue = "value" const flagData = "data" func txCmd...
package selector import "context" // SelectOptions is Select Options. type SelectOptions struct { Filters []Filter } // SelectOption is Selector option. type SelectOption func(*SelectOptions) // Filter is node filter function. type Filter func(context.Context, []Node) []Node // WithFilter with filter options func...
package main import ( "encoding/json" "flag" "fmt" "io/ioutil" "os" "strconv" ) var version = "undefined" func main() { pretty := flag.Bool("p", false, "pretty print") escape := flag.Bool("e", false, "quote print") vv := flag.Bool("v", false, "print version") flag.Parse() if *vv { fmt.Fprintln(os.Stdou...
package util func StringValue(p *string) string { if p == nil { return "" } return *p }
package action import ( "encoding/json" "fmt" "strings" "github.com/iris-contrib/blackfriday" "github.com/microcosm-cc/bluemonday" "github.com/mylxsw/adanos-alert/configs" "github.com/mylxsw/adanos-alert/internal/repository" "github.com/mylxsw/adanos-alert/pkg/messager/email" "github.com/mylxsw/asteria/log" ...
package utils type TreeNode struct { Val int Left *TreeNode Right *TreeNode } //Hierarchical traversal //[1,2,5,3,4,null,6]
package exchange import ( "github.com/stretchr/testify/assert" "log" "testing" ) func TestBittrex_SetPairs(t *testing.T) { bittrex := Bittrex{} bittrex.SetPairs() pairs := bittrex.GetConfig().Pairs assert.Contains(t, pairs, &Pair{"BTC", "ETH"}) assert.Contains(t, pairs, &Pair{"BTC", "LTC"}) } func TestBitt...
package middlewares import ( "net/http" "github.com/julienschmidt/httprouter" ) func AuthMiddleware(handler httprouter.Handle) httprouter.Handle { return httprouter.Handle(func(w http.ResponseWriter, r *http.Request, p httprouter.Params) { // Authorization: Bearer <token> // authHeader, ok := r.Header["Author...
package manifest import ( "crypto/md5" "fmt" "io" "io/ioutil" "os" "path/filepath" "github.com/ghodss/yaml" ) type Entry struct { Path string `json:"path" jsonschema_description:"relative storage path"` MD5 string `json:"md5" jsonschema_description:"MD5 of file"` Source string `json:"source" ...
package main import "fmt" // *************************************************** // by default channels are unbuffered // i.e., they will only accept sends (chan <-) // only if there is receive (<- chan) ready to // receive the send value. // Buffered channels accept a limited number of values // without a correspond...
package anime import ( "context" "reflect" "testing" "github.com/DATA-DOG/go-sqlmock" ) func TestRepository(t *testing.T) { t.Run("GetAnimes(limit = 2, offset = 0) returns []Anime{{...}, {...}}", func(t *testing.T) { db, mock, err := sqlmock.New() if err != nil { t.Errorf("An error '%s' was not expecte...
package main //55. 跳跃游戏 //给定一个非负整数数组,你最初位于数组的第一个位置。 // //数组中的每个元素代表你在该位置可以跳跃的最大长度。 // //判断你是否能够到达最后一个位置。 // //示例1: // //输入: [2,3,1,1,4] //输出: true //解释: 我们可以先跳 1 步,从位置 0 到达 位置 1, 然后再从位置 1 跳 3 步到达最后一个位置。 //示例2: // //输入: [3,2,1,0,4] //输出: false //解释: 无论怎样,你总会到达索引为 3 的位置。但该位置的最大跳跃长度是 0 , 所以你永远不可能到达最后一个位置。 //思路 动态规划 func...
// Copyright (c) 2014 ZeroStack 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...
/* * OFAC API * * OFAC (Office of Foreign Assets Control) API is designed to facilitate the enforcement of US government economic sanctions programs required by federal law. This project implements a modern REST HTTP API for companies and organizations to obey federal law and use OFAC data in their applications. * ...
package main import "fmt" //map _,ok:= m[V] func main() { srcArr:=[]string{"red", "black", "red", "pink", "blue", "pink", "blue"} dst:=deleteRepeatElement(srcArr) fmt.Println(dst) dst2:=deleteEmptyStringByMap(srcArr) fmt.Println(dst2) } func deleteEmptyStringByMap(src []string)(dst []string) { m:=make(map[st...
package store import "github.com/skoltai/limithandling/domain" // AppRepository specifies the possible interactions with Apps type AppRepository interface { Create(app App) int Get(id int) (App, error) Update(app App) bool All() []App LimitOverrides(id int) []domain.Limit } // SimpleAppRepository implements a s...
// 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 hypervisor import ( "context" "chromiumos/tast/remote/hypervisor" "chromiumos/tast/testing" ) func init() { testing.AddTest(&testing.Test{ Func: IsMa...
package glutton import ( "context" "fmt" "io" "net" "net/url" "strings" "github.com/reiver/go-telnet" log "go.uber.org/zap" ) //telnetProxy Struct type telnetProxy struct { logger *log.Logger curConn net.Conn proxyclient *telnet.Client hostconn *telnet.Conn glutton *Glutton host ...
package panicdemo import ( "fmt" "testing" "time" ) func Test_Panic(t *testing.T) { panicDemo() } func panicDemo() { // 1. panic 会终止服务 // 2. panic 会沿着函数调用链, 逆向传染,直到退出或被捕获。 // 3. 但是, panic 退出不会终止 defer // 4. 因此可以在 defer 中使用 recover 捕获 panic, 中断传染。 // 5. 只能在相同 G 内的函数调用链中使用 defer , 才能在任意一个环节捕获 panic。 // 6. 根据...
package sshttp import ( "fmt" "io" "net/http" "net/url" "os" "path/filepath" "sort" "github.com/pkg/sftp" "golang.org/x/crypto/ssh" ) // File implements http.File using remote files over SFTP, and is returned // by FileSystem's Open method. type File struct { // Embed for interface implementation *sftp.Fi...
package app import ( "encoding/json" "io" "testing" "github.com/cosmos/cosmos-sdk/simapp" abci "github.com/tendermint/tendermint/abci/types" "github.com/tendermint/tendermint/libs/log" dbm "github.com/tendermint/tm-db" "github.com/tharsis/ethermint/encoding" ) func BenchmarkEthermintApp_ExportAppStateAndVali...
package bd import ( "api-documentos/modelos" ) //Insertar Orden de Compra func InserOrden(orden modelos.OrdenCompra)(respuesta modelos.RespuestaBasica){ query, err:= db.Prepare("call usp_InsOrdenCompra(?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,...
package main import ( "encoding/json" "fmt" "github.com/shawnwyckoff/go-utils/dsa/jsons" ) // 基础类型(比如int)及其type出来的新类型,支持omitempty // 结构体及其type出来的新类型,不支持omitempty // 结构体S实现omitempty的唯一方法就是,在使用它的结构体P中显式的使用它的指针*S作为成员 type InInfo struct { Address string } type Info InInfo func (info Info) MarshalJSON() ([]byte, er...
// Copyright (C) 2021 Storj Labs, Inc. // See LICENSE for copying information. package rpcpool_test import ( "context" "crypto/tls" "fmt" "log" "time" "storj.io/common/identity" "storj.io/common/peertls/tlsopts" "storj.io/common/rpc" "storj.io/common/rpc/rpcpool" "storj.io/common/rpc/rpctest" "storj.io/dr...
// Copyright (C) 2019 Storj Labs, Inc. // See LICENSE for copying information. package encryption import ( "bytes" "testing" ) func TestIncrementBytes(t *testing.T) { for i, test := range []struct { inbuf []byte amount int64 err bool outbuf []byte truncated bool }{ {nil, 10, false, ni...
// +build !clustered,!gcloud package datastore import ( "reflect" "testing" "github.com/janelia-flyem/dvid/dvid" ) func TestRepoGobEncoding(t *testing.T) { uuid := dvid.UUID("19b87f38f873481b9f3ac688877dff0d") versionID := dvid.VersionID(23) repoID := dvid.RepoID(13) repo := newRepo(uuid, versionID, repoID,...
package runtime import ( "io/ioutil" "os" "path/filepath" "github.com/kirsle/configdir" "github.com/spf13/viper" "gopkg.in/yaml.v2" ) const ( oldConfigPath = "gscloud" configPath = "gridscale" ) // AccountEntry represents a single account in the config file. type ProjectEntry struct { Name string `yam...
// Copyright 2017 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, ...
/* Execution prompting the user to enter an integer, then it adds that number to an int slice, it sorts that slice and prints it to screen. Execution stops when user types "x". */ package main import ( "fmt" "sort" "strconv" ) func main() { arr := make([]int, 0, 3) givenValue := "" fmt.Println("Please insert ...
package main import ( "flag" "fmt" "github.com/mit-dci/zkledger" ) var num = flag.Int("num", 2, "The number of banks you want generate keys for") var loadKeys = flag.Bool("load", false, "Loads the keys if they already exist") func main() { flag.Parse() pki := zkledger.PKI{} if *loadKeys { pki.MakeTestWithK...
package main import ( "flag" "fmt" "io" "io/ioutil" "os" "path/filepath" "strings" "github.com/andrew-d/isbinary" "github.com/fatih/color" "github.com/y-yagi/configure" ) type config struct { Home string `toml:"home"` } const cmd = "blogrep" var ( warningColor = color.New(color.FgYellow).SprintFunc() ...
package controls import ( "github.com/upyun/go-sdk/upyun" "sofuny/config" "sofuny/models" ) // 数据库 var db = models.Connection() // 又拍云 var up = upyun.NewUpYun(&upyun.UpYunConfig{ Bucket: config.Config().Upyun.Bucket, Operator: config.Config().Upyun.Operator, Password: config.Config().Upyun.Password, })
package geojson // A list of the geojson types that are currently supported. const ( TypePoint = "Point" TypeMultiPoint = "MultiPoint" TypeLineString = "LineString" TypeMultiLineString = "MultiLineString" TypePolygon = "Polygon" TypeMultiPolygon = "MultiPolygon" )
//simulator bytom miner package main import ( "bufio" "encoding/hex" "encoding/json" "flag" "fmt" "log" "math/big" "net" "os" "runtime" "strconv" "time" //"github.com/bytom/consensus/difficulty" "github.com/bytom/mining/tensority" "github.com/bytom/protocol/bc" "github.com/bytom/protocol/bc/types" by...
// Package imagesort contains a single executable located in cmd/imagesort package imagesort
package main import ( "fmt" "net/http" "encoding/json" "io/ioutil" ) func main() { http.HandleFunc("/plus", plus) fmt.Println(http.ListenAndServe(":9010", nil)) } type PlusInput struct { Number1 int `json:"number1"` Number2 int `json:"number2"` } func plus(w http.ResponseWriter, r *http.Request) { body, _...
package web import ( "context" "math" "net/http" "strconv" ) const ( recordsPerPage = 20 ) func (s *Server) GetExchangeTicks(res http.ResponseWriter, req *http.Request) { req.ParseForm() page := req.FormValue("page") pageToLoad, err := strconv.ParseInt(page, 10, 32) if err != nil || pageToLoad <= 0 { pa...
package main import ( "fmt" ) func (ts tables) delta() (ds filesDelta) { for i, _ := range ts { if i == 0 { continue } t1 := ts[i-1] t2 := ts[i] fdelta := fileDelta{} fdelta.oldFileName = t1.sourceFileName fdelta.newFileName = t2.sourceFileName fdelta.rowDelta = rowDelta{} for key, _ := ran...
package main import ( "fmt" "io/ioutil" "log" "os" "path/filepath" "strings" "github.com/emicklei/dot" "github.com/emicklei/xconnect" "gopkg.in/yaml.v2" ) // read all xconnect config files // start a webservice to display dot graphs in PNG var master = dot.NewGraph(dot.Directed) var networkIDtoNode = map[s...
//package with commands package commands import ( "database/sql" "log" _ "github.com/mattn/go-sqlite3" ) // GetImage возвращает путь к обложке книги, если она есть func GetImage(database string, query string) string { var path1 string db, err := sql.Open("sqlite3", database) if err != nil { panic(err) } ...
package user import ( "easyquery" ) var RoleCrudService *RoleService type RoleService struct { easyquery.Crud } func init() { RoleCrudService = NewDefaultRoleService() } func NewRoleService(crud easyquery.Crud) *RoleService { return &RoleService{crud} } func NewDefaultRoleService() *RoleService { return NewR...
package main import ( "encoding/json" "fmt" "io" "log" "net/http" "gorm.io/driver/postgres" "gorm.io/gorm" "gorm.io/gorm/clause" ) func main() { data, err := request() if err != nil { log.Fatalln(err) } log.Printf("%+v\n", data) dbInsert("TODO", data) } func dbInsert(dsn string, data Stations) { d...
package azure import ( "context" "encoding/json" "errors" "fmt" "log" "strings" "time" "github.com/Azure/go-autorest/autorest" "github.com/protofire/polkadot-failover-mechanism/pkg/helpers/fanout" "github.com/Azure/azure-sdk-for-go/profiles/2019-03-01/resources/mgmt/insights" ) func getMetricsResourceURL...
package gorequest import ( "bytes" "encoding/json" "fmt" "github.com/moul/http2curl" "github.com/pkg/errors" "io" "io/ioutil" "log" "mime/multipart" "net/http" "net/http/httputil" "net/textproto" "net/url" "strconv" "strings" "time" ) func (s *Agent) SetDebug(enable bool) *Agent { s.Debug = enable r...
package main import ( "log" adm "github.com/appcelerator/amp/cluster/ampadmin" "github.com/spf13/cobra" ) type CheckOptions struct { version bool scheduling bool all bool } var checksOpts = &CheckOptions{} func checks(cmd *cobra.Command, args []string) { if checksOpts.version || checksOpts.all { ...
package ssh import ( "fmt" "io" "reflect" "strings" "time" validation "github.com/go-ozzo/ozzo-validation" "golang.org/x/crypto/ssh" "github.com/cyberark/secretless-broker/pkg/secretless/log" "github.com/cyberark/secretless-broker/pkg/secretless/plugin/connector" ) // ServerConfig is the configuration info...
package node import ( "fmt" "log" "net/http" "github.com/josetom/go-chain/common" "github.com/josetom/go-chain/core" ) const ( RequestBalances = "/balances" RequestTransactions = "/transactions" RequestAddPeers = "/node/peers" RequestNodeStatus = "/node/status" RequestNodeSync = "/node/sync" ...
package exec import ( "context" "testing" "time" "github.com/aws/aws-sdk-go/aws" "github.com/aws/aws-sdk-go/service/athena" "github.com/aws/aws-sdk-go/service/athena/athenaiface" "github.com/skatsuta/athenai/internal/stub" "github.com/stretchr/testify/assert" ) const testWaitInterval = 10 * time.Millisecond ...
/* 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 seaweed import ( //"strconv" //"path" "fmt" "github.com/qiaogw/pkg/config" //"path" "testing" "github.com/stretchr/testify/assert" ) func TestSeaweedfs(t *testing.T) { err := config.LoadConfig() r := NewSeaweedfs(`test`) fmt.Println(r.baseURL) err = r.DeleteDir(`/buckets/buck1/s3data`) asser...
package protocol // Machine defines on which machine "Job" is gonna be handled. type Machine struct { // Provider specifies machine provider, either of [local, ec2, gce, k8s] Provider string `json:"provider" yaml:"provider"` // CPU specifies how many CPU cores are required for the "Job" CPU int `json:"cpu,omitempt...
package server import ( "fmt" "io" "net" "testing" "time" ) func TestNewNetServer(t *testing.T) { go func() { time.Sleep(1 * time.Second) conn, err := net.Dial("tcp", "localhost:8789") if err != nil { t.Errorf("error dial") } message := &Message{ Data: []byte("set fwt llh"), } message.DataLe...
package internal import ( "context" "errors" "io" "io/ioutil" "strings" "testing" "github.com/docker/docker/api/types" "github.com/packethost/pkg/log" "github.com/stretchr/testify/assert" ) func setupTestLogger(t *testing.T) log.Logger { t.Helper() service := "github.com/tinkerbell/tink" logger, err := ...
package connectioninfo import ( "context" "testing" dynatracev1beta1 "github.com/Dynatrace/dynatrace-operator/src/api/v1beta1" "github.com/Dynatrace/dynatrace-operator/src/dtclient" "github.com/Dynatrace/dynatrace-operator/src/scheme" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" ...
package statefulset import ( "context" "encoding/json" "net/http" "reflect" "go.uber.org/zap" "k8s.io/api/admission/v1beta1" admissionregistration "k8s.io/api/admissionregistration/v1beta1" appsv1 "k8s.io/api/apps/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "sigs.k8s.io/controller-runtime/pkg/webhook...
// Copyright (c) KwanJunWen // This source code is licensed under the MIT license found in the // LICENSE file in the root directory of this source tree. package estemplate import "fmt" // DatatypeByte Core Datatype for numeric value. // A signed 8-bit integer with a minimum value of -128 and a maximum value of 127....
package word import ( "strings" "unicode" ) // Word represents a word type Word struct { runes []rune } // New instantiate word func New(str string) Word { return Word{runes: []rune(str)} } // Cleanup removes not alphanumeric func (r Word) Cleanup() Word { words := strings.FieldsFunc(string(r.runes), isLetterO...
package console import "testing" func TestParse(t *testing.T) { ok := "23x14" x, y, err := Parse(ok) if err != nil { t.Fatal(err) } if x != 23 || y != 14 { t.Fatalf("bad coordinates: wanted %dx%d have %dx%d", 23, 14, x, y) } bad := []string{ "asdfg", "123x", "x123", "132x143x43", "x8xx6x5x", ...
package port import ( "context" "github.com/shandysiswandi/echo-service/internal/domain" ) type TodoUsecase interface { FetchTodos(context.Context) ([]*domain.Todo, error) GetTodoByID(context.Context, string) (*domain.Todo, error) CreateTodo(context.Context, domain.TodoCreatePayload) error UpdateTodoByID(cont...
package requests import ( "fmt" "net/url" "strings" "time" "github.com/google/go-querystring/query" "github.com/atomicjolt/canvasapi" "github.com/atomicjolt/string_utils" ) // ListPlannerItemsPlanner Retrieve the paginated list of objects to be shown on the planner for the // current user with the associated...
package candishared import "math" // Result common output type Result struct { Data interface{} Error error } // SliceResult include meta type SliceResult struct { Data interface{} Meta Meta } // Meta model type Meta struct { Page int `json:"page"` Limit int `json:"limit"` TotalRecords int `j...
package pipelinerun import ( "testing" "k8s.io/apimachinery/pkg/util/diff" ) func TestDashboardURL(t *testing.T) { for _, tc := range []struct { detailsURLAnnotation string wantDetailsURL string }{ { detailsURLAnnotation: "https://tekton.dev", wantDetailsURL: "https://tekton.dev", }, ...
// Copyright 2009 The Go Authors. All rights reserved. // Copyright 2019 The gVisor Authors. // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. // This is mostly copied from the standard library's sync/rwmutex.go. // // Happens-before relationships indicated to the ...
package mapreduce import "fmt" // schedule starts and waits for all tasks in the given phase (Map or Reduce). func (mr *Master) schedule(phase jobPhase) { var ntasks int var nios int // number of inputs (for reduce) or outputs (for map) switch phase { case mapPhase: ntasks = len(mr.files) ...
// Copyright 2017 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 leetcode_go func reverseList(head *ListNode) *ListNode { cur := head var pre, temp *ListNode for cur != nil { temp = cur.Next cur.Next = pre pre = cur cur = temp } return pre }
package main import "fmt" func main() { switch "Medhi" { case "Medhi", "Daniel": fmt.Println("Sup Medhi and Daniel") case "Jacob": fmt.Println("Sup Jacob") default: fmt.Println("No matches") } }
package api import ( "net" "time" "github.com/kklin/quilt-dev/db" "github.com/kklin/quilt-dev/api/pb" "github.com/kklin/quilt-dev/api/util" "golang.org/x/net/context" "google.golang.org/grpc" ) // Client provides methods to interact with the Quilt daemon. type Client struct { pbClient pb.APIClient } // New...
package service import ( "context" "google.golang.org/grpc/status" "login/model" "shared/utility/errors" "shared/utility/glog" "shared/protobuf/pb" ) type RPCLoginHandler struct { pb.UnimplementedLoginServer } func (RPCLoginHandler) CheckToken(ctx context.Context, req *pb.CheckTokenReq) (*pb.CheckTokenResp...
package main import ( "fmt" "github.com/kataras/iris" "github.com/iris-contrib/middleware/logger" ) func main() { fmt.Print("USER MANAGEMENT START") api := iris.New() api.Use(logger.New()) api.Get("/", func(ctx *iris.Context) { ctx.JSON(iris.StatusOK,iris.Map{"status":true}) }) user := api.Party("/user"...
package util import ( "testing" "time" "github.com/stretchr/testify/assert" "github.com/cyberark/secretless-broker/bin/juxtaposer/timing" ) func TestGetStandardDeviation(t *testing.T) { t.Run("nil input", func(t *testing.T) { input := &map[int]int{} res := GetStandardDeviation(input) assert.Equal(t, res...
package rcl import ( dlog "github.com/dyweb/gommon/log" ) const ( // Extension is file extension for RCL without dot Extension = "rcl" // DotExtension is '.' + Extension DotExtension = ".rcl" ) var ( logReg = dlog.NewRegistry() log = logReg.Logger() )
package main import ( "bytes" "crypto/tls" "encoding/gob" "fmt" "log" "net" "os" "sync" "time" ) func serve(app *config) { if app.tls && !fileExists(app.tlsKey) { log.Printf("key file not found: %s - disabling TLS", app.tlsKey) app.tls = false } if app.tls && !fileExists(app.tlsCert) { log.Printf(...
// 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 parser import ( "github.com/google/go-cmp/cmp" "github.com/jdormit/logr/timeseries" "log" "testing" "time" ) func parseTime(timeStr string) time.Time { time, err := time.Parse("02/Jan/2006:15:04:05 -0700", timeStr) if err != nil { log.Fatal(err) } return time } func TestParseLogLine(t *testing.T) ...
package Integer import ( "testing" ) func TestAdd(t *testing.T) { var a Integer = 1 var b Integer = 2 var c *Integer = &a c.Add(b) if *c != 3 { t.Error("Integer Less() failed.Got ", *c, "Expected 3") } } func TestLess(t *testing.T) { var a Integer = 1 var b Integer = 2 if a.Less(b) == false { t.Error("...
package main import ( "encoding/json" "fmt" "io" "net/http" "net/url" "os" "path" ) const URL = "http://img.omdbapi.com/" type Movie struct { Title string Year string Poster string } func generateFilename(movie *Movie) string { ext := path.Ext(movie.Poster) return fmt.Sprintf("%s_%s%s", movie.Title, ...