text
stringlengths
11
4.05M
package main import ( "fmt" "sort" "strings" ) type Person struct { Name string Age int } type PersonSlice []Person func (ps PersonSlice) Len() int { return len(ps) } func (ps PersonSlice) Swap(i, j int) { ps[i], ps[j] = ps[j], ps[i] } // func (ps PersonSlice) Less(i, j int) bool { // return ps[j].Age < ...
package main func main() { recursive(10) } func recursive(n int) { if n < 1 { return } println(n) recursive(n - 1) }
package vault import ( "errors" "fmt" "os" "testing" "github.com/hashicorp/vault/api" "github.com/libopenstorage/secrets" "github.com/libopenstorage/secrets/vault/utils" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" ) func setup() { os.Unsetenv(api.EnvVaultToken) os.Unsetenv(a...
package courses var Courses = map[int]string { 1: "Mathematics", 2: "Chemistry", 3: "Physics", 4: "Logic", }
package live import ( G "github.com/ionous/sashimi/game" R "github.com/ionous/sashimi/runtime" ) // func CarriedNotWorn(obj G.IObject) (carrier G.IObject) { carried := false for _, wob := range []string{"owner"} { if p := obj.Object(wob); p.Exists() { carrier, carried = p, true break } } // so we aren...
package cache import ( "time" "sync" "strconv" "../config" "../handlerTable" ) // Item 存储单元结构 type Item struct { val []byte createdTime time.Time lifespan time.Duration nilLifespan time.Duration handlerTable handlerTable.Table } // Bucket 内存缓存存储结构 type Bucket struct { sync.RWMutex dur ...
package pkg // Stack is a Stack implementation type Stack struct { top int el []interface{} } // New initializes a Stack ready to be used func New() *Stack { return &Stack{ top: -1, el: make([]interface{}, 0, 5), } } // Pop removes and returns the topmost element and true or returns nil and false func (s *...
package slices func StringsReverse(ss []string) { last := len(ss) - 1 for i := 0; i < len(ss)/2; i++ { ss[i], ss[last-i] = ss[last-i], ss[i] } }
package main import ( eh "github.com/Azure/azure-event-hubs-go/v3" azblob "github.com/Azure/azure-storage-blob-go/azblob" ) func CreateEvent(blobItem azblob.BlobItemInternal, content []byte) *eh.Event { event := eh.Event{} event.Data = content event.Properties = make(map[string]interface{}, len(blobIte...
package v1beta1 import ( "github.com/rancher/wrangler/pkg/condition" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" ) var ( UpgradeCompleted condition.Cond = "completed" // NodesUpgraded is true when all nodes are upgraded NodesUpgraded condition.Cond = "nodesUpgraded" // SystemServicesUpgraded is true when Harv...
package loadclient import ( "encoding/json" "fmt" "io/ioutil" "math/rand" "net/url" "strings" "time" "github.com/prometheus/common/config" "github.com/ViaQ/cluster-logging-load-client/loadclient/internal" logcli "github.com/grafana/loki/pkg/logcli/client" "github.com/grafana/loki/pkg/logproto" log "githu...
// Copyright 2020 The ChromiumOS Authors // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. // Package arcappcompat will have tast tests for android apps on Chromebooks. package arcappcompat import ( "context" "time" "chromiumos/tast/common/android/ui" "chromi...
package conts import ( "database/sql" "encoding/json" "fmt" "io/ioutil" "os/exec" "strings" _ "github.com/lib/pq" ) func dbCheck(env string) bool { var dbData map[string]string // file_get_contents dat, err := ioutil.ReadFile("/config/" + env + "/db.json") check(err) // json_decode err = json.Unmarsha...
package main import ( "fmt" "reflect" "time" ) type User2 struct { Name string Age int } func (u User2) Print(prfix string){ fmt.Printf("%s ; Name is %s Age is %d", prfix, u.Name, u.Age) } func main() { u := User2{"张三", 20} t := reflect.TypeOf(u) fmt.Println(t) fmt.Printf("%T\n", u) fmt.Printf("...
package nats import ( "context" ) // RequestFunc may take information from an NATS request and put it into a // request context. In Servers, RequestFuncs are executed prior to invoking the // endpoint. In Clients, RequestFuncs are executed after creating the request // but prior to invoking the client. type RequestF...
package sqlutil import ( "database/sql" "encoding/base64" "errors" "fmt" "reflect" "strconv" "sync" ) // AppendValue appends to dst a UTF-8 string representation of src. Byte slices will be formatted via RFC 4648 Base64. func AppendValue(dst []byte, src interface{}) ([]byte, error) { switch val := src.(type) ...
package main import ( "flag" "log" "net/http" "github.com/aligator/neargo/datasource/geonames" "github.com/aligator/neargo/server" ) func main() { gn := geonames.Geonames{} gn.Flag() host := flag.String("host", "0.0.0.0:3141", "Host and Port to listen on.") flag.Parse() neargo := server.Neargo{ Source: ...
package functions import "github.com/webmachinedev/types" func GetPackage(id string) types.Package { }
// Copyright 2019 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 IBM Corporation 2020, 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...
package main import "fmt" func main(){ fmt.Println("Enter temperature in Fahrenhite: ") var temp float64 fmt.Scanf("%f", &temp) temp = ((temp-32)*5/9) fmt.Println("Temperature in Celsius is: ",temp) }
// 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 contract import ( "fmt" "regexp" ) var ( contractNameRegex = regexp.MustCompile("^[a-zA-Z_]{1}[0-9a-zA-Z_.]+[0-9a-zA-Z_]$") ) const ( contractNameMaxSize = 16 contractNameMinSize = 4 ) // ValidContractName return error when contractName is not a valid contract name. func ValidContractName(contractName ...
// Copyright (c) 2016-2019 Uber Technologies, 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...
package main import ( "encoding/json" "fmt" "io/ioutil" "net/http" "os" "github.com/gin-gonic/gin" ) func main() { // Listen on port and reply with bing image url r := gin.Default() r.GET("/", func(c *gin.Context) { c.String(200, getImageURL()) }) port := os.Args[1:][0] r.Run(":" + port) // listen on ...
package shell import ( "testing" "github.com/stretchr/testify/assert" ) func TestStringifier(t *testing.T) { assert.Equal(t, "du -c /foobar", DiskUsageWithTotal("/foobar").String()) assert.Equal(t, "tail -n 1", FilterLastLineOnly().String()) assert.Equal(t, "du -c /foobar | tail -n 1", Pipe(DiskUsageWithTotal("...
/* Copyright 2021 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 leetcode_1137_第N个泰波那契数 /* 泰波那契序列 Tn 定义如下: T0 = 0, T1 = 1, T2 = 1, 且在 n >= 0 的条件下 Tn+3 = Tn + Tn+1 + Tn+2 给你整数 n,请返回第 n 个泰波那契数 Tn 的值。 示例 1: 输入:n = 4 输出:4 解释: T_3 = 0 + 1 + 1 = 2 T_4 = 1 + 1 + 2 = 4 示例 2: 输入:n = 25 输出:1389537 */ /* dp数组存取之前求过的结果,当下次要的时候直接取 */ func tribonacci(n int) int { var dp = make([]int,...
package packets import "bytes" import "io" type EncryptreqPacket struct { E int N []byte EnCode uint8 FixedHeader } func (en *EncryptreqPacket) Unpack(r io.Reader) error{ return nil } func (en *EncryptreqPacket) Write(w io.Writer) error{ var body bytes.Buffer getLen :...
package main import ( "log" "net/http" "../src/api" "../src/static" "../src/templates" "../src/universe" ) func main() { err := universe.Init("127.0.0.1", 6666) if err != nil { log.Fatal(err) } http.Handle("/api/", api.Handler()) http.Handle("/static/", http.StripPrefix("/static/", static.Handler())) ...
package define const TestEnv = "test" //单元测试标识 //redis 订阅发布中发送的任务标识 type RedisTaskMark string const ( GrabPoetryAll RedisTaskMark = "poetryAll" //抓取诗词所有数据 GrabPoetryRecommend RedisTaskMark = "poetryRecommend" //抓取诗词推荐数据 ) //任务执行状态 type TaskStatus int const ( TaskStatusImplemented TaskStatus = 0 //未...
package main import ( "fmt" "os" "bufio" ) // write code for receiver here func main(){ file, err := os.Open("generator_output.txt") // read our generator_output file in // handle event where the file cannot open correctly if err != nil { panic(err) } defer file.Close() // when the program is terminate...
package model import "time" type EsItem struct { Metric string `json:"metric"` Endpoint string `json:"endpoint"` Timestamp time.Time `json:"timestamp"` Step int64 `json:"step"` Value float64 `json:"value"` CounterType string `...
package usecase import ( "github.com/izumin5210/scaffold/domain/scaffold" ) // GetScaffoldsUseCase is an use-case for loading scaffolds type GetScaffoldsUseCase interface { Perform(dir string) ([]scaffold.Scaffold, error) }
package bellows import ( "encoding/json" "github.com/stretchr/testify/assert" "testing" ) var ( example = map[string]interface{}{ "a": "b", "b": []string{"1", "2", "3"}, "c": []interface{}{ map[string]interface{}{"d": 1, "e": true, "k": []int{5, 6, 7}}, map[string]interface{}{"d": 2, "e": false, "t": ...
package main import ( "fmt" "image" "image/png" "os" "github.com/kbinani/screenshot" ) func main() { x := 0 y := 0 w := 10 h := 10 rect := image.Rect(x, y, x+w, y+h) img, err := screenshot.CaptureRect(rect) bounds := img.Bounds() var histogram [16][4]int for y := bounds.Min.Y; y < bounds.Max.Y; y++ { ...
package manifests import ( "bytes" "context" "io" "net/http" "os" "strconv" "testing" "github.com/Dynatrace/dynatrace-operator/src/dtclient" "github.com/pkg/errors" "github.com/stretchr/testify/require" k8serrors "k8s.io/apimachinery/pkg/api/errors" "sigs.k8s.io/e2e-framework/klient/decoder" "sigs.k8s.io...
package main import ( "fmt" "github.com/lxn/win" "log" "syscall" "time" "unsafe" ) var DiskCounters = []string{ "Avg. Disk sec/Read", "Avg. Disk sec/Write", "Disk Read Bytes/sec", "Disk Write Bytes/sec", "Current Disk Queue Length", "Disk Reads/sec", "Disk Writes/sec", "% Disk Time", "% Disk Read Time"...
package main func main() { var x []int x = append(x, 4, 5) }
package main import ( "flag" "golang-crontab/master" "runtime" "time" ) var configFile string func initArgs() { flag.StringVar(&configFile, "config", "./master.json", "配置文件位置") flag.Parse() } func initEnv() { runtime.GOMAXPROCS(runtime.NumCPU()) } func main() { initArgs() initEnv() // 加载配置 err := mas...
package check import ( "encoding/json" "fmt" "strings" "sync" "time" "github.com/jbvmio/krc" "github.com/jbvmio/krc/config" "github.com/jbvmio/krc/db" "github.com/jbvmio/krc/output" krcSync "github.com/jbvmio/krc/sync" "github.com/jbvmio/kafkactl" "github.com/tidwall/pretty" ) var restartCG chan bool va...
// Copyright (c) 2020 Meng Huang (mhboy@outlook.com) // This package is licensed under a MIT license that can be found in the LICENSE file. // Package msg provides a way to use System V message queues. package msg
package antnet import ( "testing" ) func Test_MinHeap(t *testing.T) { mh := NewMinHeap() for i := 10000; i > 0; i-- { mh.Push(i, i) } m, p := mh.GetMin() top := mh.Top() Printf("min : %v %v %v\n", m, p, top) for i := 0; i < 10; i++ { x := mh.Pop() Printf("%v ", x) } Println("") mh.Push(1, 554654) ...
/* Copyright 2018 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 agreed to in writing, ...
package onsdb import ( "context" "log" "os" "runtime" "golang.org/x/sync/errgroup" "github.com/smartystreets/scanners/csv" ) // PostcodeData represents an individual postcode with its associated data type PostcodeData struct { Postcode string `csv:"pcds"` Latitude string `csv:"lat"` Longi...
package local import ( "bytes" "context" "errors" "io" "os" "path/filepath" "testing" "github.com/golang/mock/gomock" "github.com/google/uuid" "github.com/stretchr/testify/assert" "github.com/traPtitech/trap-collection-server/src/config/mock" "github.com/traPtitech/trap-collection-server/src/domain/values...
package cache import ( "encoding/json" "github.com/go-redis/redis" "github.com/pkg/errors" ) type Client interface { Insert(id string, object interface{}) error Get(id string, interfaceType interface{}) error GetAll() (map[string]string, error) Remove(id string) error RemoveAll() error Close() } type RedisC...
package twitterstream import ( "bytes" "fmt" "github.com/fallenstedt/twitter-stream/httpclient" "io/ioutil" "net/http" "testing" ) func TestAddRules(t *testing.T) { var tests = []struct { body string mockRequest func(queryParams string, body string) (*http.Response, error) result *rulesRespo...
package main import ( "github.com/wudiliujie/common/log" "github.com/wudiliujie/common/module" "github.com/wudiliujie/common/mysql" "time" "yxlserver/services/conf" "yxlserver/services/consts" "yxlserver/services/logic/reload" "yxlserver/services/module/app" "yxlserver/services/module/db" "yxlserver/services...
package handlers import ( "net/http" ) func AssetsServer(assetsDir string) http.Handler { return http.FileServer(http.Dir(assetsDir)) }
package router import ( "net/http" "github.com/sudarshan-reddy/benjerry/httputils" ) //ScopesType is used to indicate tokens that are //static/provided by application type ScopesType int //AuthTokenType is used to indicate authtoken in context type AuthTokenType int const ( //ContextKeyScopes is a constant that...
package cmd import ( "github.com/cnrancher/autok3s/pkg/cli/kubectl" "github.com/spf13/cobra" ) func KubectlCommand() *cobra.Command { return kubectl.EmbedCommand() }
package core import ( "encoding/json" "fmt" "io/ioutil" "path/filepath" "strings" "github.com/layer5io/meshery/internal/store" "github.com/layer5io/meshkit/models/oam/core/v1alpha1" ) type genericCapability struct { // OAMRefSchema is the json schema for the workload OAMRefSchema string `json:"oam_ref_schem...
// Copyright (c) 2016-2019 Uber Technologies, 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...
package main import ( "bufio" "context" "fmt" "log" "math/rand" "net" "os" "strconv" "strings" "unicode" "./propu" "./uploader" "google.golang.org/grpc" ) type server struct { } //candado para regular el acceso al namenode. var ocupado bool = false //recibimos la propuesta , aceptamos o rechazamos y r...
package cmd import ( "os" "path/filepath" "strings" log "github.com/sirupsen/logrus" "github.com/urfave/cli" "github.com/ludwieg/ludco/langs" ) var Compile = cli.Command{ Name: "compile", Aliases: []string{"c"}, Usage: "Compiles a Ludwieg project", Flags: []cli.Flag{ cli.StringFlag{ Name: "lang...
// 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 numrect func countGoodRectangles(rectangles [][]int) int { good := 0 max := 0 for _, r := range rectangles { side := r[0] if side > r[1] { side = r[1] } if side > max { max = side good = 1 } else if side == max { good++ } } return good }
package main import ( "context" "fmt" "go-grpc-microservice/microservice/microservicepb" "log" "google.golang.org/grpc" ) func main() { fmt.Println("Hellow i am client") cc, err := grpc.Dial("localhost:50051", grpc.WithInsecure()) if err != nil { log.Fatalf("could not comment: %v\n", err) } defer cc.Cl...
// 191. Writing documentation 打包PKG 註解位置 package m_Yearchange import ( "fmt" ) // Yearchange() 備註 func Yearchange(xi int) int { sum := xi * 7 fmt.Println("here is in -Yearchange pkg- u send:", xi) fmt.Println("human year:", xi, "dog year:", sum) return sum }
package leetcode /** * Definition for singly-linked list. * type ListNode struct { * Val int * Next *ListNode * } */ func removeNthFromEnd(head *ListNode, n int) *ListNode { cur := head var length int for cur != nil { length++ cur = cur.Next } virtual := &ListNode{0, head} newcur := virtual fo...
package configwrite import ( "testing" "github.com/hashicorp/hcl/v2" "github.com/stretchr/testify/assert" ) type stepTest struct { name string step Step in map[string]string expected map[string]string diags hcl.Diagnostics } type stepTests []stepTest func testStepChanges(t *testing.T, test...
package game import ( "github.com/nsf/termbox-go" ) type PainterConfig struct { Colors struct { Snake termbox.Attribute Food termbox.Attribute Bg termbox.Attribute } Symbols struct { Snake rune Food rune } } func PainterCfg() *PainterConfig { var cfg PainterConfig cfg.Colors.Snake = termbox.Co...
package router import ( "github.com/gin-gonic/gin" "hd-mall-ed/packages/client/controller/authController" ) func authRouter(router *gin.RouterGroup) { auth := router.Group("/auth") { // 登录接口 auth.POST("/login", authController.GetAuth) // 退出登录 auth.GET("/logout", authController.Logout) } }
package container import ( "github.com/bitmaelum/bitmaelum-server/core/account/server" "github.com/bitmaelum/bitmaelum-server/core/config" "github.com/mitchellh/go-homedir" ) var accountService *server.Service = nil var accountRepository *server.Repository = nil func GetAccountService() *server.Service { if a...
package main import ( "fmt" "os" "os/signal" "./config" "net/http" //"gopkg.in/Shopify/sarama.v1" "github.com/Shopify/sarama" ) var osSignalChan = make(chan os.Signal,1) var client *Client func main() { signal.Notify(osSignalChan,os.Interrupt) go handleShutdown() port := config.BindPort() kHost := config...
package experiments import ( "fmt" "os" "strings" "text/tabwriter" "github.com/joho/godotenv" "github.com/go-task/task/v3/internal/logger" ) const envPrefix = "TASK_X_" var GentleForce bool func init() { readDotEnv() GentleForce = parseEnv("GENTLE_FORCE") } func parseEnv(xName string) bool { envName := ...
package web import ( "encoding/json" "fmt" "io" "net/http" "github.com/AbhilashBalaji/abcd/config" "github.com/AbhilashBalaji/abcd/replication" "github.com/AbhilashBalaji/abcd/db" ) // Server Contains HTTP handlers for DB type Server struct { db *db.Database shards *config.Shards } // NewServer create...
package npilib import ( c "github.com/arkaev/npilib/commands" ) //HandleRegisterPeer will process "RegisterPeer" command func HandleRegisterPeer(nc *Conn, msg *Msg) { rs := msg.Parsed.(*c.RegisterPeerRs).Response.Params nc.allowEncoding = rs.AllowEncoding nc.domain = rs.Domain nc.node = rs.Node nc.peer = rs.Pee...
package main import ( "flag" "fmt" "log" "net/http" "time" ) type Forever struct{} func (f *Forever) ServeHTTP(w http.ResponseWriter, r *http.Request) { log.Printf("%s, %s, %s", r.RemoteAddr, r.Method, r.URL) closeNotify := w.(http.CloseNotifier).CloseNotify() flusher := w.(http.Flusher) w.WriteHeader(htt...
package tasks_test import ( "context" "fmt" "net/http" "net/http/httptest" "sync" "testing" "time" "github.com/ooni/probe-cli/v3/pkg/oonimkall/internal/tasks" ) func TestRunnerMaybeLookupBackendsFailure(t *testing.T) { server := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request...
package ch09 func dailyTemperatures(T []int) []int { stack := make([]int, 0) result := make([]int, len(T)) for i := 0; i < len(T); i++ { for len(stack) > 0 && T[stack[len(stack)-1]] < T[i] { last := stack[len(stack)-1] result[last] = i - last stack = stack[:len(stack)-1] } stack = append(stack, i)...
// Copyright 2022 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 routers import ( "github.com/astaxie/beego" "meetingRecord/controllers" ) func init() { beego.Router("/default", &controllers.MainController{}) beego.Router("/login", &controllers.LoginController{}) beego.Router("/register", &controllers.RegisterController{}) beego.Router("/", &controllers.HomeControlle...
package storage import ( "context" "io" "github.com/ipfs/go-cid" "github.com/filecoin-project/specs-actors/actors/abi" ) type Data = io.Reader type Storage interface { // Creates a new empty sector (only allocate on disk. Layers above // storage are responsible for assigning sector IDs) NewSector(ctx conte...
package amx import ( "encoding/json" "testing" "github.com/prebid/prebid-server/openrtb_ext" "github.com/stretchr/testify/assert" ) var validBidParams = []string{ `{"tagId":"sampleTagId", "adUnitId": "sampleAdUnitId"}`, `{"tagId":"sampleTagId", "adUnitId": ""}`, `{"adUnitId": ""}`, `{"adUnitId": "sampleAdUni...
package main import "fmt" // map 类型test func printM(cc map[string]string) { for c := range cc { fmt.Println("capital of ", c, "是", cc[c]) } } type c struct{ A int B string } func main() { fmt.Println("map 学习;") // 申名变量; var countryCapitalMap map[string]string // 创建集合 countryCapitalMap = make(map[string]...
// 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 main import ( "fmt" "github.com/AntonMaltsev/uis_dockable/client" "github.com/codegangsta/cli" "log" "os" // "strconv" ) func main() { app := cli.NewApp() app.Name = "UIS cli" app.Usage = "cli to work with the UIS microservice" app.Version = "0.0.1" app.Flags = []cli.Flag{ cli.StringFlag{"host"...
// 门店装修服务 package elemeOpenApi // 创建招贴 // sign 招贴信息和其关联门店ID集合 func (sign *Sign) CreateSign(sign_ interface{}) (interface{}, error) { params := make(map[string]interface{}) params["sign"] = sign_ return APIInterface(sign.config, "eleme.decoration.sign.createSign", params) } // 修改招贴 // signId 招贴ID // sign 招贴信息和其关联门...
package main import ( "os" "path" "github.com/mitchellh/go-homedir" log "github.com/sirupsen/logrus" "github.com/spf13/viper" "github.com/sp0x/torrentd/config" ) var appConfig config.ViperConfig func initConfig() { // We load the default config file homeDir, _ := homedir.Dir() if configFile != "" { vipe...
package main import ( "fmt" ) func main() { // The type [n]T is an array of n values of type T. // An array's length is part of its type, so arrays cannot be resized. var a [2]string a[0] = "Hello" a[1] = "World" fmt.Println(a[0], a[1]) // Hello World fmt.Println(a) // [Hello World] // An array has...
package main import ( "flag" "fmt" "io/ioutil" "os" "github.com/bitrise-io/step-yml-linter/lint" "github.com/bitrise-io/step-yml-linter/step" "gopkg.in/yaml.v3" ) var filePath = flag.String("file", "step.yml", "Path to the file") func main() { flag.Parse() stepYMLContent, err := ioutil.ReadFile(*filePath)...
package main import ( "github.com/astaxie/beego" _ "go_mod-project/cmd/blog/routers" "go_mod-project/cmd/blog/utils" ) func main() { utils.InitMysql() beego.Run() }
package main import "sort" type Ints []int type ByValueAscending []int func (b ByValueAscending) Len() int { return len(b) } func (b ByValueAscending) Less(i int, j int) bool { return b[j] < b[i] } func (b ByValueAscending) Swap(i int, j int) { b[i], b[j] = b[j], b[i] } func (a Ints) HighestProduct() int { i...
package main import ( "github.com/gin-gonic/gin" ) func setupRouter() *gin.Engine { router := gin.Default() initializeRoutes(router) return router } // @title Ingrid Backend Coding Task App // @version 1.0 // @description This is a sample REST API application built for Ingrid coding task. // @contact.name Arkad...
// Copyright 2015 The Prometheus 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 app import ( "testing" "github.com/stretchr/testify/require" "github.com/stretchr/testify/suite" ) func TestNewClient(t *testing.T) { testCases := []struct { name string mnemomonicStr string expErr bool }{ {"success", Mnemonic, false}, {"invalid mnemonic", "error", true}, {"e...
// Copyright 2016-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 ag...
/* Copyright 2019 The Knative 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, soft...
package checkers_test import ( "testing" . "github.com/bentrevor/checkers/src" ) var rules = CheckersRules{} func TestRules_KnowsWhereAPieceCanMove(t *testing.T) { board := NewGameBoard() whitePiece, _ := board.GetPieceAtSpace(G3) blackPiece, _ := board.GetPieceAtSpace(H6) whitePieceWithoutMoves, _ := board.G...
package main import ( "flag" "fmt" "go/ast" "go/importer" "go/parser" "go/printer" "go/token" "go/types" "log" "os" "reflect" "github.com/davecgh/go-spew/spew" ) func main() { path := flag.String("path", "../example", "The source path of a Go package") check := flag.Bool("check", true, "Add or remove N...
// Copyright 2013 Daniel Jo. All rights reserved. // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. // Package console defines an API for manipulating a terminal. Currently it is // built around VT100 escape sequences, though it is conceivable that the API // may b...
// 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 gamepad import ( "context" "time" "chromiumos/tast/errors" "chromiumos/tast/local/bundles/cros/gamepad/dualshock" "chromiumos/tast/local/bundles/cros/gamepad/j...
package main import ( "fmt" "tempconv/tempconv" ) //Exercise 2.1 -- Add types/constants and functions to tempconv for processing temperatures in Kelvin func main() { fmt.Printf("Brrrr! %v\n", tempconv.AbsoluteZeroC) fmt.Printf("Brrrr! %v\n", tempconv.CToF(tempconv.BoilingC)) fmt.Printf("F to K = %v\n", tempconv...
package resources import ( "io" "strings" "sync" "sync/atomic" "errors" ) type protocolReader struct { protocol string open func(url string) (io.ReadCloser, error) } // Resource 资源类型 type Resource string var ( readerMu sync.Mutex readerProtocols atomic.Value // ErrForNotSupportResource 不支持的资源类...
package discovery import ( "math/rand" "net/url" "testing" ethcommon "github.com/ethereum/go-ethereum/common" "github.com/livepeer/go-livepeer/common" "github.com/livepeer/go-livepeer/core" "github.com/livepeer/go-livepeer/eth" lpTypes "github.com/livepeer/go-livepeer/eth/types" "github.com/livepeer/go-livep...
package com import ( "JsGo/JsBench/JsStatistics" "JsGo/JsHttp" "JsGo/JsLogger" "JsGo/JsStore/JsRedis" "JunSie/constant" "fmt" ) //获取完整的产品统计 func GetProductStatics(session *JsHttp.Session) { type Para struct { ProID string //产品id } st := &Para{} if err := session.GetPara(st); err != nil { JsLogger.Error(...
package ast import ( "github.com/felixangell/goof/types" ) type Node interface { Type() types.Type String() string }
package main import ( "encoding/base64" "flag" "io/ioutil" "log" "os" "os/user" "github.com/portantier/asydns-client/asydns" "github.com/portantier/asydns-client/util" "github.com/portantier/asydns-client/xcrypto" ) func main() { optURL := flag.String("url", "https://asydns.org", "API URL") optRevoke := ...