text
stringlengths
11
4.05M
package hasher import ( "crypto/sha256" "fmt" "hash" "go.starlark.net/starlark" "github.com/tilt-dev/tilt/internal/tiltfile/starkit" ) type Hashes struct { TiltfileSHA256 string AllFilesSHA256 string } type Plugin struct{} func NewPlugin() Plugin { return Plugin{} } func (e Plugin) NewState() interface{}...
package carrera import termbox "github.com/ktnyt/termbox-go" type Event termbox.Event type Color termbox.Attribute var ( Default = Color(termbox.ColorDefault) Black = Color(termbox.ColorBlack) Red = Color(termbox.ColorRed) Green = Color(termbox.ColorGreen) Yellow = Color(termbox.ColorYellow) Blue ...
package queue func Action(method string, mapData map[string]string) Queue { switch method { default: return nil } }
package main import "testing" var ( testCase1 string = "osama" testCase2 string = "omama" expectedResultCase1 string = "huruf mati: 2, huruf hidup: 2" expectedResultCase2 string = "huruf mati: 1, huruf hidup: 2" ) func TestVocalConsonant(t *testing.T) { var result1 = vocalConsonant(testCase1) t.Logf("%s", re...
package main /** * Definition for a binary tree node. * type TreeNode struct { * Val int * Left *TreeNode * Right *TreeNode * } */ type TreeNode struct { Val int Left *TreeNode Right *TreeNode } func getAllElements(root1 *TreeNode, root2 *TreeNode) []int { res1 := getAll(root1) res2 := app...
package operator import ( "github.com/turnage/redditproto" ) // MockOperator mocks Operator; it returns canned responses. type MockOperator struct { // PostsErr is returned in the error field of Posts. PostsErr error // PostsReturn is returned by Posts. PostsReturn []*redditproto.Link // UserContentErr is retur...
package difftimes import ( "testing" "time" ) func TestDiff(t *testing.T) { type args struct { aTimeString string bTimeString string formatTime string } tests := []struct { name string args args wantDiffYear int }{ { name: "sample success", args: args{ formatTime: "2006...
package sms // FetchMsgPayload is the payload type of the FetchSMS method. type FetchMsgPayload struct { // Africa’s Talking application username. Username string `form:"username" json:"username" xml:"username"` // This is the id of the message that you last processed. LastReceivedID string `form:"lastReceivedI...
package clause import ( "fmt" "reflect" "strings" ) // generators are used to generate sql clauses var generators map[Type]func(...interface{}) (string, []interface{}) func init() { generators = make(map[Type]func(...interface{}) (string, []interface{})) generators[SELECT] = _select generators[INSERT] = _inser...
package main import ( "bufio" "fmt" "golang.org/x/tools/container/intsets" "io" "log" "os" "regexp" "sort" ) type State map[int]bool type StateList []State func (sl StateList) Print() { min := intsets.MaxInt max := intsets.MinInt for _, state := range sl { for k := range state { if k < min { min ...
package main import ( "fmt" // "net/http" // _ "net/http/pprof" "github.com/EasyDarwin/EasyDarwin/rtsp" ) func main() { // go func() { // fmt.Println(http.ListenAndServe(":6060", nil)) // }() s := rtsp.GetServer() fmt.Println(s.Start()) }
package main import ( "context" "fmt" "geerpc" ) type StartGameReq struct{ User int } type StartGameRsp struct{ StartResult string } func main() { client,err := geerpc.XDial("tcp@127.0.0.1:9999",geerpc.DefaultOption) if err != nil { fmt.Println("XDial err:",err) return } ...
// Package weightconv converts weights in Pounds and Kilograms package weightconv import "fmt" type Pound float64 type Kilogram float64 func (p Pound) String() string { return fmt.Sprintf("%g pound", p) } func (k Kilogram) String() string { return fmt.Sprintf("%g kilograms", k) } func PToKg(p Pound) Kilogram { ret...
package pb import ( "fmt" "game_tools/dt" "strings" ) // proto文件中关于消息结构的定义 type MsgStruct struct { Name string // 消息名称 Fields []Field // 消息中的字段 } // 代表消息中的一个字段 type Field struct { T string // 字段类型 N string // 字段名称 S int // 字段序列 IsArray bool // 是否数组 } // 生成消息中的字段行 func (l *Field) L...
// cpu.go package node import ( "bufio" "fmt" "os" "time" linuxproc "github.com/c9s/goprocinfo/linux" ) var hostname string func submit_cpu(pluging_instance int, pluging_name string, unixTs int64, value uint64) string { s := fmt.Sprintf("PUTVAL %s/cpu-%d/absolute-%s %d:%d\n", hostname, pluging_instance, plu...
package commands import ( "bufio" "fmt" "io/ioutil" "os" "os/exec" "path/filepath" "strings" "sync" "github.com/go-errors/errors" "github.com/jesseduffield/lazynpm/pkg/config" "github.com/jesseduffield/lazynpm/pkg/utils" "github.com/mgutz/str" "github.com/sirupsen/logrus" gitconfig "github.com/tcnksm/g...
package largest import "math" func largestAltitude(gain []int) int { var max, alt int for _, g := range gain { alt += g if alt > max { max = alt } } return max } func largestAltitudeMathMax(gain []int) int { var ( max float64 alt int ) for _, g := range gain { alt += g max = math.Max(max, flo...
package tuner // tuner.go is a texel tuning implementation for Blunder. import ( "blunder/engine" "bufio" "fmt" "math" "os" "strings" ) const ( DataFile = "/home/algerbrex/quiet-labeled.epd" NumCores = 4 NumWeights = 774 Draw float64 = 0.5 WhiteWin float64 = 1.0 BlackWin float64 = 0....
/* * @file * @copyright defined in aergo/LICENSE.txt */ package p2putil import ( "net" "reflect" "testing" ) func TestResolveHostDomain(t *testing.T) { type args struct { domainname string } tests := []struct { name string args args exist bool wantErr bool }{ {"TSucc",args{"www.google.c...
package ui import ( "image" "image/color" "image/draw" "log" ) // IconGroup is a tile-hased grid display of object icons type IconGroup struct { component columns, rows int iconWidth, iconHeight int // size of each icon objects []IconGroupObject // holds the icons to displa...
package accesscontrol import ( "context" "net/http" "net/http/httptest" "testing" "github.com/corioders/gokit/errors" "github.com/corioders/gokit/web/middleware/accesscontrol/role" ) func TestNewLogin(t *testing.T) { accesscontrol, err := New("TestNewLogin, accesscontrol, number 1", validAccesscontrolKey) if...
package easy import ( "container/list" ) /* https://leetcode.com/problems/two-sum-iv-input-is-a-bst/description/ Given a Binary Search Tree and a target number, return true if there exist two elements in the BST such that their sum is equal to the given target. */ type TreeNode struct { Val int64 Left *TreeN...
// 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 rgbkbd import ( "context" "io/ioutil" "log" "time" "chromiumos/tast/ctxutil" "chromiumos/tast/local/chrome" "chromiumos/tast/local/chrome/uiauto/faillog" "c...
// 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...
package togo import ( "bytes" goast "go/ast" "go/token" "reflect" "strconv" phpast "github.com/stephens2424/php/ast" "github.com/stephens2424/php/ast/printer" ) func (t *Togo) ToGoStmt(php phpast.Statement) goast.Stmt { if v := reflect.ValueOf(php); v.Kind() == reflect.Ptr { php = v.Elem().Interface().(php...
// Copyright 2014 Wandoujia Inc. All Rights Reserved. // Licensed under the MIT (MIT-LICENSE.txt) license. package main import ( "github.com/wandoulabs/codis/ext/redis-port/args" "github.com/wandoulabs/codis/ext/redis-port/cmd" ) func main() { switch args.Code() { case "decode": cmd.Decode(args.NCPU(), args.In...
// Mandelbrot emits a PNG image of the Mandelbrot fractal. package main import ( "fmt" "image" "image/color" "image/png" "log" "math/cmplx" "net/http" "strconv" ) func main() { const ( width, height = 1024, 1024 ) params := map[string]float64{ "xmin": -2, "xmax": 2, "ymin": -2, "ymax": 2, "zoom...
package cache import ( "context" "strings" "github.com/go-redis/redis/v7" newrelic "github.com/newrelic/go-agent" ) var ( newrelicKey = contextKey("newrelicsegment") ) // NewRelicHook is used to instrument all calls to redis using a newrelic segment. type NewRelicHook struct { } // BeforeProcess is called bef...
// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved. // See LICENSE.txt for license information. // package api_test import ( "github.com/mattermost/mattermost-cloud/k8s" "github.com/mattermost/mattermost-cloud/model" log "github.com/sirupsen/logrus" ) type mockSupervisor struct{} func (s *mockSup...
package main import ( "bufio" "fmt" "log" "os" "strconv" ) func main() { var numbersOne, numbersTwo []int file, err := os.Open("day5_input.txt") if err != nil { log.Fatal(err) } defer file.Close() scanner := bufio.NewScanner(file) for scanner.Scan() { num, _ := strconv.Atoi(scanner.Text()) number...
// Copyright 2018 Authors of Cilium // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // // http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed ...
package file import ( "bytes" "fmt" "html/template" "io/ioutil" "os" ) // ReadFile 读取文件内容 func ReadFile(filePath string) (string, error) { fmt.Println(os.Getwd()) f, err := os.Open(filePath) if err != nil { return "", err } defer f.Close() bs, err := ioutil.ReadAll(f) if err != nil { return "", err ...
package main import ( "encoding/json" "fmt" "log" "net/http" "os" "github.com/go-redis/redis" "github.com/gorilla/mux" "github.com/streadway/amqp" ) type Person struct { Id string `json:"id"` Name string `json:"name"` City string `json:"city"` } var redisClient *redis.Client var QUEUE_NAME = "hello" va...
package selector import ( "context" "sync" ) // Default is composite selector. type Default struct { NodeBuilder WeightedNodeBuilder Balancer Balancer lk sync.RWMutex weightedNodes []Node } // Select select one node. func (d *Default) Select(ctx context.Context, opts ...SelectOption) (selected N...
package main import "fmt" //定义接口 type Noterfier interface { notify() } //定义结构体,实现接口 type Caller struct { name string age int } func (C *Caller) notify(){ fmt.Println("实现了调用") } func main() { c:=Caller{"Dongkun",24} //初始化结构体 Real(&c) } //调用接口的函数 func Real(n Noterfier){ n.notify() }
package dashrates import ( "encoding/json" "fmt" "io/ioutil" "net/http" "strconv" "time" ) // PoloniexAPI implements the RateAPI interface and contains info necessary for // calling to the public Poloniex price ticker API. type PoloniexAPI struct { BaseAPIURL string PriceTickerEndpoint string } // N...
package prefix import ( "math/rand" "reflect" "testing" "testing/quick" "time" ) var r = rand.New(rand.NewSource(time.Now().UnixNano())) func random() *MyStruct { v, _ := quick.Value(reflect.TypeOf(&MyStruct{}), r) return v.Interface().(*MyStruct) } func TestGoGenerate(t *testing.T) { this := random() that...
package action import ( "context" "github.com/hidayatullahap/go-monorepo-example/cmd/gateway/entity" "github.com/hidayatullahap/go-monorepo-example/pkg/grpc" pb "github.com/hidayatullahap/go-monorepo-example/pkg/proto/auth" ) func (a *GatewayAction) Login(ctx context.Context, request entity.LoginRequest) (string...
// Copyright (c) 2016 Uber Technologies, Inc. // // 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 limitation the rights // to use, copy, modify, merge...
package gomo import ( "time" ) // APIExecution records the execution time of the call type APIExecution struct { StartTime time.Time EndTime time.Time clock func() time.Time } // Start the timer func (e *APIExecution) Start() { e.StartTime = e.now() } // End the timer func (e *APIExecution) End() { e.En...
// https://programmers.co.kr/learn/courses/30/lessons/12940 package main func gcd0(a, b int) int { for b != 0 { a, b = b, a%b } return a } func p12940(n int, m int) []int { var a int a = gcd0(n, m) return []int{a, n / a * m} }
package protein import ( "errors" "strings" ) var ( ErrStop = errors.New("invalid codon stop") ErrInvalidBase = errors.New("invalid base") c2pMap = map[string]string{ "AUG": "Methionine", "UUU": "Phenylalanine", "UUC": "Phenylalanine", "UUA": "Leucine", "UUG": "Leucine", "UCU": "Serine", "...
package main import ( "encoding/json" "io/ioutil" "log" "net" ) var ubcranges []*net.IPNet func ParseIPs() { ubcranges = make([]*net.IPNet, 0) var ubcips []string ipsdata, err := ioutil.ReadFile("ubcIPs.json") if err != nil { log.Panicf("Error reading ubcIPs file: %v\n", err) } err = json.Unmarshal(ipsda...
package odoo import ( "fmt" ) // IrTranslation represents ir.translation model. type IrTranslation struct { LastUpdate *Time `xmlrpc:"__last_update,omptempty"` Comments *String `xmlrpc:"comments,omptempty"` DisplayName *String `xmlrpc:"display_name,omptempty"` Id *Int `xmlrpc:"id,om...
package migrations import ( "github.com/GibJob-ai/GObjob/db" ) // migrate the db func Migrate(db *db.DB) { migrate_1_add_user(db) migrate_2_add_files(db) }
package GoMylog import ( "io" "io/ioutil" "log" "os" ) var Trace *log.Logger var Info *log.Logger var Warning *log.Logger var Error *log.Logger type Level int const ( ERROR Level = 1 + iota WARNING INFO TRACE ) func Init(logLevel Level) { var ( errorHandle io.Writer infoHandle io.Writer warnin...
// Package main ... package main import ( "fmt" "github.com/go-rod/rod" ) func main() { rod.New().MustConnect().MustPage("https://www.google.com/").MustWaitLoad().MustPDF("sample.pdf") fmt.Println("wrote sample.pdf") }
package shared import ( "encoding/json" "fmt" ) // ConnectionError - dump of http request type ConnectionError struct { Code string `json:"code"` Message string `json:"message,omitempty"` } func (conn *ConnectionError) Error() string { return conn.Code } func (conn ConnectionError) printTab(prefix string) {...
/* * Copyright 2018 Google 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 required by applicable law or agreed to...
package routingtable import ( "github.com/bio-routing/bio-rd/net" "github.com/bio-routing/bio-rd/route" "github.com/bio-routing/bio-rd/routingtable/filter" ) // RouteTableClient is the interface that every type of RIB must implement type RouteTableClient interface { AddPath(*net.Prefix, *route.Path) error Remove...
package cmd import ( "fmt" "os" "github.com/influxdata/influx-spec/meta" "github.com/influxdata/influx-spec/spec" "github.com/influxdata/influx-stress/write" "github.com/spf13/cobra" ) var mf metaFlags func init() { metaCmd := &cobra.Command{ Use: "meta", Short: "Run suite of tests to verify that meta ...
/** * Copyright (c) 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 ...
package randperm import ( "math/rand" ) func Permute(v []int64, r *rand.Rand) { n := int32(len(v)) for n > 0 { i := r.Int31n(n) aux := v[n - 1] v[n - 1] = v[i] v[i] = aux n-- } }
/* Copyright 2020 Docker Compose CLI 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 main import "fmt" func main() { // array multi dimensi var numbers1 = [2][3]int{[3]int{4,3,6}, [3]int{9,1,5}} var numbers2 = [2][3]int{{2,5,1}, {2,1,6 }} fmt.Println("numbers1", numbers1) fmt.Println("numbers2", numbers2) var fruits = [4]string{"apple", "orange", "banana", "grape"} i := 0 for i < ...
package generator_test import ( "fmt" "github.com/bmdelacruz/generator" ) func ExampleController_Yield() { g := generator.New( func(gc *generator.Controller) (interface{}, error) { v, r, e := gc.Yield(1) fmt.Println("Controller#Yield(1) returns (", v, r, e, ")") return nil, nil }, ) v, r, e := g.N...
/* * Copyright (c) 2013 Matt Jibson <matt.jibson@gmail.com> * * Permission to use, copy, modify, and distribute this software for any * purpose with or without fee is hereby granted, provided that the above * copyright notice and this permission notice appear in all copies. * * THE SOFTWARE IS PROVIDED "AS IS" A...
package x import "net/http" func Run(addr string) error { return http.ListenAndServe(addr, &mux{}) }
package util // Migrated, slightly modified from www.jaapsch.net/scramble_cube.htm import ( "math" "math/rand" "github.com/coreyog/rubikstimer/config" ) // Scramble returns a scramble string func Scramble() string { var seq = []int{} // move sequences seqlen := config.GlobalConfig().ScrambleLength //tl=numb...
package controller import ( "database/sql" "fmt" "strconv" "gitee.com/goshark/dhs/model" "gitee.com/johng/gf/g/encoding/gjson" "gitee.com/johng/gf/g/frame/gmvc" "gitee.com/johng/gf/g/net/ghttp" ) type ControllerHome struct { gmvc.Controller } // 初始化控制器对象,并绑定操作到Web Server func init() { ghttp.GetServer().Bi...
// 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...
// ===================================== // // author: gavingqf // // == Please don'g change me by hand == // //====================================== // /*you have defined the following interface: type IConfig interface { // load interface Load(path string) bool // clear interface Clear() }...
package wal import ( "bytes" "context" "fmt" "io" "os" "path/filepath" "strings" "sync" "github.com/google/uuid" "github.com/grafana/tempo/tempodb/backend" "github.com/grafana/tempo/tempodb/encoding" "github.com/grafana/tempo/tempodb/encoding/common" ) const maxDataEncodingLength = 32 // AppendBlock is ...
package ontap import "encoding/xml" type EnvRequest struct { XMLName xml.Name `xml:"netapp"` Text string `xml:",chardata"` Version string `xml:"version,attr"` Xmlns string `xml:"xmlns,attr"` NmsdkVersion string `xml...
// 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 servo import ( "context" "fmt" "regexp" "strconv" "strings" "time" "chromiumos/tast/errors" "chromiumos/tast/testing" ) // These are the EC Servo controls ...
package cpu import ( "encoding/binary" "fmt" "log" "strings" nesmath "github.com/sardap/gos/math" "github.com/sardap/gos/memory" "github.com/sardap/gos/ppu" ) type Cpu struct { Registers *Registers Memory *memory.Memory Ppu *ppu.Ppu Cycles int ExtraCycles byte // h...
package main import ( // 包的导入是到目录一级 而不是到文件一级 "gogogo/foopkg" ) // 这里不能直接给包外的类型添加新的方法 // func (p Pointfoo) foobar() error { // return nil // } func main() { var p = new(foopkg.Pointfoo) // 大写的结构体成员就可以导出 p.Name = "1024" // 小写的结构体成员不能导出 // p.x = 1024 // 小写的方法名字也不会被导出 // p.distance...
package filesystem import ( "io" "io/fs" ) type File interface { io.Closer io.Reader io.Writer io.Seeker fs.File fs.ReadDirFile } // FileSystem is a header interface for representing a file-system. // // permission cheat sheet: // // +-----+---+--------------------------+ // | rwx | 7 | Read, write and execu...
// Copyright 2017 Google Inc. All Rights Reserved. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // // http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable...
package main import ( "fmt" ) //值传递 func swap(x int32, y int32) { var t int32 = 0 t = x x = y y = t } //多值返回 func swap2(x int32, y int32) (int32, int32) { return y, x } //引用传递 func swap3(x *int32, y *int32) { var t int32 = 0 t = *x *x = *y *y = t } func main() { var x int32 = 10 var y int32 = 20 fmt....
package swagger2gql import ( "regexp" "time" "github.com/pkg/errors" "github.com/EGT-Ukraine/go2gql/generator/plugins/dataloader" "github.com/EGT-Ukraine/go2gql/generator/plugins/graphql/lib/names" ) type FieldConfig struct { ContextKey string `mapstructure:"context_key"` } type ObjectConfig struct { Fields ...
/* Copyright 2020 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 gbc import "github.com/pokemium/worldwide/pkg/util" func (g *GBC) push(b byte) { g.Store8(g.Reg.SP-1, b) g.Reg.SP-- } func (g *GBC) pop() byte { value := g.Load8(g.Reg.SP) g.Reg.SP++ return value } func (g *GBC) pushPC() { upper, lower := byte(g.Reg.PC>>8), byte(g.Reg.PC) g.push(upper) g.push(lower)...
package cmd import ( "errors" "fmt" "github.com/Miniand/venditio/core" "github.com/Miniand/venditio/inject" "os" ) const ( DEP_COMMANDER = "cmdCommander" ) type Handler func(args []string) error type Commander interface { Register(command string, handler Handler) Handle(args []string) error } func Register...
package product import ( "time" "gopkg.in/mgo.v2/bson" ) // Product represents information about product type Product struct { ID bson.ObjectId `json:"id" bson:"_id"` Name string `json:"name"` Manufacturer string `json:"manufacturer"` Ean string `json:"ean"` ...
package handlers import ( "fmt" "net/http" ) func Home(w http.ResponseWriter, r *http.Request) { sessionToken, _ := r.Cookie("session_token") login := fmt.Sprintf("%v",Cache.Get(sessionToken.Value)) data := struct{ Username string }{ login, } render("home",data,w) }
package main import ( "encoding/binary" "errors" "fmt" "github.com/m4rw3r/uuid" zmq "github.com/pebbe/zmq4" "sync" "time" ) const ( OutBufferSize = 10 MaxWorkers = 16 PollInterval = 100 * time.Microsecond AliveTimeout = 2 MaxKAFailed = 2 HeartbeatingInterval = 1 ...
package requests import ( "fmt" "net/url" "strings" "github.com/google/go-querystring/query" "github.com/atomicjolt/canvasapi" "github.com/atomicjolt/string_utils" ) // ListAppointmentGroups Retrieve the paginated list of appointment groups that can be reserved or // managed by the current user. // https://ca...
package main import ( "net/http" "io/ioutil" "time" "fmt" "flag" ) func main() { start := time.Now() var port string flag.StringVar(&port, "port", "3000", "文字列を入力します。") flag.Parse() url := fmt.Sprintf("http://localhost:%s/", port) for i := 0; i < 10000; i++ { resp,...
// 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 nodewith import ( "regexp" gotesting "testing" "chromiumos/tast/local/chrome/uiauto/role" ) func TestArXbPseudolocale(t *gotesting.T) { if pseudo := makeArXBSt...
package swagger import ( "encoding/json" "fmt" "io" "net/http" "path/filepath" "reflect" "strings" "sync" ) // Object represents the object entity from the swagger definition type Object struct { IsArray bool `json:"-"` GoType reflect.Type `json:"-"` Name string ...
// Copyright 2020 cloudeng llc. All rights reserved. // Use of this source code is governed by the Apache-2.0 // license that can be found in the LICENSE file. package flags_test import ( "testing" "cloudeng.io/cmdutil/flags" ) func TestValidate(t *testing.T) { l := func(args ...interface{}) []interface{} { retu...
package common import ( config "github.com/goconf" log "code.google.com/p/log4go" ) var Conf configFile2 const ( COMMON = "common" TAOKE = "taoke" ) type configFile2 struct { conf *config.ConfigFile } func init() { if err := Conf.LoadConfigFile("conf/taoke.conf"); err != nil { panic(err) } } fun...
package polyline_test import ( "github.com/marinewater/polyline" "reflect" "testing" ) func TestEncode(t *testing.T) { encodeTests := []struct { name string Points []polyline.Point Precision uint32 Expected string }{ { name: "empty string (precision: 5)", Points: []polyline.Poin...
package main import ( "fmt" "log" "mime" "net/http" "os" "path" "runtime" "strings" "time" "rsc.io/cloud" "rsc.io/cloud/diskcache" "rsc.io/cloud/google/gcs" ) var ( start = time.Now() ) func main() { if !strings.HasPrefix(os.Getenv("BUCKET"), "gs://") { log.Fatal("-webroot argument must be a gs:// U...
package stack import ( "fmt" ) type ( // ArrayStack 구조체는 내부 자료구조로 슬라이스를 사용한다 ArrayStack struct { stack []interface{} size int cursor int } // Stack 인터페이스 Stack interface { IsFull() bool IsEmpty() bool Push(item interface{}) Stack Pop() interface{} Peek() interface{} } ) func New(size int) ...
package baidupcs import ( "fmt" "net/url" ) var ( appid = 260149 ) // PCSApi 百度 PCS API 详情 type PCSApi struct { url url.URL bduss string writed bool } // NewPCS 提供 百度BDUSS, 返回 PCSApi 指针对象 func NewPCS(bduss string) *PCSApi { return &PCSApi{ url: url.URL{ Scheme: "http", Host: "pcs.baidu.com",...
package model // URLInfo contains info on a test lists URL type URLInfo struct { CategoryCode string `json:"category_code"` CountryCode string `json:"country_code"` URL string `json:"url"` }
package api import ( "context" "encoding/json" "fmt" "github.com/gin-gonic/gin" "go.mongodb.org/mongo-driver/bson" "go.mongodb.org/mongo-driver/mongo/options" "io/ioutil" "jxc/auth" "jxc/models" "jxc/serializer" "net/http" "strconv" "time" "github.com/360EntSecGroup-Skylar/excelize" ) type ResponseDeta...
package fakes import ( "sync" awskms "github.com/aws/aws-sdk-go/service/kms" ) type KeysClient struct { DescribeKeyCall struct { sync.Mutex CallCount int Receives struct { DescribeKeyInput *awskms.DescribeKeyInput } Returns struct { DescribeKeyOutput *awskms.DescribeKeyOutput Error ...
package main import ( "fmt" "math" "time" ) func main() { start := time.Now() initialization() solveMaze() end := time.Now() summary(start, end) } /* The function initialization() will print a line to to notify the user that maze solving has started It will call updateToken() to give the tokenCache an init...
package request import ( "encoding/base64" "net/http" "testing" "github.com/stretchr/testify/assert" ) func TestAuthNone(t *testing.T) { req, err := http.NewRequest("GET", POSTMAN_ECHO_ROOT, nil) assert.Nil(t, err, "Should be nil") auth := newAuthNone() auth.Configure(req) assert.Empty(t, req.Header.Get(...
/* * Copyright (c) 2019. * by Steve Brush, Iridium Developers */ // Iridium core RPC API tests package iridium_go import ( "github.com/steevebrush/iridium-go/iridiumWalletdRPC" "github.com/steevebrush/iridium-go/iridiumdRPC" "strconv" "testing" ) func TestIridiumdRPCVersion(t *testing.T) { name, major, minor...
package main import ( "fmt" ) // Take note at what a beautiful func (person Person) Wave() string { return fmt.Sprintf("%s is waving at you!", person.FirstName) } // Lowercase functions are only hidden from OTHER PACKAGES but are still callable from anywhere withing the current package. func (person Person) pri...
package raw import "encoding/json" import "github.com/gorilla/mux" import "net/http" import "strconv" import "ops_log" import "ops_uds" import "io/ioutil" type json_msg_t struct { Status int `json:"status"` Version int `json:"version"` Data interface{} `json:"data"` } func Init() { } func responseWit...
/* * Copyright 2018 Anoop Vijayan Maniankara * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law ...
package main //121. 买卖股票的最佳时机 //给定一个数组,它的第i 个元素是一支给定股票第 i 天的价格。 // //如果你最多只允许完成一笔交易(即买入和卖出一支股票一次),设计一个算法来计算你所能获取的最大利润。 // //注意:你不能在买入股票前卖出股票。 // // // //示例 1: // //输入: [7,1,5,3,6,4] //输出: 5 //解释: 在第 2 天(股票价格 = 1)的时候买入,在第 5 天(股票价格 = 6)的时候卖出,最大利润 = 6-1 = 5 。 //注意利润不能是 7-1 = 6, 因为卖出价格需要大于买入价格;同时,你不能在买入前卖出股票。 //示例 2: // /...
package main import "fmt" func main() { arr1 := [3]int{1, 2} fmt.Println(arr1, len(arr1), cap(arr1)) arr2 := [...]int{13, 13, 123, 12312, 31, 23, 12, 312, 3, 1, 23, 12, 3} fmt.Println(arr2, len(arr2), cap(arr2)) fmt.Println("#########################") a := [...]string{"usa", "mexico", "russia", "kek"} b := ...
package liveupdates import ( "fmt" v1 "k8s.io/api/core/v1" "github.com/tilt-dev/tilt/internal/container" "github.com/tilt-dev/tilt/internal/controllers/apis/liveupdate" "github.com/tilt-dev/tilt/internal/k8s" "github.com/tilt-dev/tilt/internal/store/k8sconv" "github.com/tilt-dev/tilt/pkg/apis/core/v1alpha1" )...
// 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, ...