blob_id stringlengths 40 40 | content_id stringlengths 40 40 | repo_name stringlengths 5 114 | path stringlengths 5 318 | language stringclasses 5
values | extension stringclasses 12
values | length_bytes int64 200 200k | license_type stringclasses 2
values | content stringlengths 143 200k |
|---|---|---|---|---|---|---|---|---|
142c87ee9c469d351b1a821f409bea6585cf2f66 | 7998067bcfec1d31b07552fea4f965babe8ef417 | ManchersterByTheSea/openBilibili | /go-common/app/interface/main/activity/dao/like/match.go | Go | go | 5,427 | no_license | package like
import (
"context"
"database/sql"
"fmt"
match "go-common/app/interface/main/activity/model/like"
xsql "go-common/library/database/sql"
"go-common/library/log"
"go-common/library/xstr"
)
const (
_matchSidSQL = "SELECT id,sid,max_stake,stake,name,url,cover,ctime,mtime FROM act_matchs WHERE stat... |
ef1a8c6e94ced6f84219147211dc8a6b3c10c83a | 69aad74ef33ff87bc91a53e3de5933208e0e332c | turbonomic/kubeturbo | /pkg/discovery/util/key_func_test.go | Go | go | 2,863 | permissive | package util
import (
"testing"
)
func TestParseContainerId(t *testing.T) {
type mytriple struct {
input string
podId string
index int
}
tests := []*mytriple{
&mytriple{
input: "a-1",
podId: "a",
index: 1,
},
&mytriple{
input: "1466089904-b2333a79-2901-11e7-a3d7-00505680effd-0",
podId:... |
d16233b0582bc76da4bee302a62b6af537d67bff | d02ec2baac7cadb3d4f8ca5618e8d4516dfe0c45 | hedianbin/publicchain | /day09_06_Net_Hander/BLC/Server_handle.go | Go | go | 1,052 | no_license | package BLC
import (
"bytes"
"encoding/gob"
"log"
"fmt"
)
//处理接收到的version数据
func handleVersion(request []byte,bc *Blockchain) {
/*
1.从request中获取版本的数据:[]byte
2.反序列化---Version{}
3.操作bc,获取自己的最后block的height
4.跟对方比较
*/
//1.从request中获取版本的数据:[]byte
versionBytes:=request[COMMAND_LENGTH:]
//2.反序列化---Version{}
... |
095f54437d2a95b69e55e8d60e057807194b6185 | 2501a3bd798866933bc5a9dd99c829b45d76bd8f | tmsmr/swarm-host-monitoring | /exporter/metrics.go | Go | go | 2,565 | no_license | package main
import (
"encoding/json"
"errors"
"fmt"
"net/http"
"strconv"
)
type nodeInfo struct {
Name string `json:"name"`
}
type nodeLoad struct {
Load1 float64 `json:"load1"`
Load5 float64 `json:"load5"`
Load15 float64 `json:"load15"`
}
type nodeMem struct {
Total int64 `json:"total"`
Available... |
937442db168f6435f95f05bf08fcc3da69ac7e48 | a6fadfdb66a8a1df46e894a015895d4c5e9e1eb9 | jethro91/fiber-mongo-redis-boilerplate | /src/apiRoot/role/create.go | Go | go | 1,267 | no_license | package role
import (
"fmt"
"github.com/gofiber/fiber/v2"
"go.mongodb.org/mongo-driver/bson"
"github.com/jethro91/fiber-mongo-redis-boilerplate/src/model"
"github.com/jethro91/fiber-mongo-redis-boilerplate/src/util"
)
type createSchema struct {
ID string `bson:"_id" json:"_id" validate:"min=3,max=128,requir... |
478abe5468614cee42142c6bdd185b0d98e5d9b1 | e1361f1a597e2f2ba452b36f47ea4e705f558e02 | disktnk/sb-audio | /plugin/plugin.go | Go | go | 216 | no_license | package plugin
import (
"github.com/disktnk/sb-audio"
"gopkg.in/sensorbee/sensorbee.v0/bql"
)
func init() {
bql.MustRegisterGlobalSourceCreator("audio_device", bql.SourceCreatorFunc(
audio.NewDeviceSource))
}
|
050953b9b3d4cffdf7b2df99f4dea42bc5de633c | 5653af219e185a0f6d541685af9704006edae6e5 | makasimorg/gitcall-go-runner | /test/apps/error/error.go | Go | go | 244 | no_license | package main
import (
"context"
"fmt"
"github.com/corezoid/gitcall-go-runner/runner"
)
func usercode(ctx context.Context, data map[string]interface{}) error {
return fmt.Errorf("error-happened")
}
func main() {
runner.Run(usercode)
}
|
5d9efbb8b949db77fe407f86c0b6b827e59f7e57 | 2c5b4c2a39eb697084eb6a172c157cc8d61241fb | Evan2698/chimney-go | /configure/config.go | Go | go | 1,376 | permissive | package configure
import (
"encoding/json"
"io/ioutil"
"log"
"os"
)
// AppConfig ..
type AppConfig struct {
ServerPort uint16 `json:"server_port"`
Server string `json:"server"`
QuicPort uint16 `json:"quic_port"`
UDPPort uint16 `json:"udp_port"`
LocalUDP uint16 `json:"local_udp_port"`
LocalPort u... |
1e964613b4f9aa5aaa5978a430fad2e8d07bfa56 | b8fd630c6ec887d4f6fe69ce6682a4c3976380cc | giwayne/rio | /modules/build/controllers/gitcommit/service.go | Go | go | 5,226 | permissive | package gitcommit
import (
"fmt"
"github.com/rancher/rio/modules/build/pkg"
webhookv1 "github.com/rancher/gitwatcher/pkg/apis/gitwatcher.cattle.io/v1"
riov1 "github.com/rancher/rio/pkg/apis/rio.cattle.io/v1"
"github.com/rancher/rio/pkg/indexes"
"github.com/rancher/rio/pkg/services"
"github.com/rancher/wrangle... |
a0f89ee002700bdcf5f0a659bf04c31e8d249f8f | 5acf06685c643b5db09a33dda7d900f20e83daec | sinesiobittencourt/docker | /vendor/src/github.com/opencontainers/runc/libcontainer/seccomp/config.go | Go | go | 1,620 | permissive | package seccomp
import (
"fmt"
"github.com/opencontainers/runc/libcontainer/configs"
)
// ConvertStringToOperator converts a string into a Seccomp comparison operator.
// Comparison operators use the names they are assigned by Libseccomp's header.
// Attempting to convert a string that is not a valid operator resu... |
4e20b2d6ed0abdbf9a2ba5613f956ebe7e2de492 | 37f8f82ef00e5d21cb2ebced349512cb3250f77b | Dedgar/interview | /binary_search/binary_search.go | Go | go | 977 | no_license | package main
import (
"fmt"
)
func search(nums []int, target int) int {
numCount := len(nums)
// Don't waste time iterating slices that exclusively contain bigger or smaller numbers than the target
if nums[0] > target || nums[numCount-1] < target {
return -1
}
bot := 0
top := numCount - 1
// identify mid... |
c4d31207b6704798900f22ec99246a7be8858706 | ebfa3fa2fd5576e4b65ff23a2a5675f56faf5472 | Sjeanpierre/Go-Snake-go | /main.go | Go | go | 5,869 | permissive | package main
import (
"fmt"
"github.com/pkg/term"
"log"
"math/rand"
"os"
"time"
)
const (
rows = 25 //X
columns = 40 //Y
)
const (
RuneSq = '■'
RuneDArrow = '↓'
RuneLArrow = '←'
RuneRArrow = '→'
RuneUArrow = '↑'
RuneDiamond = '◆'
RunePi = 'π'
RuneHLine = '─'
RuneLLCorner =... |
0775fc1d41ce1b8ee86c70d9889fb3e4d4ccc053 | d62b5e98a696a658f1ccea908c65b21a64961484 | SeppPenner/Dragonfly | /supernode/daemon/mgr/task/manager.go | Go | go | 8,699 | permissive | /*
* Copyright The Dragonfly Authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agr... |
ea4170cc47b9f052d24d0a05314b787f5789b3a6 | 80e5c979e6eb5c3ea6203e2df1c3483bc02e71a2 | everimbaq/AnnChain | /genesis/eth/ethdb/database.go | Go | go | 11,351 | permissive | // Copyright 2014 The go-ethereum Authors
// This file is part of the go-ethereum library.
//
// The go-ethereum library is free software: you can redistribute it and/or modify
// it under the terms of the GNU Lesser General Public License as published by
// the Free Software Foundation, either version 3 of the License... |
880593e3f8a8af2a97948b6456badedfbef0f976 | 88649420654598847d27e17d158da003ef182b40 | roessland/gopkg | /mathutil/factorial_test.go | Go | go | 1,333 | no_license | package mathutil
import "testing"
import "github.com/stretchr/testify/assert"
func TestFactorial(t *testing.T) {
assert.Equal(t, int64(2432902008176640000), Factorial(20), "large number")
assert.Panics(t, func() { Factorial(21) }, "overflowing number")
assert.Equal(t, int64(1), Factorial(0), "zero factorial")
}
f... |
95afbbc42c559a3ad9d03835905e7506840dc81b | ebe6783444aa6550d078fae4074dd6e3a8b18eeb | codenotary/immudb | /cmd/immuclient/command/server_info.go | Go | go | 549 | permissive | package immuclient
import "github.com/spf13/cobra"
func (cl *commandline) serverInfo(cmd *cobra.Command) {
ccmd := &cobra.Command{
Use: "info",
Short: "Return server information",
PersistentPreRunE: cl.ConfigChain(cl.connect),
PersistentPostRun: cl.disconnect,
RunE: func(cmd *cobr... |
a5ea6c4cbd50d293b1a0f708021abf6df11192ed | be7b83cbbde3f0390512abe97e15251c03469e83 | jimsmart/schema | /dialect_sqlite.go | Go | go | 1,385 | permissive | package schema
import (
"database/sql"
)
// TODO(js) Can we see tables in an attached database? How are their names handled? See https://sqlite.org/lang_naming.html
const sqliteAllColumns = `SELECT * FROM %s LIMIT 0`
const sqliteTableNamesWithSchema = `
SELECT
"" AS schema,
name
FROM
sqlite_master
WHERE
... |
a3e9a61a8e3b53117053a650f72e32e554534fba | 0da03c9829a6e563da13f198559928ed38aafc81 | openshift/openshift-apiserver | /pkg/authorization/apiserver/registry/clusterrole/proxy.go | Go | go | 5,071 | no_license | package clusterrole
import (
"context"
metainternal "k8s.io/apimachinery/pkg/apis/meta/internalversion"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/runtime"
"k8s.io/apiserver/pkg/registry/rest"
rbacv1 "k8s.io/client-go/kubernetes/typed/rbac/v1"
restclient "k8s.io/client-go/rest"
"k8... |
db963226ea00fea69de981d904fb5f3d2bc635e2 | 75258069ec93ff37ddb713187674c84395aed023 | kschiffer/lorawan-stack | /pkg/events/builder.go | Go | go | 3,018 | permissive | // Copyright © 2020 The Things Network Foundation, The Things Industries B.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
//
// Un... |
9e2d06206eca0690e27e85c611494ab13e7bd89c | 171757318cf692a6de87cb3dc11058127efadfc3 | gabsilcos/projetos-go | /src/github.com/user/servidor_web/main.go | Go | go | 612 | no_license | package main
import (
"fmt"
"net/http"
"github.com/user/servidor_web/manipulador"
)
func main() {
http.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) {
fmt.Fprintln(w, "Olá Mundo!") //F print recebe uma fç
})
http.HandleFunc("/funcao", manipulador.Funcao) //não é necessário, várias rotas com s... |
8b79058390b3cf38f74f46607977eeb791e00afb | 8ede3fa535f572aaf0c8eb61ec3c68a6e2a57afb | daviresio/ajuda-desk-sync-database | /model/base.go | Go | go | 203 | no_license | package model
import "time"
type BaseModel struct {
Id uint64 `json:"id"`
CreatedAt time.Time `json:"created_at"`
UpdatedAt time.Time `json:"updated_at"`
DeletedAt *time.Time `json:"deleted_at"`
}
|
9f1e5566c89c6bb371989fa011e2505c70804e17 | 93e9782d179cb410ddc5f373677e0055f6b25327 | mogaika/god_of_war_browser | /pack/wad/scr/store/sstore.go | Go | go | 533 | no_license | package store
import "github.com/mogaika/god_of_war_browser/pack/wad"
type ScriptLoader func([]byte, *wad.WadNodeRsrc) (interface{}, error)
type ScriptContentJsonLoader interface {
FromJSON(wrsrc *wad.WadNodeRsrc, data []byte) ([]byte, error)
}
var gScriptLoaders = make(map[string]ScriptLoader, 0)
func AddScriptL... |
dd2f74b20daeea00260b354f0e0fff28469f06ca | 8df4d61eadb81e159fbf5442531be0ff958d2572 | hongyucai/easy-server | /gateway/supports/log_settings.go | Go | go | 2,369 | no_license | package supports
import (
"fmt"
"log"
"os"
"strings"
"time"
"github.com/kataras/golog"
"github.com/kataras/iris/v12"
"github.com/kataras/iris/v12/middleware/logger"
)
const (
deleteFileOnExit = false // 进程退出是否关闭当前日志文件
sysTimeform = "2006/01/02 - 15:04:05"
sysTimeformShort = "2006-01-02"
dir ... |
f4726d8ec3d697aad8475a22459b17c27f87416a | f7f1132a374937793a9d49bffb320549e8b87877 | rubyist/go-dnsimple | /dnsimple_test.go | Go | go | 2,079 | permissive | package dnsimple
import (
"encoding/json"
"io/ioutil"
"net/http"
"net/http/httptest"
"net/url"
"reflect"
"testing"
)
var (
mux *http.ServeMux
client *DNSimpleClient
server *httptest.Server
)
// This method of testing http client APIs is borrowed from
// Will Norris's work in go-github @ https://github.c... |
b4766d5b08cf41598105db63d66be68aa7212844 | b7680aff4b5038061b9408c9cd0b98daf2c4b9fb | danilNikolaenko1990/sitemap_stat | /stat/measurer_mock_test.go | Go | go | 724 | no_license | package stat
import (
"sitemap_stat/domain"
)
const (
TestSite = "site"
TestResponseTimeInMilliseconds = 1
TestStatusCode = 200
TestError = "error"
TestTimeFromStartToFirstByte = 2
)
type MeasurerMock struct {
RecordedPassedData []string
}
func (m ... |
70bb99a1537d2c8ca82e039ed173ded84eba7883 | 2f12f034a92398addaadd239a2738ed2eaac662d | pauleyj/gobee | /_examples/echo/cmd/server/server.go | Go | go | 3,620 | permissive | package server
import (
"fmt"
"github.com/pauleyj/gobee"
"github.com/pauleyj/gobee/_examples/echo/cmd/common"
"github.com/pauleyj/gobee/api"
"github.com/pauleyj/gobee/api/rx"
"github.com/pauleyj/gobee/api/tx"
"github.com/tarm/serial"
"reflect"
"time"
)
// NewEchoServer constructs a new echo server
func NewEc... |
6f2ec653652bac4fda2eab90b4910761a5e560ce | 0dca0b919d82df69cac93e1ea0b5e7876ff3231c | kkirsche/chezmoi | /cmd/unmanaged.go | Go | go | 941 | permissive | package cmd
import (
"fmt"
"os"
"path/filepath"
"strings"
"github.com/spf13/cobra"
vfs "github.com/twpayne/go-vfs"
)
var unmanagedCmd = &cobra.Command{
Use: "unmanaged",
Args: cobra.NoArgs,
Short: "List the unmanaged files in the destination directory",
RunE: makeRunE(config.runUnmanagedCmd),
}
func i... |
8fcbfe8a98fa1f1f91769151fc211d3a5cbe38f9 | 9eaee9f2515879d4bbb20e2252811da083952b91 | livbarn/iris | /context/configuration.go | Go | go | 4,533 | permissive | package context
// ConfigurationReadOnly can be implemented
// by Configuration, it's being used inside the Context.
// All methods that it contains should be "safe" to be called by the context
// at "serve time". A configuration field may be missing when it's not
// safe or its useless to be called from a request han... |
f04d7866f1fb520ec5ed8899d74c1a8912260bb8 | bf4c7e520f392f975c6b83a4ec8836aa73e01b21 | t4rest/mail | /2/0_funcs/1_closures/closures.go | Go | go | 240 | no_license | package main
import (
"fmt"
"time"
)
func main() {
myTimer := getTimer()
f := func() {
myTimer()
}
f()
}
func getTimer() func() {
start := time.Now()
return func() {
fmt.Printf("Time from start %v", time.Since(start))
}
}
|
d2cfe7652d9dbd1bb458516d4d3aa0e961404c28 | dee7aefe9c3d10ebc7a0c20b6d7c61414b293008 | oliverdding/OJiG | /leetcode/48-rotate-image/solution.go | Go | go | 431 | permissive | package leetcode
/*
对角线,左右镜面旋转
*/
func rotate(matrix [][]int) {
n := len(matrix)
for row := 0; row < n; row++ {
for col := 0; col < n-row; col++ {
matrix[row][col], matrix[n-col-1][n-row-1] = matrix[n-col-1][n-row-1], matrix[row][col]
}
}
for col := 0; col < n; col++ {
for row := 0; row < n/2; row++ {
... |
911fbadc8918bcd4ea05fa507f607ec4240da5d7 | 49ade7f77311c048003b08c8933042b2bde08f9c | richardtector/pipeline | /pipeline.go | Go | go | 18,927 | permissive | //
// January 2016, cisco
//
// Copyright (c) 2016 by cisco Systems, Inc.
// All rights reserved.
//
//
// Code orchestrating the various bits of the pipeline
//
// Go generate directives. Think of this as limited makefile. Some
// autogeration of source is required. Currently, we have:
//
// - autogeneration of .pb.g... |
a4b2baa6e4ddc05e855002ced49cd2e9c1ca8867 | 21300110b8c2b381c29c582030c9a6a3f9379e88 | mcastelino/virtcontainers | /sshd.go | Go | go | 4,028 | permissive | //
// Copyright (c) 2016 Intel Corporation
//
// 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... |
51a9459e07a15f8ad702ded5539e68eceb8fccb8 | 8d3a0b158c6f0422b78ca0165f34d643714d7202 | kode4food/ale | /internal/assert/testenv.go | Go | go | 655 | permissive | package assert
import (
"github.com/kode4food/ale/compiler/encoder"
"github.com/kode4food/ale/core/bootstrap"
"github.com/kode4food/ale/env"
)
var testEnv = bootstrap.DevNullEnvironment()
// GetTestEnvironment returns an immutable root testing Environment
func GetTestEnvironment() *env.Environment {
return testE... |
a08454f3b4329061b34eacd805d48d9116c85051 | 7a0db1ccfe53be0013354880a92472c447808b37 | Theodoree/tools | /leekcode/go/1400-1499/1464.go | Go | go | 364 | no_license | package _400_1499
import "sort"
/*
1464. 数组中两元素的最大乘积
给你一个整数数组 nums,请你选择数组的两个不同下标 i 和 j,使 (nums[i]-1)*(nums[j]-1) 取得最大值。
请你计算并返回该式的最大值。
*/
func maxProduct(nums []int) int {
sort.Ints(nums)
return (nums[len(nums)-1] - 1) * (nums[len(nums)-2] - 1)
}
|
b8d7ff8880f1ee6c93380352e42a26775c75b8f8 | acee3d86ccb28e47c67c7f9a23623e53c386a9e8 | eroatta/src-reader | /port/outgoing/adapter/algorithm/splitter/conserv.go | Go | go | 791 | permissive | package splitter
import (
"strings"
"github.com/eroatta/src-reader/entity"
"github.com/eroatta/token/conserv"
)
// NewConservFactory creates a new Conserv splitter factory.
func NewConservFactory() entity.SplitterFactory {
return conservFactory{}
}
type conservFactory struct{}
func (f conservFactory) Make(mini... |
9f10c2d25c76cea3a0ca015a4c41aaf68d0ecafa | 735b99e56ca7c0335c754aafbcf85f29a0def506 | DmitryPrischep/Course-Project-of-Data-Base | /handlers/thread.go | Go | go | 4,041 | no_license | package handlers
import (
"encoding/json"
"io/ioutil"
"net/http"
"github.com/DmitriyPrischep/Course-Project-of-Data-Base/database"
"github.com/DmitriyPrischep/Course-Project-of-Data-Base/models"
"github.com/go-openapi/swag"
"github.com/gorilla/mux"
)
func GetThread(w http.ResponseWriter, r *http.Request) {
p... |
eeb6f6664fb7885f190fb3726683333b5d30c4ae | a5b528be04ab718a3bb0d78cb53d3c2bf25ca37e | kyberorg-lab/go-api | /api/profile.go | Go | go | 592 | permissive | package api
import (
"github.com/gin-gonic/gin"
"go-rest/app"
tokenService "go-rest/app/token"
"net/http"
)
type Profile struct {
Username string `json:"username"`
Permissions []string `json:"permissions"`
}
func GetProfileEndpoint(context *gin.Context) {
tokenClaims, _ := tokenService.GetToken(context)
... |
f51d0cd203b57e034b2b0f302a81424fc3fbcee9 | d98e9fab4830b4791fc591b21bbfca3885f9367b | monasuite/lnd | /contractcourt/briefcase.go | Go | go | 42,698 | permissive | package contractcourt
import (
"bytes"
"encoding/binary"
"fmt"
"io"
"github.com/btcsuite/btcd/btcec/v2/ecdsa"
"github.com/btcsuite/btcd/chaincfg/chainhash"
"github.com/btcsuite/btcd/txscript"
"github.com/btcsuite/btcd/wire"
"github.com/lightningnetwork/lnd/kvdb"
"github.com/monasuite/lnd/channeldb"
"github... |
98017bfc0b9f998ab716f3f058691caa2f5a2292 | 7b28e9e0e9f42211cd1dcb5ba79dbb50d7241ca5 | 8treenet/iris | /_examples/http_responsewriter/quicktemplate/controllers/index.go | Go | go | 368 | permissive | package controllers
import (
"github.com/8treenet/iris/v12/_examples/http_responsewriter/quicktemplate/templates"
"github.com/8treenet/iris/v12"
)
// Index renders our ../templates/index.qtpl file using the compiled ../templates/index.qtpl.go file.
func Index(ctx iris.Context) {
tmpl := &templates.Index{}
// re... |
1f6e76db4a084e3a5bce2df195f7b059592d6bfe | d7c39984bac487826a6e749dc3d2d7c2451b713d | Zenozhouzhao/evans | /logger/logger.go | Go | go | 1,471 | permissive | // Package logger provides logging functions.
// As default, logger discards all passed messages. See SetOutput for more details.
package logger
import (
"io"
"io/ioutil"
"log"
)
var (
defaultLogger = newDefaultLogger()
enabled bool
)
// Reset resets logging all parameters.
func Reset() {
defaultLogger =... |
0dc6f2e60e42c69374d713543a2595647386bbfc | 16aced78cce4db8ce6562a1b0391914791bfddb9 | swarmfund/swarm-psim | /psim/balancereporter/main.go | Go | go | 973 | no_license | package balancereporter
import (
"context"
"gitlab.com/distributed_lab/figure"
"gitlab.com/distributed_lab/logan/v3/errors"
"gitlab.com/swarmfund/psim/psim/app"
"gitlab.com/swarmfund/psim/psim/conf"
"gitlab.com/swarmfund/psim/psim/utils"
)
func init() {
app.RegisterService(conf.BalanceReporterService, setupSe... |
2d2726016477dad72df67dece7a7a5a6648598d4 | da2a221fa0badaf88de377980f58bc7ebb6d9e1f | p9c/podlegacy | /wire/msginv.go | Go | go | 4,531 | permissive | package wire
import (
"fmt"
"io"
)
// defaultInvListAlloc is the default size used for the backing array for an inventory list. The array will dynamically grow as needed, but this figure is intended to provide enough space for the max number of inventory vectors in a *typical* inventory message without needing to ... |
66045f1680a6d7f8b540325225c55b97982d5ba0 | bb3a8637f356a24cea588e1027b796b4bf56cb3c | salvador-dali/unnamed | /psql/psql.go | Go | go | 1,904 | no_license | // Package storage is responsible for all database operations
package psql
import (
"../config"
"../misc"
"database/sql"
"errors"
"fmt"
"github.com/lib/pq"
"log"
)
var Db *sql.DB
// Init prepares the database abstraction for later use
func Init() {
// It does not establish any connections to the database, no... |
93ac3ea49548367e13408515721c4b90aded4188 | b919a8f0bf6b5f9a9f663851efd526d0bf7d83f8 | dockerizer/linuxkit | /src/cmd/linuxkit/pkglib/build.go | Go | go | 2,904 | permissive | package pkglib
import (
"fmt"
"os"
"runtime"
)
type buildOpts struct {
force bool
push bool
}
// BuildOpt allows callers to specify options to Build
type BuildOpt func(bo *buildOpts) error
// WithBuildForce forces a build even if an image already exists
func WithBuildForce() BuildOpt {
return func(bo *buildO... |
77e71e6c27db82ee18199843f5c8605107647fa1 | 1a1672fc974aa112d7abc89dfb08e042fac2d2d9 | joe223/thriftgo | /plugin/plugin.go | Go | go | 4,493 | permissive | // Copyright 2021 CloudWeGo Authors
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to... |
d46d08a372b5821c6911b9146b8b9ae82f186283 | a2dcb35644f074e5e0d881d0d70d0c44bc67bc6f | wangzhongcan654/onecloud | /pkg/mcclient/modules/mod_images.go | Go | go | 17,990 | permissive | // Copyright 2019 Yunion
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writi... |
2431c9a0a440cf65fe65de921bb9722d13a6d016 | 6fbd55832f1b3abb36f201ccb94e35b35491c839 | IntrntSrfr/meido-old | /bot/commands/unban.go | Go | go | 637 | no_license | package commands
import (
"fmt"
"github.com/intrntsrfr/meido/bot/service"
"github.com/bwmarrin/discordgo"
)
func (ch *CommandHandler) unban(args []string, ctx *service.Context) {
if len(args) <= 1 {
return
}
userID := args[1]
err := ctx.Session.GuildBanDelete(ctx.Guild.ID, userID)
if err != nil {
retu... |
da90eebc7b844a6dcb3d67aa0c6213b13de9527b | 877a7e6ad46b650a54a652cdbcc7577b9dc0c978 | mcasper/climbpro-go | /game/utility_test.go | Go | go | 2,228 | no_license | package game
import (
"testing"
)
func TestAtFinishLine(t *testing.T) {
piece := Piece{
Shape: "square",
Coordinates: []Coordinate{
Coordinate{
X: 1,
Y: 0,
},
Coordinate{
X: 2,
Y: 0,
},
Coordinate{
X: 1,
Y: 1,
},
Coordinate{
X: 1,
Y: 2,
},
},
}
if !at... |
6aecf9ca6f2ff5cd1894259418bd7c8f27d4599d | 77c25ba7ee747e387afa5a6e0b08e36eba22ae15 | vbaksa/promoter | /vendor/golang.org/x/net/context/ctxhttp/ctxhttp_test.go | Go | go | 4,090 | permissive | // Copyright 2015 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.
// +build !plan9
package ctxhttp
import (
"io/ioutil"
"net"
"net/http"
"net/http/httptest"
"sync"
"testing"
"time"
"golang.org/x/net/context"
)
cons... |
20c02811dd67bc0f543b5e2ab09b278134df9755 | 09186957ec5f401a711bd1cbc9e2789d75187a23 | vshn/logging-operator | /pkg/model/output/oss.go | Go | go | 4,875 | permissive | // Copyright © 2019 Banzai Cloud
//
// 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 i... |
42cc05ae59a8858afdf2f131735964bffa3a34fc | 7f23b114c771582894688865c514a3d0b3d27951 | petrosagg/matasano | /set1/problem1/main.go | Go | go | 1,484 | no_license | package problem1
import (
"bytes"
"flag"
"fmt"
)
func getB64Char(c byte) byte {
switch {
case 0 <= c && c <= 25:
return c + 'A'
case 26 <= c && c <= 51:
return c + 'a' - 26
case 52 <= c && c <= 61:
return c + '0' - 52
case c == 62:
return '+'
case c == 63:
return '/'
}
return '*'
}
func B64Encod... |
a798f605d0c22158dfc86ff8876b9c89cafab83d | df276ea22610332a0feaa75ba9b22e02d50d0f6c | werf/werf | /cmd/werf/cr/login/login.go | Go | go | 4,440 | permissive | package login
import (
"context"
"fmt"
"os"
"path/filepath"
"github.com/spf13/cobra"
"golang.org/x/crypto/ssh/terminal"
"oras.land/oras-go/pkg/auth"
"oras.land/oras-go/pkg/auth/docker"
"github.com/werf/logboek"
"github.com/werf/werf/cmd/werf/common"
secret_common "github.com/werf/werf/cmd/werf/helm/secret... |
6de98c92e4e84a346dbb4099486cc7f5ed5124b5 | 0bbfa69bb025e26a9cc708a9e162720ecca3f2f3 | yuenjee/fabric-ledgerone | /core/ledger/kvledger/kv_ledger_provider.go | Go | go | 11,381 | permissive | /*
Copyright IBM Corp. All Rights Reserved.
SPDX-License-Identifier: Apache-2.0
*/
package kvledger
import (
"bytes"
"errors"
"fmt"
"github.com/golang/protobuf/proto"
"github.com/ledgerone/fabric-ledgerone/common/ledger/util/leveldbhelper"
"github.com/ledgerone/fabric-ledgerone/core/ledger"
"github.com/ledge... |
1baeea23f0b13c8506575ece7389f7bf2ff0e9f5 | b8e641514c4e9a48927ca156b037161821872783 | AKovalevich/goth | /providers/vk/session.go | Go | go | 1,593 | permissive | package vk
import (
"encoding/json"
"errors"
"strings"
"time"
"github.com/AKovalevich/goth"
)
// Session stores data during the auth process with VK.
type Session struct {
AuthURL string
AccessToken string
ExpiresAt time.Time
userID int64
email string
}
// GetAuthURL returns the URL for t... |
a4f110061a77ecc480d1e5df018a4697cdc127a1 | 6aabf3cb05f04c2fe16646ba107f6b4bd6257490 | irisnet/irishub-sync | /store/document/tx.go | Go | go | 3,881 | no_license | package document
import (
"github.com/irisnet/irishub-sync/store"
"gopkg.in/mgo.v2"
"gopkg.in/mgo.v2/bson"
"time"
)
const (
CollectionNmCommonTx = "tx_common"
TxStatusSuccess = "success"
TxStatusFail = "fail"
Unknow_Status = "unknown"
Tx_Field_Hash = "tx_hash"
Tx_Field_Type = "type"... |
38752868f1fb011c92d4b7b1c15211ea3c4530f8 | a64e6bf15ce34844788aab132c37a8bbe92ca0d5 | alexanderbez/titan | /core/db.go | Go | go | 5,030 | permissive | package core
import (
"context"
"fmt"
"os"
"time"
"github.com/alexanderbez/titan/config"
"github.com/dgraph-io/badger"
)
const (
// Default BadgerDB discardRatio. It represents the discard ratio for the
// BadgerDB GC.
//
// Ref: https://godoc.org/github.com/dgraph-io/badger#DB.RunValueLogGC
badgerDiscard... |
6f79fd097ac9832aa318471ff182443b215a5c68 | 736f08dc374dfa9c8ef8db3ca8a91f99329bcb98 | wrightrocket/fizzle | /examples/testscene/visibleentity.go | Go | go | 831 | permissive | // Copyright 2016, Timothy Bogdala <tdb@animal-machine.com>
// See the LICENSE file for more details.
package main
import (
fizzle "github.com/tbogdala/fizzle"
scene "github.com/tbogdala/fizzle/scene"
)
// RenderableEntity is an interface for entities that have a renderable to draw.
type RenderableEntity interface... |
2cf1e622a3ad09a7cde7c32ce647ce7be6e3ca67 | 4b3c557c15a4d2e7d3db77da771971c0886c8ed9 | StenaIT/carl-guild-group2-todo | /db.go | Go | go | 1,334 | no_license | package main
import (
"log"
"gopkg.in/mgo.v2"
)
func createDbSession() (*mgo.Session, error) {
return mgo.Dial("localhost")
}
//Insert TodoItem to db
func Insert(item TodoItem) error {
log.Println("Adding item")
session, err := createDbSession()
if err != nil {
return err
}
defer session.Close()
c := se... |
75d1e155ce35c5e05e96a41d819a5d2c1448da02 | 566f3d3e137bf60cd4509469080189d31b416ead | ossf/scorecard | /attestor/command/sign.go | Go | go | 3,824 | permissive | // Copyright 2022 OpenSSF Scorecard Authors
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agr... |
5a53972eb6b5406467c3a7ee3841686cb148d445 | 1133515257edb66bc4bc08e24fea85afc164c1eb | kampofo/go-learning | /ninja_level-006/001/main.go | Go | go | 237 | no_license | package main
import "fmt"
func main() {
fmt.Println(foo())
fmt.Println(bar())
}
// fucntion returns an int
func foo() int {
return 5
}
// function returns both an int and a string
func bar() (int, string) {
return 2, "hello"
}
|
e4f22aaf869ca823d069cefdcec0f7703c3bfd85 | df6f3f047328c024eb92ccf17560469078fa19a7 | wdaglb/jenkins-cli | /app/cmd/job_edit.go | Go | go | 5,982 | permissive | /*
MIT License
Copyright (c) 2019 Zhao Xiaojie
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, d... |
b111a0d6d25cfb98e46c1eca282ee88a7d0fceba | 84dd773d8fece2eed9ce60285d920eae0c78f776 | hans-d/coredhcp | /cmds/coredhcp/main.go | Go | go | 3,883 | permissive | // Copyright 2018-present the CoreDHCP Authors. All rights reserved
// This source code is licensed under the MIT license found in the
// LICENSE file in the root directory of this source tree.
// This is a generated file, edits should be made in the corresponding source file
// And this file regenerated using `coredh... |
68415609026a1a85df5a323d6f16d24df3436868 | 80bc1b8bfb12a93f44dbb9d5d96675692db624df | tengrommel/go_jobs | /ch05/example/example6/main.go | Go | go | 228 | no_license | package main
import (
"time"
"fmt"
)
type Cart struct {
name string
age int
}
type Train struct {
Cart
int
start time.Time
}
func main() {
var t Train
t.name = "fuck"
t.Cart.age = 34
t.int = 200
fmt.Println(t)
}
|
f90be8fb7b8d694cdddc2d7bb267daf95e869a75 | f0750eb72162fd44e517bec8a422838c5f88cfbe | frankneu/leetcode | /src/leetcode/Question17LetterCombinations.go | Go | go | 1,005 | no_license | package main
import "strings"
var NUMBERS = map[int]string{
50: "abc",
51: "def",
52: "ghi",
53: "jkl",
54: "mno",
55: "pqrs",
56: "tuv",
57: "wxyz",
}
func letterCombinations(digits string) []string {
var result []string
var values []string
var index = make([]int, len(digits))
for i := 0; i < len(digits... |
eaf705cc67e6375b019fda94f6e84fb612d3f212 | 8eccc2ce8fd3a091473ed8c27cee3ac8ff91915e | xingchenzck/my-data-authentication-system- | /DataCertProjest/blockchain/block.go | Go | go | 1,366 | no_license | package blockchain
import (
"bytes"
"encoding/gob"
"time"
)
type Block struct {
Height int64 //区块高度
TimeStamp int64 //时间戳
Hash []byte //区块的hash
Data []byte // 数据
PrevHash []byte //上一个区块的Hash
Version string //版本号
Nonce int64 //随机数,用于pow工作量证明算法计算
}
/**
生成创世区块,返回区块信息
*/
func CreateGen... |
741ca495b6c0a2b41853ddf66e114c758d8872be | b4811ba7119deb9048ae4788937c2135f36ef216 | ahmadrezamusthafa/assessment | /domain/repository/orderproduct/model.go | Go | go | 380 | no_license | package orderproduct
import "time"
type OrderProduct struct {
ID string `db:"id" json:"id"`
OrderID string `db:"order_id" json:"order_id"`
ProductID string `db:"product_id" json:"product_id"`
Qty int `db:"qty" json:"qty"`
CreatedAt time.Time `db:"created_at" json:"created_at"`
... |
d51f020de8e3f6c82bc6a0cabd5790e3c042bba2 | ed4e8b9f5b88d8e3f7c03d675abbec8452e8c985 | caoruidong/containerd | /services/server/server.go | Go | go | 13,593 | permissive | /*
Copyright The containerd Authors.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to... |
163c032c0099fe9778d029d6525b26ec2c22201d | e0474b0f3d1928744bddde40ff0b8959fddffb59 | srkgupta/mmctl | /vendor/github.com/splitio/go-toolkit/v4/sse/event.go | Go | go | 2,734 | permissive | package sse
import (
"strconv"
"strings"
"sync"
)
const (
sseDelimiter = ":"
sseData = "data"
sseEvent = "event"
sseID = "id"
sseRetry = "retry"
)
// RawEvent interface contains the methods that expose the incoming SSE properties
type RawEvent interface {
ID() string
Event() string
Dat... |
754a107e29e63d292518f344b262fba8cbdc2d74 | 57fbcfed3d021274861aa52f6da5c79d4d5b8638 | m-lukas/github-analyser | /db/redis.go | Go | go | 1,890 | no_license | package db
import (
"os"
"strconv"
"github.com/m-lukas/github-analyser/logger"
"github.com/m-lukas/github-analyser/util"
"github.com/go-redis/redis"
)
//RedisClient contains the redis db client and its config
type RedisClient struct {
Client *redis.Client
Config *RedisConfig
}
//RedisConfig contains config ... |
e60869c1d9202929e542ae8a4f4118ebb0dddcf5 | 05bf646baa9f4c5a02e6da749eacb833cdfa170b | terjesannum/loki | /pkg/storage/stores/composite_store.go | Go | go | 7,873 | permissive | package stores
import (
"context"
"sort"
"github.com/prometheus/common/model"
"github.com/prometheus/prometheus/model/labels"
"github.com/grafana/loki/pkg/iter"
"github.com/grafana/loki/pkg/logproto"
"github.com/grafana/loki/pkg/logql"
"github.com/grafana/loki/pkg/storage/chunk"
"github.com/grafana/loki/pkg... |
f1f00d547164f48e377ec104b83bd1fa2b5ef561 | 754ae51bb0eeaa3b064b0ae30a8c8f3b07a80a09 | kjm0001/m3db | /src/coordinator/ts/series.go | Go | go | 3,937 | permissive | // Copyright (c) 2018 Uber Technologies, Inc.
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge... |
4d5c95e4c890700aa255025891832d5dc1b12930 | ffd4c156c726e148e06f34dc2735733174bd4359 | velut/fsutils-go | /magefile.go | Go | go | 831 | permissive | // +build mage
package main
import (
"fmt"
"github.com/magefile/mage/mg"
"github.com/magefile/mage/sh"
)
// Test tests the fs library.
func Test() error {
mg.Deps(InstallDeps)
fmt.Println("Testing...")
return sh.Run("go", "test", "-v", "-race", "./fs")
}
// Lint lints the fs library.
func Lint() error {
fm... |
e4ff0183c8a4f7ed2133cfb554eda9c4a9ebc5ee | f6511ea6f0648f3f79c0405368291041fd5ea7d0 | Jimdo/observatory-exporter | /vendor/github.com/carlpett/stream_exporter/linemetrics/config.go | Go | go | 611 | permissive | package linemetrics
import (
"time"
)
type metricKind string
const (
counter metricKind = "counter"
gauge metricKind = "gauge"
histogram metricKind = "histogram"
summary metricKind = "summary"
)
type MetricsConfig struct {
Name string
Kind metricKind
Pattern string
HistogramConfig `yaml:",in... |
f7447456d782d8904731ecf81888bcc99b4ca0b3 | 2e7be088d0535992468c8c2ac561a11aef608510 | isgasho/kruise | /test/e2e/e2e.go | Go | go | 9,204 | no_license | /*
Copyright 2019 The Kruise Authors.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, soft... |
ecd6efc23952b581ed197c23bff2a612872485a2 | b44609e5c2639a3b22e81fe22e3298ea1e81d314 | wicoady1/tri-reso-encoder-script | /operations/video_encoding.go | Go | go | 3,892 | no_license | package operations
import (
"fmt"
"log"
"os"
"path/filepath"
"time"
"github.com/floostack/transcoder/ffmpeg"
"github.com/wicoady1/tri-reso-encoder-script/config"
ui "github.com/gizak/termui/v3"
"github.com/gizak/termui/v3/widgets"
)
type Operations struct {
conf *config.Config
progressInfo *widge... |
98af47bf8c4e8e81f19443759ce9990815b3a745 | 848a00c8671696f0ba3b8dab57546a4c222c4ccc | AmarjitGhuman/aistore | /ais/tests/multiproxy_test.go | Go | go | 54,541 | permissive | // Package integration contains AIS integration tests.
/*
* Copyright (c) 2018-2020, NVIDIA CORPORATION. All rights reserved.
*/
package integration
import (
"errors"
"fmt"
"math/rand"
"net/http"
"net/url"
"path/filepath"
"reflect"
"strings"
"sync"
"testing"
"time"
"github.com/NVIDIA/aistore/api"
"gith... |
a93012e1c4ad87bd4414d0a48b0cd37816e6f553 | 8b050facc4ace2659d5ad3737ee0ee229351c627 | microsoftgraph/msgraph-beta-sdk-go | /identitygovernance/access_reviews_definitions_item_instances_item_decisions_item_instance_stop_apply_decisions_request_builder.go | Go | go | 4,933 | permissive | package identitygovernance
import (
"context"
i2ae4187f7daee263371cb1c977df639813ab50ffa529013b7437480d1ec0158f "github.com/microsoft/kiota-abstractions-go"
i20a3050780ee0b0cde0a884a4f35429a20d60067e3bcda382ec5400079147459 "github.com/microsoftgraph/msgraph-beta-sdk-go/models/odataerrors"
)
// AccessRevie... |
039f63b9a2c464a949fa9485e9c04faf7b98f4d4 | 5f08fa900e22e718af4ad8a698131269b05de769 | gr4yha7/rod | /lib/examples/compare-chromedp/eval/main.go | Go | go | 483 | permissive | package main
import (
"log"
"github.com/go-rod/rod"
)
// This example shows how we can use Eval to run scripts in the page.
// Note: `this` in the eval function will refer to the element that Eval is
// called on. This can be useful for things such as blurring elements.
func main() {
browser := rod.New().Connect... |
bf9582158ec785c836f8934c5547973b5ed594d6 | 725b6faeae7503200f45d0172759f5f438ea06a8 | ylogx/gophrase | /pkg/words_test.go | Go | go | 1,035 | permissive | package pkg
import "testing"
func Test_ensureWordListExists_DataExists_DoNoting(t *testing.T) {
inputVocab := []string{"hgfe", "dcba"}
vocab := &english{wordsData: inputVocab}
err := vocab.ensureWordListExists()
words := vocab.words()
if err != nil {
t.Fatalf("Expected error to be nil but got %q", err)
}
i... |
0a62c2acaacab0fa298f062486856bc3364cd5b2 | 679f8c5430998e48865981c28861ca20096b957b | vrealzhou/lambda-local | /internal/template/process_test.go | Go | go | 756 | permissive | package template
import (
"testing"
"time"
)
func TestParse(t *testing.T) {
// Open a template from file (can be JSON or YAML)
functions, err := Parse("/Users/zhouy4l/go/src/stash.abc-dev.net.au/ter/serverless-event-management/deployments/aws/ingestor-sam.yaml", map[string]string{
"HostEnv": "staging",
... |
efe7c492de8afd3e8750cee573af928991a4287c | 1405bf64a09cbd41aad0029cecdf7314d3af9006 | haishenming/exercise_from_LeetCode | /0011_ContainerWthMostWater/LeetCode_11_040.go | Go | go | 1,236 | no_license | package _011_ContainerWthMostWater
import "fmt"
//给定 n 个非负整数 a1,a2,...,an,每个数代表坐标中的一个点 (i, ai) 。在坐标内画 n 条垂直线,垂直线 i 的两个端点分别为 (i, ai) 和 (i, 0)。找出其中的两条线,使得它们与 x 轴共同构成的容器可以容纳最多的水。
//
// 说明:你不能倾斜容器,且 n 的值至少为 2。
//
//
//
// 图中垂直线代表输入数组 [1,8,6,2,5,4,8,3,7]。在此情况下,容器能够容纳水(表示为蓝色部分)的最大值为 49。
//
//
//
// 示例:
//
// 输入: [1,8,6,2,5... |
09e7cd9f8ff6c76425d4e28b022ceab7b0a84c5f | 891d24fe1465bba10d66c0aa9ddb3dbc6535598a | coco-roll/websocket-demo | /main.go | Go | go | 355 | no_license | package main
import (
"net/http"
"demo/routers"
"demo/setting"
"fmt"
)
func main() {
router := routers.InitRouter()
s := &http.Server{
Addr: fmt.Sprintf(":%d", setting.HTTPPort),
Handler: router,
ReadTimeout: setting.ReadTimeout,
WriteTimeout: setting.WriteTimeout,
MaxHeaderBytes... |
c0f4e7ddbb0f200643a111e5b95042c7bec62a79 | 6821c39f0cc7d1be736dd533099f12b747fd07e2 | barismar/goyave | /websocket/websocket_test.go | Go | go | 17,082 | permissive | package websocket
import (
"errors"
"fmt"
"net/http"
"net/http/httptest"
"strings"
"sync"
"testing"
"time"
ws "github.com/gorilla/websocket"
"goyave.dev/goyave/v3"
"goyave.dev/goyave/v3/config"
)
type WebsocketTestSuite struct {
goyave.TestSuite
previousTimeout int
}
func (suite *WebsocketTestSuite) Se... |
31723c5376470ec538f82990a5d550ea340c9743 | 9d627ae266ddd4f32055acfee1ddf3c0849403fd | weiqiangzheng/tidb | /expression/integration_test.go | Go | go | 179,622 | permissive | // Copyright 2017 PingCAP, Inc.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to i... |
70eaf70cf87e0800afca3a1d4c85aa30e909f354 | 3994eac712dbbd83300d98475fb7ab51b5a56d0a | RcrdBrt/redisbank | /user.go | Go | go | 2,861 | no_license | // Package redisbank provides an API for a banking system on top of Redis.
package redisbank
import (
"golang.org/x/crypto/bcrypt"
"log"
)
func userExists(username string) bool {
return r.HExists("user_ids", username).Val()
}
// GetUserID returns the username unique (incremental) ID as a string.
func GetUserID(us... |
ed4715a0cc789f6008d52297a70058f3786b6476 | abd24e80ba81b22c4a2c40330bb7144a3bd78bc0 | fsyangjie/swag | /gen/gen_test.go | Go | go | 3,134 | permissive | package gen
import (
"os"
"path"
"testing"
"github.com/stretchr/testify/assert"
)
func TestGen_Build(t *testing.T) {
searchDir := "../testdata/simple"
config := &Config{
SearchDir: searchDir,
MainAPIFile: "./main.go",
OutputDir: "../testdata/simple/docs",
PropNamingStrategy: "... |
f6a4d14c842c854370e0b3a381edf4911d5b2596 | 560025d473e9bba85a47519075a2fdfed1aa00da | wahello/bull | /ent/schema/user.go | Go | go | 657 | no_license | package schema
import (
"time"
"github.com/facebook/ent"
"github.com/facebook/ent/schema/field"
)
// User holds the schema definition for the User entity.
type User struct {
ent.Schema
}
// Fields of the User.
func (User) Fields() []ent.Field {
return []ent.Field{
field.String("first_name").Default(""),
fi... |
e1764b470bf586774a3f0f6511c35913a156e02b | 005c8683daf18c7cde8378e9b8fa89f30c41d63b | Ingensi/dockbeat | /vendor/github.com/docker/engine-api/types/types.go | Go | go | 17,290 | permissive | package types
import (
"os"
"time"
"github.com/docker/engine-api/types/container"
"github.com/docker/engine-api/types/mount"
"github.com/docker/engine-api/types/network"
"github.com/docker/engine-api/types/registry"
"github.com/docker/engine-api/types/swarm"
"github.com/docker/go-connections/nat"
)
// Contai... |
daa848ecf5613ac9b4d2305789c934550e548a9d | 0b6b8e01520c0ae21d93d3f4790a90099af56c37 | awinlei/cellnet | /kcp/acceptor.go | Go | go | 1,457 | permissive | package kcp
import (
kcp "github.com/xtaci/kcp-go"
"github.com/davyxu/cellnet"
"github.com/davyxu/cellnet/extend"
"net"
)
type kcpAcceptor struct {
*kcpPeer
listener net.Listener
}
func (k *kcpAcceptor) Start(address string) cellnet.Peer {
if k.IsRunning() {
return k
}
k.SetAddress(address)
var err e... |
b54e173ceb9297f6a3e7e0bd267e521bef0055de | 9e4d0dba6ee2ee948025e8ccc434724670a6502c | golang/tools | /cmd/guru/implements.go | Go | go | 10,013 | permissive | // Copyright 2013 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 main
import (
"fmt"
"go/ast"
"go/token"
"go/types"
"reflect"
"sort"
"strings"
"golang.org/x/tools/cmd/guru/serial"
"golang.org/x/tools/go/loa... |
e00c48530b7bf13363b440f4910dc6c4cd80e40b | 9f501d80cab2e4ba219d206d0a7d9559b996a48e | mdanzinger/prevalentify | /pkg/input/file.go | Go | go | 865 | no_license | package input
import (
"bufio"
"context"
"fmt"
"os"
"prevalentify"
)
const defaultBuffer = 50
// FromFile returns an input generator that generates the input from a file.
func FromFile(file string) (prevalentify.InputGenerator, error) {
f, err := os.Open(file)
if err != nil {
return nil, fmt.Errorf("error o... |
974358a2f03332379f2dd13b6a28759c70464452 | 2b1b0d284f5137d8c9fc6be12561f9fb712bc7b2 | andreidenissov-cog/studio-go-runner | /vendor/github.com/awnumar/memcall/memcall_windows.go | Go | go | 2,791 | permissive | // +build windows
package memcall
import (
"errors"
"fmt"
"unsafe"
"golang.org/x/sys/windows"
)
// Placeholder variable for when we need a valid pointer to zero bytes.
var _zero uintptr
// Lock is a wrapper for windows.VirtualLock()
func Lock(b []byte) error {
if err := windows.VirtualLock(_getPtr(b), uintptr... |
5e0c0da59a1e6831163a7a6d94de8b9d47c39c24 | 36327f58e6fdafd197859b2b63cd95feefce6422 | erkexzcx/Study-Workflow-Tracking-Information-System | /src/teachers.go | Go | go | 6,049 | no_license | package main
import (
"fmt"
"log"
"net/http"
"strconv"
"strings"
"unicode/utf8"
"github.com/gin-contrib/sessions"
"github.com/gin-gonic/gin"
)
func teachersPageGet(c *gin.Context) {
session := sessions.Default(c)
admin, _ := strconv.ParseBool(fmt.Sprintf("%v", session.Get("admin")))
query := `
SELECT
... |
524948abe147ae1785cbbd341f01e2b825232af6 | 80f582b380a6bbc1e99ec1fcd6866c10d5a7c362 | nkhuyu/melon | /debug/debug.go | Go | go | 2,178 | permissive | /*
Package debug adds debug endpoint to admin page.
*/
package debug
import (
"expvar"
"fmt"
"net/http"
"net/http/pprof"
"strings"
"github.com/goburrow/gol"
"github.com/goburrow/melon/core"
)
const (
pprofPath = "/debug/pprof/"
expvarPath = "/debug/vars"
)
var (
logger gol.Logger
)
func init() {
logger... |
accc73bcd496f4ebfc092482192e1fecca2e2a3c | 70e780516e17989fd3ac0b81a274b620b0453a32 | D10221/tinyauth | /encoder/encoder_test.go | Go | go | 392 | no_license | package encoder
import (
"testing"
"strings"
)
func Test_Encoder(t *testing.T){
var encoder Encoder = &DefaultEncoder{BasicScheme: "Basic "}
encoded:= encoder.Encode("left", "right")
if !strings.HasPrefix(encoded, "Basic "){
t.Error("Missing Scheme")
}
out,e := encoder.Decode(encoded)
if e!=nil {
t.... |
46b8ebb381b59e8afe83675beeb60022f9c98a32 | 202d594e1fb7398495941d7465a1c0a77908b313 | joaopedrosgs/URI | /Beginner/1016/main.go | Go | go | 820 | no_license | /* Distance
Adapted by Neilor Tonin, URI Brazil
Timelimit: 1
Two cars (X and Y) leave in the same direction. The car X
leaves with a constant speed of 60 km/h and the car Y
leaves with a constant speed of 90 km / h.
In one hour (60 minutes) the car Y can get a distance
of 30 kilometers from the X car, in other words... |
a972075db285d8d9f5bcb659c45cadb9a7d5f1ab | a41c7def049e59c375a23ab9df4b18f0aa833bda | refiito/testapp | /db.go | Go | go | 1,647 | no_license | package main
import (
"database/sql"
"errors"
"github.com/jameskeane/bcrypt"
)
var schema = `
CREATE TABLE IF NOT EXISTS users(
user_id SERIAL PRIMARY KEY,
email TEXT NOT NULL,
password TEXT,
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP
);
DO $$
BEGIN
IF to_regclass('public.index_user_email_unique') I... |
e9bc412c935a27273c0d9ce6e95b7cf5e77850e1 | eee215f685941c12a09e7fb37f8b054bae16e2b8 | mhocouchbase/sync_gateway | /rest/main_legacy.go | Go | go | 5,793 | permissive | // Copyright 2022-Present Couchbase, Inc.
//
// Use of this software is governed by the Business Source License included
// in the file licenses/BSL-Couchbase.txt. As of the Change Date specified
// in that file, in accordance with the Business Source License, use of this
// software will be governed by the Apache Lic... |
8eb92145b84cf7613809b942d43c8177dbd785cd | fab4062a502e09b7444046067d98a8178823f837 | erw7/nyagos | /mains/lua-dll/to.go | Go | go | 8,570 | permissive | package lua
import (
"errors"
"fmt"
"reflect"
"unsafe"
)
const dbg = false
var ClosureIsNotAvaliable = errors.New("Can't assign a closure")
var lua_tointegerx = luaDLL.NewProc("lua_tointegerx")
func (this Lua) ToInteger(index int) (int, error) {
var issucceeded uintptr
value, _, _ := lua_tointegerx.Call(this... |
27c69f9bb32db1310650965023118863b9d33d82 | 32765b1dc507cf32060e967736e506b1f2ef076c | TharushiPinimuthu/go-patterns | /state/book-travelling/states/4_feedback.go | Go | go | 372 | no_license | package states
import "github.com/dima-kov/go-patterns/state/book-travelling/models"
type ReadFeedback struct {
Book models.Book
}
func (rf *ReadFeedback) RequestByUser(user interface{}) error {
return nil
}
func (rf *ReadFeedback) ConfirmByOwner(user interface{}) error {
return nil
}
func (rf *ReadFeedback) Wr... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.