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 |
97d496d79a7ef78bf8ac83a92e163fbbce543672 | Go | arnodel/golua | /runtime/value_noscalar.go | UTF-8 | 5,704 | 3.03125 | 3 | [
"Apache-2.0"
] | permissive | [
"Apache-2.0"
] | permissive | // +build noscalar
//
// This implementation of Value disables special casing of ints, floats and
// bools. It causes more memory allocations.
package runtime
// A Value is a runtime value.
type Value struct {
iface interface{}
}
// AsValue returns a Value for the passed interface.
func AsValue(i interface{}) Valu... | true |
3ab88d1e44ead060c876318c92d607bf4a0a21e3 | Go | Okumi/o-editor | /build_test.go | UTF-8 | 1,692 | 2.75 | 3 | [
"BSD-3-Clause"
] | permissive | [
"BSD-3-Clause"
] | permissive | package main
import (
"fmt"
"os"
"testing"
)
func ExampleEditor_BuildOrExport_goError() {
e := NewSimpleEditor(80)
e.mode, _ = detectEditorMode("err.go")
os.Chdir("test")
// The rename is so that "err.go" is not picked up by the CI tests
os.Rename("err_go", "err.go")
s, performedAction, compiledOK := e.Buil... | true |
6f3ca4cd94ec27ec56ef13932a17a5fb895230a9 | Go | ferjmc/cms | /functions/user-put/main.go | UTF-8 | 1,691 | 2.78125 | 3 | [] | no_license | [] | no_license | package main
import (
"encoding/json"
"github.com/aws/aws-lambda-go/events"
"github.com/ferjmc/cms/entities"
"github.com/ferjmc/cms/functions"
"github.com/ferjmc/cms/pkg/auth"
"github.com/ferjmc/cms/pkg/user"
)
type Request struct {
User UserRequest `json:"user"`
}
type UserRequest struct {
Username string ... | true |
4e18559170f55839554bb0bedd7b5d81564817f2 | Go | wkym461a/gphotos | /uploadingMedia.go | UTF-8 | 3,564 | 2.65625 | 3 | [
"MIT"
] | permissive | [
"MIT"
] | permissive | package gphotos
import (
"bytes"
"io/ioutil"
"net/http"
"os"
"strconv"
)
// UploadingMedia is the only instance of UploadingMediaRequests(https://godoc.org/github.com/Q-Brains/gphotos#UploadMediaRequests).
var UploadingMedia UploadingMediaRequests = uploadingMediaRequests{}
// UploadingMediaRequests is a collec... | true |
21ba3c32f39089a184d7ef4c8cd0da9a9c08a190 | Go | agungsetiawan/bwastartup | /user/repository.go | UTF-8 | 1,182 | 3.421875 | 3 | [] | no_license | [] | no_license | package user
import "gorm.io/gorm"
type Repository interface {
Save(user User) (User, error)
FindByEmail(email string) (User, error)
FindByID(ID int) (User, error)
Update(user User) (User, error)
FindAll() ([]User, error)
}
type repository struct {
db *gorm.DB
}
func NewRepository(db *gorm.DB) *repository {
... | true |
f1242edaf630e18b618bcfc6499db5b190c4e240 | Go | stream2000/gom4db | /network/reactor/gnet.go | UTF-8 | 2,328 | 2.65625 | 3 | [] | no_license | [] | no_license | package reactor
import (
"container/heap"
"fmt"
"github.com/golang/protobuf/proto"
"github.com/panjf2000/gnet"
"github.com/panjf2000/gnet/pool/goroutine"
"gom4db/cache"
"gom4db/pbmessages"
"log"
)
type cacheServer struct {
*gnet.EventServer
addr string
multiCore bool
async bool
codec gne... | true |
8e001113cc0ae2610492e1c73f7cad71a2e7e664 | Go | nurali-techie/play-go | /gob-encoding/recv/recv.go | UTF-8 | 739 | 3.296875 | 3 | [] | no_license | [] | no_license | package main
import (
"encoding/gob"
"log"
"net"
)
type Emp struct {
Name string
Age *int
}
func main() {
log.SetFlags(log.Lmicroseconds)
log.Printf("starting ..\n")
addr, err := net.ResolveTCPAddr("tcp4", ":8050")
if err != nil {
log.Fatalf("Resolve failed, %v", err)
}
lisntener, err := net.ListenTCP... | true |
b6b3df472da74bec56da5d7c5100a9acc21ee562 | Go | EqCScO9nTa/v2ray-core | /common/buf/multi_buffer_test.go | UTF-8 | 3,785 | 2.734375 | 3 | [
"MIT"
] | permissive | [
"MIT"
] | permissive | package buf_test
import (
"bytes"
"crypto/rand"
"io"
"testing"
"github.com/google/go-cmp/cmp"
"io/ioutil"
"os"
"v2ray.com/core/common"
. "v2ray.com/core/common/buf"
)
func TestMultiBufferRead(t *testing.T) {
b1 := New()
common.Must2(b1.WriteString("ab"))
b2 := New()
common.Must2(b2.WriteString("cd"))
... | true |
5e3a8eed11f778bf59c235904f78e21526e76a70 | Go | sguzwf/wsh2s | /flush_writer.go | UTF-8 | 372 | 2.796875 | 3 | [] | no_license | [] | no_license | package wsh2s
import "net/http"
type flushWriter struct {
http.ResponseWriter
}
func (w *flushWriter) FlushHeader(code int) {
w.ResponseWriter.WriteHeader(code)
w.ResponseWriter.(http.Flusher).Flush()
}
func (w *flushWriter) Write(p []byte) (n int, err error) {
n, err = w.ResponseWriter.Write(p)
if n > 0 {
w... | true |
fe490da86d4b55c3c10427c57ecd0ac7f0e4fde7 | Go | qewetfty/leetcodeProblem | /treeNode/problem938.go | UTF-8 | 603 | 3.1875 | 3 | [] | no_license | [] | no_license | package treeNode
import "github.com/leetcodeProblem/data"
//Given the root node of a binary search tree,
// return the sum of values of all nodes with value between L and R (inclusive).
//
//The binary search tree is guaranteed to have unique values.
//Note:
//The number of nodes in the tree is at most 10000.
//The ... | true |
08259708e32a91953c284ec426f368ee855a86cc | Go | simukti/sqldb-logger | /rows.go | UTF-8 | 3,557 | 2.765625 | 3 | [
"MIT"
] | permissive | [
"MIT"
] | permissive | package sqldblogger
import (
"context"
"database/sql/driver"
"io"
"reflect"
"time"
)
// rows is a wrapper which implements:
// - driver.Rows
// - driver.RowsNextResultSet
// - driver.RowsColumnTypeScanType
// - driver.RowsColumnTypeDatabaseTypeName
// - driver.RowsColumnTypeLength
// - driver.RowsColumnTypeNulla... | true |
afae8ae506b269235a90b370c97d8214fac39a39 | Go | softonic/homing-pigeon | /pkg/messages/message.go | UTF-8 | 543 | 3.171875 | 3 | [
"Apache-2.0"
] | permissive | [
"Apache-2.0"
] | permissive | package messages
import "errors"
type Message struct {
Id interface{}
Body []byte
acked bool
}
func (m Message) Nack() (Ack, error) {
err := m.setAsAcked()
if err != nil {
return Ack{}, err
}
return Ack{
Id: m.Id,
Ack: false,
}, nil
}
func (m Message) Ack() (Ack, error) {
err := m.setAsAcked()
... | true |
af65c374621d7fdc3cd29b5096781301f3d8cc54 | Go | YoungFox/Lets-go | /src/build-web-application-with-golang/struct/main.go | UTF-8 | 7,244 | 4.15625 | 4 | [] | no_license | [] | no_license | // package main
// import "fmt"
// type person struct {
// name string
// age int
// }
// func main() {
// var P person // P现在就是person类型的变量了
// P.name = "Astaxie" // 赋值"Astaxie"给P的name属性.
// P.age = 25 // 赋值"25"给变量P的age属性
// fmt.Printf("The person... | true |
c54bb83522a5472ab96c0ad902ce50acb86f75ae | Go | sanae10001/graphql-go-extension-scalars | /datetime.go | UTF-8 | 1,637 | 3.421875 | 3 | [
"MIT"
] | permissive | [
"MIT"
] | permissive | package scalars
import (
"errors"
"time"
)
var (
DateTimeWrongInputFormat = errors.New("Scalar.DateTime: wrong input format, expected RFC3339")
DateTimeWrongInputType = errors.New("Scalar.DateTime: wrong input type")
)
func NewDateTime(t time.Time) *DateTime {
if t.IsZero() {
return nil
}
d := DateTime{Ti... | true |
188a98ed6ae7148711e4c25ea43e272513f701a6 | Go | fibbery/leetcode | /783.二叉搜索树节点最小距离.go | UTF-8 | 634 | 2.96875 | 3 | [] | no_license | [] | no_license | /*
* @lc app=leetcode.cn id=783 lang=golang
*
* [783] 二叉搜索树节点最小距离
*/
package main
import "math"
// @lc code=start
/**
* Definition for a binary tree node.
* type TreeNode struct {
* Val int
* Left *TreeNode
* Right *TreeNode
* }
*/
func minDiffInBST(root *TreeNode) int {
result, pre := math.Ma... | true |
e870127f1b31aa721d5dd3421056cbcc1e4c95e1 | Go | fossabot/api-14 | /pkg/github/roundtrip.go | UTF-8 | 981 | 2.90625 | 3 | [] | no_license | [] | no_license | package github
import (
"net/http"
"net/textproto"
funk "github.com/thoas/go-funk"
)
func newAcceptFilteringTripper(
underlying http.RoundTripper,
valuesToFilter ...string,
) http.RoundTripper {
if underlying == nil {
underlying = http.DefaultTransport
}
return acceptFilteringTripper{
Tripper: underlying... | true |
4cf25c206bcbe92bd3ce842349e21b168ce35113 | Go | relax-space/ping-kafka-mysql | /main.go | UTF-8 | 1,377 | 2.609375 | 3 | [] | no_license | [] | no_license | package main
import (
"fmt"
"os"
"os/signal"
"syscall"
"time"
_ "github.com/go-sql-driver/mysql"
"github.com/go-xorm/xorm"
)
func main() {
if err := pingKafka(); err != nil {
fmt.Println(err)
return
}
fmt.Println("consumer is ready!")
if err := pingMysql(); err != nil {
fmt.Println(err)
return
... | true |
162bbfc9f9a8cc18a0f72400733d4852262d738e | Go | trumae/evolvegamelib | /evolvegamelib_test.go | UTF-8 | 555 | 2.625 | 3 | [] | no_license | [] | no_license | package evolvegamelib
import "testing"
func TestAngle(t *testing.T) {
n := angle([8]int{2, 2, 2, 2, 2, 2, 2, 2}, 1)
if n != 0 {
t.Error("Erro na funcao angle")
}
n = angle([8]int{2, 2, 2, 2, 2, 2, 2, 2}, 3)
if n != 1 {
t.Error("Erro na funcao angle")
}
n = angle([8]int{2, 2, 2, 2, 2, 2, 2, 2}, 5)
if n != ... | true |
f79eef2940b13dfd434e5ab86b0189c79b4d778d | Go | TedForV/goutil | /algorithm/heapsort.go | UTF-8 | 2,211 | 3.265625 | 3 | [
"MIT"
] | permissive | [
"MIT"
] | permissive | package algorithm
// UpAdjust upajust the last node (inserted new node situation)
func UpAdjust(arr []int) {
if len(arr) == 0 || len(arr) == 1 {
return
}
childIndex := len(arr) - 1
parentIndx := getParentIndex(childIndex)
for {
if childIndex == 0 && arr[childIndex] >= arr[parentIndx] {
break
}
arr[chil... | true |
5c18df4bcc37d451846cd73c6e86b13bbd38cda0 | Go | Hussainzz/mySpaceB | /models/models.go | UTF-8 | 2,840 | 2.75 | 3 | [] | no_license | [] | no_license | package models
import (
"errors"
"github.com/astaxie/beego"
"github.com/astaxie/beego/orm"
"fmt"
"time"
"github.com/gogather/com"
)
type Users struct{
Id string `orm:"pk" json:"id"`
Username string `json:"username"`
Password string `json:"pwd"`
Salt string `json:"salt"`
Email string `orm:"unique" json:"ema... | true |
aeb0d529e30101252fef636bc4121b2e5c531d90 | Go | markfisher/rokn | /pkg/reconciler/broker/resources/exchange_test.go | UTF-8 | 2,804 | 2.578125 | 3 | [
"Apache-2.0"
] | permissive | [
"Apache-2.0"
] | permissive | package resources_test
import (
"context"
"fmt"
"github.com/markfisher/rokn/pkg/reconciler/broker/resources"
"github.com/markfisher/rokn/pkg/reconciler/internal/testrabbit"
"gotest.tools/assert"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
eventingv1beta1 "knative.dev/eventing/pkg/apis/eventing/v1beta1"
"test... | true |
e738c783c5ab20d36c0e17fc7e84c6635cf2ce66 | Go | timdadd/simpleMS | /services/frontend/lib/common/web.go | UTF-8 | 5,492 | 3.03125 | 3 | [
"LicenseRef-scancode-warranty-disclaimer",
"MIT"
] | permissive | [
"LicenseRef-scancode-warranty-disclaimer",
"MIT"
] | permissive | package common
import (
"errors"
"fmt"
"html/template"
"io"
"io/ioutil"
"net/http"
"os"
"path/filepath"
"runtime/debug"
"strings"
"time"
)
// https://blog.golang.org/error-handling-and-go
type appHandler func(http.ResponseWriter, *http.Request) *appError
type appError struct {
err error
message stri... | true |
806a0340b8f810dc4020f63bbd7a7b7bf68c3f78 | Go | wenchaopeng/go-qlc | /common/event/event_bus_test.go | UTF-8 | 4,508 | 3.0625 | 3 | [
"MIT"
] | permissive | [
"MIT"
] | permissive | /*
* Copyright (c) 2019 QLC Chain Team
*
* This software is released under the MIT License.
* https://opensource.org/licenses/MIT
*/
package event
import (
"sync"
"testing"
"time"
)
func TestNew(t *testing.T) {
bus := New()
if bus == nil {
t.Log("New EventBus not created!")
t.Fail()
}
}
func TestHasC... | true |
3552e0202026ee6fb858d9c64754c787875f52eb | Go | fd0/drainchecker | /drainchecker.go | UTF-8 | 1,226 | 3.28125 | 3 | [
"BSD-2-Clause"
] | permissive | [
"BSD-2-Clause"
] | permissive | package drainchecker
import (
"fmt"
"io"
"io/ioutil"
"net/http"
"os"
)
type eofDetectRoundTripper struct {
http.RoundTripper
}
// RoundTripper returns a new http.RoundTripper which prints a message to
// stderr when the HTTP response body is not properly drained.
func RoundTripper(upstream http.RoundTripper) h... | true |
ca68ac3878894ab731fd25192140b37d577ddf4f | Go | wanghaoxi3000/go-algo | /sort/shell.go | UTF-8 | 1,040 | 3.53125 | 4 | [] | no_license | [] | no_license | package sort
import "math"
/**
* @Time : 2020/7/20 17:00
* @Author : wanghaoxi3000
* @Email : wanghaoxi3000@163.com
* @Description : 希尔排序算法
* @Revise : ---
*/
/*
希尔排序
1. 选择一个增量序列 t1,t2,……,tk,其中 ti > tj, tk = 1
2. 按增量序列个数 k,对序列进行 k 趟排序
3. 每趟排序,根据对应的增量 ti,将待排序列分割成若干长度为 m 的子序列,分别对各子表进行直接插入排序。仅增量因子为 1 时,整个序列作为一... | true |
556a3d289ed0f7eb891367bd3863450beb064b05 | Go | Johnson-jjy/Go-AC | /greedy/LC_1005_largestSumAfterKNegations.go | UTF-8 | 728 | 3.40625 | 3 | [] | no_license | [] | no_license | package greedy
import "sort"
// K次取反后最大化的数组和
// 1. 要先排序,想办法把大的负数翻转过来 2.没必要取纠结k和负数的关系,直接先翻转大的负数即可
// 3. 对于index定位,初始值应该考量的是不走else的情况
func largestSumAfterKNegations(nums []int, k int) int {
sort.Ints(nums)
index := len(nums) - 1
for i := 0; i < len(nums); i++ {
if k > 0 && nums[i] < 0 {
nums[i] = -nums[i]
... | true |
6a99892896589875bce2c1dc22f548ea576e7fd3 | Go | AndrewVos/statistic.li | /application_test.go | UTF-8 | 3,096 | 2.9375 | 3 | [] | no_license | [] | no_license | package main
import (
"encoding/json"
"io/ioutil"
"net/http"
"net/http/httptest"
"net/url"
"testing"
)
var server *httptest.Server
func setup() {
DeleteAllClientHits()
if server != nil {
server.Close()
}
server = httptest.NewServer(http.HandlerFunc(clientHandler))
}
func get(url string, cookies []*http.... | true |
2619289233f6e51d44c900d4f683b6394e648ff3 | Go | jaskiratvig/golang-restapi-dynamodb-serverless | /aws-golang-http-get-post/routers/crud/editArtist/editArtist.go | UTF-8 | 2,252 | 2.78125 | 3 | [] | no_license | [] | no_license | package main
import (
"aws-golang-http-get-post/dynamoDB"
"aws-golang-http-get-post/models"
"aws-golang-http-get-post/ses"
"encoding/json"
"fmt"
"os"
"github.com/aws/aws-lambda-go/events"
"github.com/aws/aws-lambda-go/lambda"
"github.com/aws/aws-sdk-go/aws"
"github.com/aws/aws-sdk-go/service/dynamodb"
"git... | true |
32fb8f0df8163cbe9f0e23b236c2682df3948f8b | Go | Global-localhost/cloudfoundry-cli-archived | /src/cf/commands/routes_test.go | UTF-8 | 1,518 | 2.875 | 3 | [
"Apache-2.0"
] | permissive | [
"Apache-2.0"
] | permissive | package commands_test
import (
"cf"
. "cf/commands"
"github.com/stretchr/testify/assert"
"testhelpers"
"testing"
)
func TestListingRoutes(t *testing.T) {
routes := []cf.Route{
cf.Route{
Host: "hostname-1",
Domain: cf.Domain{Name: "example.com"},
},
cf.Route{
Host: "hostname-2",
Domain: cf.... | true |
5721561a8bd093a972e02af6cece494bbae7c619 | Go | zaker/go-qr-term | /mask.go | UTF-8 | 594 | 3.171875 | 3 | [
"MIT"
] | permissive | [
"MIT"
] | permissive | package main
import "math"
type maskFunc func(x, y int) bool
var masks map[int]maskFunc = map[int]maskFunc{
0: func(x, y int) bool { return (x+y)%2 == 0 },
1: func(x, y int) bool { return (x)%2 == 0 },
2: func(x, y int) bool { return (y)%3 == 0 },
3: func(x, y int) bool { return (x+y)%3 == 0 },
4: func(x, y int... | true |
63ea74c153634fe068fc1df8931c4ceb26ce308b | Go | alexon1234/golang-api | /pkg/post/domain/post.go | UTF-8 | 342 | 2.734375 | 3 | [
"MIT"
] | permissive | [
"MIT"
] | permissive | package domain
// Post - Domain of the post
type Post struct {
ID string `json:"id"`
Title string `json:"title"`
Body string `json:"body"`
}
// Repository - interface of the Post Repository
type Repository interface {
RunMigrations()
FetchPosts() (*[]Post, error)
GetPost(id string) (*Post, error)
CreatePos... | true |
912e84ef2b63e275859f9225ce281a8f95f9aa59 | Go | dna2zodiac/codehub | /google/golang/1.14.2/index.suffixarray.go | UTF-8 | 2,235 | 3.40625 | 3 | [
"MIT"
] | permissive | [
"MIT"
] | permissive | // Copyright 2010 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
// Package suffixarray implements substring search in logarithmic time using
// an in-memory suffix array.
//
// Example use:
//
// // create index for some dat... | true |
6e1cdae6cb0997b42070b13dd8d4e21012e84890 | Go | keep94/gofunctional2 | /examples/power2/power2.go | UTF-8 | 1,905 | 3.46875 | 3 | [
"BSD-3-Clause"
] | permissive | [
"BSD-3-Clause"
] | permissive | // Copyright 2013 Travis Keep. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file or
// at http://opensource.org/licenses/BSD-3-Clause.
// This example is just like power, but does not make recursive calls to
// functional.NewGenerator. functiona... | true |
79f03a71718e04f95e231cd1d0fe6ec4ec6d4dd9 | Go | 0x7b1/algorithms | /leetcode/0079.go | UTF-8 | 1,037 | 3.5625 | 4 | [] | no_license | [] | no_license | package main
import "fmt"
func searchWord(board [][]byte, height, width int, word string, x, y, i int) bool {
if len(word) == i {
return true
}
if y < 0 || y >= height || x < 0 || x >= width {
return false
}
if board[y][x] != word[i] {
return false
}
board[y][x] ^= 0xFF
exist := searchWord(board, he... | true |
1a4cebef389369e2e7afabb30d609c660b26c5db | Go | ljfuyuan/practice | /Algorithms/InsertSort_test.go | UTF-8 | 1,042 | 3.15625 | 3 | [] | no_license | [] | no_license | /*=============================================================================
# FileName: InsertSort_test.go
# Desc:
# Author: ljfuyuan
# Email: ljfuyuan@qq.com
# Create: 2016-06-20 18:19:27
# LastChange: 2016-06-22 19:55:42
# History:
============================================... | true |
8820f226b619ce4ffc8ebeaa0ffec6e5c334696e | Go | nkoblai/goexercises | /go-tour/stringer.go | UTF-8 | 786 | 3.5 | 4 | [] | no_license | [] | no_license | package stringer
import (
"fmt"
"strconv"
"strings"
)
// IPAddr type represents ip-adress.
type IPAddr [4]byte
var hosts = map[string]IPAddr{
"loopback": {127, 0, 0, 1},
"googleDNS": {8, 8, 8, 8},
}
// String returns address as a dotted quad.
func (ip IPAddr) String() string {
str := fmt.Sprintf("%v", ip[0])... | true |
ab13d209094f547f3d364ce8c366030e4af43b8f | Go | mfhholmes/Orbital | /src/github.com/mfhholmes/Orbital/actionList.go | UTF-8 | 2,190 | 3.390625 | 3 | [] | no_license | [] | no_license | package main
import (
"sort"
)
import (
"time"
)
import (
"fmt"
)
var isRunning bool
type processFunc func()
type controlInstruction struct {
runLoop bool
delay time.Duration
}
type actionItem struct {
execTime time.Time
process processFunc
}
//ActionList is a list of Action Items, which is then
type Ac... | true |
f78f9e1a61ac91ba52e6e8e3c44ecd8997a5e43f | Go | shieldproject/misfit-toys | /dedsocket/main.go | UTF-8 | 2,752 | 2.671875 | 3 | [
"MIT"
] | permissive | [
"MIT"
] | permissive | package main
import (
"crypto/tls"
"fmt"
"net"
"net/http"
"net/url"
"os"
"github.com/gorilla/websocket"
"github.com/jhunt/go-ansi"
"github.com/shieldproject/shield/client/v2/shield"
"golang.org/x/crypto/ssh/terminal"
)
// This program connects to the SHIELD websocket and then just doesn't read the
// buffe... | true |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.