text
stringlengths
11
4.05M
package dexml import ( "fmt" "log" "testing" "errors" apdm "spca/apd/models" ) func TestDeXmlSetup(t *testing.T){ fmt.Println("Test 1: Data Encode Setting to Xml Setup") xmlHdl := NewDeXmlHdl() if xmlHdl == nil { fmt.Println("Error in getting the Xml hand...
package main import "fmt" func max(x, y int) int { if x > y { return x } return y } func rob(nums []int) int { if len(nums) == 0 { return 0 } if len(nums) == 1 { return nums[0] } dp := [2][]int{} for i := 0; i < 2; i = i + 1 { dp[i] = make([]int, len(nums)+1) } dp[1][1] = nums[0] for i := 2; i <=...
package influx import ( "testing" "time" "github.com/bingoohuang/gou/lang" "github.com/stretchr/testify/assert" ) type delay struct { ModifiedTime time.Time `influx:"time" measurement:"pipeline_delay"` ID uint64 `influx:"tag" name:"delay_id"` Delay float64 `influx:"field"` Something ...
package objectstorage type CachedObjects []CachedObject func (cachedObjects CachedObjects) Release(force ...bool) { for _, cachedObject := range cachedObjects { cachedObject.Release(force...) } }
package MySQL import ( "AlgorithmPractice/src/common/Intergration/DB" "AlgorithmPractice/src/common/conf" "database/sql" "fmt" "sync" ) /** * @author liujun * @version V1.0 * @date 2022/7/15 19:06 * @author-Email ljfirst@mail.ustc.edu.cn * @description */ var ( DBMySqlCliInstance *DBMySqlCli DBMySqlCliO...
package main import ( "bufio" "fmt" "io" "os" "strings" ) type CommonUse struct { Contents string } //实现stringer接口 相当于java的toString func (c *CommonUse) String() string { return fmt.Sprintf("Retriever:{Contents=%s}", c.Contents) } func printFile(filename string) { file, err := os.Open(filename) if err != ni...
package handler import ( "fmt" "time" "github.com/dustinengle/itshere/pkg/client" "github.com/dustinengle/itshere/pkg/data" "github.com/dustinengle/itshere/pkg/v1/reply" "github.com/gin-gonic/gin" ) func DeleteMailbox(c *gin.Context) { mailbox := new(data.Mailbox) if err := c.BindJSON(mailbox); err != nil { ...
package main import ( "flag" "fmt" "log" "math" "math/rand" "net/http" "os" "runtime" "strconv" "sync" "time" "io/ioutil" "os/exec" "github.com/go-yaml/yaml" "github.com/google/uuid" "github.com/labstack/echo" "github.com/labstack/echo/middleware" api "github.com/synerex/synerex_alpha/api" napi "g...
package chapter5 import ( "fmt" ) type person struct { name string email string } // 如果一个函数有接收者,这个函数就被称为方法。 // Go语言既允许使用值,也允许使用指针来调用方法,不必严格符合接收者的类型。 // Go 编译器为了支持这种方法调用在背后做的事情,帮我们做了指针被解引用为值,或者 引用值得到一个指针 func (p person) notify() { fmt.Printf("Sending User Email To %s<%s>\n", p.name, p.email) } func (p *person) ...
package main func main() { x := make([]int, 2, 10) _ = x[6:10] _ = x[6:] // 截取符号 [i:j],如果 j 省略,默认是原切片或者数组的⻓度,x 的⻓度是 2,小于起始下标 6 , 所以 panic。 _ = x[2:] }
package domain import ( "errors" "time" ) var ( ErrTodoNotFound = errors.New("todo not found") ) type ( Todo struct { ID string `json:"id" bson:"id"` Title string `json:"title" bson:"title,omitempty"` Description string `json:"description" bson:"description,omitempty"` Completed ...
package main import "fmt" func main() { var pi float64 step := 1000000000 x := 3.0 y := -1.0 pi = 4.0 for i := 0; i < step; i++ { pi = pi + (4.0 / x * y) x += 2.0 y = -y } fmt.Println("pi = ", pi) }
package repository var repos *AllRepository type AllRepository interface { Create() error }
package main import ( "goApi/controllers/api" "goApi/controllers/users" "log" "os" "goApi/utils/db" "github.com/gin-gonic/gin" "github.com/joho/godotenv" ) func main() { // Load env variables err := godotenv.Load() if err != nil { log.Fatal("Error loading .env file") } // Set gin to production mode ...
package system import ( "errors" "time" "github.com/fanda-org/postmasters/database/models" "golang.org/x/crypto/bcrypt" // "github.com/jinzhu/gorm" // "github.com/satori/go.uuid" // _ "github.com/jinzhu/gorm/dialects/postgres" // "database/sql" ) // User model type User struct { models.Base UserName s...
package router import ( "sync" "github.com/gin-gonic/gin" "github.com/zhj0811/fabric-normal/apiserver/handler" ) // Router 全局路由 var router *gin.Engine var onceCreateRouter sync.Once //GetRouter 获取路由 func GetRouter() *gin.Engine { onceCreateRouter.Do(func() { router = createRouter() }) return router } func...
// SPDX-License-Identifier: MIT // Package locale 提供了一个本地化翻译服务。 package locale import ( "github.com/issue9/localeutil" "golang.org/x/text/language" "golang.org/x/text/message" ) // DefaultLocaleID 默认的本地化语言 ID // // 当未调用相关函数设置 ID,或是设置为一个不支持的 ID 时, // 系统最终会采用此 ID。 const DefaultLocaleID = "cmn-Hans" var ( // 保证有个初...
package main import ( "context" "fmt" "github.com/zcong1993/ip2region-service/service" "go.opencensus.io/examples/exporter" "go.opencensus.io/exporter/jaeger" "go.opencensus.io/plugin/ocgrpc" "go.opencensus.io/stats/view" "go.opencensus.io/trace" "log" "net" "net/http" "os" "github.com/grpc-ecosystem/grp...
package main import ( "github.com/panicthis/A" "github.com/panicthis/B" ) func main() { A.Visit() B.Visit() }
// Copyright 2020 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 // // https://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed to in wri...
package main import ( "fmt" "os" "net/http" "io" ) func main() { fmt.Println("启动更新 ...") out, err := os.Create("pudge.exe")//windows为 .exe if err != nil { fmt.Println("err:", err) } //http://www.baidu.com/ngrok/lasdver/ resp, _ := http.Get("http://127.0.0.1:8080/pudge.exe") defer resp.Body.Close() n, _ ...
package linqo type Action interface { String() string //PrettyPrint() string }
package main import ( "fmt" "sort" ) func main() { var a int sum := 0 var list []int fmt.Scan(&a) for i := 1; i <= a; i++ { var x int fmt.Scan(&x) sum += x list = append(list, x) } sort.Ints(list) fmt.Printf("%d %d %d\n", list[0], list[len(list)-1], sum) }
package mcts3 import ( "fmt" "math/rand" ) type GameState struct { player int board [25]int cachedResults [3]float64 } type Node struct { move int player int parent *Node childNodes []*Node wins float64 visits float64 score float64 // score should be 0 for a l...
package lc // Time: O(n) // Benchmark: 4ms 3.3mb | 76% 29% func getMinDistance(nums []int, target int, start int) int { rounds := start if len(nums)-start > start { rounds = len(nums) - start } for i := 0; i <= rounds; i++ { if start-i >= 0 && nums[start-i] == target { return i } if start+i < len(num...
package channel import ( "github.com/mitchellh/mapstructure" "github.com/slack-clone-server/config" r "gopkg.in/rethinkdb/rethinkdb-go.v5" ) // iota vai adicionar os valores: 1,2,3 automaticamente const ( ChannelStop = iota UserStop MessageStop ) func Add(client *config.Client, data interface{}) { var channel...
package parseBlock import ( "github.com/hyperledger/fabric-protos-go/common" utils "github.com/hyperledger/fabric/protoutil" ) type FilterTx struct { BlockNum uint64 //区块编号 Timestamp int64 `protobuf:"bytes,3,opt,name=timestamp,proto3" json:"timestamp,omitempty"` //秒 } func FilterParseTransaction(block *common....
package cli import ( "fmt" "io" "os" "github.com/apprenda/kismatic/pkg/install" "github.com/apprenda/kismatic/pkg/util" "github.com/spf13/cobra" ) type validateOpts struct { planFile string verbose bool outputFormat string skipPreFlight bool } // NewCmdValidate creates a new install validate ...
package main import "testing" type tuple struct { y, x int } func TestPowi(t *testing.T) { for k, v := range map[tuple]int{ tuple{9, 19}: 1350851717672992089, tuple{0, 8}: 0, tuple{0, 0}: 1} { if r := powi(k.y, k.x); r != v { t.Errorf("failed: %d^%d = %d, got %d", k.y, k.x, v, r) } } } func Te...
package aggregator import ( "encoding/json" "fmt" "io/ioutil" "net/http" "net/http/cookiejar" "net/url" "strconv" "strings" "time" "gitlab.com/vultour/steamcli/objects" log "github.com/sirupsen/logrus" "golang.org/x/net/html" "golang.org/x/net/html/atom" ) type gameMatcher []*map[int]struct{} // GameE...
package main import "clipper" func main() { m := clipper.NewMaster() m.StartUp() }
package main // Leetcode 983. (medium) func mincostTickets(days []int, costs []int) int { last := days[len(days)-1] dp := make([]int, last+1) idx := 0 for i := 1; i < last+1; i++ { if i != days[idx] { dp[i] = dp[i-1] continue } cost := 1<<31 - 1 oneDaysAgo := i - 1 sevenDaysAgo := i - 7 thirtyDay...
package spotifyauth import ( "github.com/Iteam1337/go-udp-wejay/utils" "github.com/ankjevel/spotify" "golang.org/x/oauth2" ) type Interface interface { AuthURL(id string) string NewClient(*oauth2.Token) spotify.Client Exchange(string) (*oauth2.Token, error) } type SpotifyAuth struct { auth spotify.Authentica...
package pencode import ( "bytes" "encoding/binary" "unicode/utf16" ) type UTF16LEEncode struct{} func (u UTF16LEEncode) Encode(input []byte) ([]byte, error) { var b bytes.Buffer runes := []rune(string(input)) utf16ints := utf16.Encode(runes) for _, r := range utf16ints { tmp := make([]byte, 2) binary.Litt...
package adapter import ( "fmt" "github.com/centrifuge/go-substrate-rpc-client/v3/types" "github.com/pkg/errors" "github.com/shopspring/decimal" "math/big" "strconv" "strings" ) // removeHexPrefix removes the prefix (0x) of a given hex string. func removeHexPrefix(str string) string { if hasHexPrefix(str) { ...
package odoo import ( "fmt" ) // IrQwebFieldContact represents ir.qweb.field.contact model. type IrQwebFieldContact struct { LastUpdate *Time `xmlrpc:"__last_update,omptempty"` DisplayName *String `xmlrpc:"display_name,omptempty"` Id *Int `xmlrpc:"id,omptempty"` } // IrQwebFieldContacts represents...
package tests import ( "reflect" "testing" ) /** * [1195] Distribute Candies to People * * We distribute some number of candies, to a row of n = num_people people in the following way: * * We then give 1 candy to the first person, 2 candies to the second person, and so on until we give n candies to the last pe...
package Add_Two_Numbers import "testing" func Test(t *testing.T) { l1 := ListNode{ Val: 2, Next: &ListNode{ Val: 4, Next: &ListNode{ Val: 3, Next: nil, }, }, } l2 := ListNode{ Val: 5, Next: &ListNode{ Val: 6, Next: &ListNode{ Val: 4, Next: nil, }, }, } l3 := addT...
package main import "fmt" import "github.com/sushruta/go-key-value-db/memtable" func main() { bst := memtable.BstConstructor() bst.Insert("handbag", 8786) bst.Insert("handlebars", 3869) bst.Insert("handicap", 70836) bst.Insert("handkerchief", 16433) fmt.Println(bst.Ino...
package entity import "github.com/google/uuid" const ( TransaksiDetailTableName = "transaksi_detail" ) //TransaksiModel is a model for entity.TransaksiDetail type TransaksiDetail struct { ID uuid.UUID `gorm:"type:uuid;primary_key" json:"id"` Produk string `gorm:"type:string;null" json:"produk"` ...
package shoot import ( "github.com/mandelsoft/cmdint/pkg/cmdint" "github.com/afritzler/garden-examiner/pkg" "github.com/afritzler/garden-examiner/cmd/gex/const" "github.com/afritzler/garden-examiner/cmd/gex/context" "github.com/afritzler/garden-examiner/cmd/gex/util" ) func init() { filters.Add(&SeedFilter{})...
// 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, ...
package iterators_test import ( "fmt" "log" "testing" "github.com/adamluzsi/frameless/ports/iterators" "github.com/adamluzsi/testcase/assert" "github.com/adamluzsi/testcase/random" ) func ExampleFilter() { var iter iterators.Iterator[int] iter = iterators.Slice([]int{0, 1, 2, 3, 4, 5, 6, 7, 8, 9}) iter = i...
package main import ( "context" "encoding/json" "fmt" "os" "testing" "time" "google.golang.org/grpc" "google.golang.org/grpc/credentials" pb "github.com/4726/discussion-board/services/search/pb" "github.com/golang/protobuf/proto" "github.com/olivere/elastic/v7" "github.com/stretchr/testify/assert" ) var...
package main import ( "github.com/gondor/docker-volume-netshare/netshare" ) func main() { netshare.Execute() }
package main import ( "fmt" "os" "github.com/urfave/cli" "github.com/evrynet-official/evrynet-tools/lib/node" sc "github.com/evrynet-official/evrynet-tools/stakingcontract" ) func main() { app := cli.NewApp() app.Name = "stress-test tool" app.Usage = "Stress test for staking contract" app.Version = "0.0.1"...
package api import ( "bytes" "encoding/json" "fmt" "io/ioutil" "net/http" "github.com/mitchellh/mapstructure" "github.com/opsbot/cli-go/utils" log "github.com/sirupsen/logrus" ) var ( // Config - hold a reference to configuration Config Configuration ) // CheckConfig - check config is set func CheckConfig...
package retry import ( "errors" "fmt" "strings" "time" "go.uber.org/zap" ) /* QuickRetry 重试 参数: * fun func() error 重试的函数 * retryExtraCheck func(error) bool 重试额外处理检查 * retryExtra func() 额外处理 * timeout time.Duration 重试最长时间 * retryInterval time.Duration 重试间隔 返回值...
//Package twitter of GOTOJS/stream offers a stream implementation for Twitter. //Currently it is based on the twitter location API which needs to be generalized. // //The client key/secret configuration for the actual twitter API can be made in a local file // named "twitter_account.json" // // A sample file is provide...
package rt import ( "testing" "github.com/pkg/errors" ) func TestReactrJobGroup(t *testing.T) { r := New() doMath := r.Register("math", math{}) grp := NewGroup() grp.Add(doMath(input{5, 6})) grp.Add(doMath(input{7, 8})) grp.Add(doMath(input{9, 10})) if err := grp.Wait(); err != nil { t.Error(errors.Wra...
package http import ( "net/http" "github.com/urfave/negroni" ) type Server struct { *http.Server } func Address() string { return ":8080" } func NewServer() (*Server, error) { mux := http.NewServeMux() handler := newHandler("ping") mux.Handle("/ping", handler) router := negroni.New() router.UseHandler(mu...
package main import ( "encoding/json" "fmt" "io/ioutil" "math/rand" "time" "github.com/netsec-ethz/conn-tester/client/tests" "github.com/netsec-ethz/conn-tester/client/tests/httptest" "github.com/netsec-ethz/conn-tester/client/tests/ntptest" "github.com/netsec-ethz/conn-tester/client/tests/tcpin" "github.co...
package main import ( "bufio" "fmt" "github.com/codegangsta/cli" "github.com/ntedeschi/lineage/devpat" "log" "os" "strings" ) func main() { log.SetPrefix("lineage ") log.SetFlags(0) app := cli.NewApp() app.Name = "lineage" app.Usage = "analyze lineage trees" var minsize int var percent float64 var cu...
package roles import ( "net/http" ) // Registry stores links between roles and rights type Registry struct { roles map[Role][]Right } // NewRegistry returns new role access registry func NewRegistry() *Registry { t := Registry{} t.Reset() return &t } // Router is a http mux type Router interface { Get(patter...
package tdpos import ( "encoding/json" "testing" "time" "github.com/golang/protobuf/proto" bmock "github.com/xuperchain/xupercore/bcs/consensus/mock" lpb "github.com/xuperchain/xupercore/bcs/ledger/xledger/xldgpb" common "github.com/xuperchain/xupercore/kernel/consensus/base/common" cctx "github.com/xuperchai...
package main import ( "fmt" "net/http" "io/ioutil" "encoding/xml" "io" _"github.com/lib/pq" "database/sql" "strconv" ) const ( DB_USER = "???" DB_PASSWORD = "???" DB_NAME = "???" DB_HOST = "localhost" CAMINHO = "/arquivamento/???/" CAMINHO_ERROR = "/arquivamento/error/...
// +build go1.7 package apns2 import ( "context" "net/http" "net/http/httputil" log "github.com/sirupsen/logrus" ) // A Context carries a deadline, a cancellation signal, and other values across // API boundaries. // // Context's methods may be called by multiple goroutines simultaneously. type Context interfac...
package vis /*MyName is visible from main.go because the first letter of the variable is capitalized, unlike yourName which is not visible.*/ var MyName = "Raffi" var yourName = "Test"
// 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 solutions func candy(ratings []int) int { length := len(ratings) if length == 0 { return 0 } totalCandies := 1 leftNeighbour := 1 for i := 1; i < length; { if ratings[i] > ratings[i - 1] { leftNeighbour = leftNeighbour + 1 totalCandies += leftN...
package main import ( "bytes" "encoding/base64" "flag" "fmt" "io/ioutil" "net" "net/http" "net/url" "os" "os/signal" "strings" "syscall" "time" "github.com/google/martian/v3" martianLog "github.com/google/martian/v3/log" "github.com/google/martian/v3/mitm" log "github.com/sirupsen/logrus" ) var ( p...
package main import ( "fmt" "github.com/jinzhu/gorm" _ "github.com/jinzhu/gorm/dialects/mysql" ) //定义数据模型 type User struct { ID int64 Name string `gorm:"default:'noname'"` Age int64 } //在字段有默认值的情况下仍要传入0值 //方法1 使用指针 // type User struct { // ID int64 // Name ×string `gorm:"default:'noname'"` // Age int64...
package mill import ( "bytes" "fmt" "io/ioutil" "os" "path/filepath" "strings" "testing" "time" "github.com/google/skylark" "github.com/windmilleng/pets/internal/proc" "github.com/windmilleng/pets/internal/school" "github.com/windmilleng/pets/internal/service" "github.com/windmilleng/wmclient/pkg/dirs" )...
package ravendb import ( "bytes" "io" "net/http" "strings" ) // Note: the implementation details are different from Java // We take advantage of a pipe: a read end is passed as io.Reader // to the request. A write end is what we use to write to the request. var _ RavenCommand = &BulkInsertCommand{} // BulkInser...
package ucfunnel import ( "encoding/json" "fmt" "testing" "github.com/prebid/openrtb/v19/openrtb2" "github.com/prebid/prebid-server/adapters" "github.com/prebid/prebid-server/config" "github.com/prebid/prebid-server/openrtb_ext" ) func TestMakeRequests(t *testing.T) { imp := openrtb2.Imp{ ID: "1234", ...
package upload import ( "crypto/md5" "encoding/hex" "fmt" "io" "net/http" "os" "path" "strconv" "time" "github.com/510909033/bgf_log" ) var logger = bgf_log.GetLogger("upload_bo") func Save(name string) (id int64, err error) { bo := &UploadBO{} newBO, err := NewUploadBO(bo, false) h := md5.New() h.Wr...
package main import ( "context" "github.com/aws/aws-lambda-go/events" "github.com/aws/aws-lambda-go/lambda" "github.com/drhodes/golorem" ) type Response events.APIGatewayProxyResponse func Handler(ctx context.Context) (Response, error) { resp := Response{ StatusCode: 200, IsBase64Encoded: false, Body...
// main.go package main import ( "errors" "net/http" "strconv" "github.com/gin-gonic/gin" ) var router *gin.Engine func main() { router = gin.Default() router.LoadHTMLGlob("templates/*") initializeRoutes() router.Run() } func initializeRoutes() { router.GET("/", showIndexPage) router.GET("/about-u...
// +build linux package devicemapper import ( "encoding/json" "fmt" "io" "io/ioutil" "os" "os/exec" "path" "strings" "syscall" "github.com/hyperhq/hyper/storage" "github.com/hyperhq/runv/lib/glog" ) type jsonMetadata struct { Device_id int `json:"device_id"` Size int `json:"size"` Tra...
package sorts import ( "fmt" "math" "math/rand" "time" ) // TestSorts test sort algorithms func Tests() { fmt.Println("*****************Sorting******************") arr := []int{5, 2, 4, 6, 1, 3} fmt.Println("-----------SortInt--------------") fmt.Println(arr) SortInt(arr) fmt.Println(arr) i := LinearSearc...
package amqppool import ( "errors" "log" "os" "testing" ) func TestShouldCreateANewAmqpPool(t *testing.T) { //Arrange connectionString := os.Getenv("AMQP_CONNECTION") maxChannels := 10 logger := log.New(os.Stdout, "", log.LstdFlags) //Action pool, err := NewPool(connectionString, maxChannels, logger) defe...
package template import ( "net/http" "github.com/gorilla/mux" "github.com/wincentrtz/gobase/gobase/infrastructures/db" "github.com/wincentrtz/gobase/gobase/utils" "github.com/wincentrtz/gobase/models/dto/responses" ) type TemplateHandler struct { templateUsecase TemplateUsecase } func NewTemplateHandler(r *mu...
// Copyright 2019 Yunion // // 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 writi...
package main import ( "context" "fmt" "strconv" "errors" "time" "github.com/go-redis/redis/v8" ) type Database interface { GetKey(string) (string, string, error) SetKey(string) error CheckExist(string) bool IncreaseVisit(string) error FlushAll() error Lock() error Unlock() error } type RedisServer stru...
package function import ( "encoding/json" "errors" "github.com/hecatoncheir/Storage" "log" "os" ) type Storage interface { CreateJSON([]byte) (string, error) } type Functions interface { ReadPageInstructionByID(string, string) storage.PageInstruction } type Executor struct { Store Storage Functions Fun...
package backtracking import ( "reflect" "testing" "github.com/NBR41/gosudoku/model" ) func TestGetMapValues(t *testing.T) { v := getMapValues(4) exp := map[int]struct{}{1: {}, 2: {}, 3: {}, 4: {}} if !reflect.DeepEqual(exp, v) { t.Error("unexpected value") } } func TestGetPossibilities(t *testing.T) { cel...
/* Copyright IBM Corp. All Rights Reserved. SPDX-License-Identifier: Apache-2.0 */ package mirbft import ( pb "github.com/IBM/mirbft/mirbftpb" ) // Actions are the responsibility of the library user to fulfill. // The user receives a set of Actions from a read of *Node.Ready(), // and it is the user's responsibili...
package LeetCode import ( "fmt" ) func Code264() { num := nthUglyNumber(100) fmt.Println(num) } /** 编写一个程序,找出第 n 个丑数。 丑数就是只包含质因数 2, 3, 5 的正整数。 示例: 输入: n = 10 输出: 12 解释: 1, 2, 3, 4, 5, 6, 8, 9, 10, 12 是前 10 个丑数。 说明: 1 是丑数。 n 不超过1690。 来源:力扣(LeetCode) 链接:https://leetcode-cn.com/problems/ugly-number-ii 著作权归领扣网络所...
// Copyright 2020 Dell Inc, or its subsidiaries. // SPDX-License-Identifier: Apache-2.0 package service import ( "encoding/json" "flag" "fmt" "os" "gitlab.eng.vmware.com/dell-iot/iotss-utils/util" "gitlab.eng.vmware.com/dell-iot/iotss/go-skeleton-project/model" "gitlab.eng.vmware.com/dell-iot/iotss/go-skeleto...
/* * Copyright 2022 Kube Admission Webhook 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 applicabl...
package cmd import ( "fmt" "github.com/spf13/cobra" "os" ) var ( VERSION string ) var RootCmd = &cobra.Command{ Use: "sweady", Short: "First cluster docker swarm ready for production", } func Execute(version string) { VERSION = version if err := RootCmd.Execute(); err != nil { fmt.Println(err) os.Exi...
package main //code: https://play.golang.org/p/Lmbyn7bO7e import ( "context" "fmt" "runtime" "time" ) func main() { ctx, cancel := context.WithCancel(context.Background()) fmt.Println("error check 1:", ctx.Err()) fmt.Println("num gortins 1:", runtime.NumGoroutine()) go func() { n := 0 for { select { ...
package whoislookup import ( "bytes" "encoding/base64" "encoding/json" "errors" "fmt" "github.com/PuerkitiBio/goquery" "github.com/davecgh/go-spew/spew" "io/ioutil" "log" "math/rand" "net" "net/http" "net/url" "os" "os/exec" "regexp" "strings" "sync" "time" ) // use for dump...
package portal import ( "fmt" "net/http" "time" "github.com/golang/glog" "kope.io/auth/pkg/configreader" "kope.io/auth/pkg/keystore" "kope.io/auth/pkg/oauth" "kope.io/auth/pkg/tokenstore" ) type HTTPServer struct { config *configreader.ManagedConfiguration listen string staticDir string oauthServer ...
package mocks import ( "github.com/oreuta/easytrip/models" ) type BankUAClientMock struct { Body []byte Unpacked []models.CurrencyBank Err error } func (m BankUAClientMock) Get() (body []byte, err error) { return m.Body, m.Err } func (m BankUAClientMock) GetCurrBank() (unpacked []model...
package cmd_test import ( "bytes" "os" "path/filepath" "testing" "github.com/raba-jp/primus/pkg/cli/cmd" ) func TestExecute(t *testing.T) { tests := []struct { name string args []string goldenFile string }{ { name: "no args", args: []string{}, goldenFile: "execute_no_a...
package model import ( "encoding/json" "fmt" "time" "mdstest/helper" "golang.org/x/crypto/bcrypt" "github.com/jinzhu/gorm" "github.com/pkg/errors" ) const UserStatusActive = "A" const UserStatusInactive = "I" const UserStatusDeleted = "D" var UserStatusMap = map[string]string { "A" : "Active", "I" : "Ina...
package main import ( "net/http" "net/http/httptest" "testing" "github.com/gorilla/mux" "github.com/stretchr/testify/assert" ) func Test_getBooks(t *testing.T) { ww := httptest.NewRecorder() type args struct { w http.ResponseWriter r *http.Request } tests := []struct { name string args args want ...
package cache import ( "encoding/json" "errors" "fmt" "os" "path/filepath" "strings" "github.com/ayoisaiah/stellar-photos-server/config" "github.com/ayoisaiah/stellar-photos-server/unsplash" "github.com/ayoisaiah/stellar-photos-server/utils" ) const stellarPhotosCollectionID = 998309 const ( standardRes =...
package describe import ( "context" "encoding/json" "errors" "fmt" "github.com/spf13/cobra" kcmdutil "k8s.io/kubectl/pkg/cmd/util" "k8s.io/kubectl/pkg/util/templates" "github.com/openshift/oc-mirror/pkg/bundle" "github.com/openshift/oc-mirror/pkg/cli" ) type DescribeOptions struct { *cli.RootOptions From...
package main import ( "fmt" // "time" "strconv" "remoteCacheToGo/cacheClient" ) func main() { fmt.Println("Client test") errorStream := make(chan error) // creates new cacheClient struct and connects to remoteCache instance // no tls encryption -> param3: false client := cacheClient.New() go clie...
/******************************************************************************* * Copyright 2017 Samsung Electronics 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...
package guard import ( "context" "github.com/adamluzsi/frameless/internal/consttypes" ) type Locker interface { // Lock locks the Locker resource. // If the lock is already in use, the calling will be blocked until the locks is available. // It returns a context that represent a locked context, and an error that...
package main import ( "bufio" "context" "encoding/json" "flag" "fmt" "html/template" "io" "io/ioutil" "net/http" "os" "os/exec" "path" "strings" "sync" "time" "github.com/google/uuid" log "github.com/sirupsen/logrus" ) type query struct { Code string `json:"code"` Args map[...
package hasher import ( "crypto/sha1" "fmt" ) type PasswordHasher interface { Hash(password string) (string, error) } type SHA1Hasher struct { salt string } func NewSHA1Hasher(salt string) *SHA1Hasher { return &SHA1Hasher{salt: salt} } func (h *SHA1Hasher) Hash(password string) (string, error) { hash := sha1....
package config import ( "fmt" "path/filepath" "reflect" "time" "github.com/dnephin/configtf" pth "github.com/dnephin/configtf/path" docker "github.com/fsouza/go-dockerclient" "github.com/pkg/errors" ) // ImageConfig An **image** resource provides actions for working with a Docker // image. If an image is bui...
package release import ( "log" "os" "os/exec" "github.com/google/go-github/github" "github.com/goreleaser/goreleaser/clients" "github.com/goreleaser/goreleaser/context" "golang.org/x/sync/errgroup" ) // Pipe for github release type Pipe struct{} // Description of the pipe func (Pipe) Description() string { ...
/* * KIAB SDK * * KIAB SMS Service * * OpenAPI spec version: * * Generated by: https://github.com/swagger-api/swagger-codegen.git */ package swagger type Body struct { GrantType string `json:"grant_type"` RefreshToken string `json:"refresh_token,omitempty"` ClientId string `json:"client_id"` Client...
package module import ( "github.com/ypyf/salmon/runtime" "regexp" "sync" "github.com/sirupsen/logrus" "github.com/ypyf/salmon/chat/adapter" "github.com/ypyf/salmon/store" "github.com/ypyf/salmon/store/redis" lua "github.com/yuin/gopher-lua" ) type ChatBot struct { sync.Mutex store store.Store avail ...
//go:build rocksdb package rocksdb import ( "fmt" "github.com/iotaledger/grocksdb" "github.com/iotaledger/hive.go/runtime/ioutils" ) // RocksDB holds the underlying grocksdb.DB instance and options. type RocksDB struct { db *grocksdb.DB ro *grocksdb.ReadOptions wo *grocksdb.WriteOptions fo *grocksdb.FlushOpt...