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 |
|---|---|---|---|---|---|---|---|---|
26cb96b4c952ec063868aac8995fb956a7944fcd | 6a9ed34136b1f114d09895d126d169692413a534 | clia/kratos | /tool/protobuf/protoc-gen-bswagger/generator.go | Go | go | 9,298 | permissive | package main
import (
"encoding/json"
"net/http"
"regexp"
"strings"
"github.com/clia/kratos/tool/protobuf/pkg/gen"
"github.com/clia/kratos/tool/protobuf/pkg/generator"
"github.com/clia/kratos/tool/protobuf/pkg/naming"
"github.com/clia/kratos/tool/protobuf/pkg/tag"
"github.com/clia/kratos/tool/protobuf/pkg/ty... |
f18895de8250e9da09f7b8fe38848750449fc16f | 26bfd0632cc39bba44eb600341aae9596f223a8d | sk-develop/actions-test | /env.go | Go | go | 568 | no_license | package main
import (
"github.com/kelseyhightower/envconfig"
)
var envVars Variables = initVariables()
func initVariables() Variables {
var vars Variables
if err := envconfig.Process("", &vars); err != nil {
panic(err)
}
return vars
}
// Variables .
type Variables struct {
PsqlPort int `envconfig:"PS... |
5b7249919e6661243892146b5bc5f80030ca1442 | bc923362cf7e17955cf692c32021c04efdac19a0 | koficypher/algowithgo | /module01/reverse.go | Go | go | 473 | no_license | package module01
import (
"fmt"
)
//ReverseString reverses a string
func ReverseString(word string) string {
var res string
for i := len(word) - 1; i >= 0; i-- {
// fmt.Println(string(word[i]))
res = res + string(word[i])
}
//fmt.Println(res)
return res
}
//ReverseStringAlt is an alternative for reversing ... |
c86e6e15f34a8b9fa7f775ce2f86bda1746db16b | 90538a9c2e2765c0cf753e843253bb4f2ad700d8 | AgeloVito/fscan | /WebScan/lib/client.go | Go | go | 2,203 | permissive | package lib
import (
"context"
"crypto/tls"
"errors"
"github.com/shadow1ng/fscan/common"
"golang.org/x/net/proxy"
"log"
"net"
"net/http"
"net/url"
"strings"
"time"
)
var (
Client *http.Client
ClientNoRedirect *http.Client
dialTimout = 5 * time.Second
keepAlive = 5 * time.Second
)... |
42888bafad199490d41f15e9ea0bc559b18f58cf | fb787f62aeddad8ed7f0e9f6f9e3555bbb324ec2 | barnettZQG/gomig | /migrate.go | Go | go | 1,822 | permissive | package main
import (
"fmt"
"log"
"github.com/barnettzqg/gomig/db"
"github.com/barnettzqg/gomig/db/common"
)
const (
PATH_CONFIG_DEFAULT = "config.yml"
)
type MigrateCommand struct {
/* config file */
File string `short:"f" long:"file" description:"The path of the configuration file to use" default:"config.y... |
78bd895cfdfc147d4df4f456a9e9605aa25504bd | 3c457f1f2ae06b86163cdb05d98fc68d38b9556e | nhunam/apus | /redis/redis.go | Go | go | 1,262 | no_license | package redis
import (
"context"
"encoding/json"
"fmt"
"github.com/go-redis/redis/v8"
"gitlab.com/apus-backend/base-service/config"
"time"
)
type Redis struct {
Rdb *redis.Client
CommonDur time.Duration
}
func NewRedis(c config.Config) (*Redis, error) {
commonDur, err := time.ParseDuration(c.Redis.Ttl... |
5793e451461eedf79afd69c637e0f8ddbd000ff4 | 7fb8b9e2aae2c34b7f2fd784cc33a42c3b19cbeb | swipswaps/octant | /internal/describer/crd_watcher.go | Go | go | 2,865 | permissive | /*
Copyright (c) 2019 the Octant contributors. All Rights Reserved.
SPDX-License-Identifier: Apache-2.0
*/
package describer
import (
"context"
"fmt"
"sync"
"github.com/pkg/errors"
"k8s.io/apimachinery/pkg/apis/meta/v1/unstructured"
kcache "k8s.io/client-go/tools/cache"
"github.com/vmware-tanzu/octant/intern... |
9d05bb4ee34aa28bbb3b1143dc3c4d1a384ed753 | a1907dfb47cf1c7740868f7521e1c6c48c5cbb63 | JasonMKurtz/bitly-svc | /src/endpoint.go | Go | go | 1,202 | no_license | package main
import (
"encoding/json"
"net/http"
"strings"
bitlinks "./bitlinks"
metrics "./metrics"
server "./server"
userinfo "./userinfo"
)
var app server.Routes
func main() {
// The port that our endpoint will be accessible on.
app = server.Routes{Port: "5000"}
// All endpoints that we will serve. In... |
fe0a5848d9f6046d4be46a1ac0cc83103295dc5c | d05b4aaf0f6dc939517216e472e71ffdb0d20799 | jiaxinwang/cookiecutter-go-cli | /{{cookiecutter.app_name}}/model/sample.go | Go | go | 474 | no_license | package model
import (
"time"
)
type Dog struct {
ID uint `gorm:"primaryKey" json:"id"`
CreatedAt time.Time `json:"created_at"`
UpdatedAt time.Time `json:"updated_at"`
DeletedAt *time.Time `sql:"index" json:"-"`
Name string
}
type Cat struct {
ID uint `gorm:"primaryKey" json:"... |
499dc146de01290f84d5069a3cd65a491431a36e | 6ae40cf9c5834b6a95e6c76cbd578ab4ea5cc3ca | codifierr/go-examples | /rmq/sender/main.go | Go | go | 1,083 | permissive | package main
import (
"fmt"
"log"
"time"
"github.com/streadway/amqp"
)
func failOnError(err error, msg string) {
if err != nil {
log.Fatalf("%s: %s", msg, err)
}
}
func main() {
conn, err := amqp.Dial("amqp://guest:guest@localhost:5672/")
failOnError(err, "Failed to connect to RabbitMQ")
defer conn.Close... |
5d32269930506c7f8e9de0499d00d5a264369ee9 | e3eb299a9fdd1ed38a4993510545388d93ae2919 | zouhuigang/crawler-dianping | /mainex/test/ini1.go | Go | go | 567 | no_license | package main
import (
"fmt"
"github.com/go-ini/ini"
)
func main() {
Write()
}
//读取值
func Read() {
cfg := ini.Empty()
cfg.Section("author").Key("GITHUB").String() // how about continuation lines?
cfg.Section("package").Key("FULL_NAME").String()
cfg.Section("dianping").Key("name").String()
}
func Write() {
cf... |
ee296539718ad0fcd58cba4fa4fefb4af1e0537c | 7360d7335124745fae437025068ea3a49d12bc3c | forkkit/ok | /compiler/statement.go | Go | go | 972 | permissive | package compiler
import (
"github.com/elliotchance/ok/ast"
"github.com/elliotchance/ok/vm"
)
func compileStatement(compiledFunc *vm.CompiledFunc, statement ast.Node, breakIns, continueIns vm.Instruction, file *vm.File) error {
switch n := statement.(type) {
case *ast.Break:
compiledFunc.Append(breakIns)
retur... |
f06509c44458bb70214cfd6410c09f1dacf309cf | 5713df12a39f4afcf47a2a93493b0145a53c2de0 | bogdan-radocea/syros | /api/cluster-repository.go | Go | go | 2,300 | permissive | package main
import (
"time"
log "github.com/Sirupsen/logrus"
"github.com/stefanprodan/syros/models"
"gopkg.in/mgo.v2/bson"
)
func (repo *Repository) AllClusterHealthChecks() ([]models.ClusterHealthCheck, error) {
s := repo.Session.Copy()
defer s.Close()
c := s.DB(repo.Config.Database).C("cluster_checks")
c... |
5924dc4e8606121e2dae0f888c474e80545e73e1 | e7bf2ff7f0445e981a4dff3be2061bc4cc0d6b55 | coreygirard/euler-go | /code/pe2.go | Go | go | 211 | no_license | package main
import "fmt"
func main() {
a := 1
b := 1
c := a + b
total := 0
for {
if a > 4000000 {
break
}
if a%2 == 0 {
total += a
}
a = b
b = c
c = a + b
}
fmt.Println(total)
}
|
076d0922158a9b74a9f10a1618280f25354b7bef | 1efe5e8fc9b1089ee3ca040754d2037aee09a88f | AlexWoo/webrtc | /sctptransport.go | Go | go | 6,365 | permissive | // +build !js
package webrtc
import (
"errors"
"io"
"math"
"sync"
"github.com/pion/datachannel"
"github.com/pion/logging"
"github.com/pion/sctp"
)
const sctpMaxChannels = uint16(65535)
// SCTPTransport provides details about the SCTP transport.
type SCTPTransport struct {
lock sync.RWMutex
dtlsTransport ... |
d433f33df918497b7c572080a1c3ebbce39afd02 | 0a238064fd7812c35064c231f9231f0b6ea91f7b | Manali-Jain-squareops/0search | /blockworker/code/go/blockworker/core/encryption/keys.go | Go | go | 1,056 | permissive | package encryption
import (
"bufio"
"io"
"blockworker/core/common"
"blockworker/core/config"
"github.com/0chain/gosdk/core/zcncrypto"
)
/*ReadKeys - reads a publicKey and a privateKey from a Reader.
They are assumed to be in two separate lines one followed by the other*/
func ReadKeys(reader io.Reader) (public... |
17d2009b7e96c003105dacd5c5603af09bd8cfc0 | 613831d90dfec384468d79f4a32ad68746e8d2e7 | hashgraph/hedera-sdk-go | /delegate_contract_id_unit_test.go | Go | go | 4,691 | permissive | //go:build all || unit
// +build all unit
package hedera
/*-
*
* Hedera Go SDK
*
* Copyright (C) 2020 - 2023 Hedera Hashgraph, LLC
*
* 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
*... |
fab4b3e8bed9ac585e6037e4bc89a2ee7a2398f3 | 2f7260801e2610c11547e8c1eab70aa8c72cf053 | mayeral/hornet | /pkg/config/dashboard_config.go | Go | go | 1,648 | permissive | package config
const (
// the bind address on which the dashboard can be access from
CfgDashboardBindAddress = "dashboard.bindAddress"
// whether to run the dashboard in dev mode
CfgDashboardDevMode = "dashboard.dev"
// the theme for the dashboard to use (default or dark)
CfgDashboardTheme = "dashboard.theme"
/... |
1604f68072f889252454b9515dea1f3f872b756e | af9255bc23a3105ead901c7b3f9c3b001cd7ea7b | stupidchen/leetcode | /src/leetcode/goSolution/P3785.go | Go | go | 819 | no_license | package goSolution
func canSwimToTheEnd(grid [][]int, t int) bool {
n := len(grid)
m := len(grid[0])
q := [][]int{{0, 0}}
v := Initialize2DIntSlice(n, m, -1)
v[0][0] = 0
for h := 0; h < len(q); h++ {
x, y := q[h][0], q[h][1]
for d := 0; d < 4; d++ {
tx, ty := x + DX[d], y + DY[d]
if tx >= 0 && ty >= 0 ... |
4c121d3066b50cc339f514b3eda5905abc479c17 | 449c1a2c475fd4475d5fb6558664dee0c8046ed3 | hellojukay/gors | /cmd/record.go | Go | go | 559 | no_license | package cmd
import (
"github.com/hellojukay/gors/record"
"github.com/spf13/cobra"
)
var rfilename string
var RecordCmd = &cobra.Command{
Use: "rec",
Short: "record you terminal and save to a filename",
Long: "record you terminal and save to a filename",
Run: func(cmd *cobra.Command, args []string) {
reco... |
7f9d95787399bc91660ce64b7ed3e1d23734d554 | dd9f4cf3370a90fc2d8111ea60f93eb1aacc68d0 | ChimeraCoder/golang-stuff | /github.com/cloudfoundry/gorouter/registry.go | Go | go | 7,314 | permissive | package router
import (
"encoding/json"
"fmt"
mbus "github.com/cloudfoundry/go_cfmessagebus"
steno "github.com/cloudfoundry/gosteno"
"math/rand"
"github.com/cloudfoundry/gorouter/stats"
"github.com/cloudfoundry/gorouter/util"
"strings"
"sync"
"time"
)
type Uri string
type Uris []Uri
func (u Uri) ToLower() ... |
4da1022bbbde55cf6c8e0b5a3de9b53a9b97db17 | da8860795282ab78e3ce90dca73d6cc79b453517 | vlasove/test03 | /internal/app/storage/storage.go | Go | go | 721 | no_license | package storage
import (
"database/sql"
_ "github.com/lib/pq" // postgres adapter
)
// Storage ...
type Storage struct {
config *Config
db *sql.DB // later
repo *Repository
}
// New ...
func New(config *Config) *Storage {
return &Storage{config: config}
}
// Open ...
func (s *Storage) Open() error {
d... |
895ee5047c354460d92a06b565f2864a21c711c2 | d9e78c04ceff7855bf0d7ae598e785416092142c | dianchengwangCHN/tinysql | /planner/cascades/transformation_rules.go | Go | go | 34,369 | permissive | // Copyright 2018 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... |
09ef8076c7a8c066e3cd95af96b582da6bc5c480 | 97b4afb1831ad70fb0ed498dbde6b926fe5a3db4 | globocom/grou-loader | /api/engine.go | Go | go | 671 | no_license | package api
import (
"github.com/gin-gonic/gin"
"github.com/globocom/grou-loader/loader"
"os"
)
func NewEngine(port string) *Engine {
osHostname, _ := os.Hostname()
return &Engine{engine: gin.Default(), port: port, handler: NewEngineHandler(osHostname, port)}
}
type Engine struct {
tools *loader.Tools
engin... |
15b090e946cf6d76970b2edc869bd862f29ab25f | 7f6b09e1f0b904ef23ea4025e7aa9684141b9d0c | showmen-gupta/distributed-works | /lab2/grpc/server/server_test.go | Go | go | 9,284 | no_license | package main
import (
"fmt"
"sort"
"strconv"
"strings"
"testing"
"golang.org/x/net/context"
pb "github.com/uis-dat320-fall16/labs/lab3/grpc/proto"
)
func TestGRPCServer(t *testing.T) {
testGRPCCalls(insertTests, "Insert Tests", t)
testGRPCCalls(lookupTests, "Lookup Tests", t)
testGRPCCalls(keysTests, "Key... |
588c362abb2e979a7511ef87d738d7b6044172c6 | b994e8318519b6114d57eb3a83e86ccc97f93a00 | HubSpot/vitess | /go/vt/topo/test/election.go | Go | go | 4,023 | permissive | /*
Copyright 2017 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 writing, software
dis... |
d69bded7abcbc445069076df3e8229f549b46c3c | db68b3c9b4660febd64e9b1603f5a15f3c2773c5 | kauncoder/cryptopals-challenges | /set-2/Set2-Challenge11.go | Go | go | 5,704 | no_license | package main
import (
"fmt"
"crypto/aes"
"crypto/rand"
)
//one function to generate AES keySize
//have two functions one uses cbc and the other ecb
//next function to genrate key and encrypt; this one takes the plaintext, appends random bytes to the plaintext, flips a coin to chose cbc or ecb mode and enc... |
819d12e934a4dbb8fa1e79c893672c259d62911e | 7cc3b06a6f184545c6f535fefec49158732dc7e3 | mylxsw/adanos-scheduler | /repo/job.go | Go | go | 2,607 | permissive | package repo
import (
"context"
"time"
)
// Job 定义了一个任务
type Job struct {
ID string `json:"id"`
Name string `json:"name"`
Description string `json:"description"`
Command string `json:"command"`
CreatedAt time.Time `json:"created_at"`
UpdatedAt time.Time `json:"updated_at"`
... |
1304fe8210e1832f4fed35f5aae66c42d67ef556 | d5245a45f0b3e92bb724cfe4af774acee2362beb | sowdf/golang | /src/crawker/zhenai/parser/citylist.go | Go | go | 608 | no_license | package parser
import (
"crawker/engine"
"regexp"
)
const cityListRe = `<a href="(http://www.zhenai.com/zhenghun/[0-9a-z]+)" [^>]*>([^<]+)</a>`
func ParseCityList(contents []byte, _ string) engine.ParseResult {
//<a href="http://www.zhenai.com/zhenghun/xinzhu" data-v-5e16505f>新竹</a>
re := regexp.MustCompile(city... |
8cf260ae9f52c24a59df49afd03ecba6977bb9f9 | 84f5c3a9c657a1e893faa8c9cd5f6bb7e03137a9 | shishir-a412ed/Algorithms | /src/goProof/gzip_unzip.go | Go | go | 1,435 | no_license | // Reads an input tar ball into memory, compress it into a gzip stream. Write that compressed gzip stream onto a buffer.
//Takes a gzip reader on that buffer and uncompress the gzip stream. Write the original tar ball back onto the disk.
//NOTE: To run this program please use your own tar ball.
package main
import (... |
016f9d004336ae7a6e92ea71a9b4c4f77164c24d | 8d652096dc2175369427f185221a522f51851c75 | lemaral/cnd | /pkg/k8/client/client.go | Go | go | 1,006 | permissive | package client
import (
"os"
"path"
"k8s.io/client-go/kubernetes"
"k8s.io/client-go/rest"
"k8s.io/client-go/tools/clientcmd"
clientcmdapi "k8s.io/client-go/tools/clientcmd/api"
)
//Get returns a kubernetes client. If namespace is empty, it will use the default namespace configured.
func Get(namespace string) (... |
e0e1c1646cdc180549cdea20650d675aee7a5a61 | 11d024ef2bb0bd82e4d5273696353b8c36653974 | samcrow-ind/learn-chaincode | /create Patient/CreatePatient.go | Go | go | 8,575 | 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 not use this... |
03b976c8ad9b98a9ef13462bbb83dfe8bd70173d | 73f3b5b05607985200e2e832ebbc2e9b951c5ff6 | knolleary/cli | /src/cf/net/uaa_gateway_test.go | Go | go | 1,086 | permissive | package net_test
import (
"cf/configuration"
. "cf/net"
"fmt"
. "github.com/onsi/ginkgo"
. "github.com/onsi/gomega"
"net/http"
"net/http/httptest"
testconfig "testhelpers/configuration"
)
var failingUAARequest = func(writer http.ResponseWriter, request *http.Request) {
writer.WriteHeader(http.StatusBadReques... |
7bbd3880fca93dce3445b6a4c46e04b6d5d35d2e | 82446f056d6a32a9b800464ca8f75c57eb801b95 | comet-ml/kubeflow | /bootstrap/vendor/github.com/ksonnet/ksonnet/cmd/env_set_test.go | Go | go | 1,115 | permissive | // Copyright 2018 The ksonnet 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 applica... |
e3725a8375f657bfad649d12efd365edf36a2e1f | 869e845513d1ac7608193c8ece78194c8f541a07 | jlcool/kefu_server | /controllers/services_statistical.go | Go | go | 3,252 | permissive | package controllers
import (
"encoding/json"
"kefu_server/utils"
"time"
"github.com/astaxie/beego"
"github.com/astaxie/beego/logs"
"github.com/astaxie/beego/orm"
"github.com/astaxie/beego/validation"
)
// ServicesStatisticalController struct
type ServicesStatisticalController struct {
beego.Controller
}
// ... |
941e054cd9a7125133a654253d76abf10908c9d1 | c93590aa4b2a829d4f19c0cd2bdb552d753bb9d2 | eriklupander/rt | /internal/pkg/mat/matrix_test.go | Go | go | 8,233 | permissive | package mat
import (
"fmt"
"github.com/stretchr/testify/assert"
"testing"
)
func TestCreateMatrix2x2(t *testing.T) {
m2 := NewMat2x2([]float64{-3, 5, 1, -2})
assert.Equal(t, -3.0, m2.Get(0, 0))
assert.Equal(t, 5.0, m2.Get(0, 1))
assert.Equal(t, 1.0, m2.Get(1, 0))
assert.Equal(t, -2.0, m2.Get(1, 1))
}
func Te... |
e2eb52412c3400e02e065b793077825115647197 | 91b27df814a90e1d3b2482010ac1642f9d121acb | tanguyfalconnet/amazon-vpc-cni-k8s | /pkg/ipamd/datastore/data_store.go | Go | go | 26,505 | permissive | // Copyright Amazon.com Inc. or its affiliates. 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. A copy of the
// License is located at
//
// http://aws.amazon.com/apache2.0/
//
// or in the "license" file ... |
fb61e65c5b3ce78514750a9c3651ab91dbe6effd | 0ae707f36cfce7d8da7c3116233b6010cde43b75 | qingfuwang/azure-sdk-for-go | /storage/table.go | Go | go | 3,337 | permissive | package storage
import (
"fmt"
"net/url"
"bytes"
"strconv"
"crypto/rand"
"strings"
"time"
)
type Table struct{
accountName string
accountKey string
tableName string
intilized bool
}
func CreateTable(accountName string,accountKey string,tableName string) (Table,error){
t:=Table{accountName,accountKey,table... |
2d364a1315e25dcbeaa061fdba3da0436c9cf48d | 260c716eb18cf4d89ee8846ade63c03d21a89f99 | happyfire/gostudy | /gopl/ch4/embed/main.go | Go | go | 652 | no_license | package main
import "fmt"
type Point struct {
X, Y int
}
type Circle struct {
Point //匿名成员
Radius int
}
type Wheel struct {
Circle //匿名成员
Spokes int
}
func main() {
{
//结构体字面值没有简短表示匿名成员的语法
//w := Wheel{8, 8, 5, 20} //编译错误
//w := Wheel{X: 8, Y: 8, Radius: 5, Spokes: 20} //unknown field
}
{
w := W... |
f50b19819ca0b1aef8f7858fd6eba13b9b1dabd4 | ccf3f7302527086b059e820d5b818791febded7c | vivimouret29/pulumi-azure-native | /sdk/go/azure/providerhub/skusNestedResourceTypeFirst.go | Go | go | 5,147 | permissive |
package providerhub
import (
"context"
"reflect"
"github.com/pkg/errors"
"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
)
type SkusNestedResourceTypeFirst struct {
pulumi.CustomResourceState
Name pulumi.StringOutput `pulumi:"name"`
Properties SkuResourceResponsePropertiesOutput `pulumi:... |
471319e618850a49f0582e992c1e7691b5a4a596 | 04f27fed4c79d24d26a2cf23073f734245911245 | vincenwang/tinychain | /p2p/protocol.go | Go | go | 1,224 | permissive | package p2p
import (
"github.com/tinychain/tinychain/p2p/pb"
"errors"
"github.com/libp2p/go-libp2p-peer"
)
var (
errDupHandler = errors.New("p2p handler duplicate")
)
// Protocol represents the callback handler
type Protocol interface {
// Typ should match the message type
Type() string
// Run func handles t... |
d39244e04cf479995e01e5534a8f62e4d4389896 | c3bb7f9ea9c11cc22bbaaadc72e0814036006b28 | paivagustavo/opentelemetry-go | /sdk/trace/simple_span_processor.go | Go | go | 4,566 | permissive | // Copyright The OpenTelemetry 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 agre... |
46433eae051b73dd7a05ac75aaeae570f43162c5 | c3950046e4350aa9cfdc2a29c43dd49667ab83e4 | newsletter2go/go-git | /storage/filesystem/config_test.go | Go | go | 1,085 | permissive | package filesystem
import (
"io/ioutil"
"os"
"github.com/src-d/go-git-fixtures"
"github.com/newsletter2go/go-git/storage/filesystem/internal/dotgit"
. "gopkg.in/check.v1"
"gopkg.in/src-d/go-billy.v3/osfs"
)
type ConfigSuite struct {
fixtures.Suite
dir *dotgit.DotGit
path string
}
var _ = Suite(&ConfigSu... |
d47df419c952b33c5c16608b6a0b2d67e9124f1b | 2e15bd96d970d566e5447f9cdf1e1adc7169c5f6 | closeio/flashback | /ops_reader_test.go | Go | go | 9,269 | no_license | package flashback
import (
"bytes"
"fmt"
"testing"
"time"
. "gopkg.in/check.v1"
"gopkg.in/mgo.v2/bson"
)
var (
logger *Logger
)
// Hook up gocheck into the "go test" runner.
func Test(t *testing.T) {
TestingT(t)
}
type TestFileByLineOpsReaderSuite struct{}
var _ = Suite(&TestFileByLineOpsReaderSuite{})
/... |
c81089c72dde37d6ebac62d977e8f81081968eaa | e3dd5acc22aeb777c8b98a2758b10657fe366a27 | edenbuaa/nuclio | /pkg/platform/kube/ingress/ingress.go | Go | go | 14,897 | permissive | package ingress
import (
"context"
"fmt"
"strings"
"github.com/nuclio/nuclio/pkg/cmdrunner"
"github.com/nuclio/nuclio/pkg/common"
"github.com/nuclio/nuclio/pkg/platformconfig"
"github.com/nuclio/errors"
"github.com/nuclio/logger"
"k8s.io/api/core/v1"
"k8s.io/api/extensions/v1beta1"
apierrors "k8s.io/apima... |
0a7d66cae5ee6bc05834f7ee6ed80ba18f615061 | 78ceab09f5e1d18074eddb2281fe287abcc10a5b | saurabhm3hra/magma | /orc8r/lib/go/protos/directoryd_helper.go | Go | go | 2,890 | permissive | /*
Copyright 2020 The Magma Authors.
This source code is licensed under the BSD-style license found in the
LICENSE file in the root directory of this source tree.
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR... |
1697224bcf4e4ae7a47f65fe4de7a1f994fc9755 | 80aa2ab12818eaa43e553781d58385b8aac2afe5 | cch123/monkey | /repl/repl.go | Go | go | 515 | no_license | package repl
import (
"bufio"
"fmt"
"io"
"github.com/cch123/monkey/lexer"
"github.com/cch123/monkey/token"
)
// PROMPT used to notice user
const PROMPT = ">>"
// Start starts the repl
func Start(in io.Reader, out io.Writer) {
scanner := bufio.NewScanner(in)
for {
fmt.Printf(PROMPT)
scanned := scanner.Sc... |
c11776c9329a5f02ad4b3334314db86e862b35ae | ff6f23a78df33ee5be6150c1336d8e14c4afb412 | jhh130910/golang | /pkg/05.values/values.go | Go | go | 230 | no_license | package main
import "fmt"
func main() {
fmt.Println("go" + "lang")
fmt.Println("1+1 =", 1+1)
fmt.Println("7.0/3.0 =", 7.0/3.0)
fmt.Println(true && false)
fmt.Println(true || false)
fmt.Println(!true)
}
|
71b9a3e61302126e97c50bc6acbf60ec9a5287ce | 7d788c6ffca3f3d9f0682cfffc912fd42adac831 | thermeon/gocui | /guier.go | Go | go | 1,547 | permissive | // Copyright 2014 The gocui 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 gocui
// Gui represents the whole User Interface, including the views, layouts
// and keybindings.
type Guier interface {
Close()
Size() (x, y int... |
3d28284aa910a920bc70e15987a2ff05c44df116 | 99c84e1ba4c164a2e662eca80bb7ce3fec0cbc0e | SrihariPatil/go-training | /hello/main.go | Go | go | 219 | no_license | package main
import (
"fmt"
"github.com/GoesToEleven/GolangTraining/02_package/stringutil"
)
func main() {
fmt.Println("hello world")
fmt.Println(stringutil.Reverse("!oG ,sir"))
fmt.Println(stringutil.MyName)
}
|
0a1b6e94cc0906c454ac5a61d44af8dfaf6d1051 | 8ec2869c7bbc5ce395ae7113f1d7989f1ab88f39 | zpq/beeblog | /models/models.go | Go | go | 1,167 | no_license | package models
import (
"os"
"path"
"time"
"github.com/Unknwon/com"
"github.com/astaxie/beego/orm"
_ "github.com/mattn/go-sqlite3"
)
const (
_DB_NAME = "data/beeblog.db"
_SQLITE3_DRIVER = "sqlite3"
)
type Category struct {
Id int64
Title string //default varchar(255)
Crea... |
53177ee05b69b94e81332a183ebb045afc37f759 | 5e08793baca18c6bf01af6b99c8da2b87b3355db | ewagmig/xgo2-1 | /xgo2.go | Go | go | 14,707 | permissive | // Go CGO cross compiler
// Copyright (c) 2014 Péter Szilágyi. All rights reserved.
//
// Released under the MIT license.
// Wrapper around the GCO cross compiler docker container.
package main
import (
"flag"
"fmt"
"go/build"
"io"
"log"
"net/http"
"os"
"os/exec"
"os/user"
"path/filepath"
"strconv"
"strin... |
0fa064e68e50c397bfb018f99613df4a7d13040c | 67fb2a49c117e11d96b9e53de0408d83bd2aebea | ChinaArJun/fabric-sdk-go-gm | /pkg/core/mocks/mockconfigbackend.go | Go | go | 2,231 | permissive | /*
Copyright SecureKey Technologies Inc. All Rights Reserved.
SPDX-License-Identifier: Apache-2.0
*/
package mocks
import (
"strings"
"github.com/ChinaArJun/fabric-sdk-go-gm/pkg/core/config"
)
//MockConfigBackend mocks config backend for unit tests
type MockConfigBackend struct {
//KeyValueMap map to override C... |
b71b023c250994df9396a44898f2171d61ce9c09 | 5e3b385c602a0b55cd790b86f1d66717f76b4c88 | zhedahht/leetcode | /leetcode0875.go | Go | go | 620 | no_license | /*
LeetCode 875: https://leetcode.com/problems/koko-eating-bananas/
*/
package leetcode
import "math"
func minEatingSpeed(piles []int, H int) int {
getTime := func(piles []int, speed int) int {
result := 0
for _, p := range piles {
result += (p + speed - 1) / speed
}
return result
}
min, max := 1, 0
... |
a65d7ee52c895b3670b1ae93cfefa9963befe624 | 3c1692cbfbf3321b042634652352af4c05769f5f | gpedro/cloak | /controllers/guilds.go | Go | go | 8,761 | no_license | package controllers
import (
"image"
"image/gif"
"io/ioutil"
"net/http"
"net/url"
"os"
"time"
"github.com/Cloakaac/cloak/models"
"github.com/Cloakaac/cloak/util"
"github.com/julienschmidt/httprouter"
"github.com/nfnt/resize"
"github.com/raggaer/pigo"
)
type GuildController struct {
*pigo.Controller
}
/... |
db33a0da0a8fbb9913e15adb95528d64ef4186a0 | de293be16cc93dab0dac3c11492a85d8a6f230ab | cage1016/ms-demo-authz | /internal/app/authz/storage/v1/resource.go | Go | go | 250 | no_license | package v1
import "time"
type Resource struct {
ID string `db:"id" json:"id"`
Name string `db:"name" json:"name"`
CreatedAt time.Time `db:"created_at" json:"createdAt"`
UpdatedAt time.Time `db:"updated_at" json:"updatedAt"`
}
|
5c3bf95ba4d330ddc505bf1a4d69c58fcf786518 | d304a6c152a4307a88fc4c20adf68f902a91e8a1 | awesome-product/goalert | /graphql2/graphqlapp/tx.go | Go | go | 1,347 | permissive | package graphqlapp
import (
context "context"
"database/sql"
"github.com/target/goalert/util/errutil"
)
// withContextTx is a helper function that handles starting and using a single transaction for a request.
//
// If there is not already a nested transaction in the current context, one is started and a new
// co... |
ffd00c5d78b5d8d9d9a5209f9f8cd0af4e79fe7d | 162de35e770cd6e7ca4971eef90e3dce0ecd1204 | tbruyelle/gostuff | /gl/model.go | Go | go | 2,346 | no_license | package main
import (
"fmt"
"github.com/go-gl/gl"
glfw "github.com/go-gl/glfw3"
)
type Model struct {
buffer gl.Buffer
vertices []Vertex
sizeVertices int
prg gl.Program
posLoc gl.AttribLocation
colLoc gl.AttribLocation
timeLoc gl.UniformLocation
vao gl.VertexArr... |
93c3af0e55849e8078a67bc6fe4e6d9752d19d15 | 1964dba5e6b4c48b679d959688540348699428f8 | n4matos/go-ws-tks | /app/models/atendimentos.go | Go | go | 845 | no_license | package models
type Atendimentos struct {
NumeroGuiaPrestador string `json:"numeroGuiaPrestador"`
CodigoAutorizacao int `json:"codigoAutorizacao"`
SenhaAutorizacao string `json:"senhaAutorizacao"`
DataAutorizacao string `json:"dataAutorizacao"`
DescricaoGlosa string `json... |
2401e836ff3539323b8011573ec07d75f0539417 | caad5ca07241d2ba029b35342adc3358a3abd586 | isabella232/sourcegraph | /enterprise/cmd/precise-code-intel-worker/internal/worker/handler.go | Go | go | 9,101 | permissive | package worker
import (
"compress/gzip"
"context"
"fmt"
"io"
"sync/atomic"
"time"
"github.com/inconshreveable/log15"
"github.com/keegancsmith/sqlf"
"github.com/pkg/errors"
"github.com/sourcegraph/sourcegraph/cmd/frontend/backend"
"github.com/sourcegraph/sourcegraph/enterprise/cmd/precise-code-intel-worker/... |
21060290981c0ddb653e080b31451ed6405a13ef | a0fb2c3f70364bbbedba5c5f47801addbd90118e | knull-cn/AnnChain | /cmd/client/commons/abi_helpers.go | Go | go | 4,269 | permissive | // Copyright © 2017 ZhongAn Technology
// 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 ... |
d16c2a21aa46263c8ebbd1d80474fdfcee3f5d77 | 928e65f7ba6156508aaa8c8938061a15187e948a | fuzzylimes/UdemyGolangIntro | /23_error-handling/03_custom-error/03_fmt-errorf/main.go | Go | go | 270 | no_license | package main
import (
"fmt"
"log"
)
func main() {
_, err := Sqrt(-10)
if err != nil {
log.Fatalln(err)
}
}
func Sqrt(f float64) (float64, error) {
if f < 0 {
return 0, fmt.Errorf("norgate math: square root of a negative number: %v", f)
}
return 42, nil
}
|
56ccb45b43520d99b2a6713a593a055d81402bbe | ca8a5587e8ab4cfe4ff6df4689a4ae2ee5d6cc95 | Wondertan/trapezza-go | /session/manager.go | Go | go | 2,372 | no_license | package session
import (
"context"
"errors"
"sync"
)
const IDLength = 5
var ErrNotFound = errors.New("session: not found")
type Manager struct {
ctx context.Context
l sync.RWMutex
sessions map[ID]*Session
}
func NewManager(ctx context.Context) *Manager {
return &Manager{
ctx: ctx,
sessions:... |
335f381894bf96a5fd50b0e5dc4d4e029949bbcb | ee0a28f2004c2cb2ec223d42cbe1a8963a507590 | kubernetes/kops | /vendor/github.com/gophercloud/gophercloud/openstack/identity/v2/tokens/urls.go | Go | go | 385 | permissive | package tokens
import "github.com/gophercloud/gophercloud"
// CreateURL generates the URL used to create new Tokens.
func CreateURL(client *gophercloud.ServiceClient) string {
return client.ServiceURL("tokens")
}
// GetURL generates the URL used to Validate Tokens.
func GetURL(client *gophercloud.ServiceClient, tok... |
85950ae34c471511d4bc2e52c1e4e4e5e9244e27 | 7ccd255fa3a9de2c5b0eff344748baaba5f89f9b | kissingtiger/zcloud | /src/cloud/k8s/yaml.go | Go | go | 4,880 | no_license | package k8s
import (
"fmt"
"k8s.io/apimachinery/pkg/apis/meta/v1/unstructured"
"github.com/astaxie/beego/logs"
v12 "k8s.io/apimachinery/pkg/apis/meta/v1"
"strings"
"cloud/util"
"k8s.io/client-go/dynamic"
"encoding/json"
)
// 通过yaml文件创建服务
func CreateService() {
}
//apiVersion: apps/v1beta1
//kind: Deploym... |
acbffb7681c9fc58602fc246491d161ceeb070c5 | b863d04996626196c880dbd1beef1b6312b0e0b6 | metrumresearchgroup/rcmdparser | /rcmdparser/parse-checkdir.go | Go | go | 2,193 | no_license | package rcmdparser
import (
"bytes"
"fmt"
"path/filepath"
"github.com/dpastoor/goutils"
"github.com/spf13/afero"
)
// ParseCheckDir reads the relevant files in a check directory
// should take form of
// * 00check.log
// * 00install.out
// * (maybe) tests/testthat.Rout
// * (maybe) tests/testthat.Rout.fail
//
... |
638bde311d3de0b2fbabd0d4a690ba36ad8c56a2 | 6f1d7799c23535417336a65e007ab37f92c7a1df | influenzanet/user-management-service | /pkg/utils/weekday.go | Go | go | 3,530 | no_license | package utils
import (
"fmt"
"math/rand"
"strconv"
"strings"
"time"
)
type Interval struct {
min int
max int
entry time.Weekday
}
// Weekday assignation strategy
type Weight struct {
total int // Total of cumulated weights
intervals []Interval // Range of weight for each entry
}
type WeekDa... |
f8d0cec7b12cb78a2fda48236fa7442b367ccbda | 1e48152674230de6c49c38cdcb2068c6c919a3fa | aliafshar/tools | /claat/update.go | Go | go | 4,868 | permissive | // Copyright 2016 Google Inc. 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... |
fa402a62816163aadf7e3cf017cacebe548e17a4 | 81e6d1de5a2a24a00e505f46a45a137725ce491d | Global19-atlassian-net/grafana | /pkg/server/server.go | Go | go | 8,945 | permissive | package server
import (
"context"
"errors"
"flag"
"fmt"
"io/ioutil"
"net"
"os"
"path/filepath"
"strconv"
"sync"
"time"
"github.com/facebookgo/inject"
"golang.org/x/sync/errgroup"
"github.com/grafana/grafana/pkg/api"
"github.com/grafana/grafana/pkg/api/routing"
"github.com/grafana/grafana/pkg/bus"
_ ... |
f793174f0d967517f32f1050b47a0d49b3c48234 | f23242002c326ac49ece6ab08a4295c1173f990f | isotopsweden/docker-farmer | /vendor/github.com/docker/docker/vendor/src/github.com/docker/swarmkit/manager/state/store/by.go | Go | go | 2,412 | permissive | package store
import "github.com/docker/swarmkit/api"
// By is an interface type passed to Find methods. Implementations must be
// defined in this package.
type By interface {
// isBy allows this interface to only be satisfied by certain internal
// types.
isBy()
}
type byAll struct{}
func (a byAll) isBy() {
}
... |
eb380d6f7f34a745ddfeeeb2251f58f1e172ff45 | 4d6a4d90cc3bb10daead88ba4eb97ba2464ac426 | AmyGuo/leetCode | /Tree/257.treePaths/path_test.go | Go | go | 372 | no_license | package _57_treePaths
import "testing"
//
// 1
/// \
//2 3
// \
// 5
//
//输出: ["1->2->5", "1->3"]
//
func TestBinaryTreePaths(t *testing.T) {
node := new(TreeNode)
node.Val = 1
node.Left = &TreeNode{Val: 2, Left: &TreeNode{Val: 7}, Right: &TreeNode{Val: 5}}
node.Right = &TreeNode{Val: 3}
t.Log(BinaryTr... |
a88c3ae2e97014e9b7403ed4d5003fa705713d39 | 7f098456824dc19e312187e301f801ea7b1e46c1 | globalways/notifications | /web/services/preferences_finder_test.go | Go | go | 2,493 | permissive | package services_test
import (
"errors"
"github.com/cloudfoundry-incubator/notifications/fakes"
"github.com/cloudfoundry-incubator/notifications/models"
"github.com/cloudfoundry-incubator/notifications/web/services"
. "github.com/onsi/ginkgo"
. "github.com/onsi/gomega"
)
var _ = Describe("Pr... |
5797dfcf031d41da0c00d6b223d99be26b3619be | 0231aee716d67937e9adff30a9fef5c8fa5e3f85 | wanderer163/marketstore | /executor/rewritebuffer.go | Go | go | 3,301 | permissive | package executor
import (
"encoding/binary"
"math"
_ "go.uber.org/zap"
"github.com/alpacahq/marketstore/v4/utils/io"
_ "github.com/alpacahq/marketstore/v4/utils/log"
)
// RewriteBuffer converts variable_length records to the result buffer.
//
// variable records in a file: [Actual Data (VarRecLen-4 byte) , Int... |
0a243118c4796b69c130ca0cceef59ef016bff66 | 12c11e234c82680b7d58f4559d65595f24bed904 | andybenavides/CSCI-191T | /Presentation13Exercises/exercise1.go | Go | go | 260 | no_license | package main
import "fmt"
func main() {
Sum(93451, 232, 223, 423)
name := "Andy"
fmt.Print(name, "\n")
fmt.Printf("%v\n", name)
fmt.Println(name)
}
func Sum(num2 ...int){
sum := 0
for _, value := range num2{
sum += value
}
fmt.Println(sum)
}
|
726ce955783380ef225209de33c0695ccbae66de | 00ff65e61b1395b1722e679fd16835d20e6a7cb4 | netrixone/udig | /whois.go | Go | go | 5,208 | permissive | package udig
import (
"bufio"
"bytes"
"fmt"
"github.com/domainr/whois"
"io"
"strings"
)
var (
// SupportedWhoisProperties is a set of WHOIS properties that WhoisResolver honors.
SupportedWhoisProperties = map[string]bool{
"registry domain id": true,
"registrant": true,
"registrant ... |
373cc2cd838662e553e3be03826b5bed1cc41092 | aee5feddda563401fec35a65bf124c32a741b4eb | zhaojizhuang/knative-gcp | /test/upgrade/prober/verify.go | Go | go | 6,244 | permissive | /*
* Copyright 2020 The Knative Authors
* Modified work Copyright 2020 Google LLC
* 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
*
*... |
c40497548724b077a257bb3dccb4bf6005b155db | d909fe8b229e6ca6862e626c365bd4f2bb781629 | aaronjimv/Introduccion-a-Go | /6_paquetes/1_archivos/2_leer/6_walk/6_walk.go | Go | go | 875 | no_license | /*
A menudo, queremos recorrer una carpeta de forma
recursiva (leer el contenido de la carpeta, todas
las subcarpetas, todas las subcarpetas, etc.).
Para facilitar esto, hay una función Walk en el
paquete path / filepath:
*/
package main
import (
"fmt"
"os"
"path/filepath"
)
func main() {
filepath.Walk(".... |
fb6726a2dc843ed38e26ccf0d874336a773303dd | 087eb359055067099af9d21809dbb79dc09e1069 | dominikschulz/gopass | /pkg/clipboard/clipboard.go | Go | go | 3,114 | permissive | package clipboard
import (
"context"
"fmt"
"os"
"os/exec"
"github.com/atotto/clipboard"
"github.com/fatih/color"
"github.com/gopasspw/gopass/internal/notify"
"github.com/gopasspw/gopass/internal/out"
)
var (
// Helpers can be overridden at compile time, e.g. go build \
// -ldflags=='-X github.com/gopasspw/... |
4e25686c45d69d1d937942e2cc3cddba3da2ffc9 | 38f6b1a178d575dd90b02caace2e1fed8f758333 | kubenav/kubenav | /pkg/server/server.go | Go | go | 738 | permissive | package server
import (
"net/http"
"github.com/kubenav/kubenav/pkg/kube"
"github.com/kubenav/kubenav/pkg/server/middleware"
)
type server struct {
kubeClient kube.Client
}
// Start creates all routes for our internal http server and starts the server on port "14122".
func Start(kubeClient kube.Client) {
s := &... |
1f3cd2a80d7c1f24f04569ed1115d09e0f09f669 | d72a9d16a33e0e7f0c948e0ef7133b7e7231c60e | lowstz/qingcloud-terraform-provider | /qingcloud/resource_qingcloud_keypair.go | Go | go | 4,396 | permissive | package qingcloud
import (
"fmt"
"github.com/hashicorp/terraform/helper/schema"
qc "github.com/yunify/qingcloud-sdk-go/service"
)
func resourceQingcloudKeypair() *schema.Resource {
return &schema.Resource{
Create: resourceQingcloudKeypairCreate,
Read: resourceQingcloudKeypairRead,
Update: resourceQingclo... |
b38d87cec47f633186cd9411d6b03ed71704cc07 | 9767274dbd678a2948468af2177c62819788f28f | chenxull/MyLeetCode | /second/2019.8.19/804/804.unique-morse-code-words.go | Go | go | 774 | no_license | package problem804
/*
* @lc app=leetcode id=804 lang=golang
*
* [804] Unique Morse Code Words
*/
var table = []string{".-", "-...", "-.-.", "-..", ".", "..-.", "--.", "....", "..", ".---", "-.-", ".-..", "--", "-.", "---", ".--.", "--.-", ".-.", "...", "-", "..-", "...-", ".--", "-..-", "-.--", "--.."}
func uniq... |
02bbd30298dbee3d2c369b590bf8e006dd9d0a14 | 466045ba3a84e33781765e57176f06e325a2a2e4 | Oscarvince/incubator-apisix-dashboard | /api/service/upstream.go | Go | go | 5,635 | permissive | package service
import (
"encoding/json"
"fmt"
"github.com/apisix/manager-api/conf"
"github.com/apisix/manager-api/errno"
"github.com/apisix/manager-api/utils"
"github.com/satori/go.uuid"
)
type UpstreamDao struct {
Base
Name string `json:"name"`
Description string `json:"description,omitempty... |
cfb1b8ba4b13098aca5e51eda2cb4b47a24fc5a4 | 950b1c2da88cf7d88e4eeb5a54620f6affac41ef | ctdk/raintank-apps | /snap/plugin/snap-collector-rt-gitstats/gitstats/gitstats.go | Go | go | 6,098 | permissive | package gitstats
import (
"fmt"
"log"
"time"
"github.com/google/go-github/github"
"github.com/intelsdi-x/snap/control/plugin"
"github.com/intelsdi-x/snap/control/plugin/cpolicy"
"github.com/intelsdi-x/snap/core"
"github.com/intelsdi-x/snap/core/ctypes"
"golang.org/x/oauth2"
)
const (
// Name of plugin
Nam... |
baf704817c6fec60a4f458f290b849875c916869 | c4efc12f4b63eb57f0266d74cc154bf06c915efb | beego/beeweb | /routers/video.go | Go | go | 1,024 | permissive | // Copyright 2013 Beego Web 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 ... |
65116e7843c872fb6088cf2167420cfc900555ba | 8f4ebdebdcc214232dc4be406b56a98809c5616f | pingjing0628/golang-practice | /4.5_JSON/description.go | Go | go | 1,036 | no_license | package main
import (
"encoding/json"
"fmt"
"log"
)
// 將 GO 資料結構 轉換成 JSON 被稱為 marshaling, 透過 json.Marshal 完成
type Movie struct {
Title string
Year int `json:"released"`
Color bool `json:"color,omitempty"`
Actors []string
}
// omitempty 若欄位為空就不輸出
func main() {
// Marshaling
var movies = []Movie{
{Ti... |
ef1dc10fb5e13b8d56de00700d9ea8c767aa3d11 | e0ccfa943da515f2ae247967a9fa6a5236562561 | fasibio/gosoline | /pkg/sqs/info_test.go | Go | go | 2,455 | no_license | package sqs_test
import (
"github.com/applike/gosoline/pkg/cfg"
monMocks "github.com/applike/gosoline/pkg/mon/mocks"
"github.com/applike/gosoline/pkg/sqs"
"github.com/applike/gosoline/pkg/sqs/mocks"
"github.com/aws/aws-sdk-go/aws"
awsSqs "github.com/aws/aws-sdk-go/service/sqs"
"github.com/stretchr/testify/asser... |
df9b3cd77ff9fa3e748fa0503bf1eafa276ea77c | fb5d7622aa02bbab9ddd4b9f6b94a45964ba6caa | octopot/forma | /internal/storage/executor/internal/postgres/user.go | Go | go | 1,704 | permissive | package postgres
import (
"context"
"database/sql"
"go.octolab.org/ecosystem/forma/internal/domain"
"go.octolab.org/ecosystem/forma/internal/errors"
"go.octolab.org/ecosystem/forma/internal/storage/types"
)
// NewUserContext TODO issue#173
func NewUserContext(ctx context.Context, conn *sql.Conn) userScope {
re... |
505ca6e0e3586839845c3d4296d473d460bb9d59 | f67e2a87054776eeb2939cca6461946441ed080e | tawawhite/tengo | /cmd/tengo/main.go | Go | go | 6,856 | permissive | package main
import (
"bufio"
"bytes"
"flag"
"fmt"
"io"
"io/ioutil"
"os"
"path/filepath"
"strings"
"github.com/d5/tengo/v2"
"github.com/d5/tengo/v2/parser"
"github.com/d5/tengo/v2/stdlib"
)
const (
sourceFileExt = ".tengo"
replPrompt = ">> "
)
var (
compileOutput string
showHelp bool
showVe... |
8788be0ac3bb43ee95f7856fef7dd4be701b2f79 | f480fbbbc778e8a7c53ce1deb6c33d69e6526826 | Whisker17/GoSort | /src/8_CountingSort.go | Go | go | 697 | no_license | package main
import "fmt"
/*
计数排序的核心在于将输入的数据值转化为键存储在额外开辟的数组空间中。
作为一种线性时间复杂度的排序,计数排序要求输入的数据必须是有确定范围的整数。
*/
func CountingSort(datas []int, maxValue int) []int {
bucketLen := maxValue + 1
bucket := make([]int, bucketLen)
sortedIndex := 0
len := len(datas)
for i := 0; i < len; i++ {
bucket[datas[i]]++
}
for ... |
c6d886b677094e645bcf6da55d689447d09ecb2e | b2d0f5096e32818d6dbad300056ce80491a5f2d3 | dyv/paxos | /db_app/db_backend/db_backend.go | Go | go | 1,423 | no_license | package db_backend
import (
"encoding/json"
"fmt"
"github.com/dyv/paxos"
)
type OpType int
const (
GET OpType = iota
PUT
)
func (o OpType) String() string {
switch o {
case GET:
return "GET"
case PUT:
return "PUT"
default:
return "ERROR"
}
}
type Op struct {
T OpType
K string
V string
}
func (... |
1256a0d5d2f1f8646fd0f27025c723d1bfe2083a | 8446c280bdb0312e21c74254cfc021958f93fc21 | gnewton/jsongomesh | /handlers.go | Go | go | 3,360 | permissive | package main
import (
"github.com/ant0ine/go-json-rest/rest"
"log"
)
var COPYRIGHT_AND_LEGAL = MESH_COPYRIGHT + "; " + MESH_OWNER
func GetAll(w rest.ResponseWriter, req *rest.Request) {
if req.Request.Method != "GET" {
return
}
w.WriteJson(newEnvelope(allNouns))
}
func GetAllDescriptors(w rest.ResponseWrite... |
c337138454be0708af911db69ae8453a11beb661 | 344f21cd22fc9d275b3833b5e1fdad714ff39730 | uber-qlam/cadence | /service/history/historyEngine_test.go | Go | go | 196,469 | permissive | // Copyright (c) 2017 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... |
5ba079b80046a9022ec0c8c308f333e0cf67852f | 619b5bffb407e68262a50922fe3a7bd4b65b3bb5 | wsoyinka/warewulf | /internal/app/wwctl/overlay/create/root.go | Go | go | 704 | permissive | package create
import (
"github.com/spf13/cobra"
)
var (
baseCmd = &cobra.Command{
Use: "create [overlay name]",
Short: "Initialize a new Overlay",
Long: "Create a new Warewulf provisioning overlay",
RunE: CobraRunE,
Args: cobra.ExactArgs(1),
}
SystemOve... |
9c7960a59b62168a8ee482f6793392fa465ac923 | c61656b225a679a4c40b8d9f6e4115f418fc6720 | GlobchanskyDenis/matcha | /common/structures.go | Go | go | 3,138 | no_license | package common
import (
"fmt"
"strings"
"time"
)
type User struct {
Uid int `json:"uid"`
Mail string `json:"mail,omitempty"`
Pass string `json:"-"`
EncryptedPass string `json:"-"`
Fname string `json:"fname"`
Lname string `json:"lname"`
B... |
2b04a64e6638cad34f81e556b9b1874a89941278 | c77a4a99729c2a01d6e84248b73d5e9dfc94d4a4 | beautiful-code/sal | /services/application/main.go | Go | go | 1,011 | no_license | package main
import (
"net/http"
"github.com/rs/cors"
"github.com/urfave/negroni"
"github.com/beautiful-code/sal/common/utils"
"github.com/beautiful-code/sal/services/application/app"
"github.com/beautiful-code/sal/services/application/models"
"github.com/beautiful-code/sal/services/application/routers"
)
/... |
095e470dd50815085a21850b8ef3dced620b71ec | cce537fb662bfeba64f72ec343a7654bb3528fa1 | nicolov/rclone | /fs/rc/rc.go | Go | go | 4,578 | permissive | // Package rc implements a remote control server and registry for rclone
//
// To register your internal calls, call rc.Add(path, function). Your
// function should take ane return a Param. It can also return an
// error. Use rc.NewError to wrap an existing error along with an
// http response type if another respon... |
369760729b586cbd6f5b9d42fa3be2ff780dc8be | 449661aac922b2c13e226d9989150ed890251df0 | oldtree/go-mongo | /mongo/mongo.go | Go | go | 5,732 | permissive | // Copyright 2010 Gary Burd
//
// 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 wr... |
0de8a29a44c7a46cb5fee3bb701106a4086a76af | 4546e1a942fb5fe883f7676851fcc31e8c1651d7 | lucasallan/mysocketctl-go | /cmd/connect.go | Go | go | 5,501 | permissive | /*
Copyright © 2020 NAME HERE <EMAIL ADDRESS>
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... |
f39f12edb97c78acc258998a943709155192aecb | 893204c68c5ebe2b5b4357070a962a4b06204831 | JinheLin/tidb | /br/pkg/lightning/importer/import.go | Go | go | 74,970 | permissive | // Copyright 2019 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... |
fbc38e7647c323e7e8f4d1da9d9aad9018e9a6ec | 2d57bbbcba960c3e61bb719b4fc4ca96741fb9ec | muditsaurabh/noms | /go/nbs/compacting_chunk_source.go | Go | go | 2,983 | permissive | // Copyright 2016 Attic Labs, Inc. All rights reserved.
// Licensed under the Apache License, version 2.0:
// http://www.apache.org/licenses/LICENSE-2.0
package nbs
import (
"sync"
"github.com/attic-labs/noms/go/chunks"
"github.com/attic-labs/noms/go/d"
)
func newCompactingChunkSource(mt *memTable, haver chunkRe... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.