text stringlengths 11 4.05M |
|---|
package rpcd
import (
"github.com/Cloud-Foundations/Dominator/lib/errors"
"github.com/Cloud-Foundations/Dominator/lib/srpc"
proto "github.com/Cloud-Foundations/Dominator/proto/imaginator"
)
func (t *srpcType) GetDependencies(conn *srpc.Conn,
request proto.GetDependenciesRequest,
reply *proto.GetDependenciesRespo... |
/*
Package strings provides some convenience methods and types for dealing with strings.
Hasher32
Makes generating 32-bit hashes from strings more convenient.
Hasher64
Makes generating 64-bit hashes from strings more convenient.
*/
package strings
|
package dbms_test
import (
"net"
"testing"
"github.com/nim4/DBShield/dbshield/dbms"
)
var mysqlCount int
func mysqlDummyReader(c net.Conn) (buf []byte, err error) {
sampleIO := [][]byte{
{
0x5b, 0x00, 0x00, 0x00, 0x0a, 0x35, 0x2e, 0x37, 0x2e, 0x31, 0x35, 0x2d,
0x30, 0x75, 0x62, 0x75, 0x6e, 0x74, 0x75, 0... |
/*
Given the root of a binary tree, return all root-to-leaf paths in any order.
A leaf is a node with no children.
Example 1:
Input: root = [1,2,3,null,5]
Output: ["1->2->5","1->3"]
Example 2:
Input: root = [1]
Output: ["1"]
Constraints:
The number of nodes in the tree is in the range [1, 100].
-100 <= ... |
package main
import (
"bufio"
"fmt"
"os"
)
func main() {
file, _ := os.Open("input/day05.txt")
defer file.Close()
scanner := bufio.NewScanner(file)
var part2visual [127][8]bool
max := 0
for scanner.Scan() {
row, column := findRowColumn(scanner.Text())
part2visual[row][column] = true
seatId := calculat... |
package gogen
import (
"github.com/stretchr/testify/suite"
"github.com/stretchr/testify/assert"
"path/filepath"
"testing"
)
// Please note that this test suite refers to the
// test_fixtures/simple.go test file.
type ParseAnnotationsSuite struct {
suite.Suite
build *Build
file *File
st *Structure
i... |
package ds_block_processing
import (
"fmt"
"strconv"
"libs/mediator"
"libs/block_storage"
"libs/data_conversion"
)
void StoreDSBlockToDisk(DSBlock dsblock) {
fmt.println();
m_mediator.m_dsBlockChain.AddBlock(dsblock);
fmt.println("Block num = %d", dsblock.GetHeader().GetBlockNum());
fmt.println("DS diff =... |
package main
import (
"fmt"
"github.com/waltton/confload"
)
// Config struct with params to start the application
type Config struct {
Database struct {
Name string `conf:"name" conf-usage:"database name"`
} `conf:"database"`
Server struct {
Addr string `conf:"addr"`
Port int `conf:"port"`
} `conf:"se... |
package server
import (
"strings"
)
var DataPopulated Jsonresponse
func(this *ServerStruct) BuyingStocks(request Request, reply *Reply) error{
stocksWithPercentage := strings.Split(request.StockSymbolAndPercentage, ",")
stocksPercentageMap, url := makeUrl(stocksWithPercentage)
DataFromYahoo(url)
s... |
package main
import "fmt"
func fibonacci() func () int {
fibo := 1
before_fibo := 0
return func() int {
bbb := fibo
fibo = before_fibo + fibo
before_fibo = bbb
return fibo
}
}
func main() {
f := fibonacci()
for i := 0; i < 10; i++ {
fmt.Println(f())
}
}
|
/*
Tencent is pleased to support the open source community by making Basic Service Configuration Platform available.
Copyright (C) 2019 THL A29 Limited, a Tencent company. All rights reserved.
Licensed under the MIT License (the "License"); you may not use this file except
in compliance with the License. You may obtain... |
package mid
import (
"example.com/algorithms/algo/mock"
"reflect"
"testing"
)
func TestSortList(t *testing.T) {
tests := []struct {
name string
args []int
want []int
}{
{"test1", []int{4, 2, 1, 3}, []int{1, 2, 3, 4}},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
input := mock.M... |
package main
import (
"fmt"
"github.com/hyperledger/fabric/core/chaincode/shim"
sc "github.com/hyperledger/fabric/protos/peer"
)
// TODO: DEFINE THE SMART CONTRACT STRUCTURE
type SmartContract struct {
}
func (s *SmartContract) Init(APIStub shim.ChaincodeStubInterface) sc.Response {
fmt.Println("===============... |
package logging
import (
"log"
"os"
"github.com/rollbar/rollbar-go"
"github.com/spf13/viper"
)
const (
EnvProd = "production"
EnvLocal = "local"
)
var (
logger = log.New(os.Stderr, "gamedb: ", log.LstdFlags)
)
func Error(err error) {
if err != nil {
logger.Println(err.Error())
if viper.GetString("E... |
package indexer_test
import (
"time"
_ "github.com/manishrjain/gocrud/drivers/leveldb"
_ "github.com/manishrjain/gocrud/drivers/memsearch"
"github.com/manishrjain/gocrud/indexer"
"github.com/manishrjain/gocrud/search"
"github.com/manishrjain/gocrud/store"
"github.com/manishrjain/gocrud/x"
)
type SimpleIndexer... |
package database
type TbRequestLog struct {
ID uint
DevAddr uint `gorm:"column:devAddr"`
CodingRt int
CodingRp int
InvokeIDPriority int `gorm:"column:Invoke_Id_Priority"`
ObisIdx int
AttriMethd int `gorm:"column:Attri_Methd"`
Flags int `gorm:"col... |
package blockchain
import (
"encoding/json"
"fmt"
"net/http"
"net/url"
"time"
"math/big"
"bytes"
"encoding/hex"
"errors"
"sync"
)
func NewBlockChain(nodeID, broadcast string) (*BlockChain, error) {
bc := &BlockChain{
nodeID: nodeID,
broadcast: broadcast,
chain: make([]Block, ... |
package main
import (
"math"
"sort"
)
func threeSumClosest(nums []int, target int) int {
gap := math.MaxInt32
res := 0
sort.Ints(nums)
for i := 0; i < len(nums)-1; i++ {
l := i + 1
r := len(nums) - 1
for l < r {
sum := nums[i] + nums[l] + nums[r]
diff := sum - target
if diff < 0 {
l++
if ... |
package roboticSystem
import (
"arrays"
"fmt"
"utils"
"vectors"
)
type Link struct {
DHParameters DHParameters
ThetaSpace utils.Range1D
}
type System struct {
BasePosition vectors.Vector3D
Links []Link
}
func NewSystem(x, y, z float64) System {
return System{
BasePosition: vectors.NewVector3D(x,... |
package main
import (
"testing"
"github.com/abhinav/git-pr/cli/clitest"
"github.com/abhinav/git-pr/gateway/gatewaytest"
"github.com/abhinav/git-pr/ptr"
"github.com/abhinav/git-pr/repo"
"github.com/abhinav/git-pr/service"
"github.com/abhinav/git-pr/service/servicetest"
"github.com/golang/mock/gomock"
"github... |
package ast
import (
"bytes"
"github.com/raventid/clojurium/token"
)
type Node interface {
TokenLiteral() string
String() string
}
type Statement interface {
Node
statementNode()
}
type Expression interface {
Node
expressionNode()
}
// Program Node is a root of any programm
type Program struct {
Statement... |
/*
Goal
Write a program or function that returns the day of the week for a date, eg.
01/06/2020 -> Mon
However, it's unknown if the date is in the format mm/dd/yyyy or dd/mm/yyyy. If you can be certain of the day of the week, return it. If there is uncertainty, return an error.
02/07/2020 -> Err (Thu? Fri?)
... |
package main
import (
"fmt"
"os"
"golang.org/x/net/html"
)
func main() {
doc, err := html.Parse(os.Stdin)
if err != nil {
fmt.Fprintf(os.Stderr, "outline: %v\n", err)
os.Exit(1)
}
outline(nil, doc)
frequency := make(map[string]int)
tagFrequency(frequency, doc)
fmt.Println("\n\nHTML Tag frequency")
f... |
package avl
// Insert ...
func (t *Tree) Insert(data int) {
if t.Root == nil {
t.Root = NewNode(data)
return
}
t.Root = insert(t.Root, data)
}
func insert(root *Node, data int) *Node {
if root == nil {
return NewNode(data)
} else if root.Data > data {
root.Left = insert(root.Left, data)
} else if root... |
package form
import (
"bytes"
"github.com/astaxie/beego/logs"
"strings"
"text/template"
)
type TextInput struct {
Name string
Verify string // default: phone,email,number,date,url,identity,required
Id string
ReqText string // 必填自定义提示
AutoComplete bool
Placeholder string
Filter... |
package github
import (
"context"
"errors"
"fmt"
"net/http"
"testing"
"github.com/brigadecore/brigade/v2/apiserver/internal/api"
"github.com/stretchr/testify/require"
)
func TestNewThirdPartyAuthHelper(t *testing.T) {
config := ThirdPartyAuthHelperConfig{}
helper, ok := NewThirdPartyAuthHelper(config).(*thi... |
package util
// UserDetails is the struct contains complete details of a user profile
type UserDetails struct {
Name string `json:"name"`
Dob string `json:"dob"`
Age int32 `json:"age"`
Email string `json:"email"`
Phone string `json:"phone"`
}
|
package cmd
import (
"errors"
"fmt"
"github.com/MYOB-Technology/pops/lib"
"github.com/spf13/cobra"
)
var flagEncSecret string
var encCmd = &cobra.Command{
Use: "enc",
Short: "Encrypt Chef Data Bag",
Long: `Encrypt Chef data bag using a secret file.
Outputs the result to STDOUT.
Currently only Ver.1 data ba... |
package main
import (
"fmt"
"go-todo-101/todo"
)
func main() {
list := todo.NewList()
// add 3 todo
list.AddTodo(todo.NewTodo("task 1"))
list.AddTodo(todo.NewTodo("task 2"))
list.AddTodo(todo.NewTodo("task 3"))
fmt.Println(list)
// complete 1 todo
completeTodo := list.GetTodo(1)
completeTodo.Complete()
... |
package problem0093
import "testing"
func TestRestoreIpAddress(t *testing.T) {
t.Log(restoreIpAddresses("0000"))
t.Log(restoreIpAddresses("25525511135"))
t.Log(restoreIpAddresses("1111"))
t.Log(restoreIpAddresses("010010"))
t.Log(restoreIpAddresses("101023"))
}
|
package main
import (
"errors"
"log"
"math"
"time"
"github.com/shanghuiyang/rpi-devices/dev"
"github.com/shanghuiyang/rpi-devices/util"
"github.com/stianeikeland/go-rpio"
)
const (
devName = "/dev/ttyAMA0"
baud = 9600
swPin = 7
csPin = 17
homeX = 2.43
homeY = 2.56
homeBuf = 0.15
)
func mai... |
package main
import (
"runtime"
"reflect"
"fmt"
)
func decorator(f func()) func() {
return func() {
funcName :=
runtime.FuncForPC(
reflect.ValueOf(f).Pointer()).
Name()
fmt.Println("begin to call " + funcName)
f()
} }
func inne... |
/*
Background
The number of values for a given type is called the cardinality of that type, and that of type T is written as |T|.
Haskell and a few other languages have a certain set of enum types, each of which has a small finite number of values (the exact names vary, so this challenge uses some arbitrarily chosen ... |
// +build !integration
package std
import (
"context"
"testing"
"github.com/andersfylling/disgord"
)
type clientMock struct {
id disgord.Snowflake
}
var _ msgFilterdg = (*clientMock)(nil)
func (c *clientMock) GetCurrentUser(ctx context.Context, flags ...disgord.Flag) (*disgord.User, error) {
return &disgord.... |
package manager
import (
"time"
"encoding/json"
"context"
"os"
//"go.etcd.io/etcd/mvcc/mvccpb"
"go.etcd.io/etcd/clientv3"
"github.com/apsdehal/go-logger"
"github.com/ricky1122alonefe/hawkEye-go/module"
)
const (
ALL = "all"
SCHEDULE = "schedule"
SIMPLE = "simple"
)
var (
log *logger.Logger
log_er... |
package keeper
import (
"context"
"strings"
"google.golang.org/grpc/codes"
"google.golang.org/grpc/status"
sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/irisnet/irismod/modules/oracle/types"
)
var _ types.QueryServer = Keeper{}
// Feed queries a feed by feed name
func (k Keeper) Feed(c context.Contex... |
package server
import (
"net/http"
"strings"
"github.com/gorilla/mux"
"github.com/rs/zerolog/log"
)
// UserSummary returns general information about a user. It pulls in information from multiple places (properties, expenses,
// historical data, etc.)
type UserSummary struct {
Properties *PropertiesSummar... |
package core
import (
"github.com/cilium/kubenetbench/utils"
)
// Benchmark interface
type Benchmark interface {
// write container server YAML
WriteSrvContainerYaml(pw *utils.PrefixWriter, params map[string]interface{})
// write container client YAML
WriteCliContainerYaml(pw *utils.PrefixWriter, params map[stri... |
package core
import (
"github.com/dosco/graphjin/core/internal/qcode"
lru "github.com/hashicorp/golang-lru"
)
type apqInfo struct {
op qcode.QType
name string
query string
}
type apqCache struct {
cache *lru.TwoQueueCache
}
func (gj *graphjin) initAPQCache() error {
var err error
gj.apq.cache, err = lru... |
package main
import (
"net"
"log"
"fmt"
)
func main() {
raddr, err := net.ResolveTCPAddr("tcp", "10.6.250.52:8000")
if err != nil {
log.Fatal(err)
}
conn, err := net.DialTCP("tcp", nil, raddr)
if err != nil {
log.Fatal(err)
}
defer conn.Close()
buf := make([]byte, 0xffff)
go func() {
for {
n, err :... |
package repositories
import (
"context"
"github.com/itsmeadi/cart/src/entities/models"
)
type User interface {
GetUserBySub(ctx context.Context, sub string) (models.User, error)
AddUser(ctx context.Context, user models.User) (int64, error)
}
|
package repository
import (
"fmt"
"github.com/jmoiron/sqlx"
"github.com/rs/zerolog/log"
"sitemap/models/entity"
"time"
)
func NewSQLdbJobRepo(Conn *sqlx.DB) *DbJobRepo {
return &DbJobRepo{
Conn: Conn,
}
}
type DbJobRepo struct {
Conn *sqlx.DB
}
func (l *DbJobRepo) Count()(int, error){
t := time.Now()
q... |
package main
import (
"fmt"
"strconv"
"strings"
"time"
"unicode/utf8"
)
type PetType struct {
Emoji string
Adult string
Name string
}
func (p PetType) String() string {
return fmt.Sprintf("%s %s", p.Emoji, p.Name)
}
var (
Chicken = PetType{Emoji: "🐔", Adult: "🐓", Name: "Chicken"}
Penguin = PetType{Emo... |
package goose
import (
"errors"
"fmt"
"log"
"os"
"path/filepath"
"strconv"
"strings"
"text/template"
"time"
)
var (
ErrNoPreviousVersion = errors.New("no previous version found")
)
type MigrationRecord struct {
VersionId int64
TStamp time.Time
IsApplied bool // was this a result of up() or down()
}
... |
package main
import (
"flag"
"fmt"
"os"
"github.com/ikester/blinkt"
)
// need to find which state we're in on startup to trigger the light.
func off(bl blinkt.Blinkt) {
bl.Clear()
bl.Show()
}
func red(bl blinkt.Blinkt) {
bl.SetAll(255, 0, 0)
bl.Show()
}
func green(bl blinkt.Blinkt) {
bl.SetAll(0, 255, 0)... |
package c44_dsa_repeated_nonce
import (
"errors"
"math/big"
"github.com/vodafon/cryptopals/set5/c39_rsa"
"github.com/vodafon/cryptopals/set6/c43_dsa_from_nonce"
)
type Text struct {
Msg []byte
S, R, M *big.Int
}
func Exploit(dsa *c43_dsa_from_nonce.DSA, texts []Text) (*big.Int, error) {
t1, t2, err := fi... |
package main
import (
"github.com/oceango/web"
)
func main() {
web.BuildConfiguration()
router := newOceanRoute()
router = GetRoutes(router)
application := web.NewApplication(router.router)
application.Run()
}
|
package arrays
import "testing"
func TestThirdMax(t *testing.T) {
if thirdMax([]int{1, 1, 2}) != 2 {
t.Fail()
}
}
|
package accesslist
import (
"fmt"
"github.com/10gen/realm-cli/internal/cli"
"github.com/10gen/realm-cli/internal/cli/user"
"github.com/10gen/realm-cli/internal/terminal"
"github.com/10gen/realm-cli/internal/utils/flags"
)
const (
headerAddress = "IP Address"
headerComment = "Comment"
)
var (
listTableHeader... |
package tests
import (
"testing"
pilot "github.com/bwireman/tuple/pilot/pkg"
test_util "github.com/bwireman/tuple/pilot/tests/test_util"
)
func Test_Pilot_JSONTags(t *testing.T) {
test_util.ValidateTags(t, pilot.NodeRegistry{})
} |
package main
import (
"net/url"
"strconv"
"testing"
"time"
)
// TestCreateJob tests that a job with overcapacity in both channel and goroutines
// does finish as it should
func TestCreateWithOneJob(t *testing.T) {
u, _ := url.Parse("http://" + localServerAddress + webhook)
job := CreateJob(Secret, *u, 10)
job.... |
// package main
/*
bool 类型表示真假值,只能为 true 或 false。请运行下面的程序:
*/
// func main() {
// var a bool = true
// b := false
// c := a && b
// d := a || b
// println(a, b, c, d)
// }
/*
Go是强类型的语言,没有隐式的类型提升和转换。让我们通过一个例子说明这意味着什么
在C语言中是完全合法的,但是在Go中却不是。i 的类型是 int 而 j 的类型是 float64,将这两个类型不同的数字相加是非法的。
运行这个程序将会报错:main.go:10:... |
// winmetric project winmetric.go
// +build windows
package win
//定义windows性能对象
const (
METRIC_SYSTEM string = "System"
METRIC_PROCESSOR string = "Processor"
METRIC_PROCESSOR_INFORMATION string = "Processor Information"
METRIC_PROCESSOR_PERFORMANCE string = "Processo... |
package main
import (
"fmt"
"net/http"
"os"
"os/signal"
"strconv"
"syscall"
Syslog "github.com/blackjack/syslog"
"github.com/julienschmidt/httprouter"
)
func Stop(srv *http.Server) {
fmt.Println("Shutting down http server")
if err := srv.Shutdown(nil); err != nil {
fmt.Printf("Failed during shutdown %s",... |
package main
import (
"encoding/json"
"fmt"
"io/ioutil"
"log"
"net/http"
"text/template"
"time"
)
type fromTo struct {
From time.Time `json:"timeFrom"`
To time.Time `json:"timeTo"`
}
func wsConnect(w http.ResponseWriter, r *http.Request) {
var err error
wsConnection, err = upgrader.Upgrade(w, r, nil)
... |
/*
Write the shortest possible code cause an error due to recursion too deep
Example error in python
RecursionError: maximum recursion depth exceeded
Example error in c
Segmentation fault
My Python version (15 bytes):
def f():f()
f()
*/
package main
func main() {
main()
}
|
package main
import (
"fmt"
"reflect"
)
func main() {
b := true
var b2 bool = false
fmt.Println(b)
fmt.Println(reflect.TypeOf(b))
fmt.Println(b2)
}
|
package main
import (
"fmt"
"time"
)
func f(from string) {
for i := 0; i < 3; i++ {
fmt.Println(from, ":", i)
}
}
func main() {
f("direct")
go f("goroutine")
go func(msg string) {
fmt.Println(msg)
}("going")
time.Sleep(time.Second)
fmt.Println("done")
}
|
package main
import "strings"
/**
通配符匹配
给定一个字符串 (s) 和一个字符模式 (p) ,实现一个支持 '?' 和 '*' 的通配符匹配。
```
'?' 可以匹配任何单个字符。
'*' 可以匹配任意字符串(包括空字符串)。
```
两个字符串完全匹配才算匹配成功。
说明:
- `s` 可能为空,且只包含从 `a-z` 的小写字母。
- `p` 可能为空,且只包含从 `a-z` 的小写字母,以及字符 `?` 和 `*`。
示例1:
```
输入:
s = "aa"
p = "a"
输出: false
解释: "a" 无法匹配 "aa" 整个字符串。
```
示例2:
```
输入... |
package controllers
import (
"api"
"app/consts"
"app/models"
"goslib/logger"
"gslib/player"
"gslib/timertask"
"time"
)
type EquipsController struct {
Ctx *player.Player
}
func (self *EquipsController) Load(params *api.EquipLoadParams) (string, interface{}) {
user := models.CreateUser(self.Ctx, &consts.User{... |
// Copyright (c) 2022 Target Brands, Inc. All rights reserved.
//
// Use of this source code is governed by the LICENSE file in this repository.
package vela
import (
"encoding/json"
"net/http"
"net/http/httptest"
"testing"
"github.com/gin-gonic/gin"
"github.com/go-vela/server/mock/server"
"github.com/go-vela... |
package xcuitest
import (
"errors"
"fmt"
"strings"
"github.com/saucelabs/saucectl/internal/region"
"github.com/saucelabs/saucectl/internal/config"
)
// Config descriptors.
var (
// Kind represents the type definition of this config.
Kind = "xcuitest"
// APIVersion represents the supported config version.
... |
package server
import (
"encoding/json"
"fmt"
"github.com/sirupsen/logrus"
)
// Hub maintains the set of active clients and broadcasts messages to the
// clients.
type Hub struct {
// Registered clients.
clients map[*Client]bool
// Inbound messages from the clients.
broadcastChan chan []byte
// Register req... |
// Package repository implements a restic repository on top of a backend.
package repository
|
package plugins
import (
_ "github.com/imsilence/gocmdb/server/cloud/plugins/aliyun"
_ "github.com/imsilence/gocmdb/server/cloud/plugins/tenant"
)
|
package setr
import (
"encoding/xml"
"github.com/thought-machine/finance-messaging/iso20022"
)
type Document01400102 struct {
XMLName xml.Name `xml:"urn:iso:std:iso:20022:tech:xsd:setr.014.001.02 Document"`
Message *SwitchOrderCancellationInstructionV02 `xml:"setr.014.001.02"`
}
fu... |
package main
import proto "github.com/golang/protobuf/proto"
import (
// "log"
// "hash/crc32"
// "bytes"
// "encoding/binary"
// "reflect"
// "strings"
"./common_proto"
"fmt"
"time"
"encoding/json"
)
var chhh = make(chan common_proto.Helloworld, 128)
func start(){
count := 0
for{
count++
str := fmt.Sprint... |
/**
*@Author: haoxiongxiao
*@Date: 2019/3/28
*@Description: CREATE GO FILE repositories
*/
package repositories
import (
"bysj/models"
"github.com/jinzhu/gorm"
)
type FeedBackRepositories struct {
db *gorm.DB
}
func NewFeedBackRepositories() *FeedBackRepositories {
return &FeedBackRepositories{db: models.GetMys... |
package jwt
import (
"errors"
"time"
"github.com/golang-jwt/jwt"
)
// 生成token
func GenToken(expire time.Duration, issuer string, jwtSecret string) (string, error) {
expireTime := time.Now().Add(expire)
standardClaims := jwt.StandardClaims{
ExpiresAt: expireTime.Unix(),
Issuer: issuer,
}
tokenClaims :=... |
package smhi
import (
"context"
"encoding/json"
"fmt"
"io"
"net/http"
"net/url"
)
const (
baseURL = "https://opendata-download-metobs.smhi.se/"
)
// Client is a client
type Client struct {
client *http.Client
BaseURL *url.URL
common service
Temperatures *TemperatureService
}
type service struct {
cli... |
package merchant
import (
"context"
"tpay_backend/adminapi/internal/common"
"tpay_backend/model"
"tpay_backend/adminapi/internal/svc"
"tpay_backend/adminapi/internal/types"
"github.com/tal-tech/go-zero/core/logx"
)
type GetMerchantWalletLogListLogic struct {
logx.Logger
ctx context.Context
svcCtx *svc.S... |
package main
import (
"fmt"
"strings"
)
func indexOfRune(chars []rune, char rune) int {
for i, c := range chars {
if c == char {
return i
}
}
return -1
}
func nextToken(chars []rune) string {
if len(chars) == 0 {
return ""
}
if chars[0] == '\\' {
wspChars := []rune{'\\', chars[1]}
return stri... |
package agent_test
import (
"io/ioutil"
"github.com/Sirupsen/logrus"
. "github.com/bryanl/dolb/agent"
"github.com/bryanl/dolb/kvs"
"github.com/bryanl/dolb/pkg/app"
"github.com/bryanl/dolb/service"
. "github.com/onsi/ginkgo"
. "github.com/onsi/gomega"
)
var _ = Describe("EtcdServiceManager", func() {
var (... |
package pcsdownload_test
import (
"github.com/iikira/BaiduPCS-Go/internal/pcsfunctions/pcsdownload"
"testing"
)
func BenchmarkIsSkipMd5Checksum(b *testing.B) {
md5Str := "8091310d5f4719769995a74d8e6d0530"
for i := 0; i < b.N; i++ {
pcsdownload.IsSkipMd5Checksum(120, md5Str)
}
}
|
package pretty_poly
import "testing"
import "math"
import "math/rand"
import "github.com/franela/goblin"
import "fmt"
type geoHashTestCase struct {
precision int8
interval interval
num float64
result geohash
}
func geohashCreationTestCase ( ) (float64, [ ] bool, interval) {
precision := r... |
//~+7.000000e+000
//~0
//~0
//~+0.000000e+000 +0.000000e+000 +0.000000e+000
//Mostly borrowed from program-solutions/2-typecheck
package main
func incr(x float64) float64 {
return x + 1.0
}
type point struct {
x, y, z float64
}
func new_point() point {
var p point
p.x = incr(-1.0)
p.y = 0.0
p.z = 0.0
return ... |
package service
import (
"fmt"
_ "github.com/go-sql-driver/mysql"
"github.com/go-xorm/xorm"
"xorm.io/core"
"github.com/BinacsLee/server/config"
"github.com/BinacsLee/server/libs/log"
)
type MysqlService interface {
}
type MysqlServiceImpl struct {
Config *config.Config `inject-name:"Config"`
Logger log.L... |
/*
Copyright 2021 The KubeVela 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, softw... |
package main
import (
"fmt"
"log"
"time"
"github.com/veandco/go-sdl2/ttf"
"github.com/mooncaker816/gophercises/poker/deck"
"github.com/mooncaker816/gophercises/poker/room"
"github.com/veandco/go-sdl2/sdl"
)
const (
SDL_LEFT_BUTTON = 1
SDL_RIGHT_BUTTON = 3
)
func run() error {
var w *sdl.Window
var r *s... |
package paths
import (
"testing"
"github.com/prometheus/common/model"
"github.com/prometheus/prometheus/prompb"
"github.com/stretchr/testify/require"
)
func TestMetricLabelsFromPath(t *testing.T) {
path := "prometheus-prefix.test.owner.team-X"
prefix := "prometheus-prefix"
expectedLabels := []*prompb.Label{
... |
package main
import (
"fmt"
"github.com/prometheus/client_golang/prometheus"
"github.com/prometheus/common/log"
"gopkg.in/niedbalski/goose.v3/client"
"gopkg.in/niedbalski/goose.v3/nova"
)
var server_status = []string{
"ACTIVE",
"BUILD", // The server has not finished the original build process.
"BUI... |
package user
import (
"testing"
"time"
"github.com/syedomair/plan-api/lib"
)
func TestUserDB(t *testing.T) {
db, _ := lib.CreateDBConnection()
repo := &UserRepository{db, lib.GetLogger()}
defer repo.Db.Close()
start := time.Now()
repo.Logger.Log("METHOD", "TestUserDB", "SPOT", "method start", "time_start",... |
package main
import (
"fmt"
"net"
"bufio"
"time"
"./localip"
"./localnet"
"./iferror"
)
const (
TCPportIn = ":20024"
TCPportOut = ":20025"
UDPport = ":20023"
UDPpasscode = "svekonrules"
)
type elevdata struct {
externalOrders [6] int
internalOrders [4] int
}
type elevPacket struct {
msgType string
... |
// Copyright © 2020 Attestant Limited.
// 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 ... |
package fcache
type CacheValue struct {
Value []byte
}
func (mv CacheValue) Len() int64 {
return int64(len(mv.Value))
}
// Cache cache interface definition.The cache can be memory cache,
// disk cache or net cache. We implementation cache with LRU algorithm.
// Note: disk cache NOT support 'extra' field in current... |
// DRUNKWATER TEMPLATE(add description and prototypes)
// Question Title and Description on leetcode.com
// Function Declaration and Function Prototypes on leetcode.com
//539. Minimum Time Difference
//Given a list of 24-hour clock time points in "Hour:Minutes" format, find the minimum minutes difference between any tw... |
package btf_test
import (
"fmt"
"testing"
"github.com/cilium/ebpf/btf"
"github.com/cilium/ebpf/internal/testutils"
)
func TestHandleIterator(t *testing.T) {
// There is no guarantee that there is a BTF ID allocated, but loading a module
// triggers loading vmlinux.
// See https://github.com/torvalds/linux/com... |
/*
* 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 ... |
package main
import (
"flag"
"log"
"strings"
"github.com/sirupsen/logrus"
)
var (
useNoHost *bool
host *string
inDir *string
outDir *string
jobID *string
batchSize *int
numBatches *int
)
func main() {
// flag management
useNoHost = flag.Bool("use-no-host", false, "do not communica... |
package atomix
import (
"sync/atomic"
"unsafe"
)
// AddUint is same as [atomic.AddUint32] or [atomic.AddUint64] but for uint.
func AddUint(addr *uint, delta uint) (new uint) {
switch unsafe.Sizeof(*addr) {
case 4:
return uint(atomic.AddUint32((*uint32)(unsafe.Pointer(addr)), uint32(delta)))
case 8:
return ui... |
package gosh
import (
"encoding/json"
)
type FunID string
func NewFunID(f Dependency) FunID {
bs, err := json.Marshal(f)
if err != nil {
panic(err)
}
return FunID(bs)
}
|
package onlySendOnce
import (
"sync"
)
type call struct {
waitGroup sync.WaitGroup
val interface{}
err error
}
type Group struct {
mu sync.Mutex //虽然sendOnce的目的是让并发查询不查多次,但作为标志的m还是要锁起来不让它被并发读写
m map[string]*call //string对应key
}
//once代表只想执行一次的函数,这里指查询
func (g *Group) Do(key string, once fun... |
package sql
type DataType int
const (
NULL DataType = iota
TEXT
REAL
INTEGER
DATETIME
BOOLEAN
BLOB
)
var dataTypes = map[DataType]string{
NULL: "NULL",
TEXT: "TEXT",
REAL: "REAL",
INTEGER: "INTEGER",
DATETIME: "DATETIME",
BOOLEAN: "BOOLEAN",
BLOB: "BLOB",
}
func (d DataType) String()... |
package xlsx
import (
"encoding/xml"
"github.com/plandem/ooxml"
"github.com/plandem/xlsx/format"
"github.com/plandem/xlsx/internal/ml"
"github.com/plandem/xlsx/options"
"github.com/plandem/xlsx/types"
)
type sheetReadStream struct {
*sheetInfo
stream *ooxml.StreamFileReader
rowReader ooxml.StreamReaderI... |
package havener
import (
"net/http"
"github.com/go-zoo/bone"
"github.com/zpatrick/go-config"
"fmt"
)
type Redirector struct {
Cfg *config.Config
RegQuery chan interface{}
}
func NewRedirector(cfg *config.Config, rq chan interface{}) Redirector {
rd := Redirector{
Cfg: cfg,
RegQuery: rq,
}
return rd
}
f... |
package main
import (
"database/sql"
"fmt"
"strconv"
_ "github.com/lib/pq"
)
const (
host = "localhost"
port = 5432
user = "naini"
password = "password"
dbname = "sensor_db"
)
type tools struct {
db *sql.DB
}
var t tools
func average(list *List) float64 {
v1, _ := strconv.ParseI... |
package main
import "fmt"
func main() {
const v = 20
fmt.Printf("%T, %v\n", v, v)
var a byte = 10
b := v + a
fmt.Printf("%T, %v\n", b, b)
const c float32 = 1.2
d := c + v
fmt.Printf("%T, %v\n", d, d)
}
|
package main
import (
"fmt"
"unsafe"
)
func main() {
var a bool = false
fmt.Printf("a数据类型是:%T,a占用的字节数是:%d\n", a,unsafe.Sizeof(a))
}
|
package redis
import (
"fmt"
"time"
"github.com/insisthzr/echo-test/cookbook/twitter/conf"
"github.com/garyburd/redigo/redis"
)
var (
pool *redis.Pool
)
func init() {
pool = newPool(conf.REDIS_HOST)
}
func newPool(server string) *redis.Pool {
return &redis.Pool{
MaxIdle: 3,
IdleTimeout: 240 * time.... |
package foo
func (Foo) Bar() int {
return 42
}
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.