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 |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
102828c449327d82cfe27d04ec2883e7960a8d69 | Go | godoctor/godoctor | /analysis/names/testdata/src/foo/vendor/bar/bar.go | UTF-8 | 272 | 2.96875 | 3 | [
"BSD-3-Clause"
] | permissive | [
"BSD-3-Clause"
] | permissive | package bar
func Exported() string { return "bar" }
type I interface {
Method() int
}
type t int
func (t) Method() float64 { return 1.234 }
func callInterface(i I) {
i.Method()
}
type i struct {
Method func() float64 // Not actually a method -- this is a field!
}
| true |
6805f40ec61be585ca32ed8a1cc8471cc64c8c6b | Go | shelleyvip/golang | /new巩固/31_io.copy.go | UTF-8 | 371 | 2.78125 | 3 | [] | no_license | [] | no_license | package main
import (
"github.com/labstack/gommon/log"
"os"
)
func v1() {
var f *os.File
var err error
if len(os.Args) >1{
f,err = os.Open(os.Args[1])
if err != nil{
log.Fatal(err)
}
}else {
f = os.Stdin
}
buf := make([]byte,1024)
for{
n,err := f.Read(buf)
if err != nil{
return
}
os.... | true |
96f676069850a4f0070c74a9c008e03fbc067c59 | Go | chenqinghe/nacos-go-sdk | /discovery/lb/random.go | UTF-8 | 428 | 2.90625 | 3 | [] | no_license | [] | no_license | package lb
import (
"math/rand"
"reflect"
"time"
)
type Random struct {
r *rand.Rand
}
func NewRandom(seed ...int64) *Random {
if len(seed) == 0 {
return &Random{r: rand.New(rand.NewSource(time.Now().UnixNano()))}
}
return &Random{r: rand.New(rand.NewSource(seed[0]))}
}
func (r *Random) Select(instances in... | true |
9837bf4832adbc85ab549615b77b8b6ed35d29aa | Go | Rallstad/Heis | /go/src/network/network.go | UTF-8 | 1,967 | 3.03125 | 3 | [] | no_license | [] | no_license | package network
import (
"net"
"os"
"strings"
"fmt"
)
func ClientConnectUDP(port string)*net.UDPConn{
adress,err :=net.ResolveUDPAddr("udp","129.241.187.255"+port)
if (err != nil){
fmt.Println(adress,err)
}
connection,err := net.DialUDP("udp",nil,adress)
if err == nil{
fmt.Println("Connection achie... | true |
5e7e6efb6be7807d0d547130124d514be58aa64f | Go | bhupathi-skyflow/skyflow-go | /errors/error_codes.go | UTF-8 | 352 | 2.8125 | 3 | [
"MIT"
] | permissive | [
"MIT"
] | permissive | package errors
// ErrorCodesEnum - Enum defines the list of error codes/categorization of errors in Skyflow.
type ErrorCodesEnum string
// Defining the values of Error code Enum
const (
// Server - Represents server side error
Server ErrorCodesEnum = "Server"
// InvalidInput - Input passed was not invalid format
... | true |
5e810c415bde65a46e172415207e76de820db172 | Go | bingzhao0719/diary | /config/Config.go | UTF-8 | 1,150 | 3.015625 | 3 | [] | no_license | [] | no_license | package config
import (
"bufio"
"encoding/json"
"fmt"
"os"
)
type Config struct {
AppName string `json:"app_name"`
AppMode string `json:"app_mode"`
AppHost string `json:"app_host"`
AppPort string `json:"app_port"`
Database DatabaseConfig `database`
}
type DatabaseConfig struct {
Driver string `jso... | true |
fdbea888cc4a1ccfdde3ea70f2c7a1cc0a69d202 | Go | relloyd/halfpipe | /transform/consumer.go | UTF-8 | 770 | 2.8125 | 3 | [
"MIT"
] | permissive | [
"MIT"
] | permissive | package transform
import (
"sync"
"github.com/relloyd/halfpipe/stream"
)
// Consumers of components' channels.
type consumers struct {
sync.RWMutex
internal map[string]consumer
}
type consumer map[string]*consumerData // use ptr to consumerData since we can't do assignments like: m["key"].structVar = 1
type co... | true |
236597fc36b9869170078cc0582238b80f7f0357 | Go | nju04zq/algorithm_code | /medium/152_Maximum_Product_Subarray/max.go | UTF-8 | 1,451 | 3.265625 | 3 | [] | no_license | [] | no_license | package main
import "fmt"
import (
"math/rand"
"time"
)
func max(a, b int) int {
if a > b {
return a
} else {
return b
}
}
func min(a, b int) int {
if a < b {
return a
} else {
return b
}
}
func maxProduct(nums []int) int {
if len(nums) == 0 {
return 0
}
maxSub, maxProduct, minProduct := nums[... | true |
a01cf21ce3af0f3a98837d8d9cd54ab6af11d024 | Go | elvin-du/algorithm-lab | /code-interviews/quick-sort.go | UTF-8 | 516 | 3.28125 | 3 | [] | no_license | [] | no_license | package code_interviews
func QuickSort(data []int) {
quickSort(data, 0, len(data)-1)
}
func quickSort(data []int, l, h int) {
if h <= l {
return
}
p := data[l]
left, right := l, h
for ; l < h; {
for ; l < h; {
if data[h] < p {
data[h], data[l] = data[l], data[h]
l++
break
} else {
h--... | true |
847100ebc0603ff370797a4083ea89d7da9a762a | Go | leolinf/golang-demo | /crawler/zhenai/parser/citylist.go | UTF-8 | 576 | 2.796875 | 3 | [] | no_license | [] | no_license | package parser
import (
"golang-demo/crawler/engine"
"regexp"
)
const cityListRe = `<a href="(http://www.zhenai.com/zhenghun/[a-z0-9]+)"[^>]*>([^<]+)</a>`
func ParseCityList(contents []byte) engine.ParserResult {
re := regexp.MustCompile(cityListRe)
matchs := re.FindAllSubmatch(contents, -1)
result := engine.... | true |
ba0b865f7ebaee243cf7626ada2c391db486dd82 | Go | Reg1nleifr/go-tour | /09 routines and channels/rac.go | UTF-8 | 1,488 | 4.125 | 4 | [
"MIT"
] | permissive | [
"MIT"
] | permissive | package main
import (
"fmt"
"time"
)
func say(msg string) {
for i := 0; i < 2; i++ {
time.Sleep(100 * time.Millisecond)
fmt.Println(msg)
}
}
func sum(toSum []int, c chan int) {
sum := 0
for _, i := range toSum {
sum += i
}
c <- sum // send sum to c
}
func fibonacci(n int, c chan int) {
x, y := 0, 1
... | true |
e352da14477e2a360a753914de41a080711930c8 | Go | Bexultan2323/finalproject | /cmd/web/handlers.go | UTF-8 | 2,041 | 2.671875 | 3 | [] | no_license | [] | no_license | package main
import (
"aitu.com/snippetbox/pkg/forms"
"aitu.com/snippetbox/pkg/models"
"errors"
"fmt"
"net/http"
"strconv"
)
func (app *application) home(w http.ResponseWriter, r *http.Request) {
if r.URL.Path != "/" {
app.notFound(w)
return
}
snippet, err := app.snippets.Latest()
if err != nil {
app.... | true |
a45b2cbe6b382f3d4de20990930b9efe39f461e9 | Go | akellbl4/remark42 | /backend/app/notify/slack_test.go | UTF-8 | 4,224 | 2.578125 | 3 | [
"MIT"
] | permissive | [
"MIT"
] | permissive | package notify
import (
"context"
"log"
"net/http"
"net/http/httptest"
"testing"
"github.com/go-chi/chi/v5"
"github.com/slack-go/slack"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
"github.com/umputun/remark42/backend/app/store"
)
func TestSlack_New(t *testing.T) {
ts := ne... | true |
7454d05c4bb9d62ed0c5e19d8639d6f3598a0b3c | Go | enricodangelo/exercises-in-style | /go/src/misc/div_by_0.go | UTF-8 | 90 | 2.609375 | 3 | [] | no_license | [] | no_license | package main
import (
"fmt"
)
func main() {
var i float64 = 1
fmt.Println(i / 0.0)
}
| true |
df9b362b5accb37726376d87d65fc3d4061e1f7c | Go | ZhangLi1995/learnGin | /_ginlearn/router/router.go | UTF-8 | 4,039 | 3.171875 | 3 | [] | no_license | [] | no_license | package main
import (
"fmt"
"log"
"net/http"
"time"
"github.com/gin-gonic/gin"
)
/**
* @Description: 默认服务器
*/
func serve1() {
router := gin.Default()
router.GET("/", func(ctx *gin.Context) {
ctx.String(http.StatusOK, "Hello World")
})
router.Run(":8000")
}
/**
* @Description: http 服务器
*/
func serve2(... | true |
187f08f8b6ae3db3a76f8bdc998540d240b547eb | Go | samonzeweb/godb | /transaction.go | UTF-8 | 2,002 | 2.875 | 3 | [
"MIT",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | [
"MIT",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | package godb
import (
"database/sql"
"fmt"
"time"
)
// preparableAndQueryable represents either a Tx or DB.
type preparableAndQueryable interface {
Exec(query string, args ...interface{}) (sql.Result, error)
Query(query string, args ...interface{}) (*sql.Rows, error)
QueryRow(query string, args ...interface{}) ... | true |
5d7261a8d26c60b1aad04cc37f1946f162ab3467 | Go | dmportella/golang-tutorial | /chapter3/methods.go | UTF-8 | 351 | 4.09375 | 4 | [
"BSD-3-Clause",
"Apache-2.0"
] | permissive | [
"BSD-3-Clause",
"Apache-2.0"
] | permissive | package chapter3
import "fmt"
type rectangle struct {
width, height int
}
func (r *rectangle) area() int {
return r.width * r.height
}
func (r *rectangle) perim() int {
return 2*r.width + 2*r.height
}
func Methods() {
rect := rectangle{width: 10, height: 5}
fmt.Println(rect)
fmt.Println("area: ", rect.area... | true |
f6752ed8da77d1ac2d7ecfb8ea732dc4baf73de6 | Go | jhoscar1/golang-exercises | /composites/08/map.go | UTF-8 | 447 | 3.328125 | 3 | [] | no_license | [] | no_license | package main
import "fmt"
func main() {
friends := map[string][]string{
"oscar_jason": {"friends", "movies", "chicken fingers"},
"herren_josh": {"musicals", "movies", "teaching"},
"mansfield_june": {"ceramics", "movies", "savvy"},
}
friends["steinberg_henry"] = []string{"printing", "games", "movies"}
... | true |
1072af871dc6018f0966c65d4bfdc19036f66b35 | Go | team-e-org/backend | /app/helpers/error.go | UTF-8 | 966 | 2.609375 | 3 | [] | no_license | [] | no_license | package helpers
type AppError interface {
AppError()
Error() string
}
type InternalServerError struct {
err error
}
func (e *InternalServerError) Error() string {
return e.err.Error()
}
func (e *InternalServerError) AppError() {}
func NewInternalServerError(err error) AppError {
return &InternalServerError{er... | true |
03bd5b4e82f9cbd3977867d16cc0a0f214f281ea | Go | dskloet/bitcoin | /src/bitcoin/bitstamp/orderbook.go | UTF-8 | 1,057 | 2.578125 | 3 | [] | no_license | [] | no_license | package bitstamp
import (
"github.com/dskloet/bitcoin/src/bitcoin"
"strconv"
)
type unparsedOrderBook struct {
Timestamp string
Bids [][]string
Asks [][]string
}
func (client Client) OrderBook() (
bids []bitcoin.Order, asks []bitcoin.Order, err error) {
var unparsed unparsedOrderBook
err =... | true |
98c010a548d2b5de333b5bf2395b8fb696fef636 | Go | go-numb/go-ftx-bff | /models/time.go | UTF-8 | 338 | 2.765625 | 3 | [] | no_license | [] | no_license | package models
import (
"encoding/json"
"math"
"time"
)
const FM float64 = 1e9
type FTime struct {
time.Time
}
func (p *FTime) UnmarshalJSON(data []byte) error {
var f float64
if err := json.Unmarshal(data, &f); err != nil {
return err
}
sec, dec := math.Modf(f)
p.Time = time.Unix(int64(sec), int64(dec*F... | true |
836603355278e526749d21fb025506b949227c40 | Go | kiniamogh/trading-system | /services/websocket-service/cmd/server/main.go | UTF-8 | 1,120 | 2.59375 | 3 | [] | no_license | [] | no_license | package main
import (
"fmt"
"log"
"net/http"
"github.com/caarlos0/env"
_logger "github.com/muwazana/backoffice/pkg/logger"
"github.com/muwazana/backoffice/services/websocket-service/pkg/api"
)
type config struct {
LogLevel string `env:"LOG_LEVEL" envDefault:"info"`
ServiceName string `env:"SERVICE_HOSTNAM... | true |
90657047a7756d7812f0474178ed031849361377 | Go | dilei/leetcode-go | /cs-notes/10-rect_cover.go | UTF-8 | 414 | 3.546875 | 4 | [] | no_license | [] | no_license | package csnotes
// 矩形覆盖
// c
// 我们可以用 2*1 的小矩形横着或者竖着去覆盖更大的矩形。请问用 n 个 2*1 的小矩形无重叠地覆盖一个 2*n 的大矩形,总共有多少种方法?
func rectCover(n int) int {
if n <= 2 {
return n
}
pre1 := 1
pre2 := 2
var result int
for i:=3; i<=n; i++ {
result = pre1 + pre2
pre1 = pre2
pre2 = result
}
return result
} | true |
284c6c67c4de4217a3029569eb0f3936ac140193 | Go | flyfilly/challenges | /digitDegree/digitDegree.go | UTF-8 | 280 | 3.140625 | 3 | [] | no_license | [] | no_license | package main
import (
"math"
)
func main() {
}
func digitDegree(n int) int {
return add(n, 0)
}
func add(n int, m int) int {
if n >= 10 {
t := 0
for n > 0 {
t += n % 10
n = int(math.Floor(float64(n) / float64(10)))
}
return add(t, (m + 1))
}
return m
}
| true |
906c90338399b4dc9040f0e5f160e2cc8ecd45aa | Go | bleenco/abstruse | /pkg/gitscm/scm.go | UTF-8 | 6,369 | 2.828125 | 3 | [
"MIT"
] | permissive | [
"MIT"
] | permissive | package gitscm
import (
"context"
"encoding/json"
"fmt"
"net/http"
"github.com/drone/go-scm/scm"
"github.com/drone/go-scm/scm/driver/bitbucket"
"github.com/drone/go-scm/scm/driver/gitea"
"github.com/drone/go-scm/scm/driver/github"
"github.com/drone/go-scm/scm/driver/gitlab"
"github.com/drone/go-scm/scm/driv... | true |
276c40c5a7c455195dc5f21ce4fbb48a1595f24c | Go | jinmatt/twtrgo | /http/server.go | UTF-8 | 1,358 | 3.171875 | 3 | [] | no_license | [] | no_license | package http
import (
"context"
"log"
"net"
"net/http"
"os"
"time"
"github.com/jinmatt/twtrgo/config"
"github.com/jinmatt/twtrgo/http/handler"
)
// Server type to hold http components
type Server struct {
handler *handler.Handler
server *http.Server
listener net.Listener
}
// NewServer inits type Ser... | true |
f1ff7c07ef941a65cbe282492388e3a8884564ff | Go | apg-pk/changeagent | /discovery/discovery.go | UTF-8 | 5,140 | 2.984375 | 3 | [
"Apache-2.0"
] | permissive | [
"Apache-2.0"
] | permissive | package discovery
import (
"bytes"
"fmt"
"github.com/golang/protobuf/proto"
)
//go:generate protoc --go_out=. discovery.proto
/*
* This module contains a set of discovery services that make it easier to
* learn which servers are configured as part of a cluster, and make it easier
* to know when that configura... | true |
edaac330f579c3ca312e9147eb09b68883e2898f | Go | tathagatnawadia/GolangTcpService | /Entities/Client.go | UTF-8 | 990 | 3.015625 | 3 | [] | no_license | [] | no_license | package Entities
import (
"net"
"relay_solution/Utils"
)
type IClient interface {
GetUserId() int
GetActive() bool
SetActive(bool)
SendMessage(myMessage RelayMessage)
AddToHistory(command string)
ReceiveMessages()
}
//@todo: not a good to expose properties as public, should be private with getters and sette... | true |
7199c0eae0495115a501f7b628d39ff5e37ecafa | Go | alfalfaw/bookstore | /main.go | UTF-8 | 2,926 | 3.234375 | 3 | [
"MIT"
] | permissive | [
"MIT"
] | permissive | package main
import (
"encoding/json"
"log"
"math/rand"
"net/http"
"strconv"
"github.com/gorilla/mux"
)
// Book Struct (Model)
type Book struct {
ID string `json:"id"`
Isbn string `json:"isbn"`
Title string `json:"title"`
Author *Author `json:"author"`
}
// Author Struct (Model)
type Author stru... | true |
23641857b774569cab1d27c1674fcd82b73a15bb | Go | shimakaru/GoLang | /golang_udemy-master/4.basetype/4.main.go | UTF-8 | 108 | 2.53125 | 3 | [] | no_license | [] | no_license | package main
import "fmt"
func main() {
var bt bool = true
var bf bool = false
fmt.Println(bt, bf)
}
| true |
81091deb46d6ce7c809365760602e292d1e2149b | Go | iesreza/foundation | /lib/request/users.go | UTF-8 | 1,327 | 2.765625 | 3 | [] | no_license | [] | no_license | package request
import (
"fmt"
"github.com/iesreza/foundation/lib"
"time"
)
type User struct {
Id int64
Name string
Username string
LastActivity int64
LastSeen int64
Guest bool
Password string `xorm:"varchar(200)"`
Created time.Time `xorm:"created"`
Updated ... | true |
6a4e372148ff4103f074d5fb89f6b480c6aa6bb4 | Go | fnanez001/FrankNanez-CSCI20-Spr2020 | /1.2.2 Lab.go | UTF-8 | 921 | 3.09375 | 3 | [] | no_license | [] | no_license | // Frank Nanez
// 2-4-20
// Lab 1.2.2 CSCI20
package main
import "fmt"
func main() {
fmt.Println("Hello World")
fmt.Println()
fmt.Println("Estimated Popluation in 10 years in the US")
fmt.Println("Population is;",329234331 )
fmt.Println("Death rate every; 10 seconds")
fmt.Println("Birth rate every; 9 sec... | true |
94829a171980170791e5570cd49cf1e4660bbb53 | Go | slham/basketball | /app/api.go | UTF-8 | 1,537 | 2.53125 | 3 | [
"Apache-2.0"
] | permissive | [
"Apache-2.0"
] | permissive | package app
import (
"basketball/env"
"basketball/handlers"
"basketball/storage"
"github.com/gorilla/mux"
"github.com/rs/cors"
"github.com/slham/toolbelt/l"
"net/http"
"os"
)
type App struct {
Config env.Config
Router *mux.Router
}
func (a *App) Initialize() bool {
l.Info(nil, "application initializing")
... | true |
2d116673ecfffa495d232d193ce51c80c8777612 | Go | OpenIndustryCloud/fission-go-add-risk-data | /add-risk-data.go | UTF-8 | 9,857 | 2.65625 | 3 | [] | no_license | [] | no_license | package main
/*
This API will update ticket payload with weather
risk and fruad risk data
*/
import (
"encoding/json"
"net/http"
"strconv"
"strings"
"time"
)
const (
//FORMS
STORM_FORM_ID = 114093996871
TV_FORM_ID = 114093998312
//FIELDS
WIND_SPEED_FIELD_ID = 114100596852
TV_MODEL_FIELD_ID ... | true |
cdd77f39c983e8c5149ae0200e6fe18b37ea03f9 | Go | joelmaat/Project-Euler | /src/fibonacci.go | UTF-8 | 3,402 | 3.296875 | 3 | [] | no_license | [] | no_license | package main
import (
"fmt"
"math/big"
"reflect"
"runtime"
"time"
)
type SquareRooted struct {
// Meaning: coefficient * sqrt(rooted) + constant
coefficient, rooted, constant *big.Rat
}
func (rooted *SquareRooted) Set(template *SquareRooted) *SquareRooted {
if template == rooted {
return rooted
}
if root... | true |
5d105d5660194c41cbe2e5ffdbf3c9769fc4078a | Go | TshSophie/SomeAlgorithm | /00Sort/04_InsertSort/InsertSort.go | UTF-8 | 370 | 3.578125 | 4 | [] | no_license | [] | no_license | package main
import "fmt"
func InsertSort(arr []int) {
length := len(arr)
for i := 1; i < length; i++ {
if arr[i] < arr[i-1] {
temp := arr[i]
var j int
for j = i - 1; j >= 0 && arr[j] > temp; j-- {
arr[j+1] = arr[j]
}
arr[j+1] = temp
}
}
}
func main() {
arr := []int{5, 3, 6, 7, 2}
fmt.Pr... | true |
fd64c59e7373ce5eebe9c6a0a8048ea206b8901a | Go | ichiban/not35 | /user.go | UTF-8 | 631 | 2.90625 | 3 | [] | no_license | [] | no_license | package main
import (
"context"
"time"
"golang.org/x/crypto/bcrypt"
)
type User struct {
ID int `db:"id"`
Email string `db:"email"`
PasswordHash []byte `db:"password_hash"`
CreatedAt time.Time `db:"created_at"`
UpdatedAt time.Time `db:"updated_at"`
}
func authenticate(ctx ... | true |
b5acfbff489c0ea832d01926a6d9102d1b613eb4 | Go | Serrous/OTUS | /lesson_6/lesson_6.go | UTF-8 | 2,410 | 3.953125 | 4 | [] | no_license | [] | no_license | package main
import (
"errors"
"fmt"
"runtime"
)
type myType = func() error
func aaa() error {
sl := []int{1, 2, 3, 4, 5}
for _, i := range sl {
if i == 3 {
return errors.New("Произошла ошибка в функции aaa")
}
fmt.Println("aaa", i)
}
return nil
}
func bbb() error {
sl := []int{6, 7, 8, 9, 10}
f... | true |
1249af2757c96804c255c0dd43e951ccab3aa63e | Go | ankurrai1/getting_started_GO | /concepts_code/method.go | UTF-8 | 1,044 | 4.25 | 4 | [] | no_license | [] | no_license | // Go supports methods defined on struct as methods defined in any object orianded language
package main
import(
"fmt"
)
type rect struct {
width int
height int
}
// This area method has referance of rect struct.
func (r *rect) area() int { // pass by referance
return r.width * r.height
}
// Methods ... | true |
3be6c52238a3bdbc5bf690fa7088606a51e13bf7 | Go | d3zd3z/gosure | /store/store_test.go | UTF-8 | 2,313 | 3.109375 | 3 | [] | no_license | [] | no_license | package store
import (
"bytes"
"fmt"
"io/ioutil"
"math/rand"
"os"
"path"
"testing"
"davidb.org/x/gosure/sure"
)
func TestTmpFile(t *testing.T) {
tdir, err := ioutil.TempDir("", "store-test-")
if err != nil {
t.Fatal(err)
}
defer os.RemoveAll(tdir)
var st Store
st.Path = tdir
// Make sure we can c... | true |
9859c6a8c7134f1d20e8bd311d81352d85cfe120 | Go | rkbodenner/parallel_universe | /game/setup_rule.go | UTF-8 | 1,667 | 3.140625 | 3 | [
"MIT"
] | permissive | [
"MIT"
] | permissive | package game
import (
"fmt"
)
type SetupRule struct {
Id int
Description string
Details string
Arity string
Dependencies []*SetupRule
}
func NewSetupRule(desc string, arity string, deps ...*SetupRule) *SetupRule {
return &SetupRule{0, desc, "", arity, deps}
}
func (a *SetupRule) Equal(b *SetupRule) bo... | true |
7368616f7750e6b9121cee475db2fa8acf1d8305 | Go | tcolgate/grafana-simple-json-go | /simplejson.go | UTF-8 | 20,817 | 2.6875 | 3 | [
"Apache-2.0"
] | permissive | [
"Apache-2.0"
] | permissive | // Copyright 2016 Qubit Digital Ltd.
// 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 ... | true |
f72098c75d273f48f02e11ce11b8a1660079972f | Go | i-redbyte/golang-benchmarks | /bench_int_insert_slice_test.go | UTF-8 | 755 | 2.578125 | 3 | [] | no_license | [] | no_license | package go_benchmark
import "testing"
func insertXIntSlice(x int, b *testing.B) {
testSlice := make([]int, 0)
b.ResetTimer()
for i := 0; i < x; i++ {
testSlice = append(testSlice, i)
}
}
func BenchmarkInsertIntSlice1000000(b *testing.B) {
for i := 0; i < b.N; i++ {
insertXIntSlice(1000000, b)
}
}
func Ben... | true |
720aee8d0ef382ddb84016a7aa72ba88fee1b30f | Go | zenledger-io/go-psql | /client_test.go | UTF-8 | 38,185 | 2.765625 | 3 | [
"MIT"
] | permissive | [
"MIT"
] | permissive | package psql
import (
"context"
"errors"
"fmt"
"testing"
"time"
"github.com/stretchr/testify/require"
)
func TestClient_Test(t *testing.T) {
c := NewClient(nil)
if err := c.Start(""); err != nil {
t.Fatalf("Failed to start %v", err)
}
if _, err := c.Exec(modelsTable); err != nil {
t.Fatalf("failed to... | true |
780ef181abce9bef83e795f6849e83e6b6b8854f | Go | paingha/auth-service | /utils/verifyjwt.go | UTF-8 | 1,419 | 3.171875 | 3 | [] | no_license | [] | no_license | package utils
import (
"fmt"
"os"
jwt "github.com/dgrijalva/jwt-go"
)
//Claims struct for Jwt
type Claims struct {
ID uint `json:"id"`
jwt.StandardClaims
}
//VerifyJWT takes in token as a string and returns a boolean.
func VerifyJWT(jwtToken string) (bool, uint64) {
var response = false
var emptyString uint6... | true |
4499f4bfe92d6a1cb29424043e4af802b37f75a4 | Go | kannappanr/minio | /cmd/erasure_test.go | UTF-8 | 7,057 | 2.984375 | 3 | [
"Apache-2.0",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | [
"Apache-2.0",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | /*
* Minio Cloud Storage, (C) 2016 Minio, 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 la... | true |
1c157b29fce842a6833b64cedff495a9292ef528 | Go | go-hep/hep | /groot/riofs/plugin/http/span_test.go | UTF-8 | 4,580 | 3.09375 | 3 | [
"BSD-3-Clause"
] | permissive | [
"BSD-3-Clause"
] | permissive | // Copyright ©2022 The go-hep 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 http
import (
"reflect"
"testing"
)
func TestSpanSplit(t *testing.T) {
mk := func(beg, end int64) span {
return span{
off: beg,
len: e... | true |
fb1a5649f1ff2c920c2b0110bffe156f795a242d | Go | vbatts/gossl | /conn.go | UTF-8 | 2,007 | 2.765625 | 3 | [] | no_license | [] | no_license | package gossl
/*
#include "openssl/ssl.h"
#include "openssl/err.h"
#cgo pkg-config: openssl
*/
import "C"
import "time"
import "net"
import "fmt"
var _ = fmt.Println
type Conn struct {
conn net.Conn
ssl *SSL
bio *BIO
err error
handshakeCompleted bool
}... | true |
259aa59c3166b5cf470c25bdb8a67bca24729553 | Go | chaokaikai1/GoProject | /daxigua.com/gostudy/day04/func2/main.go | UTF-8 | 383 | 3.921875 | 4 | [] | no_license | [] | no_license | package main
import "fmt"
func sum(x, y int) int {
return x + y
}
func f1(f func(x, y int) int) {
i := f(1, 2)
fmt.Println(i)
}
func f2(x, y int) (ret func(name string) string) {
age := x + y
ret = func(name string) string {
return name
}
fmt.Println(age)
//fmt.Println(ret)
return
}
func main() {
//函数作... | true |
c07d6ee123d6ab7f451fd93e28664c6b74d8e74d | Go | tangxusc/cqrs-db | /pkg/protocol/mysql_impl/parser/select.go | UTF-8 | 2,265 | 2.953125 | 3 | [] | no_license | [] | no_license | package parser
import (
"fmt"
"github.com/xwb1989/sqlparser"
)
type SelectParseResult struct {
TableName string
TableAsName string
//名称,别名
ColumnMap map[string]string
Where []string
}
func ParseSelect(stmt *sqlparser.Select) (result *SelectParseResult) {
result = &SelectParseResult{}
err := ParseTable... | true |
cc8893fb4ecae57d5b30ad2a7cc05450d4141c2a | Go | gtalarico/pm | /internal/commands/commands_test.go | UTF-8 | 523 | 3.078125 | 3 | [
"MIT"
] | permissive | [
"MIT"
] | permissive | package commands
import (
"testing"
)
func TestGetCommand(t *testing.T) {
// Test Valid Commands
inputs := [...]string{"go", "list", "add", "remove"}
for _, input := range inputs {
command, _ := GetCommand(input)
if command.Name != input {
t.Error("Test Failed: {} inputted, {} expected, recieved: {}", inp... | true |
b765476d51151a31ee7d1fa537eb169086d5d460 | Go | benbjohnson/go-dblib | /integration/dsn.go | UTF-8 | 1,333 | 2.5625 | 3 | [
"Apache-2.0"
] | permissive | [
"Apache-2.0"
] | permissive | // SPDX-FileCopyrightText: 2020 SAP SE
// SPDX-FileCopyrightText: 2021 SAP SE
//
// SPDX-License-Identifier: Apache-2.0
package integration
import (
"database/sql"
"database/sql/driver"
"github.com/SAP/go-dblib/dsn"
)
// genSQLDBFn is the signature of functions stored in the genSQLDBMap.
type genSQLDBFn func() (... | true |
35bf7f7e1582b777b7ef5f6cf1a661c3d7b06d9f | Go | omkz/golang-echo-blog | /main.go | UTF-8 | 709 | 2.78125 | 3 | [] | no_license | [] | no_license | package main
import (
"github.com/labstack/echo/v4"
"github.com/omkz/golang-echo-blog/controllers"
"github.com/labstack/echo/v4/middleware"
"net/http"
)
func main() {
// Echo instance
e := echo.New()
// Middleware
// e.Use(middleware.Logger())
e.Use(middleware.Recover())
e.Use(middleware.LoggerWithConfig(m... | true |
886c122e2e04739e4b6052bb9c700662ff54e22c | Go | barnex/mjolnir | /helheim/user.go | UTF-8 | 1,196 | 2.921875 | 3 | [] | no_license | [] | no_license | package helheim
import (
"errors"
"fmt"
"io"
"os/user"
"strconv"
)
// Cluster user.
type User struct {
name string
share int // Relative group share of the user
use int // Current number of jobs running
que JobQueue
group *Group
mailbox Mailbox
}
// API func to add new group with share.
fun... | true |
c6c7dc40d225ab1ad202cdf9b3f60bd7b2354001 | Go | team142/snaily | /model/user.go | UTF-8 | 1,133 | 2.984375 | 3 | [
"MIT"
] | permissive | [
"MIT"
] | permissive | package model
import (
"encoding/base64"
uuid "github.com/satori/go.uuid"
"golang.org/x/crypto/bcrypt"
"log"
"strings"
)
type User struct {
ID string `json:"id"`
Email string `json:"email"`
FirstName string `json:"firstname"`
LastName string `json:"lastname"`
Password string `json:"password"`
}... | true |
c572181d0051304bd908eea9a16256eec323932e | Go | wantidea/api-go | /lib/response/message.go | UTF-8 | 4,611 | 2.625 | 3 | [] | no_license | [] | no_license | package response
import (
"fmt"
)
const (
MsgSuccess = "成功"
MsgError = "失败"
)
// MsgList 消息 map
var MsgList = map[int]string{
CodeSuccess: "成功",
CodeError: "失败",
CodeErrorInvalidParams: "参数验证失败",
CodeErrorAuthCheckTokenNull: "请携带令牌 token",
CodeErrorAuthChe... | true |
80c6ec63dd46dc33841bf8855fe105097f4cb1cd | Go | edualb/godmitri | /element/actinium_test.go | UTF-8 | 1,383 | 2.5625 | 3 | [
"MIT"
] | permissive | [
"MIT"
] | permissive | package element
import "testing"
func TestActiniumGetPeriod(t *testing.T) {
a := Actinium{}
want := "7th period"
got := a.GetPeriod()
if got != want {
t.Errorf("Actinium.GetPeriod() = got %v, want %v", got, want)
}
}
func TestActiniumGetGroup(t *testing.T) {
a := Actinium{}
want := "3B"
got := a.GetGroup()... | true |
7ee25ff84fc8e8658ac6a9951c113b6009b5bee4 | Go | ilya-mim/oac2020 | /day07/main.go | UTF-8 | 2,470 | 3.5625 | 4 | [] | no_license | [] | no_license | package main
import (
"container/list"
"fmt"
"io/ioutil"
"regexp"
"strconv"
"strings"
)
type bagRecord struct {
color string
count int
}
func readRules(path string) (map[string][]bagRecord, error) {
content, err := ioutil.ReadFile(path)
if err != nil {
return nil, err
}
lines := strings.Split(string(c... | true |
2f7ed7df6d6da3e2a4a752214eceaf3407128b09 | Go | BruceMaa/Panda | /wechat/mp/qrcode.go | UTF-8 | 4,212 | 2.703125 | 3 | [
"MIT"
] | permissive | [
"MIT"
] | permissive | package mp
import (
"encoding/json"
"fmt"
"github.com/BruceMaa/Panda/wechat/common"
)
const (
WechatQrcodeCreateApi = `https://api.weixin.qq.com/cgi-bin/qrcode/create?access_token=%s` // 创建二维码API
WechatQrcodeShowApi = `https://mp.weixin.qq.com/cgi-bin/showqrcode?ticket=%s` // 显示二维码API
)
const (
Wec... | true |
f56d6ce2f87d4a9dfd4e4f44b62990972cfac2ea | Go | dddjjj-atp/Weekend3 | /main.go | UTF-8 | 891 | 3.046875 | 3 | [] | no_license | [] | no_license | package main
import (
"encoding/json"
"io/ioutil"
"log"
"net/http"
)
type WeatherInfoJson struct {
Weatherinfo WeatherinfoObject
}
type WeatherinfoObject struct {
City string
Temp string
WD string
WS string
SD string
Time string
}
func main() {
log.SetFlags(log.LstdFlags | log.Lshortfile)
resp, e... | true |
6f07a36a6b2e46c9fec3b39ac3784e6fac198165 | Go | magicmatatjahu/go-template | /template/controller.go | UTF-8 | 3,890 | 2.703125 | 3 | [
"Apache-2.0"
] | permissive | [
"Apache-2.0"
] | permissive | {%- from "../partials/go.template" import messageName -%}
{%- from "../partials/go.template" import getOpBinding -%}
package asyncapi
import (
"asyncapi/transport"
"asyncapi/channel"
"asyncapi/message"
"asyncapi/operation"
"errors"
)
type Controller struct {
Transport transport.PubSub
contentWriters map[strin... | true |
50f0f164a5dff4a0b2ca15a49d4d20d57b5f2cb8 | Go | sherif-fanous/go-feedly | /feedly/boards.go | UTF-8 | 9,772 | 2.609375 | 3 | [
"MIT"
] | permissive | [
"MIT"
] | permissive | package feedly
import (
"io"
"net/http"
"net/url"
"strings"
"github.com/dghubble/sling"
"github.com/sfanous/go-feedly/internal/mapstructure"
"github.com/sfanous/go-feedly/internal/mime"
"github.com/sfanous/go-feedly/pkg/time"
)
// BoardService provides methods for managing personal boards, aka tags.
type Boa... | true |
355533dc054e28028f8d6dfa0207046acd34be4a | Go | NyaaPantsu/manga | /utils/zip/rar.go | UTF-8 | 1,157 | 3.046875 | 3 | [
"MIT"
] | permissive | [
"MIT"
] | permissive | package zip
import (
"github.com/nwaples/rardecode"
"io"
"os"
"path/filepath"
)
// Returns 1 if the file named src has RAR magic bytes
func IsRar(src string) bool {
f, err := os.Open(src)
if err != nil {
return false
}
defer f.Close()
buf := make([]byte, 4)
_, err = f.Read(buf)
if err != nil {
return... | true |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.