blob_id
stringlengths
40
40
language
stringclasses
1 value
repo_name
stringlengths
4
108
path
stringlengths
2
210
src_encoding
stringclasses
12 values
length_bytes
int64
13
5.82M
score
float64
2.52
5.22
int_score
int64
3
5
detected_licenses
listlengths
0
161
license_type
stringclasses
2 values
detected_licenses_right
listlengths
0
161
license_type_right
stringclasses
2 values
text
stringlengths
13
6.48M
download_success
bool
1 class
e2cb4f4d048270812323f035838246a8afefa329
Go
LeeChiChuang/GoExample
/interview/q004.go
UTF-8
1,242
3.671875
4
[]
no_license
[]
no_license
package main import ( "fmt" "reflect" "unsafe" ) /* 翻转字符串 问题描述 请实现一个算法,在不使用【额外数据结构和储存空间】的情况下,翻转一个给定的字符串(可以使用单个过程变量)。 给定一个string,请返回一个string,为翻转后的字符串。保证字符串的长度小于等于5000。 */ func reverString(s string) (string, bool) { str := []rune(s) l := len(str) if l > 5000 { return s, false } for i := 0; i < l/2; i++ { ...
true
35153d28fb3157b9fe477bae2275dc1e99dcf820
Go
aliforever/golang-backend-training
/chapter14/section14.3/api/httpswitch.go
UTF-8
311
3
3
[]
no_license
[]
no_license
package api import ( "fmt" "net/http" ) type HTTPSwitch struct { } func (hs HTTPSwitch) ServeHTTP(wr http.ResponseWriter, r *http.Request) { path := r.URL.Path switch path { case "/hello": fmt.Fprintf(wr, "Hello world! method = %q", r.Method) return default: http.NotFound(wr, r) return } }
true
e5c60fee00b32692caca008af098502f95bd4e30
Go
squzy/squzy
/apps/squzy_incident/expression/expression.go
UTF-8
2,447
2.515625
3
[ "BSD-3-Clause" ]
permissive
[ "BSD-3-Clause" ]
permissive
package expression import ( "errors" "fmt" "github.com/antonmedv/expr" "github.com/araddon/dateparse" apiPb "github.com/squzy/squzy_generated/generated/github.com/squzy/squzy_proto" timestamp "google.golang.org/protobuf/types/known/timestamppb" "strconv" "time" ) type Expression interface { ProcessRule(ruleT...
true
b10cac1e17066ca06904958a67d151d4e7dd0682
Go
konjoot/benches
/kami/contact_query.go
UTF-8
3,752
2.703125
3
[ "MIT" ]
permissive
[ "MIT" ]
permissive
package main import ( "errors" "log" "github.com/jmoiron/sqlx" ) const ( USERS_QUERY = ` select id, email, first_name, last_name, middle_name, date_of_birth, sex from users where deleted_at is null order by id limit ? offset ?;` PROFIL...
true
ad4e36803310cbd16965aca635c3dea10fc66bd6
Go
Bhanditz/wharf
/tlc/tlc_test.go
UTF-8
5,351
2.71875
3
[ "MIT", "LicenseRef-scancode-unknown-license-reference" ]
permissive
[ "MIT", "LicenseRef-scancode-unknown-license-reference" ]
permissive
package tlc import ( "io" "io/ioutil" "os" "path" "path/filepath" "runtime" "testing" "github.com/itchio/arkive/zip" "github.com/itchio/wharf/archiver" "github.com/itchio/wharf/state" "github.com/stretchr/testify/assert" ) func Test_NonDirWalk(t *testing.T) { tmpPath, err := ioutil.TempDir("", "nondirwa...
true
f9c40c3b01d771f87065d58833c538f294727741
Go
conalryan/go-notes
/lang/controlflow/main.go
UTF-8
4,389
3.890625
4
[]
no_license
[]
no_license
package main import ( "fmt" "io/ioutil" "log" "net/http" ) func main() { // Looping // for // break keyword // continue keyword fmt.Println("\nfor loop:") for i := 0; i < 5; i++ { fmt.Println(i) } // Multiple variables // Scoped to for loop for i, j := 0, 0; i < 5; i, j = i+1, j+1 ...
true
2086f2d647868afb43fcbb34db2f0bbbbb749ae8
Go
oasangqi/proxy
/internal/conn/conn_tcp.go
UTF-8
1,511
2.90625
3
[]
no_license
[]
no_license
package conn import ( "encoding/binary" "errors" "github.com/oasangqi/proxy/pkg/bufio" "github.com/oasangqi/proxy/pkg/bytes" "net" ) type TCPConn struct { conn net.Conn r *bufio.Reader w *bufio.Writer rb *bytes.Buffer wb *bytes.Buffer rp *bytes.Pool wp *bytes.Pool } func NewTcpConn(conn net...
true
99f1fb379fd97b1d32f3fd2a43eaabec456b25dd
Go
muyunil/strbot
/txqq/backup/rollBack.go
UTF-8
1,709
2.828125
3
[]
no_license
[]
no_license
package backup import ( "os" "fmt" "strings" "github.com/otiai10/copy" ) const ( RdDirErr = "回滚存档路径错误!\n检查参数路径是否存在及格式正确!\n格式参考:\n<rd worlds-2020-12-10_16-44-44>\n使用lsbd查看可回滚存档列表" RdOk = "回滚完成!" RdErr = "回滚copy错误!请管理员查看日志!" ) /*func main(){ // fmt.Println(Rd("rb worlds-2020-10-08_20-14...
true
627d8d981fba8289fe9b03fcc4d07fbebbdcfadd
Go
robhurring/cmd
/cmd.go
UTF-8
3,740
3.140625
3
[]
no_license
[]
no_license
package cmd import ( "bytes" "fmt" "os" "os/exec" "runtime" "strings" "syscall" "github.com/kballard/go-shellquote" ) var ( // isWindows determines if running on Windows or *nix isWindows = runtime.GOOS == "windows" ) // Cmd represents an OS command type Cmd struct { // Name is the name of the command N...
true
c632377ee165c6477d895e3f5678cb925a3996b7
Go
arvi3411301/init-templates
/cli/migrate/database/migration.go
UTF-8
1,716
3.5
4
[ "Apache-2.0", "MIT" ]
permissive
[ "Apache-2.0", "MIT" ]
permissive
package database import "sort" // Migrations wraps Migration and has an internal index // to keep track of Migration order in database. type Migrations struct { index uint64Slice } func NewMigrations() *Migrations { return &Migrations{ index: make(uint64Slice, 0), } } func (i *Migrations) Append(version uint64...
true
85dc84e35caeca30ab5dd9fdfb77dc75cede75e8
Go
shoenig/marathonctl
/config/configuration.go
UTF-8
697
3.234375
3
[ "MIT" ]
permissive
[ "MIT" ]
permissive
package config import ( "bufio" "fmt" "os" "strings" ) type Properties map[string]string func (p Properties) GetStringOr(s, alt string) string { v, exists := p[s] if !exists { return alt } return v } func ReadProperties(filename string) (Properties, error) { f, err := os.Open(filename) if err != nil { ...
true
a270105e696583a5e54c7d52734f307c97e958e9
Go
onlineconf/onlineconf
/admin/go/common/database.go
UTF-8
1,148
2.734375
3
[ "MIT" ]
permissive
[ "MIT" ]
permissive
package common import ( "database/sql" "net" "time" "github.com/go-sql-driver/mysql" "github.com/rs/zerolog/log" ) var DB *sql.DB func MysqlInitConfig(config DatabaseConfig) *mysql.Config { mysqlConfig := mysql.NewConfig() mysqlConfig.User = config.User mysqlConfig.Passwd = config.Password mysqlConfig.Net ...
true
b18bfa028599e5cf3cad6aec11d4cf8364b9c754
Go
gabrielperezs/CARBOnic
/lib/aws_session_pool.go
UTF-8
1,649
2.890625
3
[ "MIT" ]
permissive
[ "MIT" ]
permissive
package lib import ( "fmt" "log" "sync" "time" "github.com/aws/aws-sdk-go/aws" "github.com/aws/aws-sdk-go/aws/session" "github.com/aws/aws-sdk-go/service/sqs" ) const ( SESSION_INTERVAL time.Duration = 24 * time.Hour SESSION_RETRY time.Duration = 30 * time.Second ) var ( sessMutex sync.RWMutex Session...
true
79701165e65473faf5ddba8141791cadf703cb7a
Go
mehrdad-shokri/drone
/handler/api/user/update_test.go
UTF-8
3,194
2.59375
3
[ "Apache-2.0", "LicenseRef-scancode-proprietary-license" ]
permissive
[ "Apache-2.0", "LicenseRef-scancode-proprietary-license" ]
permissive
// Copyright 2019 Drone.IO Inc. All rights reserved. // Use of this source code is governed by the Drone Non-Commercial License // that can be found in the LICENSE file. package user import ( "bytes" "encoding/json" "net/http/httptest" "testing" "github.com/drone/drone/handler/api/errors" "github.com/drone/dro...
true
0936c25c5c9c421ec9f02881669658b41ef7441f
Go
fengyfei/nuts
/examples/udp/server/server.go
UTF-8
2,091
2.59375
3
[ "MIT" ]
permissive
[ "MIT" ]
permissive
/* * MIT License * * Copyright (c) 2017 SmartestEE Co., Ltd.. * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal * in the Software without restriction, including without limitation the rights * to use, ...
true
e20f0dda8dddd3f7138c21158d5a0daef071302e
Go
Odzen/GoLang
/Learning/functions/basics/basics.go
UTF-8
356
3.859375
4
[]
no_license
[]
no_license
package main import ( "fmt" ) func main() { for i := 0; i < 5; i++ { sayMessage("Hello go", i) } } func sayMessage(msg string, idx int) { fmt.Println(msg) fmt.Println("The value of the message is", idx) } /* We can add the type at the end to show that all the arguments are of the same type func sayMessage(ms...
true
159b2e0e50e7a057732241c39f968e9f8f65bf30
Go
ao-concepts/websockets
/connection_test.go
UTF-8
1,318
2.796875
3
[ "MIT" ]
permissive
[ "MIT" ]
permissive
package websockets_test import ( "context" "github.com/ao-concepts/websockets" "github.com/ao-concepts/websockets/mock" "github.com/stretchr/testify/assert" "testing" ) func TestNewConnection(t *testing.T) { ctx, cancel := context.WithCancel(context.Background()) socket := websockets.New(mock.NewServiceContain...
true
a004c00d416d53a5f8f8302d43ffc0a634e04d07
Go
lybobob1/CatTails
/cmd/c2/server.go
UTF-8
5,195
2.9375
3
[]
no_license
[]
no_license
package main import ( "bufio" "bytes" "encoding/json" "fmt" "log" "net" "net/http" "os" "strconv" "strings" "github.com/google/gopacket" "github.com/oneNutW0nder/CatTails/cattails" "golang.org/x/sys/unix" ) // Global to store staged command var stagedCmd string // Glabal to store target info var target...
true
24e4abc8cca9a49fa25d10a0e4215db34d815776
Go
squ1dd13/scm
/value.go
UTF-8
2,793
3.171875
3
[]
no_license
[]
no_license
package scm import ( "bytes" "encoding/binary" "errors" "fmt" "strings" ) type ElementType byte const ( ElementTypeInt ElementType = iota ElementTypeFloat ElementType = iota ElementTypeString8 ElementType = iota ElementTypeString16 ElementType = iota ) type ArrayAccess struct { Element ...
true
80a83084a729bc227bc9b1fa42cd30e6e60ba81d
Go
pombredanne/salsaflow
/version/version.go
UTF-8
3,373
2.78125
3
[ "MIT" ]
permissive
[ "MIT" ]
permissive
package version import ( // Stdlib "bytes" "encoding/json" "fmt" "io" "io/ioutil" "os" "path/filepath" "regexp" "strconv" // Internal "github.com/tchap/git-trunk/git" ) const ( PackageFileName = "package.json" GroupMatcherString = "([0-9]+)[.]([0-9]+)[.]([0-9]+)" MatcherString = "[0-9]+[.][0-9...
true
6fe0d1a6af113a9a0fb783e9b67b1b8c3b5c59a5
Go
ZBMO/algorithms
/count/count.go
UTF-8
530
3.78125
4
[]
no_license
[]
no_license
package count import ( "fmt" "time" ) func Count(array []int) []int { start := time.Now() count(array) elapsed := time.Since(start) fmt.Println("Count sort elapsed time: ", elapsed) return array } func count(array []int) { max := getMax(array) c := make([]int, max+1) for _, i := range array { c[i]++ ...
true
c551a50eba459670bf879dca175095e5996753fe
Go
BOXFoundation/boxd
/storage/memdb/storage.go
UTF-8
4,877
2.8125
3
[ "MIT" ]
permissive
[ "MIT" ]
permissive
// Copyright (c) 2018 ContentBox Authors. // Use of this source code is governed by a MIT-style // license that can be found in the LICENSE file. package memdb import ( "bytes" "context" "fmt" "sync" "time" storage "github.com/BOXFoundation/boxd/storage" ) type memorydb struct { sm sync.RWMutex wri...
true
e08fe3f98aaadaf664ac3aaf0668c72757f00c7a
Go
LCY2013/learing-go
/src/module1/ch17/share_mem/share_mem_test.go
UTF-8
834
3.015625
3
[]
no_license
[]
no_license
package share_mem import ( "sync" "testing" "time" ) //协程不安全 func TestShareMemory(t *testing.T) { counter := 0 for i := 0; i < 5000; i++ { go func() { counter++ }() } time.Sleep(time.Millisecond * 500) t.Log("counter = ", counter) } //协程安全 func TestShareMemorySafe(t *testing.T) { var mut sync.Mutex ...
true
0f45ed6152161b58348990dfce87e9d19e6f31c9
Go
liuqitoday/go-file-backup
/service/upload_service.go
UTF-8
919
2.515625
3
[]
no_license
[]
no_license
package service import ( "github.com/cheggaaa/pb/v3" "github.com/studio-b12/gowebdav" "go-file-buckup/config" "io/ioutil" "sync" ) func UploadAllFiles(allFilePaths *[]string) { if len(*allFilePaths) <= 0 { return } // init webdav client root := config.WebdavUrl user := config.WebdavUsername password := c...
true
026c19ec34af990eb65c418f7b5e4f9210c7c591
Go
bakku/minimalisp
/collection.go
UTF-8
4,302
3.25
3
[]
no_license
[]
no_license
package minimalisp // First returns the first element of a list. type First struct{} // Arity returns 1. func (f *First) Arity() int { return 1 } // Call implements the extraction of the first element. func (f *First) Call(line int, i *Interpreter, arguments []interface{}) (interface{}, error) { list, ok := argume...
true
1d98e08afa91a8d99db11a2720ded6cbf7753ff8
Go
jstrachan/jx-gitops
/pkg/kyamls/helpers.go
UTF-8
2,062
2.859375
3
[ "Apache-2.0" ]
permissive
[ "Apache-2.0" ]
permissive
package kyamls import ( "strings" "github.com/jenkins-x/jx-logging/pkg/log" "sigs.k8s.io/kustomize/kyaml/yaml" ) var quotes = []string{"'", "\""} // GetKind finds the Kind of the node at the given path func GetKind(node *yaml.RNode, path string) string { return GetStringField(node, path, "kind") } // GetAPIVer...
true
8cdc4fb07c1623aa62022eda1114c4888f93ef7d
Go
zhaoxin-BF/Ucloud_Work
/normal_gowork/12_22_study_goroutine/04_more_db_goroutine.go
UTF-8
2,909
2.9375
3
[]
no_license
[]
no_license
/* 1、根据地址的需要,无限制创建协程的个数 2、主协程打印汇总的数据 */ package main import ( "fmt" "sync" "gopkg.in/mgo.v2" ) type Person struct { Name string Age string } func main() { var wg sync.WaitGroup wg.Add(50) ch := make(chan Person, 1000000) //总文档数预测 ipt := make([]string, 50) ipt[0] = "172.18.183.132:27017" ipt[1] = "172...
true
dc32c78d36589e7a61c42fc6e0c2da29bb5a2d4e
Go
maximus-next/repo.nefrosovet.ru
/maximus-platform/profile/cmd/root.go
UTF-8
2,058
2.703125
3
[]
no_license
[]
no_license
package cmd import ( "fmt" "strings" log "github.com/sirupsen/logrus" "github.com/spf13/cobra" "github.com/spf13/viper" ) var ( CFGFile string next func() rootCmd = &cobra.Command{ Use: "profile", Short: "profile service", Long: `Just use it`, PreRun: func(cmd *cobra.Command, args []string) { ...
true
a9ea99b23e4e69a35002d37b61ad684c6665476c
Go
jjGonBas31/Go-awesome
/src/awesomeProject/32-panic-recover/panic-recover.go
UTF-8
349
3.015625
3
[]
no_license
[]
no_license
package main import "fmt" // panic se utiliza para detener errores en tiempo de ejecucion func imprimir() { fmt.Println("Hola Alex!") //panic("Error") // //cadena := recover() //} defer func() { someString := recover() fmt.Println(someString) } () panic("Error") } func main() { imprimir() ...
true
aab435f8ef069a45b1165c1da2f8ecec198895d9
Go
MrHide06/OddEvenPrime-go
/main.go
UTF-8
1,311
3.96875
4
[ "MIT" ]
permissive
[ "MIT" ]
permissive
package main import ( "fmt" ) func main() { array := [30]int{1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20} fmt.Printf("Bilangan awal : %+v, Jumlah = %d\n", array, len(array)) fmt.Println("-----------------------------------------------------------------------------------") fmt.Printf("B...
true
d6785b4e30760dae41dedb2075b35dcc8c18ea0e
Go
ramdunzo/schedular
/schedule.go
UTF-8
834
2.65625
3
[]
no_license
[]
no_license
package main import ( "database/sql" "encoding/json" "fmt" "net/http" "github.com/gorilla/mux" ) type scheduler struct { TaskID int `json:"taskId"` TimeStamp int64 `json:"timestamp"` Flag bool `json:"flag"` } var db *sql.DB func schedule(w http.ResponseWriter, r *http.Request) { var q scheduler...
true
b32a3e216c08cefd978a8a272881de75378f6383
Go
mcspring/codex
/managers/create_manager.go
UTF-8
3,320
2.8125
3
[ "MIT" ]
permissive
[ "MIT" ]
permissive
// Package managers provides AST managers for the codex package. package managers import ( "github.com/chuckpreslar/codex/nodes" "github.com/chuckpreslar/codex/sql" ) type CreateManager struct { Tree *nodes.CreateStatementNode adapter interface{} // The SQL adapter. } // AddColumn adds a UnexistingColumn from...
true
4d01b2af34dc8f314ed7527866e901d8e38ef6a1
Go
Covertness/ally
/pkg/coinbase/coinbase.go
UTF-8
609
2.84375
3
[]
no_license
[]
no_license
package coinbase import ( "fmt" "github.com/imroc/req" ) var ins *CoinBase // Init create the CoinBase connection func Init() *CoinBase { ins = New() return ins } // GetInstance get the CoinBase instance func GetInstance() *CoinBase { return ins } // New create a new instance func New() *CoinBase { return &...
true
b054b15148c7ac6948874d3911b0390fa547d316
Go
Esseh/Misc
/WebDev/WebDevProjectAttempt2/Step4/handleCookie.go
UTF-8
540
3.03125
3
[]
no_license
[]
no_license
/* This file is responsible for determining what to do with a cookie. */ package main import "net/http" //web server func handleCookie(res http.ResponseWriter,req *http.Request) User { cookie, err := req.Cookie("session-info") //Ensure that the cookie exists... if err != nil { cookie = makeDefaultCookie()...
true
ed2165baac3a52c77f828bcfbad51232d8f63978
Go
niltrix/gotutorial
/errGroup.go
UTF-8
955
3.390625
3
[]
no_license
[]
no_license
package main import ( "context" "errors" "fmt" "time" "golang.org/x/sync/errgroup" ) func counterWork5(ctx context.Context) error { timer := time.NewTimer(time.Second * 5) select { case <-timer.C: fmt.Println("5sec timer") return nil case <-ctx.Done(): fmt.Println("ctx.Done in 5sec timer") return ct...
true
df0c3aa3cd256de5ea06c3d0f47e47db924ac12a
Go
moyuanhui/go-dev
/day2/example2/main.go
UTF-8
176
2.859375
3
[]
no_license
[]
no_license
package main import ( "fmt" "os" ) func main() { goos := os.Getenv("GOOS") fmt.Println("The operating is:",goos) path := os.Getenv("PATH") fmt.Println("Path: ",path) }
true
2bd557686c430428b0faf2dfd8c02eff2da6004a
Go
geenasmith/Distributed-Go-Fish
/src/server/server.go
UTF-8
8,251
2.828125
3
[]
no_license
[]
no_license
package main import ( "encoding/json" "fmt" "io" "log" "net" "net/http" "net/rpc" "os" "sort" "sync" "time" ) import . "../helpers" import "../raft" type Player struct { ID int Hand []Card Pairs []Pairs Opponents []Player } type GameServer struct { Mu sync.Mutex Ready ...
true
1af549467e27f7defebacdf584d7d4cc1b6d47f5
Go
cloudfoundry/bbs
/models/routes.go
UTF-8
1,251
3.0625
3
[ "Apache-2.0", "LicenseRef-scancode-unknown-license-reference" ]
permissive
[ "Apache-2.0", "LicenseRef-scancode-unknown-license-reference" ]
permissive
package models import ( "bytes" "encoding/json" ) type Routes map[string]*json.RawMessage func (r *Routes) protoRoutes() *ProtoRoutes { pr := &ProtoRoutes{ Routes: map[string][]byte{}, } for k, v := range *r { pr.Routes[k] = *v } return pr } func (r *Routes) Marshal() ([]byte, error) { return r.protoR...
true
8b0b5419d275e3b725608444f0e42a0b97091011
Go
TropicalPenguinn/BlockChain
/Goblock/blockchain/main.go
UTF-8
3,734
2.734375
3
[]
no_license
[]
no_license
package main import ( "fmt" "bytes" "crypto/sha256" "strconv" "time" "math/big" "encoding/gob" "github.com/boltdb/bolt" "log" "math" ) const targetBits=24 func IntToHex(n int64) []byte{ return []byte(strconv.FormatInt(n,16)) } func (b *Block) Serialize() []byte { var result bytes.B...
true
226c7723b8b50ba1b8e66850d45e89b4e682e353
Go
xsh884826402/InvoiceVerification
/util.go
UTF-8
6,107
2.59375
3
[]
no_license
[]
no_license
package main import ( "bufio" "bytes" "encoding/base64" "encoding/json" "fmt" "io" "io/ioutil" "log" "math/rand" "mime/multipart" "net/http" "os" "os/exec" "strings" "time" ) func CreateRandomNumber() string { return fmt.Sprintf("%015v", rand.New(rand.NewSource(time.Now().UnixNano())).Int31n(1000000))...
true
f6fb72ec44d30f055fd91d14262e9f023abd3cc8
Go
sosedoff/dotfiles
/tools/scan_pano_photos.go
UTF-8
1,195
3.015625
3
[]
no_license
[]
no_license
package main import ( "fmt" "io/ioutil" "os" "os/exec" "path/filepath" "strconv" "strings" "github.com/gosexy/exif" ) func expandPath(path string) string { home := os.Getenv("HOME") return strings.Replace(path, "~", home, 1) } func scanImageFiles(path string) ([]string, error) { results := make([]string,...
true
08781dafbe0aa6a0891d0cfbeefe83fd8e230616
Go
AFloresc/atutorgobknd
/tapi/rbac/jwtmiddleware.go
UTF-8
755
2.53125
3
[]
no_license
[]
no_license
package rbac import ( jwtmiddleware "github.com/auth0/go-jwt-middleware" jwt "github.com/dgrijalva/jwt-go" "github.com/gorilla/mux" "github.com/urfave/negroni" ) type JWTMiddleware struct { jwtMW *jwtmiddleware.JWTMiddleware } func NewJWTMiddlware(authnValidationKey string) *JWTMiddleware { return &JWTMiddlewa...
true
4d14638c40056484af84d353e0fe9781561cbac3
Go
krlv/ctci-go
/ch02/05_sum_lists_test.go
UTF-8
3,129
3.375
3
[]
no_license
[]
no_license
package ch02 import "testing" func TestSumLists(t *testing.T) { n1 := New(7) n1.AppendToTail(1) n1.AppendToTail(6) n2 := New(5) n2.AppendToTail(9) n2.AppendToTail(2) expected := []int{2, 1, 9} actual := SumLists(n1, n2) for i := 0; actual != nil; i++ { if actual.data != expected[i] { t.Errorf("%dth n...
true
5675534e77779bdb7703bd4bf191f1c47ff0aec5
Go
zachmu/dolt
/go/libraries/doltcore/str_to_noms_test.go
UTF-8
2,370
2.6875
3
[ "Apache-2.0" ]
permissive
[ "Apache-2.0" ]
permissive
// Copyright 2019 Liquidata, 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...
true
2b989a2b13937b277e36153126ef693eacfca840
Go
tresnaadin/Into-the-Golang-Verse
/code/palindrome.go
UTF-8
1,214
3.84375
4
[]
no_license
[]
no_license
package code import ( "fmt" "strconv" "strings" ) // The parameter of "func utama" could be inputted on "start.go" func Utama(x string) int { inputNum := strings.Split(x, " ") // The string input value will be convert to Array arrayInput := make([]int, len(inputNum)) for i := range arrayInput { arrayInput[i]...
true
1802e8d1a8b49b4e33d6b580759d49a566fdddf7
Go
cia-rana/go-telnet-echo-client
/main.go
UTF-8
1,310
2.890625
3
[ "MIT" ]
permissive
[ "MIT" ]
permissive
package main import ( "flag" "fmt" oi "github.com/reiver/go-oi" telnet "github.com/reiver/go-telnet" termbox "github.com/nsf/termbox-go" ) func main() { host := flag.String("host", "localhost", "host") port := flag.String("port", "23", "port") flag.Parse() // Init termbox to use the getchar if err := ter...
true
39207932f4f6f9058d6ba5e058c35454e216bb93
Go
ihard/carbonapi
/expr/functions/timeShiftByMetric/function.go
UTF-8
7,070
2.609375
3
[ "BSD-2-Clause" ]
permissive
[ "BSD-2-Clause" ]
permissive
package timeShiftByMetric import ( "context" "math" "regexp" "strings" "github.com/ansel1/merry" "github.com/go-graphite/carbonapi/expr/helper" "github.com/go-graphite/carbonapi/expr/interfaces" "github.com/go-graphite/carbonapi/expr/types" "github.com/go-graphite/carbonapi/pkg/parser" ) type offsetByVersi...
true
9cc20fcdb10ff85735f2c54e18d73ed898627644
Go
nqd/cs-bc-w3
/artifacts/src/github.com/nqd/salmon_transfer/main.go
UTF-8
5,013
2.890625
3
[]
no_license
[]
no_license
package main import ( "encoding/json" "fmt" "log" "strconv" "time" "github.com/hyperledger/fabric/core/chaincode/shim" sc "github.com/hyperledger/fabric/protos/peer" ) // Define the Smart Contract structure type SmartContract struct { } type salmon struct { ObjectType string `json:"docType"` ID str...
true
a7d34735833339a261630c249f19ad9addf8eb6a
Go
ronniegane/hackerrank-solutions
/interviews/greedy/abs/abs.go
UTF-8
572
3.734375
4
[]
no_license
[]
no_license
package abs import ( "sort" ) func minAbsDiff(arr []int32) int32 { // Find the minimum absolute difference between any two numbers // in the array // First approach: sort, then compare consecutive pairs sort.Slice(arr, func(a, b int) bool { return arr[a] < arr[b] }) // Iterate comparing pairs min := arr[1...
true
90956b0ab00a5e1a3ba575850fa066baf5867da5
Go
belousandrey/new-episodes
/new_episodes.go
UTF-8
1,614
3.03125
3
[]
no_license
[]
no_license
package new_episodes import "io" const ( // DateFormat - default date format that used at most of podcasts DateFormat = "2006-01-02" ) // Episoder - interface for engines type Episoder interface { GetNewEpisodes(resp io.Reader) (episodes []Episode, last string, err error) } // Podcast - config file representatio...
true
4b045f558cdfd5a4047b3ff457af4d6c6b6b3100
Go
temporalio/ringpop-go
/hashring/rbtree_test.go
UTF-8
27,383
2.796875
3
[ "MIT" ]
permissive
[ "MIT" ]
permissive
// Copyright (c) 2015 Uber Technologies, Inc. // // Permission is hereby granted, free of charge, to any person obtaining a copy // of this software and associated documentation files (the "Software"), to deal // in the Software without restriction, including without limitation the rights // to use, copy, modify, merge...
true
51aebca8d2bbaf599d2108504adb40bc16a555c1
Go
shiki0083/beego
/go_dev/day3/example/example3/main/main.go
UTF-8
464
3.59375
4
[]
no_license
[]
no_license
package main import ( "fmt" ) func add(a int, arg ...int) int { var sum int = a for i := 0; i < len(arg); i++ { sum += arg[i] } return sum } func test(a, b int) int { result := func(a1 int, b1 int) int { return a1 + b1 }(a, b) return result } func main() { sum := add(10, 3, 3) fmt.Println(sum) var ...
true
ef212370ec8fe062ddcf8f807e6949c11785ff35
Go
psmorrow/knights-tour
/knights.go
UTF-8
5,176
3.5625
4
[ "MIT" ]
permissive
[ "MIT" ]
permissive
// A knight's tour is a sequence of moves of a knight on a chessboard such that the knight visits every square only once. // A brute-force search for a knight's tour is impractical on all but the smallest boards; for example, on an 8 × 8 board there are approximately 4×1051 possible move sequences, and it is well beyon...
true
af985c39d266e989728b3d0ebf90ef0bad8627e9
Go
nathanpaulyoung/dumb-wow-calc
/weights.go
UTF-8
3,072
3.28125
3
[ "MIT" ]
permissive
[ "MIT" ]
permissive
package main import ( "io/ioutil" "log" "gopkg.in/yaml.v2" ) type weight struct { FileName string Class string `yaml:"class"` Role string `yaml:"role"` TopEnd float32 `yaml:"top-end-dmg"` DPS float32 `yaml:"dps"` Strength float32 `yaml:"s...
true
33dfa8eb4d928591b50890b2c8677e438979d2fa
Go
image-server/image-server
/uploader/manta/manta.go
UTF-8
2,390
2.609375
3
[ "MIT" ]
permissive
[ "MIT" ]
permissive
package manta import ( "io" "log" "os" "path/filepath" "github.com/golang/glog" client "github.com/image-server/image-server/uploader/manta/client" ) type MantaClient interface { PutObject(destination string, contentType string, object io.Reader) error PutDirectory(path string) error } type Uploader struct ...
true
c6491175e25b79fa5fd7b1ffcdfd7c929f4ccf13
Go
shihyu/golang
/goWebActualCombat/chapter5/socket-rw-server1.go
UTF-8
988
3.21875
3
[ "MIT" ]
permissive
[ "MIT" ]
permissive
//++++++++++++++++++++++++++++++++++++++++ // 《Go Web编程实战派从入门到精通》源码 //++++++++++++++++++++++++++++++++++++++++ // Author:廖显东(ShirDon) // Blog:https://www.shirdon.com/ // 仓库地址:https://gitee.com/shirdonl/goWebActualCombat // 仓库地址:https://github.com/shirdonl/goWebActualCombat //++++++++++++++++++++++++++++++++++++++++ pa...
true
3360f1e640a891fee00b3239d32aa73710cdb94f
Go
jatinjindal/Riscygo
/tests/src/tester.go
UTF-8
371
2.796875
3
[]
no_license
[]
no_license
package main func main() type s struct{ a int; b[5][5] int; }; type t struct{ x[10] s; }; func f( a[5]* int, b[5][5]int) { b[1][2] = 10; } func main() { var a[10][10]int; var b[10][10]int; var c[5]*int; var y t; var i int; var fp *int; y.x[3].b[1][2] = 4; ...
true
837cad02987beefebc087a42104d76ca079b570a
Go
deverso/go-to-json
/main.go
UTF-8
791
3.15625
3
[]
no_license
[]
no_license
package main import ( "encoding/json" "log" "net/http" "text/template" ) var tmpl = template.Must(template.ParseGlob("form/*")) type Dog struct { Breed string WeightKg int } type Page struct { Json string Go string } func Index(w http.ResponseWriter, r *http.Request) { d := Dog{ Breed: "dalmation"...
true
c11150722f81f0e9573766f4d5ef51f4b7ecd941
Go
yuzameOne/staticwebsite
/main.go
UTF-8
694
2.734375
3
[]
no_license
[]
no_license
package main import ( "fmt" "net/http" "github.com/gorilla/mux" ) func HomeHandler(w http.ResponseWriter, r *http.Request) { http.ServeFile(w, r, "static/index.html") } func main() { fmt.Println("Server start ") r := mux.NewRouter() cssHandler := http.FileServer(http.Dir("./static/css/")) imagesHandler :=...
true
e758bc69a55af2492be3695edd4617fa1df7526e
Go
SezalAgrawal/GoProjects
/message-queue/rabbitmq/second_tutorial_work_queue/worker.go
UTF-8
2,684
3.21875
3
[]
no_license
[]
no_license
package main // It fakes a second of work for every dot in message body. // Pops message form queue and performs the task // If started multiple workers, they work in a round-robin dispatching way // Thus, if there is a lot of backlog of works, one could deploy extra worker nodes, // this will help in scaling. On aver...
true
0fbb60e0fac34944c20fbf0faade96915869e280
Go
hxfighting/over-blog
/back-end/Go/iris/helper/helper.go
UTF-8
4,029
2.8125
3
[ "MIT" ]
permissive
[ "MIT" ]
permissive
package helper import ( "blog/config" "errors" "github.com/kataras/iris/v12" "io" "io/ioutil" "log" "net/http" "os" "path/filepath" "regexp" "strconv" "strings" "time" ) const ( YMDHIS = "2006-01-02 15:04:05" YMD = "2006-01-02" ) func GetCurrentDirectory() string { dir, err := filepath.Abs(filepat...
true
c091873a62348cf49291476400c02b5958c1a104
Go
jfmorgenstern/fzb
/src/go/fzb.go
UTF-8
4,861
3.0625
3
[]
no_license
[]
no_license
package fzb import ( "encoding/xml" "errors" "fmt" "io/ioutil" // "os" "path/filepath" "strings" ) const ( MinimumInstances = 4 ) // the fritzing fzb format go utility type Fzb struct { XMLName xml.Name `xml:"module" json:"-" yaml:"-"` Title string `x...
true
e3f5c56a66e5b82c02452d6a651ad0c3ec6b12af
Go
rcholic/GoLang
/Workspace/src/github.com/rcholic/hello/varTest.go
UTF-8
257
3.15625
3
[]
no_license
[]
no_license
package main import "fmt" var c, python, java bool var i, j = 1, -10 func main() { k, m := 100, -20 fmt.Println(i, c, python, java) if !c { fmt.Println("c is false") } fmt.Printf("i = %d, j = %d\n", i, j) fmt.Printf("k = %d, m = %d\n", k, m) }
true
0063b023c0624362926596412c143bfe4e4db35e
Go
tychoish/grip
/send/interceptor_test.go
UTF-8
732
2.65625
3
[ "Apache-2.0" ]
permissive
[ "Apache-2.0" ]
permissive
package send import ( "testing" "github.com/tychoish/grip/level" "github.com/tychoish/grip/message" ) func TestInterceptor(t *testing.T) { base := MakeInternal() base.SetName("test") base.SetPriority(level.Debug) var count int filter := func(m message.Composer) { count++ } icept := MakeFilter(base, filter...
true
a36f9da5343ff2596fb201f755a8869ee1fc0047
Go
phuslu/go-callprivate
/examples.go
UTF-8
607
3.234375
3
[]
no_license
[]
no_license
package main import ( "fmt" "github.com/spance/go-callprivate/private" "net/http" "reflect" "runtime" ) type obj int func (o *obj) private() { fmt.Println("private func LOL.", runtime.GOOS, runtime.GOARCH) } func main() { // example 1: Call *obj.private() var o obj method := reflect.ValueOf(&o).MethodByNam...
true
2b4b129a3fcf74da3a5bc9e95e2259840717aed4
Go
naturalCloud/GoLearn
/concurrencyModels/quit.go
UTF-8
620
3.578125
4
[]
no_license
[]
no_license
package concurrencyModels import ( "fmt" "math/rand" "time" ) func boring(str string, quit chan string) (c chan string) { c = make(chan string) go func() { for i := 0; ; i++ { select { case c <- fmt.Sprintf("%s: %d", str, i): // do something case <-quit: // 退出前的清理动作 // clean up() quit <...
true
ff69df9ac4d048e2a9a2beb77ba11b9a3af31dfb
Go
tlsalstn/baekjoon
/step/stage6/go/main/nSum.go
UTF-8
273
3.625
4
[]
no_license
[]
no_license
package main import ( "bufio" "fmt" "os" ) func main() { w := bufio.NewWriter(os.Stdout) defer w.Flush() intArray := []int{1, 2, 3, 4, 5, 6} fmt.Fprint(w, sum(intArray)) } func sum(a []int) int { sum := 0 for _, num := range a { sum += num } return sum }
true
17196451a2786255ef53428e81ed6f6acecead3e
Go
sunhailiang/blockChain_Study
/src/demo/day5/function/main.go
UTF-8
352
3.765625
4
[]
no_license
[]
no_license
package main import( "fmt" ) type person struct{ gender string name string age int score float32 } //声明一个函数并只想person func (p *person) init(gender string,name string,age int,score float32){ p.gender=gender p.age=age p.name=name p.score=score fmt.Println(p) } func main(){ var stu person stu.init("man","ha...
true
87226bb9b7277616154872e3eb90a7789928bf6e
Go
tengge1/ShadowEditor
/utils/proto/main.go
UTF-8
628
2.734375
3
[ "MIT", "LicenseRef-scancode-free-unknown" ]
permissive
[ "MIT", "LicenseRef-scancode-free-unknown" ]
permissive
package main import ( "log" "example.com/proto/example" "github.com/golang/protobuf/proto" ) func main() { test := &example.Test{ Label: proto.String("hello"), Type: proto.Int32(17), Reps: []int64{1, 2, 3}, } data, err := proto.Marshal(test) if err != nil { log.Fatal("marshaling error: ", err) } ...
true
e5a74f2638dd56b73df71b9f8c508c265a0c9f8e
Go
John-Lin/ovs-cni
/ovs/backend/disk/backend.go
UTF-8
1,402
2.921875
3
[ "Apache-2.0" ]
permissive
[ "Apache-2.0" ]
permissive
package disk import ( "io/ioutil" "os" "path/filepath" "strings" ) const defaultDataDir = "/var/lib/cni/networks" // Store is a simple disk-backed store that creates one file per network namespace // container ID is a given filename. The contents of the file are the interface name for ovs. type Store struct { d...
true
cc50178528cef360acb9b7a89fe4958cbc783363
Go
nerd010/goexamples
/db3/db3.go
UTF-8
1,141
2.875
3
[ "MIT" ]
permissive
[ "MIT" ]
permissive
package main import ( "database/sql" t "tools" _ "github.com/mattn/go-sqlite3" ) func main() { dbFileT := `c:\test\test.db` if !t.FileExists(dbFileT) { t.Printfln("数据库文件%v不存在", dbFileT) return } // 打开已存在的库 dbT, errT := sql.Open("sqlite3", dbFileT) if errT != nil { t.Printfln("打开数据库时发生错误:%v", errT....
true
aecb1073a0edd11c536f084cbe4663b855120a16
Go
beatlabs/patron
/cache/redis/redis.go
UTF-8
1,736
3.046875
3
[ "Apache-2.0" ]
permissive
[ "Apache-2.0" ]
permissive
// Package redis contains the concrete implementation of a cache that supports TTL. package redis import ( "context" "errors" "time" "github.com/beatlabs/patron/cache" "github.com/beatlabs/patron/client/redis" ) var _ cache.TTLCache = &Cache{} // Cache encapsulates a Redis-based caching mechanism. type Cache s...
true
bd1b167ff4e2be6bc3f1287fb8df7ac5ae6d5bf5
Go
harman666666/StreetRep
/docs/algorithms/htn.go
UTF-8
151
2.6875
3
[]
no_license
[]
no_license
package main import "fmt" import "time" func main() { for i:=0;; i++ { time.Sleep(time.Second); fmt.Printf("User %d just joined!\n", i); } }
true
fb6884c58303fe9a4e8f8b0de6d1f8682b147ac6
Go
pallscall/way-jasy-cron
/common/util/time/time.go
UTF-8
182
2.609375
3
[]
no_license
[]
no_license
package time import "time" func Parse(t time.Time) time.Time { parse, _ := time.Parse("2006-01-02 15:04:05", time.Unix(t.Unix(), 0).Format("2006-01-02 15:04:05")) return parse }
true
a17d37b6c2ff88cfac02075c3d2e7a26a1d305e2
Go
poptip/ftc
/server.go
UTF-8
10,506
2.546875
3
[ "MIT" ]
permissive
[ "MIT" ]
permissive
// Copyright (c) 2014, Markover Inc. // Use of this source code is governed by the MIT // license that can be found in the LICENSE file. // Source code and contact info at http://github.com/poptip/ftc package ftc import ( "encoding/json" "expvar" "fmt" "io" "net/http" "strings" "time" "code.google.com/p/go.ne...
true
845c1a43c613d36789676188437c35bf7c761226
Go
dochui/blockSelf
/chaincode/paylog/paylog.go
UTF-8
3,859
2.71875
3
[]
no_license
[]
no_license
package main import ( "fmt" "github.com/hyperledger/fabric/core/chaincode/shim" "github.com/hyperledger/fabric/protos/peer" "encoding/json" "bytes" ) // Define the Smart Contract structure type SmartContract struct { } // Define the car structure, with 4 properties. Structure tags are used by encoding/json lib...
true
cae465fd206cec7a7bfab513b5fe6ce45d703b2c
Go
laonsx/gamelib
/graceful/graceful.go
UTF-8
2,806
2.796875
3
[]
no_license
[]
no_license
// +build !windows package graceful import ( "context" "errors" "flag" "log" "net" "net/http" "os" "os/exec" "os/signal" "syscall" "time" ) var ( server *http.Server listener net.Listener graceful bool ) func init() { flag.BoolVar(&graceful, "graceful", false, "graceful") } func reload(listener n...
true
0ac2e63430426fbb2b8905591684e5ed2c6661f0
Go
qsock/qf
/store/ka/consumer.go
UTF-8
4,907
2.578125
3
[ "MIT" ]
permissive
[ "MIT" ]
permissive
package ka import ( "context" "encoding/json" "errors" "fmt" "github.com/Shopify/sarama" "math/rand" "sync" ) type ConsumerConfig struct { // broker的集群地址 Brokers []string `toml:"brokers"` // topic 的名称 Topic string `toml:"topic"` // 消费组名称 Group string `toml:"group"` SASL struct { Enable bool `toml...
true
8d9ca4866fdf806f0e3073b6b0a3288e728bd061
Go
jasonrig/paypayopa-sdk-golang-example
/main.go
UTF-8
1,664
2.59375
3
[]
no_license
[]
no_license
package main import ( "github.com/google/uuid" "github.com/jasonrig/paypayopa-sdk-golang/api" "github.com/jasonrig/paypayopa-sdk-golang/api/v2/codes" "github.com/jasonrig/paypayopa-sdk-golang/request" "log" "net/http" ) func main() { // This will obtain credentials from your system environment // Be sure to s...
true
0d532bc8d0bc744864ffa1f2b952a66060047765
Go
superiqbal7/go-practice
/packages/utility/heheh.go
UTF-8
273
2.890625
3
[]
no_license
[]
no_license
package utility // Hello hi // a custom func to learn how to create package func Hello() string { return "hello from utility" } // Adder hi // a custom func to learn how to create package func Adder(args ...int) (sum int) { for i := range args { sum += i } return }
true
dba7a54303e0034cbe9a18538983575ed0d9560b
Go
WoodsChoi/algorithm
/al/al-92.go
UTF-8
1,305
3.71875
4
[]
no_license
[]
no_license
// 反转链表 II // medium /* * 反转从位置 m 到 n 的链表。请使用一趟扫描完成反转。 * * 说明: * 1 ≤ m ≤ n ≤ 链表长度。 * * 示例: * * 输入: 1->2->3->4->5->NULL, m = 2, n = 4 * 输出: 1->4->3->2->5->NULL * * 来源:力扣(LeetCode) * 链接:https://leetcode-cn.com/problems/reverse-linked-list-ii * 著作权归领扣网络所有。商业转载请联系官方授权,非商业转载请注明出处。 * * ---------------------------------------...
true
b878b8c0eb07bd89c08e773a2d2c3198b5300fb9
Go
luci/luci-go
/common/runtime/paniccatcher/catch.go
UTF-8
1,776
2.796875
3
[ "Apache-2.0" ]
permissive
[ "Apache-2.0" ]
permissive
// Copyright 2015 The LUCI 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...
true
03f57423c96bf471a3330f1ea16a6ceaf8a98fff
Go
maxshuang/diligent
/pkg/keygen/leveled_key_test.go
UTF-8
702
2.640625
3
[ "Apache-2.0" ]
permissive
[ "Apache-2.0" ]
permissive
package keygen import ( "github.com/stretchr/testify/assert" "testing" ) func TestLeveledStrKeys(t *testing.T) { k1 := NewLeveledKey([]string{"A"}, "_") assert.Equal(t, 1, k1.NumLevels()) assert.Equal(t, "A", k1.String()) assert.Equal(t, "A", k1.Prefix(0)) k2 := NewLeveledKey([]string{"A", "B"}, "_") assert....
true
3e5db6479093df48d88251568b89396febdc5874
Go
aeolusheath/FrontExersize
/data-structure-algorithm/golang/21. Merge Two Sorted Lists.go
UTF-8
700
3.84375
4
[]
no_license
[]
no_license
/** Merge two sorted linked lists and return it as a sorted list. The list should be made by splicing together the nodes of the first two lists. **/ /** * Definition for singly-linked list. * type ListNode struct { * Val int * Next *ListNode * } */ func mergeTwoLists(l1 *ListNode, l2 *ListNode) *ListNo...
true
8dc14175bd81d9d0613a49b3ba579edcc5c7ff6e
Go
linuxdeepin/warm-sched
/vendor/src/github.com/BurntSushi/xgbutil/_examples/compress-events/main.go
UTF-8
6,877
2.96875
3
[ "WTFPL" ]
permissive
[ "WTFPL" ]
permissive
/* Example compress-events shows how to manipulate the xevent package's event queue to compress events that arrive more often than you'd like to process them. This example in particular shows how to compress MotionNotify events, but the same approach could be used to compress ConfigureNotify events. Note that we show ...
true
88570e7c0b81433e4d73031c9f628dd1ca1f9de7
Go
emiddleton/zapi
/base.go
UTF-8
3,430
3.03125
3
[ "MIT" ]
permissive
[ "MIT" ]
permissive
package zapi import ( "bytes" "fmt" "io/ioutil" //"log" "encoding/json" "net/http" "net/url" //"strings" "time" ) type Client struct { Url string `json:"url"` Username string `json:"username"` Password string `json:"password"` Token string `json:"token"` httpClien...
true
76c35bfe00a04f2bcf095570b12c10eecf144007
Go
fossabot/go-nimona
/dht/provider_response.go
UTF-8
1,623
2.59375
3
[ "MIT" ]
permissive
[ "MIT" ]
permissive
package dht import ( "github.com/mitchellh/mapstructure" "nimona.io/go/peers" "nimona.io/go/primitives" ) type ProviderResponse struct { RequestID string `json:"requestID,omitempty"` Providers []*Provider `json:"providers,omitempty"` ClosestPeers []*peers.PeerInfo `json:"close...
true
ffa2bbd388e1735a1ba11e3a14751fb5d2745661
Go
campoy/links
/step2/links/repository/repository.go
UTF-8
515
3.015625
3
[ "Apache-2.0" ]
permissive
[ "Apache-2.0" ]
permissive
package repository import "errors" // A LinkRepository provides all the operations to create and store links. type LinkRepository interface { New(url string) (*Link, error) Get(id string) (*Link, error) CountVisit(id string) error } // A Link contains the information related to a shorten link. type Link struct { ...
true
958dc909ea9cf7cf3544118ab5054a4eebd36f63
Go
lancelot-ru/golang-microservice
/golang-microservice/http-server.go
UTF-8
1,982
2.875
3
[]
no_license
[]
no_license
// http-server package main import ( "bytes" "encoding/json" "log" "net/http" ) func answerSystemsHTTP(url string, m Message) Message { b, err := json.Marshal(m) checkError(err, "marshalling") log.Println(string(b)) req, err := http.NewRequest("POST", url, bytes.NewReader(b)) req.Header.Set(...
true
397f5f03157ad42a944f991cc2dbdf380c797faa
Go
stuart-warren/serveit
/router/router.go
UTF-8
2,794
3.265625
3
[ "Apache-2.0" ]
permissive
[ "Apache-2.0" ]
permissive
package router import ( "net/http" "regexp" "sync" "github.com/stuart-warren/serveit/access" ) type Route interface { Match(path string) bool Permit(permitted access.Permitted) Route Permitted() access.Permitted } type textRoute struct { path string permitted access.Permitted } func NewTextRoute(path...
true
c5de7cbd5a3efedd51b34635bf958a0b12a601cb
Go
gyliu513/liqo
/pkg/liqonet/ipam.go
UTF-8
17,959
2.65625
3
[ "LicenseRef-scancode-unknown-license-reference", "Apache-2.0" ]
permissive
[ "LicenseRef-scancode-unknown-license-reference", "Apache-2.0" ]
permissive
package liqonet import ( "fmt" "strings" "k8s.io/client-go/dynamic" "k8s.io/kubernetes/pkg/util/slice" goipam "github.com/metal-stack/go-ipam" "inet.af/netaddr" "k8s.io/klog" ) /* IPAM Interface */ type Ipam interface { GetSubnetPerCluster(network, clusterID string) (string, error) FreeSubnetPerCluster(clu...
true
729e4cdf9930c8a834580eac85827a170d8c3c27
Go
hieult1393/gobench
/master/monitor_test.go
UTF-8
568
3.21875
3
[ "MIT", "Apache-2.0" ]
permissive
[ "MIT", "Apache-2.0" ]
permissive
package master import ( "testing" "time" "github.com/stretchr/testify/assert" ) func TestMyUptime(t *testing.T) { // Make sure we print this stuff right. s := 22 * time.Second m := 4 * time.Minute h := 4 * time.Hour d := 32 * 24 * time.Hour y := 22 * 365 * 24 * time.Hour var flagtests = []struct { in ...
true
7a059b1db04f77b01b2ffe802d965dd559cac941
Go
nkostadinov/websocket
/server/client.go
UTF-8
2,657
3.0625
3
[ "MIT" ]
permissive
[ "MIT" ]
permissive
package server import ( "golang.org/x/net/websocket" "log" "encoding/json" "io" ) // Chat client. type Client struct { ws *websocket.Conn server *Server ch chan *Message events chan *Event done chan bool channels []string session string } // write channel buffer size const channelBufS...
true
8287921aaa9ab05b12472a578b074514c7e5c08c
Go
Anuja2508/CabBooking
/routing/cab.go
UTF-8
2,816
2.90625
3
[]
no_license
[]
no_license
package routing import ( "GoCab/controller" "GoCab/model" "errors" "fmt" "net/http" "github.com/labstack/echo" "github.com/labstack/gommon/log" ) // Cab router type Cab struct { cabController controller.Cab } // NewCabRouter will create new cab router func NewCabRouter( cabController controller.Cab, ) Cab...
true
b07dc95dac4bc74c6187de07d796b5dc70838624
Go
pxsalehi/reconciler
/pkg/reconciler/instances/ory/db/db_test.go
UTF-8
5,039
2.53125
3
[ "Apache-2.0" ]
permissive
[ "Apache-2.0" ]
permissive
package db import ( "testing" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" "gopkg.in/yaml.v3" "k8s.io/apimachinery/pkg/types" ) const ( postgresYaml = ` global: postgresql: postgresqlDatabase: db4hydra postgresqlUsername: hydra ...
true
7efd319a80ba32eb149e3433f7cfb3ea5b13f170
Go
paulocsilvajr/controle_pessoal_de_financas
/API/v1/model/tipo_conta/tipo_conta.go
UTF-8
8,495
3.140625
3
[ "MIT" ]
permissive
[ "MIT" ]
permissive
package tipo_conta import ( "fmt" "time" "github.com/paulocsilvajr/controle_pessoal_de_financas/API/v1/helper" "github.com/paulocsilvajr/controle_pessoal_de_financas/API/v1/model/erro" ) // ITipoConta é uma interface que exige a implementação dos métodos obrigatórios em TipoConta type ITipoConta interface { Str...
true
13d03494464b29c7d0cb30e4127e5b51bd24a164
Go
chentaihan/leetcode
/mapTag/maxNumberOfBalloons.go
UTF-8
1,109
3.3125
3
[]
no_license
[]
no_license
package mapTag /** 1189. “气球” 的最大数量 给你一个字符串 text,你需要使用 text 中的字母来拼凑尽可能多的单词 "balloon"(气球)。 字符串 text 中的每个字母最多只能被使用一次。请你返回最多可以拼凑出多少个单词 "balloon"。 示例 1: 输入:text = "nlaebolko" 输出:1 示例 2: 输入:text = "loonbalxballpoon" 输出:2 示例 3: 输入:text = "leetcode" 输出:0 提示: 1 <= text.length <= 10^4 text 全部由小写英文字母组成 来源:力扣(LeetCod...
true
c2403d387f78539d0aade7495371de0779f8b571
Go
x4AEKx/go-hw2
/listing/listing02/main.go
UTF-8
976
4.1875
4
[]
no_license
[]
no_license
package main import "fmt" // defer вызывается после return но до момента получения значения вызывающей стороной // При работе с defer - 3 правила // 1) Аргументы вычисляются в момент выполнения строки ex: defer Add(a,b) // 2) Defer'ы - выполняются по стеку // 3) Defer может читать/писать в именованный возврат func ...
true
ba5a632e67595f78278cf2c0a90c068d57e2b825
Go
Guitarbum722/meetup-client
/meetup.go
UTF-8
3,067
2.609375
3
[ "Apache-2.0" ]
permissive
[ "Apache-2.0" ]
permissive
package meetup import ( "bytes" "encoding/json" "net/http" "net/url" "time" "github.com/Guitarbum722/meetup-client/models" ) const baseURL = "https://api.meetup.com" // Clienter type Clienter interface { Members(int) (*models.Members, error) Member(int) (*models.Member, error) GroupByID([]int) (*models.Gro...
true
8f38375ba99aeb3dbd4a7f0bb27ff9cf8ce859f0
Go
LXG19961206/golang
/day09/day09.go
UTF-8
627
3.421875
3
[]
no_license
[]
no_license
// 今天没有精力学习新的内容,复习之前的东西 package main import ( "fmt" "math/rand" "time" ) func main() { fmt.Println("欢迎开始") test2() } func test() { var time = time.Now() rand.Seed(time.Unix()) var arr [21]int var slice = make([]int, 21, 21) for i := 0; i <= 20; i++ { arr[i] = rand.Intn(20) slice[i] = rand.Intn(30) } s...
true