text
stringlengths
11
4.05M
package list import ( "testing" "fmt" ) func TestNew(t *testing.T) { list := New() t.Log(list) } type item struct { key string value string } func (i *item) String() string { return fmt.Sprintf("key=%s, value=%s", i.key, i.value) } func Init(l *List) *List { e := l.PushBack(&item{"3", "33333"}) l.PushFr...
package main import "fmt" func nextint() func() int{ i := 0 return func() int { i += 1 return i } } func main(){ ni := nextint() fmt.Println(ni()) fmt.Println(ni()) fmt.Println(ni()) }
package parameters type ( GetItemRequest struct { RootRequest } GetItemListRequest struct { RootRequest TagID uint64 `json:"tag_id" mapstructure:"tag_id"` Limit int `json:"limit" mapstructure:"limit"` } GetItemFavoriteListRequest struct { RootRequest Limit int `json:"limit" mapstructure:"limit"` }...
package main import "fmt" func main() { min := 1 max := 1000000 fmt.Printf("Think of an integer between %d and %d.\n", min, max) fmt.Println("Now I'll try to guess it, using 20 questions or less.") var answer string for answer != "yes" { fmt.Print("Ready? ") fmt.Scanf("%s", &answer) } for i := 0; i < 20...
// ˅ package main // ˄ type Display struct { // ˅ // ˄ impl DisplayImpl // ˅ // ˄ } func NewDisplay(impl DisplayImpl) *Display { // ˅ return &Display{impl} // ˄ } func (self *Display) Output() { // ˅ self.Open() self.Write() self.Close() // ˄ } func (self *Display) Open() { // ˅ self.impl.ImplOp...
package main import ( "strings" "time" "github.com/kelseyhightower/envconfig" ) type Config struct { MongoURI string `envconfig:"mongo_uri"` GannettAPIKey string `envconfig:"gannett_search_api_key"` GannettAssetAPIKey string `envconfig:"gannett_asset_api_key"` SiteCodes []string Summa...
package elasticsearch import ( "errors" "reflect" "github.com/manishrjain/gocrud/search" "github.com/manishrjain/gocrud/x" "gopkg.in/olivere/elastic.v2" ) var log = x.Log("elasticsearch") // Elastic encapsulates elastic search client, and implements methods declared // by search.Engine. type Elastic struct { ...
// Copyright (c) 2019 bketelsen // // This software is released under the MIT License. // https://opensource.org/licenses/MIT package main import "github.com/bketelsen/devlx/cmd" func main() { cmd.Execute() }
package doom import ( "fmt" "strconv" ) type Mode string const ( DM Mode = "dm" CTF = "ctf" TDM = "tdm" ) type args []string func (a args) Add(key, value string) args { a = append(a, key, value) return a } type Config struct { Name string `toml:"name"` Hostname string `toml:...
package models import ( "encoding/json" "strconv" "github.com/empirefox/esecend/front" ) type WxGoodsDetail struct { ID string `json:"goods_id"` // Product.ID Name string `json:"goods_name"` // Product.Name Num uint `json:"goods_num"` Price uint `json:"price"` } type WxOrderDetail struct { Goods...
package main import ( "testing" "github.com/shanghuiyang/rpi-devices/app/car/car" "github.com/stretchr/testify/assert" ) func TestStart(t *testing.T) { car := car.New(&car.Config{}) assert.NotNil(t, car) s := newServer(car) assert.NotNil(t, s) }
package main import "net" func main() { li, err := net.Listen("tcp", ":8080") if err != nil { panic(err) } defer li.Close() for { conn, err := li.Accept() if err != nil { panic(err) } for { bs := make([]byte, 1024) n, err := conn.Read(bs) if err != nil { break } _, err = conn.W...
package main import ( "fmt" "strings" "testing" "github.com/stretchr/testify/assert" ) func TestITetrominoShape(t *testing.T) { out := ` 0001 0001 0001 0001` s := NewITetromino() out2 := shapeToString(s.Shape()) assert.Equal(t, strings.TrimSpace(out), out2) assert.Equal(t, &Size{w: 1, h: 4}, s.Size()) } fu...
package structs import "encoding/xml" type ClientUpdateRequest struct { XMLName xml.Name `xml:"ClientUpdateRequest"` Text string `xml:",chardata"` Xsd string `xml:"xsd,attr"` Xsi string `xml:"xsi,attr"` BranchCode string `xml:"BranchCode"` Requester string `xm...
package types // TypeString maps an unknown type to a string indicating its type. func TypeString(t Type) (string, bool) { switch v := t.(type) { case *Value: if v.Const { return "const", true } return "var", true case *Interface: return "interface", true case *Function: return "function", true defau...
package _559_Maximum_Depth_of_N_ary_Tree type Node struct { Val int Children []*Node } func maxDepth(root *Node) int { return maxDepthRecursively(root) } // 递归解法 func maxDepthRecursively(root *Node) int { if root == nil { return 0 } var ( result int ) for _, child := range root.Children { tr := ma...
// Copyright 2022 PingCAP, 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 to i...
package mysql import ( "database/sql" "github.com/bearname/videohost/internal/common/db" "github.com/bearname/videohost/internal/videoserver/domain/dto" "github.com/bearname/videohost/internal/videoserver/domain/model" ) type SubtitleRepository struct { connector db.Connector } func NewSubtitleRepository(connec...
package main import ( "fmt" "html" "log" "net/http" "github.com/Shopify/sarama" ) const topic = "demo-topic" func main() { producer, err := newProducer() if err != nil { fmt.Println("Could not create producer: ", err) } consumer, err := sarama.NewConsumer(brokers, nil) if err != nil { fmt.Println("Co...
package seev import ( "encoding/xml" "github.com/thought-machine/finance-messaging/iso20022" ) type Document01400101 struct { XMLName xml.Name `xml:"urn:iso:std:iso:20022:tech:xsd:seev.014.001.01 Document"` Message *AgentCAElectionCancellationRequestV01 `xml:"AgtCAElctnCxlReq"` } f...
package models import "github.com/jinzhu/gorm" type Link struct { BaseModel Img string `json:"img"` Name string `json:"name"` Url string `json:"url"` } func (link *Link) Create(db *gorm.DB) (*Link, error) { var model Link err := db.Create(&link).Error if err == nil { db.Where("id = ?", link.ID).First(&mod...
/* Package dbadmin - A package created to implement db admin related activites */ package dbadmin import ( "database/sql" "time" "github.com/nagendra547/go-db-loadbalancer/health" "github.com/nagendra547/go-db-loadbalancer/log" "github.com/nagendra547/go-db-loadbalancer/mydb" ) /*ReadReplicaRoundRobin - Get a r...
package config import ( "fmt" "os" "path/filepath" "github.com/koding/multiconfig" "github.com/tada3/triton/logging" ) const ( defaultConfigFile = "config.yaml" ) var ( homeDir string configInEffect *Config log *logging.Entry ) type Config struct { MySQLHost string `default:"localhs...
// Copyright 2014 Chris Monson <shiblon@gmail.com> // // 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 import "fmt" func main() { cases := [][]int{ {}, {}, } realCase := cases[0:] for i, c := range realCase { fmt.Println("## case", i) // solve fmt.Println(c) } }
package main func main() { } func extractMantra(matrix []string, mantra string) int { return 0 }
// Copyright 2019 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 in ...
package divider_test import ( "testing" "time" "github.com/b-2019-apt-test/divider/internal/divider" "github.com/b-2019-apt-test/divider/internal/divider/mocks" ) var runner = func(t *testing.T, test mocks.TestCase) { reporter := mocks.NewFakeResultReporter() proc := mocks.NewJobProcessor(). SetJobProvider(...
package backend_controller import ( "2021/yunsongcailu/yunsong_server/backend/backend_model" "2021/yunsongcailu/yunsong_server/backend/backend_service" "2021/yunsongcailu/yunsong_server/common" "2021/yunsongcailu/yunsong_server/param/backend_param" "2021/yunsongcailu/yunsong_server/tools" "github.com/gin-gonic/g...
package main import ( "log" "math/rand" "net/http" "time" ) func Start(res http.ResponseWriter, req *http.Request) { log.Print("START REQUEST") data, err := NewStartRequest(req) if err != nil { log.Printf("Bad start request: %v", err) } dump(data) respond(res, StartResponse{ Taunt: "battlesna...
package main import ( "fmt" "log" "math" ) // NorgateMathError - using struct for more informative custom error // We are using "N" in "NorgateMathError" because we want it to be accessible outside the package type NorgateMathError struct { lat, long string err error } func (n *NorgateMathError) Error() s...
package controller import ( "fmt" appconfig "github.com/allentom/youcomic-api/config" ApiError "github.com/allentom/youcomic-api/error" "github.com/allentom/youcomic-api/services" "github.com/gin-gonic/gin" "path" "strings" ) var BookContentHandler gin.HandlerFunc = func(context *gin.Context) { id, err := Get...
package ui import ( "fyne.io/fyne/v2" ) type viewID uint const ( LIST_TICKETS_VIEW viewID = iota SEND_TICKET_VIEW CREDENTIALS_VIEW ) type view struct { Win fyne.Window }
package amazon import ( "encoding/base64" "errors" "fmt" "strings" "time" "github.com/quilt/quilt/cluster/acl" "github.com/quilt/quilt/cluster/cloudcfg" "github.com/quilt/quilt/cluster/machine" "github.com/quilt/quilt/db" "github.com/quilt/quilt/join" "github.com/quilt/quilt/util" "github.com/aws/aws-sdk...
// Copyright 2018 The Operator-SDK 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 ...
package giantbomb import ( "encoding/json" "net/http" "net/url" "github.com/google/go-querystring/query" ) type Client struct { key string } func NewClient(key string) *Client { // TODO: check valid key return &Client{ key: key, } } func (c *Client) Search(name string) (*GameType, error) { searchUrl, _ ...
package model import ( "encoding/json" "github.com/iotaledger/goshimmer/dapps/valuetransfers/packages/address" ) // Address is the base58-encoded representation of address.Address type Address string func NewAddress(address *address.Address) Address { return Address(address.String()) } func (a Address) MarshalJ...
package TLV import ( "github.com/andrewz1/gosmpp/Exception" "github.com/andrewz1/gosmpp/Utils" ) type TLVEmpty struct { TLV Present bool } func NewTLVEmpty() *TLVEmpty { a := &TLVEmpty{} a.Construct() return a } func NewTLVEmptyWithTag(tag uint16) *TLVEmpty { a := NewTLVEmpty() a.Tag = tag return a } f...
package providers import( "errors" "net/http" "fmt" "github.com/reaxoft/oauth2_proxy/api" ) type BlitzIdpProvider struct { *ProviderData } func NewBlitzIdpProvider(p *ProviderData) *BlitzIdpProvider { p.ProviderName = "BlitzIdp" return &BlitzIdpProvider{ProviderData: p} } func makeOAuthHeader(access_token st...
package pathfileops import ( "os" "strconv" "testing" ) func TestFilePermissionConfig_IsValid_01(t *testing.T) { // expectedTextCode := "drwxrwxrwx" fh := FileHelper{} // drwxrwxrwx 20000000777 intFMode := fh.ConvertOctalToDecimal(20000000777) osFMode := os.FileMode(intFMode) fPerm, err := Fil...
package nut import "github.com/gin-gonic/gin" func (p *AdminPlugin) indexLeaveWords(l string, c *gin.Context) (interface{}, error) { var items []LeaveWord err := p.DB.Model(&items). Order("created_at DESC").Select() return items, err } func (p *AdminPlugin) destroyLeaveWord(l string, c *gin.Context) (interface{}...
// cat brightness. // +build linux package main import ( "fmt" "io" "io/ioutil" "os" "path/filepath" ) func main() { const ( dir = "/sys/class/backlight" current = "brightness" max = "max_brightness" ) fis, err := ioutil.ReadDir(dir) if err != nil { panic(err) } var rootes []string for...
package main import ( "fmt" "strings" "strconv" "reflect" ) func line() { fmt.Println(strings.Repeat("-", 30)) } func main() { i, _ := strconv.ParseInt("123", 0, 64) fmt.Println(reflect.TypeOf(i), i) // bitsize useless i, _ = strconv.ParseInt("567",0, 32) fmt.Println(reflect.TypeOf(i), i) line() // bas...
package main import ( "io/ioutil" "os" "path/filepath" "strings" "github.com/therecipe/qt/core" "github.com/therecipe/qt/quick" "github.com/therecipe/qt/widgets" ) var ( centralLayout *widgets.QGridLayout centralLayoutRow int centralLayoutColumn int ) func main() { widgets.Ne...
package types import ( "time" ) // COVID19VaccinationStatistics holds the data for COVID-19 vaccination statistics. type COVID19VaccinationStatistics struct { Area string `json:"area" fake:"{randomstring:[ΑΡΓΟΛΙΔΑΣ,ΜΥΚΟΝΟΥ,ΚΟΡΙΝΘΙΑΣ]}"` AreaID int `json:"areaid" fake:"{number...
package lnroll import ( "errors" "fmt" "time" "github.com/apg/ln" ) type Client interface { Critical(err error, extras map[string]string) (uuid string, e error) Error(err error, extras map[string]string) (uuid string, e error) } // New returns a new FilterFunc which reports errors to Rollbar. func New(client ...
package loadflags import ( "path/filepath" ) func LoadForCli(progName string) error { return loadForCli(progName) } func LoadForDaemon(progName string) error { return loadFlags(filepath.Join("/etc", progName)) }
package NoQ_RoomQ import ( "errors" "fmt" "log" "net/http" "net/url" "regexp" "time" "github.com/google/uuid" NoQ_RoomQ_Exception "github.com/redso/noq-roomq-go-sdk/Exception" NoQ_RoomQ_Utils "github.com/redso/noq-roomq-go-sdk/Utils" ) type roomQ struct { clientID string jwtSecret string tic...
package main import ( "reflect" "fmt" "io" "os" ) func main() { t := reflect.TypeOf(3) fmt.Println(t.String()) fmt.Println(t) var w io.Writer = os.Stdout fmt.Println(reflect.TypeOf(w)) fmt.Printf("%T\n", 3) v := reflect.ValueOf(3) fmt.Println(v) fmt.Printf("%v \n", v) fmt.Println(v.String()) }
package twosum var testCases = []struct { nums []int target int result []int }{ { []int{2, 7, 11, 15}, 9, []int{0, 1}, }, { []int{3, 4, 5, 2, 7}, 6, []int{1, 3}, }, { []int{1, 2, 0, 8, 11, 3}, 18, nil, }, { []int{}, 1, nil, }, }
package redfish import ( "context" "net/url" redfishApi "github.com/Nordix/go-redfish/api" redfishClient "github.com/Nordix/go-redfish/client" alog "opendev.org/airship/airshipctl/pkg/log" ) type RedfishRemoteDirect struct { // Context Context context.Context // remote URL RemoteURL url.URL // ephemera...
package main import ( "encoding/json" "io/ioutil" "os" "github.com/RHsyseng/console-cr-form/pkg/web" "github.com/go-openapi/spec" "github.com/sirupsen/logrus" ) const defaultJSONForm = "test/examples/full-form.json" const defaultJSONSchema = "test/examples/full-schema.json" const envJSONForm = "JSON_FORM" cons...
package response type Type string const ( TypeRoomInfo Type = "RoomInfo" TypeGameStart Type = "GameStart" TypeGameEvent Type = "GameEvent" ) type Response struct { Type Type Body interface{} } type Responses []*Response func (r *Responses) Add(t Type, body interface{}) { *r = append(*r, &Response{ Type: t...
package cache import ( "testing" "time" ) func TestMemCache(t *testing.T) { cache, err := New("memory?gcInterval=3s") if err != nil { t.Error(err) return } mc, ok := cache.(*mCache) if !ok { t.Fatal("not a memory cache") } if mc.gcInterval != 3*time.Second { t.Fatalf("invalid gc interval %v, should ...
package main import ( "net/http" "time" "ms/sun/servises/file_service" ) func main() { file_service.Run() defer file_service.DeferCleanUp() http.HandleFunc("/hi", func(writer http.ResponseWriter, r *http.Request) { writer.Write([]byte("hi =========")) }) go func() { ti...
package restclient import ( "bytes" "net/http" "net/http/httptest" "testing" ) func TestDebugTransport(t *testing.T) { resp := "{\"message\": \"response\"}" s := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { w.WriteHeader(200) w.Write([]byte(resp)) })) defer s.Close() ...
// Copyright (C) 2020 Cisco Systems 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 agr...
package main import ( "fmt" "github.com/jackytck/projecteuler/tools" ) func definitive() int { var minDiff int var found bool var definite bool j := 1 for !definite { j++ jn := tools.PentagonNumber(j) for k := j - 1; k > 0; k-- { kn := tools.PentagonNumber(k) if found && k == j-1 && jn-kn > minDif...
package linkedlist // 双向链表节点 type linkedListNode struct { Val interface{} prev *linkedListNode next *linkedListNode }
package exer8 // TODO: your Hailstone, HailstoneSequenceAppend, HailstoneSequenceAllocate functions // ============== RESULTS ============== // goos: linux // goarch: amd64 // pkg: exer8 // BenchmarkHailSeqAppend-12 500000 2039 ns/op // BenchmarkHailSeqAllocate-12 1000000 1189 n...
package scheme import ( "time" "github.com/yandex-cloud/ydb-go-sdk" "github.com/yandex-cloud/ydb-go-sdk/table" ) type Entry struct { ID string `json:"id"` DoctorID string `json:"doctor_id,omitempty"` SpecID string `json:"spec_id,omitempty"` PlaceID string `json:"place_id,omite...
package main import ( "errors" "github.com/PuerkitoBio/goquery" "golang.org/x/text/encoding/charmap" "io" "net/http" "net/url" "strconv" "strings" ) const sheetListUri = "exquery.html" const sheetUri = "QuerySheet" func getSheetList() ([]string, error) { doc, err := goquery.NewDocument(okusonURL + sheetList...
package day02 /* 一.CSP通信顺序进程 1.经典口号: 通过通信实现共享内存, 而不是通过共享内存实现通信 2.实现了无共享内存无锁的并发, 可匹配异步回调的性能 二.参见 1.博文: http://www.sohu.com/a/192606128_575744 2.官方文档: https://golang.org/doc/effective_go.html */
package list import ( "github.com/devspace-cloud/devspace/cmd/flags" "github.com/devspace-cloud/devspace/pkg/util/factory" "github.com/spf13/cobra" ) // NewListCmd creates a new cobra command func NewListCmd(f factory.Factory, globalFlags *flags.GlobalFlags) *cobra.Command { listCmd := &cobra.Command{ Use: "l...
package hrp import ( "crypto/tls" _ "embed" "fmt" "net" "net/http" "net/http/cookiejar" "net/url" "os" "os/signal" "path/filepath" "strings" "syscall" "testing" "time" "github.com/gorilla/websocket" "github.com/httprunner/funplugin" "github.com/jinzhu/copier" "github.com/pkg/errors" "github.com/rs/...
package misc func isLineBreak(source []rune, index uint) int { switch source[index] { case '\n': return 1 case '\r': next := index + 1 if next < uint(len(source)) && source[next] == '\n' { return 2 } } return -1 } func isSpecialChar(bt rune) bool { if bt >= 0x21 && bt <= 0x2F { // ! " # $ % & ' ( )...
package futures import ( "testing" "github.com/stretchr/testify/suite" ) type positionRiskServiceTestSuite struct { baseTestSuite } func TestPositionRiskTestService(t *testing.T) { suite.Run(t, new(positionRiskServiceTestSuite)) } func (s *positionRiskServiceTestSuite) TestGetPositionRisk() { data := []byte(`...
package tomltest import ( "math" "reflect" ) // CompareTOML compares the given arguments. // // The returned value is a copy of Test with Failure set to a (human-readable) // description of the first element that is unequal. If both arguments are equal // Test is returned unchanged. // // Reflect.DeepEqual could wo...
package easygraph import ( "encoding/json" "fmt" "strconv" "strings" ) var fmtSeparator = " " func formatRawQuery(q *rawQuery) string { var formattedQuery string if len(q.variables) > 0 { variablesQuery := formatVariables(q.variables) formattedQuery = formatQueryWithvariables( strconv.QuoteToASCII(q.str...
// This file was generated for SObject Opportunity, API Version v43.0 at 2018-07-30 03:47:48.329363948 -0400 EDT m=+34.673271418 package sobjects import ( "fmt" "strings" ) type Opportunity struct { BaseSObject AccountId string `force:",omitempty"` Amount string `for...
package i3gostatus import ( "bufio" "encoding/json" "fmt" "log" "os" "reflect" "strings" "time" "github.com/rumpelsepp/i3gostatus/lib/config" "github.com/rumpelsepp/i3gostatus/lib/model" "github.com/rumpelsepp/i3gostatus/lib/registry" "github.com/rumpelsepp/i3gostatus/lib/utils" ) var logger = log.New(os...
package main import ( "context" "io" "os" "os/signal" "path/filepath" "syscall" "github.com/Azure/testrig/commands" "github.com/cpuguy83/strongerrors" homedir "github.com/mitchellh/go-homedir" "github.com/pkg/errors" "github.com/spf13/cobra" ) func main() { var ( stateDir string configFile string ...
package testproxy import ( "github.com/stretchr/testify/assert" "net" "testing" ) func TestProxyWithBounce(t *testing.T) { assert := assert.New(t) ln, err := net.Listen("tcp", "localhost:23456") assert.NoError(err, "Could not create bouncer listener") go func() { conn, err := ln.Accept() assert.NoErrorf(e...
package renderer import ( "bytes" "fmt" "math" "sort" "strings" g2s "github.com/ONSdigital/dp-map-renderer/geojson2svg" "github.com/ONSdigital/dp-map-renderer/htmlutil" "github.com/ONSdigital/dp-map-renderer/models" "github.com/paulmach/go.geojson" ) // RegionClassName is the name of the class assigned to ...
package cli import ( "fmt" "log" "math" "math/rand" "strings" "test/broker" "test/proto" "time" ) type CliService struct { name string activeWorkers int stop chan chan struct{} broker broker.Broker producer <-chan broker.Message } func NewCliService() *CliService { return &CliServ...
package goroutine import ( "fmt" "log" "math" "sync" "time" ) func simple() { wg := &sync.WaitGroup{} for i := 0; i < math.MaxInt32; i++ { wg.Add(1) go func(i int) { defer wg.Done() fmt.Println(i) time.Sleep(time.Second) }(i) } wg.Wait() } func withChan() { wg := &sync.WaitGroup{} ch := mak...
package main import ( "flag" "fmt" "io/ioutil" "log" "os/exec" "sync" ) func main() { input_directory_flag := flag.String("inputdir", "./", "Input directory") workers_flag := flag.Int("workers", 6, "Maximum amount of concurrent goroutines") flag.Parse() workers := *workers_flag input_directory := *input_di...
package pruss const ( PAGE_SIZE = 4096 PRUSS_MAX_IRAM_SIZE = 8192 PRUSS_IRAM_SIZE = 8192 PRUSS_DATARAM_SIZE = 512 PRUSS_MMAP_SIZE = 0x40000 DATARAM0_PHYS_BASE = 0x4a300000 DATARAM1_PHYS_BASE = 0x4a302000 INTC_PHYS_BASE = 0x4a320000 PRU0CONTROL_PHYS_BASE = 0x4a322000 PRU0DEBUG_PH...
package client import ( "fmt" "google.golang.org/grpc/codes" "google.golang.org/grpc/status" "github.com/go-ocf/go-coap" kitNetCoap "github.com/go-ocf/kit/net/coap" ) func ContentTypeToMediaType(contentType string) (coap.MediaType, error) { switch contentType { case coap.TextPlain.String(): return coap.Tex...
package bbs import ( "github.com/cloudfoundry/storeadapter" "github.com/onsi-experimental/runtime-schema/models" "path" "time" ) const ClaimTTL uint64 = 10 const RunOnceSchemaRoot = "/v1/run_once" type executorBBS struct { store storeadapter.StoreAdapter } type stagerBBS struct { store storeadapter.StoreAdapte...
package main import ( "log" "net/http" "os" "github.com/99designs/gqlgen/graphql" "github.com/99designs/gqlgen/graphql/handler" "github.com/99designs/gqlgen/graphql/playground" "github.com/gorilla/mux" auth "github.com/onelittlenightmusic/opa-entrypoint-authorizer" "github.com/onelittlenightmusic/opa-entrypo...
package aggregate import ( "context" "time" "github.com/XiaoMi/pegasus-go-client/idl/admin" "github.com/XiaoMi/pegasus-go-client/idl/base" "github.com/XiaoMi/pegasus-go-client/session" log "github.com/sirupsen/logrus" ) // PerfClient manages sessions to all replica nodes. type PerfClient struct { meta *sessio...
/* * @lc app=leetcode id=26 lang=golang * * [26] Remove Duplicates from Sorted Array */ func removeDuplicates(nums []int) int { var last int var dup_count int for i, n := range nums { fmt.Println(i, n) if i == 0 { last = 0 continue } if nums[last] == n { dup_count += 1 } else { nums[last+...
package main import ( "bufio" "fmt" "os" "regexp" "strconv" ) type PasswordPayload struct { low int high int letter rune password string } func readInput() []PasswordPayload { f, _ := os.Open("input.txt") defer f.Close() input := make([]PasswordPayload, 0) re := regexp.MustCompile(`(\d+)-(\d...
package devices import ( "encoding/json" "fmt" "os" "strings" "github.com/sirupsen/logrus" "github.com/spf13/cobra" "github.com/foundriesio/fioctl/subcommands" ) var ( showHWInfo bool showAkToml bool ) func init() { showCmd := &cobra.Command{ Use: "show <name>", Short: "Show details of a specific d...
package common import ( "errors" "os/exec" "reflect" "time" ) type ( executor struct { cmd []string time.Duration } Executor interface { Exec() (string, error) SetOp([]string) SetTimeout(time.Duration) } ) func NewExecutor() Executor { return &executor{} } func (e *executor) SetOp(cmd []string) ...
package controller import "github.com/therecipe/qt/core" var Controller *viewController type viewController struct { core.QObject _ func() `constructor:"init"` _ func(bool) `signal:"blur"` } func (c *viewController) init() { Controller = c }
package realm import ( "errors" "fmt" ) var ( ErrChamberEmpty = errors.New("chamber is nil") ) type ErrToggleNotFound struct { Key string } func (tnf *ErrToggleNotFound) Error() string { return fmt.Sprintf("%v does not exist", tnf.Key) } type ErrCouldNotConvertToggle struct { Key string Type string } func...
package main import ( "errors" "github.com/soniah/gosnmp" "math" "strings" "time" ) //https://collectd.org/wiki/index.php/Data_source const ( GAUGE = 0 << iota //value is simply stored as-is INTEGER COUNTER32 COUNTER64 STRING HWADDR IPADDR ) /* 3.- Check minimal data is set (pending) name, BaseOID Base...
package luxafor // Commands recognized by the Luxafor. const ( static byte = 1 fade byte = 2 strobe byte = 3 wave byte = 4 pattrn byte = 6 )
package shop type Vend interface { }
package main import ( "bufio" "context" "flag" "fmt" "github.com/google/go-github/v38/github" "golang.org/x/oauth2" "log" "os" "strconv" "strings" ) type conf struct { username string owner string repo string prId int spammer string token ...
package utils import ( "github.com/shopspring/decimal" ) // 代收-计算商户手续费-默认内扣 func CalculatePayOrderFeeMerchant(reqAmount int64, singleFee int64, rate float64) int64 { total := decimal.NewFromInt(reqAmount) // 总金额 * (费率/100) + 单笔费用 fee := total.Mul(decimal.NewFromFloat(rate)).Div(decimal.NewFromInt(100)).Add(decim...
// Copyright (c) 2013-2015 The btcsuite developers // Use of this source code is governed by an ISC // license that can be found in the LICENSE file. package legacyrpc import ( "errors" "github.com/btcsuite/btcd/btcjson" ) // TODO(jrick): There are several error paths which 'replace' various errors // with a more...
/* * Copyright 2019 Banco Bilbao Vizcaya Argentaria, S.A. * * 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 ap...
/* You are given an integer array nums containing distinct numbers, and you can perform the following operations until the array is empty: If the first element has the smallest value, remove it Otherwise, put the first element at the end of the array. Return an integer denoting the number of operations it takes to ma...
package models import ( "net" "crypto/rsa" "github.com/monnand/dhkx" "container/list" ) // TODO: Discuss wether to define it here or to define in it in the service packe >> Downside here is that calling with Peer as caller isn't possible // Peer is the standard object for a running peer that is accepting connecti...
/* * EVE Swagger Interface * * An OpenAPI for EVE Online * * OpenAPI spec version: 0.4.1.dev1 * * Generated by: https://github.com/swagger-api/swagger-codegen.git */ package swagger import ( "net/url" "strings" "encoding/json" "fmt" ) type AllianceApi struct { Configuration *Configuration } func NewA...
package common import ( "echo-stripe/response" "fmt" "net/http" "runtime" "github.com/go-playground/validator" "github.com/labstack/echo/v4" ) func CustomHTTPErrorHandler(err error, c echo.Context) { respCode := 500 resp := response.BasicResponse{} resp.Success = false resp.Message = "" sendErrorResponse...
// find the 10001st prime // using a sieve stolen from http://golang.org/doc/play/sieve.go package main import ( "fmt" ) func main() { primes := make([]int, 10001) length := 1 primes[0] = 2 i := 3 for ;length < 10001; { prime := true for j := 0; j < length; j++ { if i % primes[j] == 0 { prime = fals...