text
stringlengths
11
4.05M
package setr import ( "encoding/xml" "github.com/thought-machine/finance-messaging/iso20022" ) type Document01000102 struct { XMLName xml.Name `xml:"urn:iso:std:iso:20022:tech:xsd:setr.010.001.02 Document"` Message *SubscriptionMultipleOrderV02 `xml:"setr.010.001.02"` } func (d *Document010...
package dispatchers import ( "fmt" "testing" ) func TestRegisterDispatcher(t *testing.T) { RegisterDispatcher("bla", NewNoopDispatcher) dispatcher := MustGetDispatcher(DispatcherConfig{ Dispatcher: "bla", }) _, ok := dispatcher.(*NoopDispatcher) if !ok { t.Error("Expected MustGetDispatcher to return Noop...
package main /** * Definition for a binary tree node. * type TreeNode struct { * Val int * Left *TreeNode * Right *TreeNode * } */ // 通过先序+后序构造二叉树 (不唯一) func constructFromPrePost(pre []int, post []int) *TreeNode { return constructFromPrePostExec(pre, post) } func constructFromPrePostExec(pre []int,...
package main import ( "log" "net" "strconv" "strings" "time" ) const ( Address = "127.0.0.1:6379" Network = "tcp" ) func Conn(network, address string) (net.Conn, error) { conn, err := net.Dial(network, address) if err != nil { return nil, err } return conn, nil } func GetRequest(args []string) []byte {...
package cis import "github.com/antonioalfa22/egida/pkg/ansible" func ShowAllMenu(connection string) { ansible.RunMenuPlaybook([]string{}, connection) }
package toml import ( "testing" ) func TestTomlGetPath(t *testing.T) { node := make(TomlTree) //TODO: set other node data for idx, item := range []struct { Path []string Expected interface{} }{ { // empty path test []string{}, &node, }, } { result := node.GetPath(item.Path) if result != i...
package main import ( "log" "ucp/global" ) func main() { log.Println(global.Init("../../client.json")) log.Println(global.Send("c1", []byte("woaini"))) // log.Println(global.Send("c1", []byte("ilove you"))) buf := make([]byte, 1500) n, err := global.Recv("c1", buf) log.Println(string(buf[:n]), err) log.Print...
package main import ( "fmt" "sync" "sync/atomic" "time" ) var ( flag int32 wg1 sync.WaitGroup ) func main() { wg1.Add(2) go incCounter1("A") go incCounter1("B") time.Sleep(2 * time.Second) atomic.StoreInt32(&flag, 1) //写 wg1.Wait() } func incCounter1(prefix string) { defer wg1.Done() for { fmt....
package main import ( "flag" "fmt" "net/http" "os" "os/signal" "strings" "sync" "time" "github.com/NectGmbH/health" "github.com/golang/glog" ) type sliceFlags []string func (i *sliceFlags) String() string { return strings.Join(*i, " ") } func (i *sliceFlags) Set(value string) error { *i = append(*i, va...
package controller import ( "encoding/json" "net/http" "tantan-demo/store" "tantan-demo/model" "github.com/gorilla/mux" "strconv" "tantan-demo/util" "tantan-demo/service" "tantan-demo/store/sharding" ) func ListUsers(w http.ResponseWriter, r *http.Request) { w.Header().Set("Content-Type", "application/json;...
package main import ( "bytes" "os" "os/exec" "path/filepath" "strings" ) type Repo struct { Origin string Branch string } func getDepRoot(repo string, gopath string, pkg string) (string, *Repo, error) { var err error pkgRoot := filepath.Join(gopath, "src", pkg) root, err := getGitTopLevel(pkgRoot) if er...
package main import ( "bytes" "crypto/cipher" "reflect" "strings" "testing" ) func TestXORCipher(t *testing.T) { cases := []struct { stream cipher.Stream src, want []byte }{ { NewXORCipher([]byte{1, 2}), []byte{1, 2, 3, 4, 5, 6}, []byte{0, 0, 2, 6, 4, 4}, }, { NewXORCipher([]byte{1, 2,...
package main import ( "./pb" "bufio" "compress/gzip" "crypto/md5" "encoding/hex" "encoding/json" "flag" "fmt" "github.com/golang/glog" "github.com/golang/protobuf/proto" "github.com/liuzl/filestore" "github.com/liuzl/ip2loc" "github.com/liuzl/store" "github.com/satori/go.uuid" "github.com/ttacon/libphon...
package test import ( "gowechatsubscribe/uploader" "testing" ) func TestDoUploadFile2Wechat(t *testing.T) { accessToken := "BjzDv40Dnst3jwjR7zGD9ivaOK0jdqxAscHgabLaPHOL15dGTcqoEXXetZeWa82eAPZo5nZ0ILmUj93k2zpbE7mF7ozhgclzztmAOxCIxrU2y0cpcL-6m0hkWNO0JO6RFSHcAHAPCR" uploader.DoUploadFile2Wechat("../qingming.jpg", ac...
package main import "fmt" import "strconv" import "strings" func isPalindrome(product int) (isP bool) { s := strconv.Itoa(product) a := strings.Split(s, "") L := len(a) for i := 0; i < L/2; i++ { a[i], a[L-i-1] = a[L-i-1], a[i] } x := strings.Join(a, "") y, _ := strconv.Atoi(x) if product == y { return tr...
//Building on the previous hands-on exercise, create a program that uses “else if” and “else”. package main import "fmt" func main() { bool := 10 > 100 if bool { fmt.Println("I'm here inside the if") } else if !bool { fmt.Println("I'm here inside the else if") } else { fmt.Printf("I'm here inside the else...
/* A Vagrant catalog is a JSON file for managing Vagrant boxes A catalog references for one or more versions which reference one or more providers which each point to a single Vagrant box file Here's the JSON of an example catalog: { "name": "testbox", "description": "Just an example", "versions": [ { "...
package skv import ( "bytes" "encoding/json" "fmt" "math/rand" "os" "sync" "testing" "time" ) func TestBasic(t *testing.T) { os.Remove("skv-test.db") db, err := Open("skv-test.db") if err != nil { t.Fatal(err) } // put a key if err := db.Put("key1", "value1"); err != nil { t.Fatal(err) } // get it...
package main import ( "fmt" ) func main() { for i := 0; i < 10; i++ { if i == 5 { continue } fmt.Println(i) //for k := 0; k < 10; k++ { // fmt.Println(i) //} } i := 1 for i < 5 { i++ fmt.Println(i) } for { fmt.Println(i) break } arr := [3]int{1, 3, 4} for _, k := range arr { fmt....
// This file contains a subset of functions of the std // math library from Go, but converted from float64 to float32. // Copyright 2009 The Go Authors. All rights reserved. // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. package assembler // Abs returns the ab...
package sese import ( "encoding/xml" "github.com/thought-machine/finance-messaging/iso20022" ) type Document02300101 struct { XMLName xml.Name `xml:"urn:iso:std:iso:20022:tech:xsd:sese.023.001.01 Document"` Message *SecuritiesSettlementTransactionInstructionV01 `xml:"SctiesS...
/* Copyright 2021 The KubeVela 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, so...
package repositories import "github.com/ariel17/railgun/api/entities" type MockDBRepository struct { Domain *entities.Domain Err error } var instance *MockDBRepository func (m *MockDBRepository) GetByID(_ int64) (*entities.Domain, error) { return m.Domain, m.Err } func (m *MockDBRepository) GetByURL(_ string) (...
package middleware import ( "io/ioutil" "net/http" "strings" "github.com/gin-gonic/gin" "github.com/rakyll/statik/fs" // Static Files "github.com/nekomeowww/vig/src/logger" _ "github.com/nekomeowww/vig/statik" ) // FrontendHandler 前端静态文件处理 func FrontendHandler() gin.HandlerFunc { statikFS, err := fs.New() ...
/* CBC bitflipping attacks Generate a random AES key. Combine your padding code and CBC code to write two functions. The first function should take an arbitrary input string, prepend the string: "comment1=cooking%20MCs;userdata=" .. and append the string: ";comment2=%20like%20a%20pound%20of%20bacon" The functi...
package main import ( "fmt" "log" "os" "path/filepath" "sort" ) type Fruit int const ( Apple Fruit = iota Orange Banana ) type User struct { name string } func showName(user *User) { fmt.Println(user.name) } func findUserFromList(name string) (*User, error) { return &User{name}, nil } func FindUser(na...
package handler import ( "github.com/gin-gonic/gin" "github.com/msvetkov/notes-app/pkg/domain" "net/http" ) // @Summary Get current user info // @Security ApiKeyAuth // @Tags user // @Description get current user info // @ID get-current-user // @Accept json // @Produce json // @Success 200 {object} domain.User /...
package main import ( "strconv" "github.com/bwmarrin/discordgo" ) const ( /* Location of the sound */ soundPath = "./sound/" /* Bot prefix */ prefix = "!mb" /* The help text */ help = "The available commands are :\n" + "-`" + prefix + " state` to display the current bot state on this channel\n" + "-`"...
// Licensed to Elasticsearch B.V. under one or more contributor // license agreements. See the NOTICE file distributed with // this work for additional information regarding copyright // ownership. Elasticsearch B.V. licenses this file to you under // the Apache License, Version 2.0 (the "License"); you may // not use ...
package main import ( "github.com/gin-gonic/gin" "net/http" ) func main() { ROUTER := gin.Default() ROUTER.LoadHTMLFiles("layout.html", "index.html") ROUTER.GET("/", func(c *gin.Context) { c.HTML(http.StatusOK, "index.html", gin.H{}) }) ROUTER.Run(":6000") }
package main import ( "bytes" "crypto/sha256" "encoding/binary" "fmt" "log" "math" "math/rand" "strconv" "strings" "sync" "sync/atomic" "time" stdErrors "errors" "github.com/gocql/gocql" "github.com/pkg/errors" "github.com/scylladb/scylla-bench/pkg/results" . "github.com/scylladb/scylla-bench/pkg/wo...
package common import ( "github.com/ztxmao/vii/library" "os" ) var ( Configer = library.ConfigerExt Logger = library.Logger Hostname, _ = os.Hostname() )
// Copyright © 2019 Sparebanken Vest // // 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 main import ( "bytes" "fmt" "sort" "text/template" "time" ) var templateFuncs = template.FuncMap{ "latest": fnLatestPages, "maxstr": fnMaxString, "date": fnDate, } func fnDate(ld localDate) string { t := time.Time(ld) return t.Format("Jan 02, 2006") } // Currently used to hold template rendering...
package blocks import ( "fmt" "github.com/bouncepaw/mycomarkup/v2/util" ) // HorizontalLine represents the horizontal line block. // // In Mycomarkup it is written like that: // ---- type HorizontalLine struct { src string } func (h HorizontalLine) isBlock() {} // MakeHorizontalLine parses the horizontal lin...
package main import ( "fmt" "net" "strings" "bufio" "io" "os" ) func main() { address := ":21" if (len(os.Args) > 1) { address = os.Args[1] } fmt.Println("Listening on " + address) ln, err := net.Listen("tcp", address) if err != nil { ...
package spaghetti import ( "syscall/js" ) type fontMesh struct { verts []float32 indicies []uint16 } type Font struct { font js.Value cache map[string]fontMesh } // Mesh generates the mesh for the given string func (f *Font) Mesh(str string, size int) ([]float32, []uint16) { // Create the cache if it doe...
package server import "testing" func TestAliasAccurate(t *testing.T) { alias := createAliasAccurate("/hello/world/foo", "/tmp") // isMatch if !alias.isMatch("/hello/world/foo") { t.Error() } if alias.isMatch("/Hello/world/foo") { t.Error() } // isSuccessorOf if !alias.isSuccessorOf("/") { t.Error() ...
package main import ( "bytes" "fmt" "io" "net" "net/http" "time" ) func main() { var myTransport http.RoundTripper = &http.Transport{ Proxy: http.ProxyFromEnvironment, DialContext: (&net.Dialer{ Timeout: 5 * time.Second, KeepAlive: 30 * time.Second, DualStack: true, }).DialContext, MaxIdleCo...
package chain import ( "github.com/ethereum/go-ethereum/accounts/abi/bind" "github.com/ethereum/go-ethereum/common" "math/big" "github.com/sanguohot/medichain/contracts/medi" "github.com/sanguohot/medichain/etc" "github.com/sanguohot/medichain/util" "time" ) func GetControllerInstance() (error, *medi.Controlle...
package main import ( "flag" "fmt" "log" "os" "path/filepath" "time" "github.com/kevinburke/goose/lib/goose" ) var createCmd = &Command{ Name: "create", Usage: "create <migration-name>", Summary: "Create the scaffolding for a new migration", Help: `Create a file with a new migration. The file will...
package utils import ( "bytes" "encoding/json" "fmt" "io" "io/ioutil" "log" "net/http" "net/url" "strings" "time" ) // 将rawData转换成map[string]string func RawData2Map(rawData []byte) (res map[string]string) { res = make(map[string]string) str := string(rawData) if IsBlank(str) || !strings.Contains(str, "&"...
package main import "fmt" type Node struct { Data int left *Node right *Node height int } func main(){ rootnode:=new(Node) rootnode=nil rootnode=insert(rootnode,10) rootnode=insert(rootnode,20) rootnode=insert(rootnode,30) rootnode=insert(rootnode,40) rootnode=insert(rootnode,50) rootnode...
package goshimmer import ( "fmt" "github.com/iotaledger/goshimmer/client" "github.com/iotaledger/goshimmer/dapps/valuetransfers/packages/address" "github.com/iotaledger/goshimmer/dapps/valuetransfers/packages/balance" valuetransaction "github.com/iotaledger/goshimmer/dapps/valuetransfers/packages/transaction" "g...
package main type Params struct { Remote string `json:"remote"` Branch string `json:"branch"` Force bool `json:"force"` SkipVerify bool `json:"skip_verify"` Commit bool `json:"commit"` }
package fileutil_test import ( "fmt" "github.com/APTrust/exchange/constants" "github.com/APTrust/exchange/util/fileutil" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" "os" "path/filepath" "strings" "testing" ) func TestExchangeHome(t *testing.T) { exchangeHome := os.Getenv("EXCH...
package utils import ( "errors" "net" "os" "os/signal" "syscall" ) // WaitExitSignal waits the exit signal. func WaitExitSignal(callback func(os.Signal) bool) { if callback == nil { return } c := make(chan os.Signal, 1) signal.Notify(c, syscall.SIGTERM, syscall.SIGINT, syscall.SIGQUIT, syscall.SIGKILL, sy...
/* Write a function that returns a lambda expression, which adds n to its input Examples adds1 = adds_n(1) adds1(3) ➞ 4 adds1(5.7) ➞ 6.7 adds10 = adds_n(10) adds10(44) ➞ 54 adds10(20) ➞ 30 Notes N/A */ package main import "math" func main() { add1 := addn(1) add10 := addn(10) add5neg := addn(-5) add0 :=...
package main import "fmt" func main() { map1 := make(map[string]string) map1["one"] = "1" map2 := map1 map2["one"] = "eins" map2["two"] = "zwei" fmt.Println("Map1:", map1) fmt.Println("Map2:", map2) if map1 == nil { } }
// Copyright 2016 Matthew Endsley // All rights reserved // // Redistribution and use in source and binary forms, with or without // modification, are permitted providing that the following conditions // are met: // 1. Redistributions of source code must retain the above copyright // notice, this list of conditions ...
package henchman import ( "bytes" //"errors" "fmt" "io/ioutil" "log" "path" "strconv" "code.google.com/p/go.crypto/ssh" ) const ( ECHO = 53 TTY_OP_ISPEED = 128 TTY_OP_OSPEED = 129 ) func loadPEM(file string) (ssh.Signer, error) { buf, err := ioutil.ReadFile(file) if err != nil { return nil, ...
// Copyright 2020-2021 Nao Yonashiro // // 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 timeline import ( "github.com/fogleman/gg" "github.com/golang/freetype/truetype" "golang.org/x/image/font/gofont/goregular" "image/color" "strconv" "time" ) func drawDropShadow(gc *gg.Context, x1, y1, x2, y2 float64) { var opacity uint8 opacity = 0x44 offset := 4.0 gc.Push() gc.SetFillStyle(gg.New...
package main import ( "bufio" "database/sql" "encoding/csv" "fmt" _ "github.com/go-sql-driver/mysql" "github.com/leekchan/accounting" "io" "log" "os" "strconv" "strings" "time" ) type fund struct { Ticker string Name string Rating int ExpenseRatio float64 Shares ...
package delivery import "github.com/adshao/go-binance/v2/common" // Ask is a type alias for PriceLevel. type Ask = common.PriceLevel // Bid is a type alias for PriceLevel. type Bid = common.PriceLevel
package five import ( "testing" ) const ( example_header = ` 1 2 3 ` large_header = ` 1 2 3 4 5 6 7 8 9 ` ) func Test_Run(t *testing.T) { cases := []struct { name string filename string header string stackSize int part int expected string }{ { name: "Pa...
package main import ( log "github.com/sirupsen/logrus" "github.com/williamhaley/inventory" "io" "os" "os/signal" "sync" ) type InventoryApp struct { server inventory.Server reader inventory.ContinuousReader } func main() { log.SetLevel(log.DebugLevel) inventoryApp := NewInventoryApp() inventoryApp.Start()...
package main import ( "github.com/urfave/cli" ) func init() { app.Commands = append(app.Commands, cli.Command{ Name: "newpost", Aliases: []string{"p"}, Usage: "Create new post", Action: func(c *cli.Context) error { if !c.Args().Present() { cli.ShowCommandHelp(c, "newpost") return nil } ...
func lastRemaining(n int) int { var helper func(num int, rev bool) int helper = func(num int, rev bool) int { if num == 1{ return 1 } else if rev == true { return helper(num >> 1, false) << 1 - 1 + (num & 1) } else { return helper(num >> 1, true) << 1 ...
func mincostTickets(days []int, costs []int) int { const INF = 1000000000 dp := make([]int,366) isExist := make(map[int]bool) for i:=0;i<len(days);i++{ isExist[days[i]]=true } for day:=1;day<=365;day++{ if isExist[day]==false{ dp[day] = dp[day-1] con...
package fsync import ( "fmt" "io/ioutil" "path/filepath" ) func walk(path string) []string { path = filepath.Clean(path) var names []string files, err := ioutil.ReadDir(path) if err != nil { panic(err) } for _, f := range files { if f.IsDir() { tnames := walk(path + "/" + f.Name()) names = append...
package main import ( "context" "fmt" "log" "net" multipb "github.com/golang-grpc-snippet/drill_exercise_1/multiplication/protobuf" "google.golang.org/grpc" ) type server struct{} func (*server) Multiplication(c context.Context, req *multipb.MultiRequest) (*multipb.MultiResponse, error) { first := req.GetNum...
package gedcom import ( "fmt" "strings" "time" ) // IndividualNode represents a person. type IndividualNode struct { *simpleDocumentNode cachedFamilies, cachedSpouses bool families FamilyNodes spouses []*IndividualNode cachedUniqueIDs *StringSet } // S...
package security import ( "context" "errors" "fmt" "sort" "strings" "time" "github.com/google/uuid" "github.com/zaddok/log" "google.golang.org/api/iterator" "cloud.google.com/go/datastore" ) type DatastoreLog struct { client *datastore.Client ctx context.Context uuid string component str...
package security import ( "encoding/json" "fmt" "io/ioutil" "net/http" ) func ipLookupTask(am AccessManager) func(session Session, message map[string]interface{}) error { return func(session Session, message map[string]interface{}) error { /* No Timezone info address := session.IP() apikey := "55db09a...
package monitor import ( "bytes" "context" "crypto/tls" "encoding/base64" "encoding/json" "fmt" "github.com/antchfx/htmlquery" "github.com/ernesto-jimenez/httplogger" "github.com/kyokomi/emoji" "github.com/tebeka/selenium" "github.com/weAutomateEverything/go2hal/remoteTelegramCommands" "github.com/weAutoma...
package server import ( "net/http" "time" "github.com/go-chi/chi" "github.com/go-chi/chi/middleware" ) // NewRouter creates a http.Handler to route endpoints for a JSON API. func NewRouter(routes ...Route) http.Handler { router := chi.NewRouter() router.Use( RequestIDMiddleware, middleware.RequestLogger(R...
package bbs import ( "github.com/cloudfoundry/storeadapter" "github.com/onsi-experimental/runtime-schema/models" ) //Bulletin Board System/Store type ExecutorBBS interface { WatchForDesiredRunOnce() (<-chan models.RunOnce, chan<- bool, <-chan error) //filter out delete... ClaimRunOnce(models.RunOnce) error Sta...
package config import ( "fmt" "log" "os" "strconv" "github.com/joho/godotenv" ) var ( ConnectionDbString = "" ApiPort = 0 SecretKey []byte ) //initialize enviroment vars func Load() { var err error if err = godotenv.Load(); err != nil { log.Fatal(err) } ApiPort, err = strconv.Atoi...
package tx import ( "context" "log" "math/big" "time" ethereum "github.com/ethereum/go-ethereum" "github.com/ethereum/go-ethereum/accounts" "github.com/ethereum/go-ethereum/accounts/abi/bind" "github.com/ethereum/go-ethereum/core/types" ) // GasPricer determines the gas price to send a tx with type GasPricer...
package rex import ( "fmt" "regexp" "strings" "testing" "github.com/kr/pretty" ) const xx = `tosca_definitions_version: tosca_simple_profile_for_wse_1_0_2 topology_template: node_templates: nginx: properties: image: "registry.cn-hangzhou.aliyuncs.com:9999/wise2c-test/elasticsearch" j...
package main import ( "fmt" "math" ) func main() { // 1000 => 10 fmt.Println(minimumCost([]int{1, 1}, []int{10, 8}, [][]int{ {6, 4, 9, 7, 1}, {5, 2, 2, 1, 3}, {3, 2, 5, 5, 2}, })) // 999 => 12 fmt.Println(minimumCost([]int{1, 1}, []int{10, 7}, [][]int{ {3, 7, 5, 3, 3}, {10, 2, 1, 2, 3}, {7, 7, 5,...
package c47_c48_bb98 import ( "crypto/rand" "crypto/rsa" "fmt" "math/big" "github.com/vodafon/cryptopals/set5/c39_rsa" ) var ( big1 = big.NewInt(1) big2 = big.NewInt(2) big3 = big.NewInt(3) B = new(big.Int) B2 = new(big.Int) B3 = new(big.Int) pubK = c39_rsa.PublicKey{} ) type BB98 struct { rsa *...
package rule import ( "net/http" ) type trueRule struct{} // NewTrueRule : func NewTrueRule() Rule { return trueRule{} } // Execute Execute Always True Rule func (r trueRule) Execute(req *http.Request) bool { return true }
package responses type Item interface { Import(modelItem interface{}) }
package goldie type Route interface{} type Routes map[Route]Action var ( Get Routes = Routes{} Post Routes = Routes{} Put Routes = Routes{} Delete Routes = Routes{} )
package Solution func Solution(nums1 []int, nums2 []int) int { n, m := len(nums1), len(nums2); dp := make([]int, m + 1); res := 0; for i := 1; i < n + 1; i++ { for j := m; j > 0; j-- { if nums1[i - 1] == nums2[j - 1] { dp[j] = 1 + dp[j - 1]; } else { ...
package main import ( "fmt" ) type MyError string func (e MyError) Error() string { return string(e) } func do() error { var ret *MyError = nil return ret } func main() { if err := do(); err != nil { fmt.Printf("Error exists: %T is not %T", err, nil) } else { fmt.Println("No error") } }
package importers import ( "reflect" "sort" "strings" "testing" ) func TestSetFromInterface(t *testing.T) { t.Parallel() setIntf := map[string]interface{}{ "standard": []interface{}{ "hello", "there", }, "third_party": []interface{}{ "there", "hello", }, } set, err := SetFromInterface(se...
package main import ( "bytes" "encoding/json" "fmt" "io/ioutil" "log" "net/http" "net/url" "sync" "sync/atomic" "time" "github.com/satori/go.uuid" "github.com/syndtr/goleveldb/leveldb" ) var dbPath = "./db/" // OutputError is set on Output when an unrecuperable error has occurred type OutputError struct...
package types const ( // ModuleName defines the module name ModuleName = "gitgood" // StoreKey defines the primary module store key StoreKey = ModuleName // RouterKey is the message route for slashing RouterKey = ModuleName // QuerierRoute defines the module's query routing key QuerierRoute = ModuleName /...
package main func subsets(nums []int) [][]int { var res [][]int dfs78(&res, []int{}, nums, 0) return res } func dfs78(res *[][]int, temp, nums []int, index int) { t := make([]int, len(temp)) copy(t, temp) *res = append(*res, t) for i := index; i < len(nums); i++ { temp = append(temp, nums[i]) dfs78(res, te...
package internal import ( "testing" cid "github.com/ipfs/go-cid" ) func TestLoggableRecordKey(t *testing.T) { c, err := cid.Decode("QmfUvYQhL2GinafMbPDYz7VFoZv4iiuLuR33aRsPurXGag") if err != nil { t.Fatal(err) } k, err := tryFormatLoggableRecordKey("/proto/" + string(c.Bytes())) if err != nil { t.Errorf(...
package parser import ( "encoding/json" "fmt" "sort" "strings" ) // A Policy is a policy made up of multiple allow or deny rules. type Policy struct { Rules []Rule } // MarshalJSON marshals the policy as JSON. func (p *Policy) MarshalJSON() ([]byte, error) { return json.Marshal(p.ToJSON()) } // String convert...
package components import ( "html/template" "github.com/GoAdminGroup/go-admin/template/types" ) type RowAttribute struct { Name string Content template.HTML types.Attribute } func (compo *RowAttribute) SetContent(value template.HTML) types.RowAttribute { compo.Content = value return compo } func (compo *...
package models type Photo struct { Id int Name string Album string Legend string }
// +build e2e package e2e import ( "testing" "github.com/gavv/httpexpect/v2" "github.com/stretchr/testify/suite" "github.com/argoproj/argo/test/e2e/fixtures" ) const baseUrlMetrics = "http://localhost:9090/metrics" // ensure basic HTTP functionality works, // testing behaviour really is a non-goal type Metric...
package main import ( "encoding/json" "fmt" "html/template" "io/ioutil" "log" "net/http" "github.com/gorilla/mux" ) // Templates var homepageTpl *template.Template // Weapons type Map struct { Id string `json:"Id"` Name string `json:"Name"` Gamers []Player Selected bool } type Weapon struc...
package testing import ( "context" "github.com/brigadecore/brigade/sdk/v3" ) type MockJobsClient struct { CreateFn func( ctx context.Context, eventID string, job sdk.Job, opts *sdk.JobCreateOptions, ) error StartFn func( ctx context.Context, eventID string, jobName string, opts *sdk.JobStartOpti...
package main /* Sample client that sends a message - either from the command line or the console - to a server. The message length is sent first as four bytes (BigEndian) to tell the server how much more is coming... */ import ( "bufio" "flag" "fmt" "net" "os" "strings" "encoding/binary" ) const ( HOST =...
package cmd import ( "fmt" "github.com/spf13/cobra" ) // VandameCommand is the command that represents the binary itselfs. var VandameCommand = &cobra.Command{ Use: "vandame", Short: vandameShort(), Long: vandameLong(), Run: func(cmd *cobra.Command, args []string) { printHelp() }, } func vandameShort() s...
package slack import ( "fmt" "net/http" "net/url" "reflect" "strings" "testing" ) func TestSlash_ServeHTTP(t *testing.T) { once.Do(startServer) serverURL := fmt.Sprintf("http://%s/slash", serverAddr) tests := []struct { body url.Values wantParams SlashCommand wantStatusCode int }{ { ...
package main import ( "fmt" "strconv" ) func main() { // Itoa : INT to ASCII var x = 12 var y = "I have this many: " + strconv.Itoa(x) fmt.Println(y) // fmt.Println("I have this many: ", strconv.Itoa(x), x) }
package go_bloom_filter import ( "github.com/spaolacci/murmur3" "github.com/willf/bitset" "sync" ) type BloomFilter struct { bitMap *bitset.BitSet mu sync.RWMutex size uint hashCount uint } func NewBloomFilter(size uint, hashCount uint) *BloomFilter { bf := BloomFilter{bitMap: bitset.New(size)...
package main import ( "encoding/json" "fmt" ) type Person struct { ID int FirstName string `json:"name"` LastName string Address string `json:"address,omitempty"` } type Employee struct { Person ManagerID int } type Contractor struct { Person CompanyID int } func main() { employees := []Employ...
package fp import ( "fmt" "path/filepath" "testing" ) func TestRel(t *testing.T) { base := "/base/root" path := []string{ "file.txt", "../file.txt", "../../file.txt", "../../../file.txt", "dir/../../../another.txt", "../file.txt/..//tset.txt//", } t.Log("--- filepath.Join(base, filepath.Clean(path...
package main import ( "oneday-infrastructure/internal/pkg/authenticate/base" "oneday-infrastructure/tools" ) func main() { tools.OpenDB("authenticate").AutoMigrate(base.LoginUserDO{}). AddIndex("uiq_tenant_code_username", "tenant_code", "username") }
package feed import ( "encoding/json" "fmt" "log" "math" "net/http" "strconv" "github.com/gorilla/mux" "github.com/mmcdole/gofeed" "github.com/patrickmn/go-cache" ) type feedModel struct { Id int `json:"id"` Name string `json:"name"` Url string `json:...
package aws import ( "errors" "io" "github.com/aws/aws-sdk-go/aws" "github.com/aws/aws-sdk-go/aws/session" "github.com/aws/aws-sdk-go/service/ec2" "github.com/aws/aws-sdk-go/service/s3" ) // ObjectConfig contains data for objects type ObjectConfig struct { Body io.ReadSeeker Bucket string KMSKeyID str...
package okgo // OKGO holds our execution blocks. type OKGO struct { err *error blocks []func() error } // NewOKGO constructs an OKGO for us. func NewOKGO(err *error) OKGO { return OKGO{ err: err, blocks: make([]func() error, 0), } } // On chains execution blocks. func (o OKGO) On(block func() error) OK...