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 |
|---|---|---|---|---|---|---|---|---|
cc1755c2c87d9a286cb68bd07994983d6ba21735 | 68c0f92f52e627990a1dad15920c644cb0042887 | MValle21/circonus-unified-agent | /plugins/inputs/infiniband/infiniband_linux.go | Go | go | 1,320 | permissive | // +build linux
package infiniband
import (
"fmt"
"strconv"
"github.com/Mellanox/rdmamap"
"github.com/circonus-labs/circonus-unified-agent/cua"
"github.com/circonus-labs/circonus-unified-agent/plugins/inputs"
)
// Gather statistics from our infiniband cards
func (_ *Infiniband) Gather(acc cua.Accumulator) erro... |
94e26ef7d4a43546b6c0e4225666f1711fab2427 | 44358b54da5f8d99bbe9036da25711008c91917e | bitcard/chevrotain | /cmrdto/dbops_test.go | Go | go | 2,650 | no_license | package main
import (
"testing"
"../util"
)
// go test -run NameOfTest
/* First Insert a Number of Identical Elements with Different Ids:
* Key 100 x3
* Key 200 x2
* Key 100, Val 1000 x3
* Key 200, Val 2000 x2
* Key 300, Val 3000 (diff key)
* Key 100, Val 1001 (pre-existing key) */
var pairs = [][2]string{
{"Key... |
17484bb9c368523fb6a839a0004bc41e3bef09f5 | a23ceb0d7b903a60e8f08305fa1b91ffdbdf091e | sandyverden/golang-learning | /switch.go | Go | go | 1,275 | no_license | // Switch statements express conditionals across many branches.
package main
import (
"fmt"
"time"
)
func main() {
// Here's a basic switch
i := 2
fmt.Println("Write ", i, " as ")
switch i {
case 1:
fmt.Println("One")
case 2:
fmt.Println("Two")
case 3:
fmt.Println("Three")
}
// You can use commas t... |
54bdbe1e0f0ead192e2d3c7077a14b3021419d58 | 5e2f5f42683004b8d7c9b00a8cce2883f7b32fc6 | alvintronnetwork/go-btfs | /core/node/provider.go | Go | go | 3,652 | permissive | package node
import (
"context"
"fmt"
"time"
"github.com/TRON-US/go-btfs/core/node/helpers"
"github.com/TRON-US/go-btfs/pin"
"github.com/TRON-US/go-btfs/repo"
"github.com/ipfs/go-ipfs-provider"
q "github.com/ipfs/go-ipfs-provider/queue"
"github.com/ipfs/go-ipfs-provider/simple"
ipld "github.com/ipfs/go-ipl... |
d46b343e50278a4fd5ae5d653e389e8f11aee14d | 2f93f64f91c0eaebf9da0a97450d45617630642b | whites11/cluster-api-provider-azure | /azure/services/natgateways/natgateways.go | Go | go | 5,128 | permissive | /*
Copyright 2021 The Kubernetes 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, ... |
7afdabd9a13d949f0a26d9058df430bf1b9dc256 | 706f8155cd9695124a999a2fa660fdf30af093ae | gitter-badger/Golang-Recipes | /server.go | Go | go | 6,362 | no_license | package main
import (
"bufio"
"bytes"
"fmt"
"html/template"
"io/ioutil"
"net/http"
"os"
// "strings"
)
// const recipesPath string = "./recipes/"
// Need to refactor ~,99, 120, 121, 152 where recipe path is hard coded.
const recipesPath string = "recipes"
/* Considered creating diff structs for each directiv... |
275f5c1fe1bb3f0be13ad2f02e3d53f3368dc416 | a25bfb988d5b00932ccd8df34dc284ea23f1a5ee | retgits/acme-serverless-order | /cmd/lambda-order-sqs-update/main.go | Go | go | 1,425 | permissive | package main
import (
"fmt"
"os"
"time"
"github.com/aws/aws-lambda-go/events"
"github.com/aws/aws-lambda-go/lambda"
"github.com/getsentry/sentry-go"
acmeserverless "github.com/retgits/acme-serverless"
"github.com/retgits/acme-serverless-order/internal/datastore/dynamodb"
wflambda "github.com/wavefronthq/wave... |
144b60d5c4e53bfa7df6dd81d3844b6ad1bbfd7f | fb7b0a6d2d8ae35f615e1cc10423103a0e9eeb56 | Icaro23246/MusicBot | /commands.go | Go | go | 14,291 | permissive | package main
import (
"fmt"
"github.com/bwmarrin/discordgo"
"log"
"strconv"
"strings"
"time"
)
// HelpReporter
func HelpReporter(m *discordgo.MessageCreate) {
log.Println("INFO:", m.Author.Username, "send 'help'")
help := "```go\n`Standard Commands List`\n```\n" +
"**`" + o.DiscordPrefix + "help`** or **`" ... |
9071a2c2e0a716522e6d738e8bfbf559c3fd916e | 51469d71129d954d472c67c634d2e49a12c30239 | clouway/go-epay | /pkg/server/api/check_bill.go | Go | go | 2,342 | permissive | package api
import (
"fmt"
"net/http"
"strings"
log "github.com/sirupsen/logrus"
"github.com/clouway/go-epay/pkg/epay"
"github.com/clouway/go-epay/pkg/server"
"github.com/clouway/go-epay/pkg/server/httputil"
)
const (
shortDescMaxLen = 40
longDescMaxLen = 4000
)
// CheckBill checks bill of customer
func ... |
bfe4fcfc7885329cd28751326bd5040f2b150276 | 3f856711f3ce8bec5196fc023117d29bfffe38c7 | weaveworks/weave | /vendor/github.com/vishvananda/netlink/route_linux.go | Go | go | 22,859 | permissive | package netlink
import (
"fmt"
"net"
"strings"
"syscall"
"github.com/vishvananda/netlink/nl"
"github.com/vishvananda/netns"
"golang.org/x/sys/unix"
)
// RtAttr is shared so it is in netlink_linux.go
const (
SCOPE_UNIVERSE Scope = unix.RT_SCOPE_UNIVERSE
SCOPE_SITE Scope = unix.RT_SCOPE_SITE
SCOPE_LINK ... |
cba9ea279903eea3b65fcd386230daaf74b5867c | 66a8929918fee7d05ae754e6d0e57595cfb58b66 | pranavgore09/wit-on-minishift | /controller/planner_backlog_blackbox_test.go | Go | go | 9,117 | permissive | package controller_test
import (
"testing"
"time"
"github.com/fabric8-services/fabric8-wit/account"
"github.com/fabric8-services/fabric8-wit/app"
"github.com/fabric8-services/fabric8-wit/app/test"
"github.com/fabric8-services/fabric8-wit/application"
. "github.com/fabric8-services/fabric8-wit/controller"
"git... |
23e1817ddb3b637be54546ca2d3c36b5b7421809 | 7efc484ef9b25c5657a597b44f4d22e0f057d1d1 | wuchangqian/wucq | /go/gif.go | Go | go | 1,247 | no_license | package main
import (
"image"
"image/color"
"image/gif"
"io"
"math"
"math/rand"
"os"
)
var palette = []color.Color{color.White, color.Black}
const (
whiteIndex = 0 // first color in palette
blackIndex = 1 // next color in palette
)
func main() {
lissajous(os.Stdout)
}
func lissajou... |
339e3959dd18d23696a1bf69fb63753e9d15b57c | b4c616360899d8794f062f6b5f2380cd4dacf1bf | isberg1/REST-API-for-igc-file-browsing | /ClockTrigger/functions.go | Go | go | 1,183 | no_license | package main
import (
"bytes"
"encoding/json"
"fmt"
"io/ioutil"
"net/http"
"os"
"strconv"
"strings"
)
// SlackMessage struct that is comparable with Slack webhooks
type SlackMessage struct {
Text string `json:"text"`
}
// reads the time between checks from file
func readFromFile() int {
//open file
file, ... |
fc0d13bd198be1c90e3bd369646fe403e7e496d0 | c54d42e5beab0a02d7ea1f5bb9699f61f53518f4 | yupwei68/giovanni | /storage/2017-07-29/blob/blobs/blob_append_test.go | Go | go | 4,817 | permissive | package blobs
import (
"context"
"fmt"
"testing"
"github.com/Azure/azure-sdk-for-go/profiles/latest/storage/mgmt/storage"
"github.com/tombuildsstuff/giovanni/storage/2017-07-29/blob/containers"
"github.com/tombuildsstuff/giovanni/storage/internal/auth"
"github.com/tombuildsstuff/giovanni/testhelpers"
)
func T... |
040f8547e1b8d719c48f43ae524c3a2b4b28230b | cac2739fdcc186cd87aec302dba2fff42e8f2290 | batazor/k8s-operator | /vendor/github.com/operator-framework/operator-sdk/pkg/generator/gen_handler.go | Go | go | 1,383 | permissive | // Copyright 2018 The Operator-SDK 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 ... |
a9a69d7b34b9a1f084eb8252e0bcc39bcc69533e | 6966a8339198f74e4d9873bbca6d6144c95c47ef | NikitaBolbatun/chain | /block_test.go | Go | go | 1,741 | no_license | package bulba_chain
import (
"golang.org/x/crypto/ed25519"
"testing"
)
//func TestBlockProcessing(t *testing.T) {
// pubkey, _, err := ed25519.GenerateKey(nil)
// if err != nil {
// t.Fatal(err)
// }
//
// validatorAddr, err := PubKeyToAddress(pubkey)
// if err != nil {
// t.Fatal(err)
// }
//
// nd := &Node{
// ... |
1462231b803f75c75df711194a4dea8ea673f559 | 10d1cad05370ca83e036f4c49584fe26545ff1fb | cloudfoundry/bosh-cli | /vendor/github.com/vito/go-interact/interact/choice.go | Go | go | 316 | permissive | package interact
// Choice is used to allow the user to select a value of an arbitrary type.
// Its Display value will be shown in a listing during Resolve, and if its
// entry in the list is chosen, the Value will be used to populate the
// destination.
type Choice struct {
Display string
Value interface{}
}
|
1635c495e292cfd2552cf8f07672a2024a0e15be | 3e37d6f5f96d7d011a4494e94168a7b4a7e2952f | ezzkim/golang | /day05/test/utils/math.go | Go | go | 207 | no_license | package utils
//Add
func Add(a, b int) int {
return a + b
}
//Sub
func Sub(a, b int) int {
return a - b
}
//Mul
func Mul(a, b int) int {
return a * b
}
//Div
func Div(a, b int) int {
return a / b
} |
82e15b13919995bd365a57503600fe97b830f15a | c7005170a76a67e9f1a243c9ea7bec574dc02578 | oracle/oci-cloud-controller-manager | /vendor/github.com/oracle/oci-go-sdk/v65/core/shape_memory_options.go | Go | go | 2,690 | permissive | // Copyright (c) 2016, 2018, 2023, Oracle and/or its affiliates. All rights reserved.
// This software is dual-licensed to you under the Universal Permissive License (UPL) 1.0 as shown at https://oss.oracle.com/licenses/upl or Apache License 2.0 as shown at http://www.apache.org/licenses/LICENSE-2.0. You may choose ei... |
47313623cdb2d7235eabe69d4514021cd2b05a48 | 480c6bbe85a8c035ef13e2fe63b77ea948f43e73 | VimalME/skia-buildbot | /go/calc/lex_test.go | Go | go | 1,912 | permissive | package calc
import (
"testing"
"go.skia.org/infra/go/testutils"
)
func TestLex(t *testing.T) {
testutils.SmallTest(t)
testCases := []struct {
input string
items []item
}{
{
input: "foo()",
items: []item{
{itemIdentifier, "foo"},
{itemLParen, "("},
{itemRParen, ")"},
{itemEOF, ""},
... |
b351214e4bf14bdd0deb2a76837e2fef09fae8d8 | e1ccb7cb6672051abb934020374b4bc96af2d3f2 | xiongqq345/go-Algorithm | /leetcode/binary search/1818 minAbsoluteSumDiff.go | Go | go | 929 | permissive | package binary_search
import "sort"
// 给你两个正整数数组 nums1 和 nums2 ,数组的长度都是 n 。
//
//数组 nums1 和 nums2 的 绝对差值和 定义为所有 |nums1[i] - nums2[i]|(0 <= i < n)的 总和(下标从 0 开始)。
//
//你可以选用 nums1 中的 任意一个 元素来替换 nums1 中的 至多 一个元素,以 最小化 绝对差值和。
//
//在替换数组 nums1 中最多一个元素 之后 ,返回最小绝对差值和。因为答案可能很大,所以需要对 109 + 7 取余 后返回。
func minAbsoluteSumDiff(n... |
b7503d339cffe7ab2c4bd04205214d83bf26198a | 12b70719b9acc802f0b2b75b881469bc5068dc24 | pradeepto/cli | /pkg/cmd/taskrun/logs_test.go | Go | go | 28,787 | permissive | // Copyright © 2019 The Tekton 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... |
527178c9980dcde735a9b2f5e662f498fc6df338 | 6da8c0ae53bbf0d3a8556ccff071fc58bb841809 | yyy33/a | /color.go | Go | go | 3,337 | permissive | package main
import (
"image"
"image/color"
"runtime"
"github.com/as/edit"
"github.com/as/frame"
"github.com/as/ui/reg"
"github.com/as/ui/win"
)
func uselightcolors() {
Palette = Lightpalette
updatecolors()
}
func usedarkcolors() {
Palette = Darkpalette
updatecolors()
}
func updatecolors() {
GridConfig... |
58d95cca2f9d090b41445a478714b96094012c56 | 7f76c8f005fb993921449104bc26839a384efe20 | nathantypanski/rust-csv | /bench/huge.go | Go | go | 717 | permissive | package main
import (
"bytes"
"encoding/csv"
"io"
"io/ioutil"
"log"
"os"
)
func asByteReader(fpath string) *bytes.Reader {
f, err := os.Open(fpath)
if err != nil {
log.Fatal(err)
}
bs, err := ioutil.ReadAll(f)
if err != nil {
log.Fatal(err)
}
return bytes.NewReader(bs)
}
func readAll(r io.Reader) {
... |
c26eb27275f1431e54a30e9442cad364c94739f7 | 9e40912bf452a44b7e9cd69097f9fe37f3de5410 | linkxzhou/kotal | /apis/ethereum2/v1alpha1/beacon_node.go | Go | go | 2,216 | no_license | package v1alpha1
import (
"github.com/kotalco/kotal/apis/shared"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
)
// BeaconNodeSpec defines the desired state of BeaconNode
type BeaconNodeSpec struct {
// Join is the network to join
Join string `json:"join"`
// Client is the Ethereum 2.0 client to use
Client Ethe... |
f972a549338c74f57bf19c4bfb8264ca2abebdea | a47551ddf40aa6871e57ae96e5b8279f56c750bb | rli-diraryi/weed-fs-1 | /go/weed/upload.go | Go | go | 2,686 | no_license | package main
import (
"code.google.com/p/weed-fs/go/operation"
"code.google.com/p/weed-fs/go/util"
"encoding/json"
"errors"
"fmt"
"net/url"
"os"
"path"
"strconv"
)
var uploadReplication *string
func init() {
cmdUpload.Run = runUpload // break init cycle
cmdUpload.IsDebug = cmdUpload.Flag.Bool("debug", fal... |
e3457092e5e6d3f719b2a668be091b75d3f7785e | 75cec080823cc73dc90085d59c0b96635903475f | fxpass/jiacrontab | /jiacrontab_admin/params.go | Go | go | 10,223 | permissive | package admin
import (
"errors"
"fmt"
"jiacrontab/models"
"jiacrontab/pkg/proto"
"jiacrontab/pkg/util"
)
var (
paramsError = errors.New("参数错误")
)
type Parameter interface {
Verify(*myctx) error
}
type JobReqParams struct {
JobID uint `json:"jobID" rule:"required,请填写jobID"`
Addr string `json:"addr" rule... |
70d5ae4570d1754f350fa9e3776c2eddf419b603 | 304793340aec053438e0ba54e3d2f8c229a33954 | bingoohuang/seaweedfs | /weed/filesys/dirty_page_interval.go | Go | go | 6,235 | permissive | package filesys
import (
"io"
"github.com/chrislusf/seaweedfs/weed/util"
)
type IntervalNode struct {
Data []byte
Offset int64
Size int64
Next *IntervalNode
}
type IntervalLinkedList struct {
Head *IntervalNode
Tail *IntervalNode
}
type ContinuousIntervals struct {
lists []*IntervalLinkedList
}
fun... |
bbe852dcc6c518861fee6d0210af49b82c323871 | 442afda00f5c4c8f93a63859eea3f2c5635ffa2e | davemcp/goLangTraining | /ninja009/003/main.go | Go | go | 817 | no_license | package main
import (
"fmt"
"runtime"
"sync"
)
// Using goroutines, create an incrementer program
func main() {
// have a variable to hold the incrementer value
incrementer := 0
// use waitgroups to wait for all of your goroutines to finish
var wg sync.WaitGroup
// launch a bunch of goroutines
const gs = 1... |
4b9706f26a922fe90dca66f21c478470df81b87f | 57f10424a9f458e6e2c0a6388b6a84274b6ccdbd | intdxdt/geom | /index/rtree.go | Go | go | 553 | no_license | package index
/*
(c) 2015, Titus Tienaah
A library for 2D spatial indexing of points and rectangles.
https://github.com/mourner/rbush
@after (c) 2015, Vladimir Agafonkin
*/
//Index type
type Index struct {
data node
maxEntries int
minEntries int
}
func NewIndex(nodeCap ...int) *Index {
var bucketSize ... |
07a943a4ebf343959c8fe144d7c8a42bf78a08e7 | 47e077d145f97ff31ace2eeeadb26de550658b9f | jiangkuanc/image | /selenium/config.go | Go | go | 280 | no_license | package selenium
import "time"
type SeleniumConfig struct {
// 服务器监听端口
Port int
// google driver 路径
DriverPath string
// 打开标签页数量
BookmarkPage int
// 超时时间 (毫秒)
Timeout time.Duration
// bing 图片地址
ImageUrl string
}
|
bf50fe78eb6b0cac68f98273eb3f07b02e97c99d | 86df69d0594aad5e7c402044fe297e15cb5ebd06 | fluxcd/flux2 | /pkg/manifestgen/manifest.go | Go | go | 1,599 | permissive | /*
Copyright 2020 The Flux 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, softwar... |
589222cf3db68262066fc319326b81c8d98733bc | 4b1a557eeafd4dba239886a960e458520121bafd | tychoish/greenbay | /check/container.go | Go | go | 3,307 | no_license | package check
import (
"fmt"
"os/exec"
"time"
"github.com/mongodb/amboy"
"github.com/mongodb/amboy/registry"
"github.com/pkg/errors"
)
func init() {
name := "lxc-containers-configured"
registry.AddJobType(name, func() amboy.Job {
return &containerCheck{
Base: NewBase(name, 0),
container: lxcChec... |
0b6bfff547018c3a15276d5cfc3b78f759d62e70 | b361d21c06bb1b5c307ae05e896da9994879cf25 | acottais/infrakit | /pkg/types/specs_test.go | Go | go | 4,619 | permissive | package types // import "github.com/docker/infrakit/pkg/types"
import (
"sort"
"testing"
"github.com/stretchr/testify/require"
)
func TestSpecs(t *testing.T) {
list, err := SpecsFromString(`
- kind: group
metadata:
name: workers
properties:
max: 10
target: 5
- kind: group
metadata:
name: m... |
3bab7c1bee4ce69330996c7b3d5db18614994c53 | 8cfa1056b700d68fc746c97db6239a1445ab5b3e | theglitch76-forks/fabric-discord-bot | /discord/command_context.go | Go | go | 1,866 | permissive | package discord
import (
"fmt"
"github.com/bwmarrin/discordgo"
)
type CommandContext struct {
Content []string
Session *discordgo.Session
Message *discordgo.MessageCreate
}
func (ctx *CommandContext) SendMessageWithAudit(msg string, action string) error {
err := ctx.SendMessage(msg)
if err != nil {
return ... |
34fcca69c26edfb01b2f20119f820df92cacc6ea | 6f35429d764818e4fd7443ca5ca19a30f2062cc8 | dennis-bell/kops | /nodeup/pkg/model/context.go | Go | go | 4,642 | permissive | /*
Copyright 2016 The Kubernetes 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, ... |
62d040f6916af24795ab452e3b24577594c11218 | 5e63ce112dc8eec8b5d1e7790756dd46d6b099cd | PatKoperwas/gobuffalo | /actions/app.go | Go | go | 1,251 | no_license | package actions
import (
"time"
"github.com/gobuffalo/buffalo"
"github.com/gobuffalo/buffalo/middleware/ssl"
"github.com/gobuffalo/envy"
"github.com/gobuffalo/x/sessions"
"github.com/unrolled/secure"
)
var ENV = envy.Get("GO_ENV", "development")
var app *buffalo.App
// App is where all routes and middleware f... |
82e2a441453e041725d894d4d3ff9131d6b43502 | 8ebcc623ee81a025eaad70308c6dcdfe26d16b08 | spanghf37/assisted-service | /internal/versions/versions_test.go | Go | go | 30,652 | permissive | package versions
import (
"context"
"errors"
"fmt"
"io/ioutil"
"os"
"testing"
"github.com/go-openapi/swag"
gomock "github.com/golang/mock/gomock"
"github.com/kelseyhightower/envconfig"
. "github.com/onsi/ginkgo"
. "github.com/onsi/gomega"
"github.com/openshift/assisted-service/internal/common"
"github.co... |
c940eaa202a09bacabebb3c1d2aedabb5ef4b4b4 | 946c2023e9f30fc0eaf3441bb2d2cb729ef38d48 | zond/chicklet | /example/example.go | Go | go | 554 | no_license | package main
import (
"github.com/zond/chicklet"
"fmt"
)
func nativeTest(i int, s string) int {
fmt.Println("nativeTest called with", i, s)
return i + len(s)
}
func main() {
context := chicklet.NewWorld()
context.Define("myNative", nativeTest)
context.Eval("func callNative(s string, i int) int { return myNati... |
a0a5a8270bf8b6a661939296c09b9cc380df3dc8 | 9390028914f67426b042e0250dc1d9120cdfe92c | Paolaufer/cloud-mta-build-tool | /internal/artifacts/project.go | Go | go | 4,353 | permissive | package artifacts
import (
"fmt"
"os"
"path/filepath"
"strconv"
"github.com/pkg/errors"
"github.com/SAP/cloud-mta-build-tool/internal/archive"
"github.com/SAP/cloud-mta-build-tool/internal/commands"
"github.com/SAP/cloud-mta-build-tool/internal/exec"
"github.com/SAP/cloud-mta-build-tool/internal/logs"
"git... |
0dcf2fc426054d33959e2bcc04ae83c55fa187f6 | 29d146cc7c76a6d1b28f2f22db9b515f740e66b3 | 844348677/go_portfolio | /program01/10_bool.go | Go | go | 820 | permissive | // 10_bool.go
package main
import (
"fmt"
)
func main() {
//声明变量
var a bool
fmt.Println(a)
a = true
//
b := false
fmt.Println(b)
var c = false
fmt.Println(c)
var f1 float32
f1 = 3.14
fmt.Println(f1)
f2 := 3.14
// f2 type is float64
fmt.Printf("f2 type is %T\n", f2)
// ascii
// 97 'a' 65'A' byte ... |
04cac26b10fe4b844bc9e9c8f19e6d3f53489beb | b266cbf55bbb8020a497f7782f5770344972c661 | Colocust/mint | /route/router.go | Go | go | 819 | no_license | package route
import (
"mint/http/server"
"sync"
)
var (
instance *Router
once sync.Once
)
type (
HandlerFunc func(string, *server.Response)
Router struct {
route map[string]HandlerFunc
}
)
func (r *Router) Handle(request []string, resp *server.Response) {
if len(request) <= 1 {
resp.Code = ser... |
db98f9526b64ceea3465f9deb457942c230804ef | 4fb06899008b430aa37b653b447a924bc5003904 | philhug/rkt | /networking/net.go | Go | go | 2,658 | permissive | // Copyright 2015 CoreOS, 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 in... |
c0542700709c90feea586adb7c25826dcf0d73d4 | 1579d28526d4b0d1d231eb9560dc85591d9f472f | altipla-consulting/baster | /pkg/proxy/proxy.go | Go | go | 7,266 | permissive | package proxy
import (
"bytes"
"encoding/json"
"fmt"
"io/ioutil"
"net/http"
"net/http/httputil"
"net/url"
"strconv"
"strings"
"time"
"github.com/altipla-consulting/collections"
"github.com/juju/errors"
log "github.com/sirupsen/logrus"
"github.com/altipla-consulting/baster/pkg/config"
"github.com/altip... |
9a74e39861c2175e74cb0246edb6a21a9701d94f | 7331bdda4a49c272ec26122be9217c1a77b38389 | rveen/electronics | /rth.go | Go | go | 592 | permissive | package electronics
import (
"strings"
)
// Rth returns the default thermal resistance of the component (to ambient) based
// on the package.
// Source:
// - http://www.yageo.com/exep/pages/download/literatures/PYu-R_Mount_7.pdf
func Rth(pkg string) float64 {
pkg = strings.ToLower(pkg)
switch pkg {
case "0201":... |
ccc8a630fb730059bf2df71ca0644870964b0e53 | c12c3f168b7be7e6d77ea74f27c6890f74726a12 | twitchy-jsonp/go-attestation | /attest/eventlog_test.go | Go | go | 2,948 | permissive | // Copyright 2019 Google 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 in ... |
d60254db248bf5507928602d72145e75128d5f19 | cf47e38aa0fd96f235531d7ffc8cdab85de94a05 | DataDog/datadog-api-client-go | /api/datadogV2/model_incident_todo_create_data.go | Go | go | 4,553 | permissive | // Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License.
// This product includes software developed at Datadog (https://www.datadoghq.com/).
// Copyright 2019-Present Datadog, Inc.
package datadogV2
import (
"fmt"
"github.com/goccy/go-json"
"github.com/DataDo... |
3d0a7895e94da7cb4a17f7685fca12f3f703a4f0 | d09b0ede60c360834fd51cdc8783938b5c0eef97 | onfoot/go-web | /tiles/hellotile.go | Go | go | 388 | no_license | package tiles
import (
"fmt"
"bytes"
)
func init() {
Register(new(HelloTile))
}
type HelloTile struct {};
func (h *HelloTile) Name() string {
return "hello"
}
func (h *HelloTile) RenderFunc(renderer *TileRenderer, arg ... interface{}) string {
str := bytes.NewBufferString("Welcome aboard")
if arg[0] != nil... |
f730d6740114511f2a1da4aec0828a5ac91a19bf | a00dd6de4e6fd099c630646e1ad9d7ec6ec72778 | turingvideo/pg | /hook_test.go | Go | go | 6,407 | permissive | package pg_test
import (
"time"
. "github.com/onsi/ginkgo"
. "github.com/onsi/gomega"
"github.com/go-pg/pg"
"github.com/go-pg/pg/orm"
)
type HookTest struct {
Id int
Value string
afterQuery int
afterSelect int
beforeInsert int
afterInsert int
beforeUpdate int
afterUpdate int
beforeDelete int... |
ee4824dd01a76f91891e88c0a159359e6bd95e74 | f80cb619bb658c15b900c82a3b17ce2a15736962 | rakesh740/questions_references | /hacker-rank/golang/checkIfOneEditAway/checkIfOneEditAway.go | Go | go | 1,166 | no_license | package main
import (
"fmt"
"strings"
)
func buildCharDifferenceTable(first, second string) map[rune]int {
firstLetters := []rune(first)
secondLetters := []rune(second)
table := make(map[rune]int)
for i := 0; i < len(firstLetters); i++ {
table[firstLetters[i]]++
}
for i := 0; i < len(secondLetters); i++ ... |
8641ad2b9fa1fb823f6892de8459adcc475793c7 | 8d2174ceb52fe8e07fcba593caf643f086016ba1 | chaokaikai1/GoProject | /dahuangfeng.com/day01/structtest2/node.go | Go | go | 509 | no_license | package main
import "fmt"
type treeNode struct {
value int
left, right *treeNode
}
//值接收者
func (node treeNode) print() {
node.value = 3
fmt.Println(node.value)
}
//指针接受者
func (node *treeNode) print2() {
node.value = 4
fmt.Println(node.value)
}
func main() {
//node:=treeNode{
// value:1,
// left:&tre... |
c77af9f3474d3e227e5d5a1e1f965d624241f4e8 | 7d2f37aefc2f692b69b306b6e99adbb8d55e0ead | otrh/go_proxy2 | /src/go_proxy/conn/addr.go | Go | go | 7,123 | no_license | package conn
import (
"encoding/binary"
"fmt"
"go_proxy/exception"
"go_proxy/util"
"math"
"net"
"strconv"
"strings"
"sync"
)
var (
rlock = &sync.RWMutex{}
)
type Addr interface {
String() string
StringWithPort() string
ToHostBytes() []byte
ToPortByte() []byte
Type() int
IsChinaAddr() bool
IsDomain()... |
bd3bf5d4ab99437a135d5035801cba04f67d54c1 | e02e594acb1ff6ceccfe0f5b48605154c7c8f718 | diandraygp/slides | /golang/examples/file-stat/stat.go | Go | go | 499 | no_license | package main
import (
"fmt"
"os"
)
func main() {
if len(os.Args) != 2 {
fmt.Printf("Usage %s FILENAME\n", os.Args[0])
os.Exit(1)
}
var filename = os.Args[1]
var st, err = os.Stat(filename)
if err != nil {
fmt.Printf("Error: %s\n", err)
if os.IsNotExist(err) ... |
5e287e7ef8a7ce531d14d99fc5d31bf1b808bba5 | 7a0d8522c9b043332f0e24091aaaa6b6a56c3853 | YouthLab/docker-registry-manager | /models/client/registry.go | Go | go | 956 | permissive | package client
import (
"github.com/Sirupsen/logrus"
"github.com/snagles/docker-registry-manager/utilities"
)
// HealthCheck takes in a registry URL and checks for communication errors
//
// Create and execute basic GET request to test if each registry can be reached
// To determine registry status we test the base... |
1869d0b16aa8fbe4e75572dababf211b98297dbd | 0d9cbdb1bc5fd418fdc45754b8868422e756574c | sbanka1/lenslocked | /controllers/helpers.go | Go | go | 588 | permissive | package controllers
import (
"net/http"
"net/url"
"github.com/gorilla/schema"
)
func parseForm(r *http.Request, dst interface{}) error {
if err := r.ParseForm(); err != nil {
return err
}
return parseValues(r.PostForm, dst)
}
func parseURLParams(r *http.Request, dst interface{}) error {
if err := r.ParseFo... |
7320d05d041c66858c0a455687d87163ce4efb8e | 2e4e83288cfc1555f1fb30f1d67acfdfa6c54167 | naphaso/meshbird | /common/ifacesrv.go | Go | go | 1,461 | permissive | package common
import (
"fmt"
"github.com/gophergala2016/meshbird/network"
"github.com/miolini/water"
"log"
"os"
"strconv"
)
type InterfaceService struct {
BaseService
localnode *LocalNode
instance *water.Interface
netTable *NetTable
logger *log.Logger
}
func (is *InterfaceService) Name() string {
... |
31dcb5fbb4489612bfd87ba947404d2ecb942e62 | 6a32a628bd8bac91a61a7a8973d69b8747602ec8 | continuouspipe/remote-environment-client | /sync/rsync/rfetch.go | Go | go | 488 | permissive | package rsync
import (
"runtime"
"github.com/continuouspipe/remote-environment-client/sync/options"
)
//use rsync to fetch all the project files from the pod, or if the filePath is not empty it
//fetch a specific file
type RsyncFetcher interface {
Fetch(string) error
SetOptions(syncOptions options.SyncOptions)
}
... |
7442c1c417c8c04b56e97c86e23131161c76e4d7 | b61a30621bbaf24bed7800a944f0b8b3826c2c6c | aolmez/storage | /config/config.go | Go | go | 988 | no_license | package config
import (
"io/ioutil"
"os"
"path/filepath"
"time"
"github.com/go-yaml/yaml"
)
var Config EnvironmentConfig
type ServerConfig struct {
Port string `yaml:"port"`
ReadTimeout time.Duration `yaml:"read_timeout"`
WriteTimeout time.Duration `yaml:"write_timeout"`
IdleTimeout time.D... |
5a06a8cb4da082f103e04260cb8f09de1d045c1e | e37fb6cc06f221d17a1a12404d86c636461e72ba | carlzhao/container | /pool/poolObjectSync.go | Go | go | 824 | no_license | package pool
/*
同步-对象内存池
*/
import (
"sync"
)
type PoolObjectSync struct {
sync.Pool
size int
}
func NewPoolObjectSync(newObject func() interface{}) IPoolObject {
sp := &PoolObjectSync{}
sp.New = newObject
return sp
}
func (ps *PoolObjectSync) Get() interface{} {
if ps.size > 0 {
ps.size--
}
return ps.P... |
5986bc55586ca89d070721341af0651fbdc6511c | b918638c7a8aad178a000fa611fd55d85057b494 | villajo/trafficcontrol | /traffic_ops/traffic_ops_golang/deliveryservice/deliveryservices.go | Go | go | 88,359 | permissive | package deliveryservice
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0... |
4634e9521a2ce527d6f4f7d7cd7dbdc86b4eb461 | 8d0bbd6587a1aa1ec41c56245331c7c80c10093c | darkicerain/weibo | /emotions_test.go | Go | go | 815 | permissive | package weibo
import (
"os"
"testing"
)
func TestEmotions(t *testing.T) {
appkey := os.Getenv("weibo_app_key")
appsecret := os.Getenv("weibo_app_secret")
username := os.Getenv("weibo_username")
passwd := os.Getenv("weibo_passwd")
redirecturi := os.Getenv("weibo_redirect_uri")
weibo := New(appkey, appsecret, u... |
f47a13e0576d388aeb43a19d38b26c4aa3ffbb1a | e9ad8829573d42c35cb1514cedd59cb673fd8c9e | xiaoyumu/go-study | /grpc/proto/dataset.go | Go | go | 405 | no_license | package proto
import "fmt"
// CreateDataSet function returns new instance of DataSet
func CreateDataSet() *DataSet {
return &DataSet{
Tables: make([]*DataTable, 0, 1),
}
}
// AddTable function adds a table into the DataSet
func (ds *DataSet) AddTable(table *DataTable) {
if len(table.Name) == 0 {
table.Name = ... |
5da002c64f1d1d48971a472e1c54fdf4177a232a | d6b2a1600a5b8980870058445f24588e6e9eb7f7 | rkunihiro/goexamples | /examples/chi/main.go | Go | go | 1,206 | no_license | package main
import (
"encoding/json"
"fmt"
"net/http"
"os"
"github.com/go-chi/chi"
"github.com/go-chi/chi/middleware"
"github.com/go-chi/cors"
)
func writeJSON(w http.ResponseWriter, obj interface{}) (err error) {
buf, err := json.Marshal(obj)
if err != nil {
return err
}
w.Header().Set("Content-Type",... |
d9ec60681782f81830cda9ad670aa7830bb2e155 | e4bcb88d0f9849a6e42b38ca4354b0d8bad35d43 | LakenLi/Go- | /Code/20210908/reflect4.go | Go | go | 226 | no_license | package main
import "reflect"
type Data struct {
X int
}
func (x *Data) Inc() {
x.X++
}
var d = new(Data)
var v = reflect.ValueOf(d)
var m = v.MethodByName("Inc")
func call() {
d.Inc()
}
func rcall() {
m.Call(nil)
}
|
3d57aea1958a7fc981055a1783739f9074c21d5a | b3b5f82a959778db5f532a677711b0e4d0e3ffaf | vaskoz/makingbreakfast | /slide15.go | Go | go | 716 | no_license | package main
import (
"time"
)
func MakeCoffee(done chan string) {
log.Println("Starting coffee.")
time.Sleep(time.Duration(5) * time.Second)
done <- "coffee"
}
func MakeToast(done chan string) {
log.Println("Starting toast.")
time.Sleep(time.Duration(3) * time.Second)
done <- "toast"
}
func MakeEggs(done ch... |
607f399a242c52d28a5041df89c5dc56aa8a1745 | 9aace9757fbb5423903cda49e2cc852b589acc89 | bq-xiao/kubernetes | /cmd/gendeepcopy/deep_copy.go | Go | go | 2,789 | permissive | /*
Copyright 2015 The Kubernetes Authors All rights reserved.
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 ag... |
2ee274f6b6054ecbaf3edf41775916a628ee6f23 | 1e58d1d7775a37310b4018ee3a975cd137cca280 | rezacsedu/bbmri-fhir-gen | /cmd/root.go | Go | go | 3,297 | permissive | // Copyright © 2019 The Samply Development Community
//
// 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 applicab... |
f7c74b6d5d5bc5ac989e25e4f938a016107fa314 | aca9863b0657631b33b670d116ca194e9af568bb | mattjmcnaughton/hacks | /gochannels/main.go | Go | go | 272 | no_license | package main
import (
"sync"
)
// Ensure that we only attempt to close a channel once.
func main() {
c := make(chan struct{})
var once sync.Once
closeFunc := func() { close(c) }
go func() {
once.Do(closeFunc)
}()
go func() {
once.Do(closeFunc)
}()
<-c
}
|
9bbc04ef2eb389e1821e39e4ddf32129139d91bd | 75f3f7a763dab43c0b04aa367b9ebbaa16c873fe | QuantumGhost/mtproto | /config.go | Go | go | 2,360 | permissive | package mtproto
import (
"fmt"
"runtime"
"time"
)
const (
appConfigError = "App configuration error: %s"
defaultPingInterval = 1 * time.Minute
defaultSendInterval = 500 * time.Millisecond
)
type Configuration struct {
Id int32
Hash string
Version string
DeviceModel string
... |
20e329093229d52a489e34c2b75ec497d4a391e1 | 4b09371b069d2ff3f29cf310f2810200cffcb1d8 | YAOChain/yao | /x/slashing/abci.go | Go | go | 1,208 | permissive | package slashing
import (
"fmt"
abci "github.com/YAOChain/yao/core/abci/types"
tmtypes "github.com/YAOChain/yao/core/types"
sdk "github.com/YAOChain/yao/types"
)
// slashing begin block functionality
func BeginBlocker(ctx sdk.Context, req abci.RequestBeginBlock, sk Keeper) {
// Iterate over all the validators ... |
d483615073b0b777c828270a4a6cb68977ee8261 | dc94365b382d63c5e19906171ee29068fe69a4dc | abhay-krishna/etcd | /tests/e2e/v2_curl_test.go | Go | go | 6,766 | permissive | // Copyright 2016 The etcd 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 t... |
cb35614e32a6fe233f7b75c46b733d52520cd42c | 5d7fba801331f050321ef19531e1cfea3893db71 | stnma7e/betuol | /math/plane.go | Go | go | 1,633 | permissive | package math
import "math"
// Represents the sides of a plane according to mathematical styles.
const (
A = iota
B = iota
C = iota
D = iota
)
// Plane is a wrapper for a 4 dimensional vector that is used to represent a plane in 3 dimensional space.
type Plane Vec4
// MakePlane returns a plane based on three inp... |
9c70eed42313043c3eaf5c2a598b621484b6728c | aba419c480d6e8ca33691630340532a95f60e5fe | laudarch/iso20022 | /Quantity7.go | Go | go | 1,348 | permissive | package iso20022
// Details on the quantity, account and other related information involved in a transaction.
type Quantity7 struct {
// Total quantity of securities to be settled.
SettlementQuantity *FinancialInstrumentQuantity1Choice `xml:"SttlmQty"`
// Denomination of the security to be received or delivered.
... |
8b773cfdd8a1ae7e2a235f186863db48ab780fc0 | bdc85bd5c7bf4c9228c377777f772c8ca83a4d45 | RodrigoCR/anzu | /modules/gaming/model.go | Go | go | 3,307 | permissive | package gaming
import (
"gopkg.in/mgo.v2/bson"
"time"
)
type Rules struct {
Updated time.Time `json:"updated_at"`
Rules []RuleModel `json:"rules"`
Badges []BadgeModel `json:"badges,omitempty"`
}
type RuleModel struct {
Level int `json:"level"`
Name string `json:"name"`
Start int `json:"sw... |
f661cc97267be6f3bfd1c4c4d0c059efe0a69e6e | 75312b5000e34a7e9a00d7b9fe157fa0c6ca6ba9 | no2key/wechat-1 | /mp/server/pay2/order_notify.go | Go | go | 3,209 | permissive | // @description wechat 是腾讯微信公众平台 api 的 golang 语言封装
// @link https://github.com/chanxuehong/wechat for the canonical source repository
// @license https://github.com/chanxuehong/wechat/blob/master/LICENSE
// @authors chanxuehong(chanxuehong@gmail.com)
package pay2
import (
"crypto/subtle"
"encoding/xm... |
160871c089c498691d8bea625540b622b5e50170 | d8b3b4f2ed7f1e84c81632dd09498291a38ac58d | c0nnyr/go-enum | /main.go | Go | go | 2,506 | permissive | package main
import (
"fmt"
"io/ioutil"
"os"
"path/filepath"
"strings"
"github.com/abice/go-enum/generator"
"github.com/go-easygen/cli"
)
type rootT struct {
cli.Helper
FileNames []string `cli:"*f,file" usage:"The file(s) to generate enums. Use more than one flag for more files."`
NoPrefix bool... |
47616da1e075341ca1391ffcde87450d1b6a31b5 | 4af5d13830cc8c7836c6d386679cfe38b13cadab | saltfun/fuchsia | /tools/sdk-tools/fserve/cmd/fserve.go | Go | go | 17,468 | permissive | // Copyright 2020 The Fuchsia 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 (
"archive/tar"
"compress/gzip"
"context"
"crypto/md5"
"errors"
"flag"
"fmt"
"io"
"io/ioutil"
"log"
"os"
"os/exec"
"path/f... |
3c81f3c1035e7fb349c9f67adb514fa5366c02b1 | 26f7c80453ac2a87d7280d877ada4675f61bad12 | habushaws/incubator-openwhisk | /tools/cli/go-whisk/whisk/trace.go | Go | go | 2,730 | permissive | /*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may ... |
3ec402e68b1da843695b94ab170bf592fd326c52 | c8fc8c747ce43edf94b4a7e2b1970ac338117156 | ryanstout/example1 | /src/drive.go | Go | go | 388 | no_license | package main
import (
"fmt"
"github.com/syndtr/goleveldb/leveldb"
)
func main() {
db, err := leveldb.OpenFile("db/example", nil)
check(err)
err = db.Put([]byte("key"), []byte("value"), nil)
check(err)
data, err2 := db.Get([]byte("key"), nil)
check(err2)
fmt.Printf("Got: %s\n", string(data))
defer db.Clo... |
3edaa2fa5cad404de556459b086548d10f173879 | 2485aba0130500a86f5cc75a6fdedc17e9df5b1e | rayman51/4th-Year---Main-Project | /Project/Server-MatchMaking/server.go | Go | go | 1,505 | no_license | package main
import (
"bufio"
"fmt"
"net"
"os"
"log"
"encoding/json"
db "./db"
)
const (
CONN_HOST = ""
CONN_PORT1 = "5002"
CONN_PORT2 = "5003"
CONN_TYPE = "tcp"
)
type Server struct {
Username string
IpAddress string
}
func main() {
go listen(CONN_PORT2)
listen(CONN_PORT1)
}
func listen(port str... |
f366766342f9d172dbfca3640d0aaddc4da7faa9 | 994fe826c1e17fb24fafe348067f7a0eeb0c7514 | BeforyDeath/raftik | /actor/actor.go | Go | go | 6,107 | no_license | package actor
import (
"encoding/json"
"fmt"
"log"
"math/rand"
"sync"
"time"
"github.com/BeforyDeath/raftik/store"
)
var (
m sync.Mutex
redigoNil string = "redigo: nil returned"
)
type Actor struct {
Store *store.Store
UUID string
Role int
Term int
VotingActive b... |
11b95224f79551f14a8000a31b9769ad8c776e72 | 29aa7dc3800e30c50fd223476bb4ea6f25a6f088 | PGZXB/PGCloudDisk | /db/file.go | Go | go | 7,283 | no_license | package db
import (
"PGCloudDisk/errno"
"PGCloudDisk/models"
"gorm.io/gorm"
"strings"
)
func AddFile(file *models.File) (s errno.Status) {
// 不允许[filename, location, user_id]重复
err := conn.Where(
"filename = ? AND location = ? AND user_id = ?",
file.Filename, file.Location, file.UserID,
).First(&models.Fi... |
0334b8165a960de8f74d1b35454ad3af5031b2ae | 02ba5a6d7a966c7aecff06406eb165ce7b09f2a1 | zoulux/leetcode | /alg/heap/main.go | Go | go | 502 | no_license | package main
import (
"container/heap"
"fmt"
"sort"
)
func main() {
h := &hp{}
heap.Push(h, 7)
heap.Push(h, 5)
heap.Push(h, 3)
heap.Push(h, 10)
fmt.Println(h.IntSlice[0])
}
type hp struct {
sort.IntSlice
}
func (h *hp) Push(x any) {
h.IntSlice = append(h.IntSlice, x.(int))
}
func (h *hp) Pop() any {
ln... |
11903b409c65bb5b29ab572675f326737d4125f4 | 64ba0cb200bd8374178d5084f5b281e537145ce5 | wangyk2019/taylors | /server/router/stock_detail.go | Go | go | 811 | permissive | package router
import (
"github.com/gin-gonic/gin"
v1 "taylors/api/v1"
"taylors/middleware"
)
func InitStockRouter(Router *gin.RouterGroup) {
StockRouter := Router.Group("stock").Use(middleware.JWTAuth()).Use(middleware.CasbinHandler())
{
StockRouter.POST("top/list", v1.StockTopCon.StockTopList)
}
{
Stock... |
57734b861fb3990c23865d8c2c38e0be038c6e44 | d01b49b1870f9e99e8c4908fff416fe444786c98 | radanalyticsio/oshinko-cli | /vendor/github.com/openshift/origin/cmd/service-catalog/go/src/github.com/kubernetes-incubator/service-catalog/plugin/pkg/admission/servicebindings/lifecycle/admission.go | Go | go | 4,000 | permissive | /*
Copyright 2017 The Kubernetes 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, ... |
071dc79f1a564de9b3ae4b596d134be5ea41dcaf | ae434fec81d3e345b26a035f3ffc557ba268ca03 | abel-oye/qanswer | /search/baidu.go | Go | go | 2,164 | permissive | package search
import (
"fmt"
"net/url"
"regexp"
"strings"
"sync"
"qanswer/util"
"github.com/ngaut/log"
)
//SearchResult 搜索总数跟频率
type SearchResult struct {
Sum int32
Freq int32
}
//GetSearchResult 返回各个搜索引擎返回的结果
func GetSearchResult(question string, answers []string) map[string][]*SearchResult {
if question == ""... |
135cf6084275d5252b6117f9f910c28efbb0d4fc | 38cda973713eb3e8f19be425f396cb7fce71bcda | lioneagle/c4 | /src/parser/parser.go | Go | go | 15,688 | permissive | package parser
import (
"config"
"fmt"
"io/ioutil"
"strconv"
//"strings"
"vm"
)
type Symbol struct {
Token Token
Name string
Class Token
Type Type
Value interface{}
BClass Token
BType Type
BValue interface{}
}
type Symbols map[string]*Symbol
type Parser struct {
src []byte
pos ... |
6dc6ed19eeec491907e8e6d5ad15013904bc4d1c | 9692cb09356f9a0539aa7ed5198c67edcb3341ad | noil/tea | /historical.go | Go | go | 5,485 | permissive | package tea
import (
"compress/gzip"
"encoding/json"
"errors"
"net/http"
"time"
)
const (
maxHistoricalTweets = 25
)
var (
// ErrExceedsMaxHistoricalTweets provide that you reach max count of tweets. (25 max)
ErrExceedsMaxHistoricalTweets = errors.New("number of tweets exceeds 25")
)
var defaultHistoricalEn... |
8a122137902e74559d4688c191c42ee16d303664 | c03848782ca7dc72a8717c1801be012f3e260e09 | DennisRutjes/lattigo | /ckks/ciphertext.go | Go | go | 1,227 | permissive | package ckks
import (
"github.com/ldsec/lattigo/v2/ring"
"github.com/ldsec/lattigo/v2/utils"
)
// Ciphertext is *ring.Poly array representing a polynomial of degree > 0 with coefficients in R_Q.
type Ciphertext struct {
*Element
}
// NewCiphertext creates a new Ciphertext parameterized by degree, level and scale.... |
b49a8235974bcda7857acc045973b49cee875382 | 731f6b76714bdbba3bb5749174eeb0fdd1c9ff4a | 3ech7oul/kld_course | /lesson5/hw1.go | Go | go | 390 | no_license | package main
import (
"fmt"
"sync"
"time"
)
func sender(i int, c chan int) {
fmt.Println(i)
c <- i
}
func reciver(c chan int) {
data := make([]int, 5)
i := <-c
data = append(data, i)
time.Sleep(time.Second)
fmt.Println(i)
}
func main() {
var c chan int = make(chan int)
var wg sync.WaitGroup
wg.Add(1... |
eab1ddfcfee5ca1e758365897bffbc169dce21d9 | 3d209e65a5d69e461efa28ee55a0c330df357ec8 | mathworks/arrow | /go/arrow/cdata/cdata.go | Go | go | 24,896 | permissive | // Licensed to the Apache Software Foundation (ASF) under one
// or more contributor license agreements. See the NOTICE file
// distributed with this work for additional information
// regarding copyright ownership. The ASF licenses this file
// to you under the Apache License, Version 2.0 (the
// "License"); you may... |
df94b24ab0f74a61cce8d11c4a524eaf71745d88 | 4fa06f062c96072b0953239c6bbd17746d748464 | wuhuaqiang/GoBatis | /reflect.go | Go | go | 12,076 | no_license | package gobatis
import (
"database/sql"
"database/sql/driver"
"errors"
"fmt"
"reflect"
"strings"
"github.com/runner-mei/GoBatis/reflectx"
)
var _scannerInterface = reflect.TypeOf((*sql.Scanner)(nil)).Elem()
var _valuerInterface = reflect.TypeOf((*driver.Valuer)(nil)).Elem()
// isScannable takes the reflect.T... |
abcbe336eb664f93d419f0b833ee62af917007f0 | b0b6b8f9b1f0408a76ac859542a72d99b1444f78 | LINBIT/stork | /vendor/gocloud.dev/gcerrors/errors.go | Go | go | 2,820 | permissive | // Copyright 2019 The Go Cloud Development Kit 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
//
// https://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by appli... |
0bac8176a84c68e3bee2f402aee7bb79710ac7d9 | 37a4bf7268a22d73ae36eb8c4109820035396784 | RobertPeng/gotest | /concurrent_prime_sieve.go | Go | go | 781 | no_license | // A concurrent prime sieve
package main
// Send the sequence 2, 3, 4, ... to channel 'ch'.
func Generate(ch chan<- int) {
for i := 2; ; i++ {
ch <- i // Send 'i' to channel 'ch'.
}
}
// Copy the values from channel 'in' to channel 'out',
// removing those divisible by 'prime'.
func Filter(in <-chan int, out cha... |
c10b939dc40b0ca98875db86a043a39dc35bc563 | c23bcca4ca9e43dcb03da81a826ebea92a246ff5 | ydfydf/learn-go | /go/src/learngo/rpc/rpcdemo.go | Go | go | 901 | no_license | package rpcdemo
import "errors"
//RPC最终被rpc client采用Service.Method的方式进行调用
//DemoService是RPC里面的Service
type DemoService struct {
}
type Args struct {
A , B int //RPC里,像这种函数的输入参数,里面的值都要Public,因为要给别人调用
}
//Div是RPC里面的Method,Method是有一定的规范的
//RPC server里的函数对参数有要求,参数必须为两个,一个是输入参数args(输入参数只能一个,但不管是什么结构都行),一个是输出参数*result(... |
6a797d5f4a32cd3a4d89fe567ef89b0fbd8c484b | 9f488335b55afd4310b800ec9e2eae7dabb21dba | nsini/kplcloud | /src/pkg/auth/transport.go | Go | go | 1,684 | no_license | package auth
import (
"context"
"encoding/json"
kitlog "github.com/go-kit/kit/log"
kithttp "github.com/go-kit/kit/transport/http"
"github.com/gorilla/mux"
"io/ioutil"
"net/http"
)
func MakeHandler(svc Service, logger kitlog.Logger) http.Handler {
//ctx := context.Background()
opts := []kithttp.ServerOption{
... |
dc39e0c9993328694a3d2b4c7239e60e0862d7ff | c8073d80010b6a31a2fbc5994b818713c3d2da6f | go-distributed/xtree | /db/recordio/record_test.go | Go | go | 700 | permissive | package recordio
import (
"bytes"
"reflect"
"testing"
)
func TestEncodeDecode(t *testing.T) {
tests := []struct {
data []byte
}{
{[]byte("someData")},
{[]byte("someOtherData")},
}
for i, tt := range tests {
buf := new(bytes.Buffer)
recordToWrite := &Record{tt.data}
if err := recordToWrite.encodeT... |
772097cfb5bd1842fb653302cd594fa199b85aa0 | b0c24625a27b1467fc007657850bd2650daf7848 | axamon/compresso | /devel/chan/cor/main.go | Go | go | 478 | permissive | package main
import (
"fmt"
"sync"
"time"
)
func dosomething(millisecs time.Duration, wg *sync.WaitGroup) {
//wg.Add(1)
//go func() {
defer wg.Done()
duration := millisecs * time.Millisecond
time.Sleep(duration)
fmt.Println("Function in background, duration:", duration)
//}()
}
func main() {
var wg sync.W... |
c4c9503d91e8c6f30c4c466321abba654ff81dfa | 4d47804256c25988373243cc4b94118c226a00ce | EmbeddedEnterprises/nexus | /client/client.go | Go | go | 41,474 | permissive | /*
Package client provides a WAMP client implementation that is interoperable with
any standard WAMP router and is capable of using all of the advanced profile
features supported by the nexus WAMP router.
*/
package client
import (
"context"
"crypto/tls"
"errors"
"fmt"
"strings"
"sync"
"sync/atomic"
"time"
... |
7695f9b39f7a05c47c1784d0bda6a1729223362d | 8042a60a97753fe27f9382a97146b7bb7d900ebe | fonero-project/fnod | /peer/doc.go | Go | go | 7,077 | permissive | // Copyright (c) 2015-2016 The btcsuite developers
// Copyright (c) 2016-2018 The Decred developers
// Use of this source code is governed by an ISC
// license that can be found in the LICENSE file.
/*
Package peer provides a common base for creating and managing Fonero network
peers.
Overview
This package builds up... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.