Dataset Viewer
Auto-converted to Parquet Duplicate
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
423885cee8f3d270f70c6a67417e212431bf52d7
Go
aquasecurity/vuln-list-update
/utils/utils.go
UTF-8
5,328
2.671875
3
[ "Apache-2.0" ]
permissive
[ "Apache-2.0" ]
permissive
package utils import ( "bytes" "crypto/rand" "encoding/json" "fmt" "log" "math" "math/big" "os" "os/exec" "path/filepath" "strings" "time" "github.com/parnurzeal/gorequest" "golang.org/x/xerrors" pb "gopkg.in/cheggaaa/pb.v1" ) var vulnListDir = filepath.Join(CacheDir(), "vuln-list") func CacheDir() s...
true
225f9dfee07ad1105dd31f864cec95933bc5ec63
Go
psirenny/flynn
/util/release/amis.go
UTF-8
3,685
2.578125
3
[ "BSD-3-Clause" ]
permissive
[ "BSD-3-Clause" ]
permissive
package main import ( "encoding/json" "log" "os" "sort" "strings" "github.com/flynn/flynn/Godeps/_workspace/src/github.com/cupcake/goamz/aws" "github.com/flynn/flynn/Godeps/_workspace/src/github.com/cupcake/goamz/ec2" "github.com/flynn/flynn/Godeps/_workspace/src/github.com/flynn/go-docopt" ) func amis(args ...
true
7e21fc879c8bfdf843e30873a3cf336ae4f90311
Go
gkarager/cluster-logging-operator
/pkg/utils/quantity_test.go
UTF-8
953
2.921875
3
[ "Apache-2.0" ]
permissive
[ "Apache-2.0" ]
permissive
package utils import ( "testing" "k8s.io/apimachinery/pkg/api/resource" ) func TestParseQuantity(t *testing.T) { if _, err := ParseQuantity(""); err == nil { t.Errorf("expected empty string to return error") } table := []struct { input string expect resource.Quantity }{ {"750k", resource.MustParse("7...
true
f73acbbfc62cda70b78784dc11254b1317a35f49
Go
luoyong0603/LeetCode_golang
/leetCode/122. 买卖股票的最佳时机 II.go
UTF-8
402
3.609375
4
[]
no_license
[]
no_license
package main import "fmt" func main() { var l = []int{7, 1, 5, 3, 6, 4} fmt.Println(maxProfit2(l)) } //贪心算法 func maxProfit2(prices []int) int { // 设置当前收益为0 var max = 0 //假设从第二天开始买入, for i := 1; i <= len(prices); i++ { //当天价格高于前一天,就卖掉 if prices[i] > prices[i-1] { max += prices[i] - prices[i-1] } } r...
true
416272a76b30e7db95ccb354253c1a64543dd091
Go
tweekmonster/nvim-go
/src/nvim-go/nvimutil/complete.go
UTF-8
1,569
2.75
3
[ "BSD-3-Clause" ]
permissive
[ "BSD-3-Clause" ]
permissive
// Copyright 2016 The nvim-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 nvimutil import ( "io/ioutil" "os" "path/filepath" "strings" "nvim-go/pathutil" "github.com/neovim/go-client/nvim" ) // CompleteFiles pro...
true
b1e867cd022849792cf8a8f62575d16bfd0680f2
Go
yxho/redspider
/engine/concurrentEngine.go
UTF-8
1,428
3.09375
3
[]
no_license
[]
no_license
package engine import ( "fmt" "log" "redspider/fetcher" ) type Processor func(request Request) (ParseResult, error) type ConcurrentEngine struct { Scheduler Scheduler WorkCount int ItemChan chan Item RequestProcessor Processor } type Scheduler interface { Submit(Request) //configureWor...
true
d59c11e8f9a8e750f3296fcfd5b44f2fa9d37bf2
Go
RevanthTanneeru/lr-cli
/cmd/delete/account/account.go
UTF-8
1,742
2.859375
3
[ "MIT" ]
permissive
[ "MIT" ]
permissive
package account import ( "encoding/json" "errors" "fmt" "net/http" "github.com/MakeNowJust/heredoc" "github.com/loginradius/lr-cli/cmdutil" "github.com/loginradius/lr-cli/request" "github.com/spf13/cobra" ) var inpEmail string var inpUID string type creds struct { Key string `json:"Key"` Secret strin...
true
33e6656194e33d93ef76e301790e2b0dbd53703c
Go
fengpf/go-implement-your-object-storage
/src/lib/objectstream/put_test.go
UTF-8
483
3.03125
3
[ "MIT" ]
permissive
[ "MIT" ]
permissive
package objectstream import ( "io" "io/ioutil" "net/http" "net/http/httptest" "testing" ) func putHandler(w http.ResponseWriter, r *http.Request) { b, _ := ioutil.ReadAll(r.Body) if string(b) == "test" { return } w.WriteHeader(http.StatusForbidden) } func TestPut(t *testing.T) { s := httptest.NewServer(h...
true
5fac79d741698f5040c771c9083abe62771e3e52
Go
paper42/makeweb
/formats.go
UTF-8
691
2.984375
3
[ "MIT" ]
permissive
[ "MIT" ]
permissive
package makeweb import ( "fmt" "gopkg.in/russross/blackfriday.v2" ) func toHTML(page Page) (Page, error) { format, ok := page.Vars["format"].(string) if ok { if format == "markdown" || format == "md" { page.Content = md2html(page.Content) } else if format == "html" { page.Content = html2html(page.Conten...
true
ed5f682f526ef5dfe84171dea1e883d5aeba7b83
Go
nathankidd/aoc2017
/7b/sol.go
UTF-8
3,371
3.5625
4
[]
no_license
[]
no_license
package main import "fmt" import "os" import "bufio" import "strings" import "strconv" type Node struct { parent *Node children []*Node name string weight int // weight of this node itself totalweight int // weight of this node and all subnodes } func PopulateSubtreeWeight(node *Node) ...
true
5c2eb28c4cdc094f2ebf969026b0b6f669bd02a6
Go
LightningPeach/lnd
/channeldb/db_test.go
UTF-8
2,014
3.203125
3
[ "MIT" ]
permissive
[ "MIT" ]
permissive
package channeldb import ( "io/ioutil" "os" "path/filepath" "testing" ) func TestOpenWithCreate(t *testing.T) { t.Parallel() // First, create a temporary directory to be used for the duration of // this test. tempDirName, err := ioutil.TempDir("", "channeldb") if err != nil { t.Fatalf("unable to create te...
true
6289f4a6dd933b1c59617383fa9e8f377a50771d
Go
richardsenar/mycroft
/reIndexer.go
UTF-8
1,167
2.765625
3
[]
no_license
[]
no_license
package sherlock import "sync" /* o8o .o8 `"' "888 oooo ooo. .oo. .oooo888 .ooooo. oooo ooo `888 `888P"Y88b d88' `888 d88' `88b `88b..8P' 888 888 888 888 888 888ooo888 Y888' 888 888 888 888 888 888 .o .o8"'88b o888o o888o o888o `...
true
07c596aa86aca5109d35bec662f52e752e4d6e25
Go
litixsoft/lxgo
/db/mongo.go
UTF-8
25,836
2.578125
3
[ "MIT" ]
permissive
[ "MIT" ]
permissive
package lxDb import ( "context" "errors" "github.com/google/go-cmp/cmp" "go.mongodb.org/mongo-driver/bson" "go.mongodb.org/mongo-driver/bson/primitive" "go.mongodb.org/mongo-driver/mongo" "go.mongodb.org/mongo-driver/mongo/options" "go.mongodb.org/mongo-driver/mongo/readpref" "time" ) const ( DefaultTimeout...
true
27697ea40ea9c0cde85515d9dfdbd0252152a3a6
Go
iamjjanga-ouo/learn-go_restapi
/echo/5_route_parameters.go
UTF-8
1,225
3.328125
3
[]
no_license
[]
no_license
// Golang with Echo - route parameters // URI에 resource에 대한 접근을 parameter를 통해서 할 수 있다. // 그리고 이 parameter에 대한 roting역시 할 수 있어 마음껏 처리가 가능하다. package main import ( "fmt" "net/http" "os" "github.com/labstack/echo" ) func main() { port := os.Getenv("MY_APP_PORT") if port == "" { port = "8080" } e := echo.New(...
true
a75209df24d6c2a8f2a1b14fcb8c739a6612adaa
Go
lionkor/learn-go
/lion/variables_1.go
UTF-8
185
3
3
[]
no_license
[]
no_license
package main import "fmt" var c, python, java bool func printC() { c := true fmt.Println(c) } func main() { var i int printC() fmt.Println(i, c, python, java) }
true
15ee578898a137525c631de1fd074895d8056d44
Go
IamNator/Cousera0
/race_conditions/main.go
UTF-8
1,309
3.46875
3
[ "MIT" ]
permissive
[ "MIT" ]
permissive
package main import ( //"sync" "fmt" "sort" "bufio" "os" "strings" "strconv" "sync" ) //Please enter an array of integers seperated by , : //3,4,34,43,65,23,65,73,2,64,74, //[2 64 74] //[23 65 73] //[34 43 65] //[3 4] // //Sorted out Array : [2 3 4 23 34 43 64 65 65 73 74] func main(){ reader := bufio.Ne...
true
51d703d35a846cc04905697e5b6747b3e3cf955a
Go
jmhobbs/go-arnoldc
/cmd/arnoldc-compile/main_test.go
UTF-8
551
2.953125
3
[]
no_license
[]
no_license
package main import ( "testing" arnoldc "github.com/jmhobbs/go-arnoldc" ) func TestGoStringForValue(t *testing.T) { cases := []struct { value arnoldc.Value expect string }{ { arnoldc.NewVariableValue("aVariable"), "aVariable", }, { arnoldc.NewIntegerValue(5), "5", }, { arnoldc.NewS...
true
7203c0205f56549ed4b90ac20e2ca237a6093445
Go
ajunlonglive/gollum
/consumer/console.go
UTF-8
3,801
2.75
3
[ "Apache-2.0" ]
permissive
[ "Apache-2.0" ]
permissive
// Copyright 2015-2018 trivago N.V. // // 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
759046b166663b4b3e272d2efbe91de755787e85
Go
holyzhuo/go-util
/time/time.go
UTF-8
2,203
3.328125
3
[]
no_license
[]
no_license
package time import ( "fmt" "strconv" "strings" "time" ) //DateFormat(time.Now(), "YYYY-MM-DD HH:mm:ss") func DateFormat(t time.Time, format string) string { res := strings.Replace(format, "MM", t.Format("01"), -1) res = strings.Replace(res, "M", t.Format("1"), -1) res = strings.Replace(res, "DD", t.Format("02...
true
f9f3c103bc489f0396edd489e653b9ed27b58f9b
Go
zzuse/coderunner
/Golang/src/ch43/func_test/func_test.go
UTF-8
2,059
3.8125
4
[]
no_license
[]
no_license
package func_test import ( "errors" "fmt" "testing" ) type Printer func(contents string) (n int, err error) func printToStd(contents string) (bytesNum int, err error) { return fmt.Println(contents) } func TestFunc(t *testing.T) { var p Printer p = printToStd p("something") } type operate func(x, y int) int ...
true
c9706f1a672568090ba859b662f41dad5642e50d
Go
peterstace/simplefeatures
/geom/alg_point_on_surface.go
UTF-8
3,909
3.3125
3
[ "MIT" ]
permissive
[ "MIT" ]
permissive
package geom import ( "math" "sort" ) func newNearestPointAccumulator(target Point) nearestPointAccumulator { return nearestPointAccumulator{target: target} } // nearestPointAccumulator keeps track of the point within a group of // candidates that is nearest to a target point. type nearestPointAccumulator struct ...
true
f4f1a683c5e522b27f43ea10cc2b878a6653fb1d
Go
shankernaik/forexample
/excercises/ninja1/bool-test.go
UTF-8
159
2.96875
3
[]
no_license
[]
no_license
package main import ("fmt") var x bool func main(){ fmt.Println(x) x=true fmt.Println(x) a:=2 b:=3 fmt.Println(a==b) a=b fmt.Println(a==b, a != b) }
true
2e08d79b5bae6dd3da36bdcde1069024079106e2
Go
negrel/debuggo
/code_gen/log/main/utils.go
UTF-8
221
3.03125
3
[ "MIT" ]
permissive
[ "MIT" ]
permissive
package main import ( "path/filepath" ) func addSuffix(filename, suffix string) string { ext := filepath.Ext(filename) extLen := len(ext) nameLen := len(filename) return filename[:nameLen-extLen] + suffix + ext }
true
12cf44cfdab375c1fb33c15dd8efb314c99eff4a
Go
ilham-bintang/merlin
/api/pkg/transformer/feast/features_cache.go
UTF-8
1,915
2.859375
3
[ "Apache-2.0" ]
permissive
[ "Apache-2.0" ]
permissive
package feast import ( "encoding/json" "fmt" "strings" "time" feast "github.com/feast-dev/feast/sdk/go" ) type CacheKey struct { Entity feast.Row Project string } func fetchFeaturesFromCache(cache Cache, entities []feast.Row, project string) (FeaturesData, []feast.Row) { var entityNotInCache []feast.Row v...
true
0f31b332e257a9dcc8be0fde965a4fd41b723394
Go
adewoleadenigbagbe/Learning-go
/errors/learn-error.go
UTF-8
2,588
3.75
4
[ "MIT" ]
permissive
[ "MIT" ]
permissive
package main import ( "errors" "fmt" "os" ) func f1(arg int) (int, error) { if arg == 42 { return -1, errors.New("can't work with 42") } return arg + 3, nil } //using error.New() func sampError() { er := errors.New("error occured") fmt.Println(er) } //using fmt Errorf func formatError() { sampleErr := fm...
true
02e12636948a56b4d0fec4e65819d87e4fac88be
Go
kicool/kicool.go
/dump/dump.go
UTF-8
3,921
3.015625
3
[]
no_license
[]
no_license
package dump import ( "fmt" "io" "os" r "reflect" "strconv" ) var emptyString = "" // Prints to the writer the value with indentation. func Fdump(out io.Writer, v_ interface{}) { // forward decl var dump0 func(r.Value, int) var dump func(r.Value, int, *string, *string) done := make(map[string]bool) dump ...
true
b08422ea3561863f22921ca0762d1ff904325e58
Go
go-phorce/dolly
/cmd/dollypki/hsm/lskey.go
UTF-8
2,413
2.53125
3
[ "Apache-2.0" ]
permissive
[ "Apache-2.0" ]
permissive
package hsm import ( "fmt" "time" "github.com/go-phorce/dolly/cmd/dollypki/cli" "github.com/go-phorce/dolly/ctl" "github.com/go-phorce/dolly/xpki/cryptoprov" "github.com/pkg/errors" ) // LsKeyFlags specifies flags for the Keys action type LsKeyFlags struct { // Token specifies slot token Token *string // Se...
true
c8b7e517b0934571ae7fe3157c7451ba64284e58
Go
JakubGogola-IDENTT/mpa
/lab2/permutations/permutations.go
UTF-8
1,120
3.53125
4
[]
no_license
[]
no_license
package permutations // SetSize sets size of permutation func (p *Permutation) SetSize(size int) { p.Size = size } // Permute permutes permutation func (p *Permutation) Permute() { perm := make([]int, p.Size) for i := range perm { perm[i] = i } unpermuted := make([]int, p.Size) copy(unpermuted, perm) for ...
true
95ee124bb683512ec69b254c6a61f7fd8795b20d
Go
Azure/azure-container-networking
/npm/pkg/dataplane/iptables/iptable.go
UTF-8
1,948
3.078125
3
[ "LicenseRef-scancode-unknown-license-reference", "MIT" ]
permissive
[ "LicenseRef-scancode-unknown-license-reference", "MIT" ]
permissive
package NPMIPtable import ( "fmt" "strings" ) // Table struct type Table struct { Name string Chains map[string]*Chain } // Chain struct type Chain struct { Name string Data []byte Rules []*Rule } // Rule struct type Rule struct { Protocol string Target *Target Modules []*Module } // Module struct...
true
ac796e8e1499d0f29cb6766d2ec2adbe33ba0c72
Go
Cloud-repos/epinio
/helpers/kubernetes/interactive_options_reader_test.go
UTF-8
5,812
2.984375
3
[ "Apache-2.0", "LicenseRef-scancode-warranty-disclaimer" ]
permissive
[ "Apache-2.0", "LicenseRef-scancode-warranty-disclaimer" ]
permissive
package kubernetes_test import ( "bytes" "io/ioutil" . "github.com/onsi/ginkgo" . "github.com/onsi/gomega" . "github.com/epinio/epinio/helpers/kubernetes" ) var _ = Describe("InteractiveOptionsReader", func() { stdin := &bytes.Buffer{} stdout := &bytes.Buffer{} reader := NewInteractiveOptionsReader(stdout, ...
true
99ccc244ef2391d31e4ed0b799c5cdaa79d3d2da
Go
cttipton/iminshell.com
/main.go
UTF-8
3,354
2.59375
3
[]
no_license
[]
no_license
package main import ( "crypto/tls" "log" "net/http" //"io/ioutil" //"fmt" //"net/url" ) //set header for all handlers instead of configuring each one. Credit Adam Ng https://www.socketloop.com/tutorials/golang-set-or-add-headers-for-many-or-different-handlers func SetHeaders(w http.ResponseWriter) { w.Header(...
true
8444e87625c8fdfbe5fe63ade2ac0c5d98f05ed8
Go
typeck/golib
/aws/s3.go
UTF-8
1,044
2.671875
3
[]
no_license
[]
no_license
package aws import ( "github.com/aws/aws-sdk-go/aws" "github.com/aws/aws-sdk-go/aws/session" "github.com/aws/aws-sdk-go/service/s3/s3manager" ) //s3manager.UploadInput{ // Bucket: aws.String(bucket), // Key: aws.String(filePath), // Body: bytes.NewReader(file), // } //size: buffer size func UploadS3(regi...
true
d9573fed80f8dd14e3257edfccee82a8a239ee56
Go
zeek0x/real-world-http
/src/06.02.04/client/main.go
UTF-8
1,192
2.734375
3
[]
no_license
[]
no_license
package main import ( "crypto/tls" "log" "net/http" "net/http/httputil" ) func main() { cert, err := tls.LoadX509KeyPair("ssl/client.crt", "ssl/client.key") if err != nil { panic(err) } client := &http.Client{ Transport: &http.Transport{ TLSClientConfig: &tls.Config{ Certificates: []tls.Certificat...
true
d48607c471fd161bfa2a82645707e3709cc08977
Go
searKing/golang
/go/database/sql/placeholder.go
UTF-8
4,394
2.90625
3
[ "MIT" ]
permissive
[ "MIT" ]
permissive
// Copyright 2020 The searKing Author. All rights reserved. // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. package sql import ( "fmt" "strings" strings_ "github.com/searKing/golang/go/strings" ) // Placeholders behaves like strings.Join([]string{"?",...,"?...
true
0eff2c4c2dbeb227db0b3207d94b636b8a6bf3bb
Go
RyanBrushett/battlesnake2020
/pkg/structs/coordinate.go
UTF-8
317
3.796875
4
[]
no_license
[]
no_license
package structs // Coordinate refers to a square on a board type Coordinate struct { X int `json:"x"` Y int `json:"y"` } // Add the values of Coordinate other to Coordinate c func (c Coordinate) Add(other Coordinate) Coordinate { result := Coordinate{ X: c.X + other.X, Y: c.Y + other.Y, } return result }
true
6d5a80c94ecca0887847f8c32598bad14ac1af60
Go
atvoid/blackA
/user/user.go
UTF-8
2,570
2.921875
3
[]
no_license
[]
no_license
package user import ( "blackA/logging" "bufio" "encoding/json" "fmt" "net" ) var area string = "User" type User struct { Id int Name string conn *net.Conn stopSigConn chan bool stopSigMsg chan bool userInput chan Command UserInput chan Command ServerInput chan Command...
true
9d8dd599691e4cb311cd9c6ff650e1b8639f2e7e
Go
yiippee/esim
/tool/new/domain_fc.go
UTF-8
1,677
2.921875
3
[ "MIT" ]
permissive
[ "MIT" ]
permissive
package new var ( domainfc1 = &FileContent{ FileName: "user.go", Dir: "internal/domain/user/entity", Content: `package entity type User struct { // ID ID int {{.SingleMark}}gorm:"column:id;primary_key"{{.SingleMark}} // username UserName string {{.SingleMark}}gorm:"column:user_name"{{.SingleMark}} ...
true
b32c83625b3daeda79c74c6827f5e1777d6f56d7
Go
seaon/sept
/backend/utils/app/response.go
UTF-8
1,215
2.953125
3
[ "MIT" ]
permissive
[ "MIT" ]
permissive
package response import ( "github.com/gin-gonic/gin" "net/http" ) type Response struct { Code int `json:"code"` Msg string `json:"msg"` Data interface{} `json:"data"` } const ( SUCCESS = 0 ERROR = 10 AuthFailed = 20 AuthExpired = 21 InvalidArgument = 100 ) var empt...
true
e7f173725d1b125514debdfb7e481305b10cd36f
Go
mjsir911/szip
/reader.go
UTF-8
3,679
2.8125
3
[]
no_license
[]
no_license
package szip import ( "io" "archive/zip" "encoding/binary" "compress/flate" "errors" "fmt" ) type Reader struct { r io.Reader cur io.ReadCloser // Central directory fields, unused mid-extraction n int centralDirectory bool } func NewReader(ri io.Reader) (ro Reader) { ro.r = ri ro.n = 0...
true
9d871ec2283929c53d403ff16af6db92e01a3402
Go
stormforger/cli
/api/meta.go
UTF-8
3,594
2.59375
3
[ "Apache-2.0" ]
permissive
[ "Apache-2.0" ]
permissive
package api import ( "encoding/json" "fmt" "io" "log" "github.com/stormforger/cli/internal/esbundle" ) // Meta holds meta data of a JSONApi response. Currently // only "links" are extracted. type Meta struct { Links *Links `json:"links"` } // Links holds JSONAPI links type Links struct { Self string `jso...
true
0c2a90f0c0f5bfb672ca965481d75e0500edd8ee
Go
gospodinzerkalo/todo_app_golang
/endpoint/task/postgre.go
UTF-8
1,479
2.9375
3
[]
no_license
[]
no_license
package task import ( "github.com/go-pg/pg" "github.com/go-pg/pg/orm" ) //Config struct type PostgreConfig struct { User string Password string Port string Host string Database string } //Connection to postgre (for task) func NewPostgre(config PostgreConfig) (TaskTodo,error) { db := pg.Connect(&pg...
true
e6ed294ac235f1b7d07ce2fdf04cfe6ca7c3e077
Go
mathom/piepan
/plugins/lua/plugin.go
UTF-8
2,059
2.515625
3
[ "MIT", "LicenseRef-scancode-unknown-license-reference" ]
permissive
[ "MIT", "LicenseRef-scancode-unknown-license-reference" ]
permissive
package plugin import ( "fmt" "os" "strings" "sync" "github.com/aarzilli/golua/lua" "github.com/mathom/piepan" "github.com/stevedonovan/luar" ) func init() { piepan.Register("lua", &piepan.Plugin{ Name: "Lua (C)", New: func(in *piepan.Instance) piepan.Environment { s := luar.Init() p := &Plugin{ ...
true
9abde4aa7761eeff8d66863e241b66af1b9dc85c
Go
nrkfeller/learn_go
/golangbasics/17maps/loopmap/loopmap.go
UTF-8
185
3.421875
3
[]
no_license
[]
no_license
package main import "fmt" func main() { ele := map[string]string{ "O": "oxygen", "N": "nitrogen", "C": "carbon", } for k, v := range ele { fmt.Println(k, "is for", v) } }
true
2940775a2106b50377078aaa1f1c71d2bc5720d6
Go
ivyhaswell/learn_golang
/methods/exercise-images.go
UTF-8
909
3.84375
4
[]
no_license
[]
no_license
/* 练习:图像 还记得之前编写的图片生成器 吗?我们再来编写另外一个,不过这次它将会返回一个 image.Image 的实现而非一个数据切片。 定义你自己的 Image 类型,实现必要的方法并调用 pic.ShowImage。 Bounds 应当返回一个 image.Rectangle ,例如 image.Rect(0, 0, w, h)。 ColorModel 应当返回 color.RGBAModel。 At 应当返回一个颜色。上一个图片生成器的值 v 对应于此次的 color.RGBA{v, v, 255, 255}。 */ package main import ( "golang.org/x/tour/pic...
true
bb5cda0dc519c66967789cd5fa0b7ab1fa600f4d
Go
GuilhermeVendramini/golang-web
/02-server/04-dial-read/main.go
UTF-8
325
2.71875
3
[]
no_license
[]
no_license
/* Edit your "/etc/hots" and add: 127.0.1.1 go */ package main import ( "fmt" "io/ioutil" "log" "net" ) func main() { conn, err := net.Dial("tcp", "go:80") if err != nil { panic(err) } defer conn.Close() bs, err := ioutil.ReadAll(conn) if err != nil { log.Println(err) } fmt.Println(string(bs...
true
375390031b3d6a481d78e4619ccc871680f890c7
Go
hjnnewton/POI
/src/api/gerSurround.go
UTF-8
1,433
2.890625
3
[]
no_license
[]
no_license
package location import ( "go-simplejson" //"github.com/bitly/go-simplejson" "encoding/json" ) // According to the latitude and longitude, return the surrounding places information func GetSurrounding(latitude string, longitude string, ak string)[]interface {}{ body:=GeoCoder(latitude, longitude, ak) js, err := ...
true
b0291852e4a8427aa32650f613be4dbcae243668
Go
Foxcapades/Argonaut
/v0/internal/render/flag-group.go
UTF-8
2,146
2.78125
3
[ "MIT" ]
permissive
[ "MIT" ]
permissive
package render import ( A "github.com/Foxcapades/Argonaut/v0/pkg/argo" "strings" ) const ( fgDefaultName = "Flag Group" fgShortPrefix = '-' fgLongPrefix = "--" fgShortAssign = sngSpace fgLongAssign = '=' fgDivider = " | " fgEmptyDiv = " " fgPadding = " " ) func flagGroup(fg A.FlagGroup, out...
true
5984e199a85eb0d9a44cde077e323dbb2264b9a8
Go
shreyanshchordia/Binary-Trees
/Go/binary_tree_traversals.go
UTF-8
1,723
4.34375
4
[ "MIT" ]
permissive
[ "MIT" ]
permissive
package main import ( "fmt" ) /* * Problem :: Print the binary tree using following traversal * 1) InOrder * 2) PreOrder * 3) PostOrder */ /** * Definition for a binary tree node. */ type TreeNode struct { Val int Left *TreeNode Right *TreeNode } /** * functions to ...
true
12bb7e09add8ffed64a311b6cbd75e0e0ebb86a7
Go
lutepluto/leetcode
/problem70/climb_stairs.go
UTF-8
223
2.734375
3
[ "MIT" ]
permissive
[ "MIT" ]
permissive
package problem70 func climbStairs(n int) int { if n <= 2 { return n } ways := make([]int, n+1) ways[0] = 0 ways[1] = 1 ways[2] = 2 for i := 3; i <= n; i++ { ways[i] = ways[i-1] + ways[i-2] } return ways[n] }
true
2d05e612fa5c1b9a5c8d9109b399d4b220a62013
Go
mdigger/passbook
/beacon.go
UTF-8
843
2.734375
3
[ "MIT" ]
permissive
[ "MIT" ]
permissive
package passbook import ( "encoding/json" "errors" ) // Beacon Dictionary: Information about a location beacon. Available in iOS 7.0. type Beacon struct { ProximityUUID string `json:"proximityUUID"` // Unique identifier of a Bluetooth Low Energy location beacon. Major uint16 `json:"major,omitempt...
true
14dad71e9f0e6815de3e0fde2f2746f1ebe8f63c
Go
whefter/rotating-rsync-backup
/constants.go
UTF-8
820
2.640625
3
[ "MIT" ]
permissive
[ "MIT" ]
permissive
package main import "regexp" // DailyFolderName is a helper constant holding the name of the daily backup grouping folder const DailyFolderName string = "_daily" // WeeklyFolderName is a helper constant holding the name of the weekly backup grouping folder const WeeklyFolderName string = "_weekly" // MonthlyFolderN...
true
fd2c71f3d622eb1d2337d7cd789a29c401546f9d
Go
facuellarg/design_patterns
/singleton/singleton/manager.go
UTF-8
414
3.53125
4
[]
no_license
[]
no_license
package singleton import "sync" type manager struct { value int } var managerSingleton *manager var mutext sync.Mutex func GetManager() *manager { mutext.Lock() defer mutext.Unlock() if managerSingleton == nil { managerSingleton = &manager{} } return managerSingleton } func (m *manager) Add() { mutext.Loc...
true
a503865375833c66b94057cf96b063ebd4910107
Go
svetlana-rezvaya/go-dice-cli
/parse_dice_notation.go
UTF-8
699
3.265625
3
[ "MIT" ]
permissive
[ "MIT" ]
permissive
package dice import ( "errors" "fmt" "strconv" "strings" ) // ParseDiceNotation ... // Example of input data: "2d20", "d20" (it means "1d20"). func ParseDiceNotation(text string) (throwCount int, faceCount int, err error) { parts := strings.Split(text, "d") if len(parts) != 2 { return 0, 0, errors.New("invali...
true
fad65a74fd7834a95c403826d0b26ede7242b20f
Go
zeppel13/pygoas
/code.go
UTF-8
19,545
3.375
3
[]
no_license
[]
no_license
/* code.go * This file is part of pygoas * * This is probably going to be a simple Mini-Python to NASM-assembly compiler * written by Sebastian Kind 2nd Janury -- 20th May 2016 */ package main import ( "fmt" "strconv" ) // programCode is the essential struct (comparable to a class in // python) which contains...
true
b1461f643a29242521c8552a1a401a088668a160
Go
extensible-cms/ecms-go-inputfilter
/TestFixtures.go
UTF-8
1,860
2.578125
3
[ "MIT" ]
permissive
[ "MIT" ]
permissive
package ecms_go_inputfilter import ( ecms_validator "github.com/extensible-cms/ecms-go-validator" "regexp" ) var ( ContactFormInputFilter InputFilter NameInput *Input EmailInput *Input SubjInput *Input MessageInput *Input ) func init() { nameValidatorOps := ecms_validator.NewRegexValidatorOptions() nameVali...
true
4b5f3d57019c66b7d9f31782b5ac477941dbf643
Go
sgnl19/icinga-checks-library
/ssh-session_test.go
UTF-8
531
2.6875
3
[ "MIT" ]
permissive
[ "MIT" ]
permissive
package icinga import "testing" func TestNewSshSessionError(t *testing.T) { tests := []struct { host string port int ssh_user string msg string }{ {"", 22, "ssh-user", "missing host"}, {"host", 0, "ssh-user", "missing port"}, {"host", 22, "", "missing ssh user"}, {"host", 22, "ssh-user", "missing s...
true
6f4bcdd28ebc31e4d20cd9ae98838c791d3c0fd9
Go
wllenyj/wtime
/example/sample.go
UTF-8
1,084
2.765625
3
[]
no_license
[]
no_license
package main import ( "fmt" "github.com/wllenyj/wtime" "math" "math/rand" "os" "os/signal" "syscall" "time" ) func main() { rand.Seed(time.Now().UnixNano()) w := wtime.NewWheel(500 * time.Millisecond) f := func(d int) { dura := time.Duration(d) * 500 * time.Millisecond //fmt.Printf("start dura: %s\n",...
true
cc518b45d18488a951404a6a48286b95443fc022
Go
Kashiwara0205/monkey
/ast/ast.go
UTF-8
8,980
3.546875
4
[]
no_license
[]
no_license
package ast import ( "../token" "bytes" "strings" ) // 全intercace型のトップ // ここに書かれたメソッドは継承しているインターフェースで必ず実現しなければいけない type Node interface{ TokenLiteral() string String() string } // Statementノードには、どんなStatementでも入る(LetとかReturnとか) type Statement interface{ Node statementNode() } // 特徴:hoge = 5の5を保持する // 値の保持に何かと...
true
21ca4285d0548fd14e87cba5ade7ff7ce9e58637
Go
bketelsen/learnonline
/actions/course.go
UTF-8
2,395
2.578125
3
[]
no_license
[]
no_license
package actions import ( "errors" "fmt" "github.com/bketelsen/learnonline/models" "github.com/gobuffalo/buffalo" "github.com/markbates/pop" ) // CoursesIndex default implementation. func CoursesIndex(c buffalo.Context) error { // courses automatically loaded in the // middleware c.Set("title", "Available Cla...
true
58bc5082048a12de5b83a1721fba3b404aabd617
Go
ivanmeca/timedQueue
/config/sample_config.go
UTF-8
715
2.828125
3
[]
no_license
[]
no_license
package config import ( "encoding/json" "os" ) func configSample() *ConfigData { var config ConfigData config.DataBase.DbName = "time-queue" config.DataBase.ServerHost = "timeQueue.DB.ivanmeca.com.br" config.DataBase.ServerPort = "9003" config.DataBase.ServerUser = "" config.DataBase.ServerPassword = "" ret...
true
f783382acd4e017311437f4e118cd2abcf4b258f
Go
ksambaiah/Programming
/go/modules/http/httpExample1.go
UTF-8
347
3.109375
3
[]
no_license
[]
no_license
package main import ( "fmt" "net/http" ) const portNumber = ":8080" func HomePageHandler(w http.ResponseWriter, r *http.Request) { w.Write([]byte("We're live !!!")) } func main() { http.HandleFunc("/", HomePageHandler) fmt.Printf("Starting application on port %v\n", portNumber) http.ListenA...
true
e669c35f9e72b70116da65258f79ec3190a63e20
Go
dingkegithub/golanguage
/funcinter/deferfunc/main.go
UTF-8
210
3.171875
3
[]
no_license
[]
no_license
package main import "fmt" func main() { for i := 0; i < 3; i++ { defer func() { fmt.Println("error: ", i) }() } for i := 0; i < 3; i++ { defer func(v int) { fmt.Println("ok: ", v) }(i) } }
true
End of preview. Expand in Data Studio
README.md exists but content is empty.
Downloads last month
9