text stringlengths 11 4.05M |
|---|
package main
import (
"fmt"
"io/ioutil"
"log"
"math/rand"
"net/http"
"os"
"path/filepath"
"runtime/trace"
"time"
"github.com/cockroachdb/pebble"
"github.com/jbowens/codenames"
)
const listenAddr = ":9091"
const expiryDur = -24 * time.Hour
func main() {
rand.Seed(time.Now().UnixNano())
// Open a Pebble... |
package main
// A Card represents a game card and everything that makes it different from other cards.
// To accomodate for other games, new attributes could be added, like an image, an attack/defense value, etc.
type card struct {
Code string `json:"code"`
Value string `json:"value"`
Suit string `json:"suit"`
/... |
// DRUNKWATER TEMPLATE(add description and prototypes)
// Question Title and Description on leetcode.com
// Function Declaration and Function Prototypes on leetcode.com
//486. Predict the Winner
//Given an array of scores that are non-negative integers. Player 1 picks one of the numbers from either end of the array fol... |
package cmd
const (
ConfigFlag = "config"
)
|
package controllercontext
import "github.com/aws/aws-sdk-go/service/ec2"
type ContextStatus struct {
ControlPlane ContextStatusControlPlane
TenantCluster ContextStatusTenantCluster
}
type ContextStatusControlPlane struct {
AWSAccountID string
NATGateway ContextStatusControlPlaneNATGateway
RouteTable Contex... |
package basic
import (
"fmt"
"reflect"
)
type User struct {
id int
name string
}
func (u User) Memfunc(){
fmt.Println("memfunc")
}
func (u User) MemfuncWitshargs(i int){
fmt.Println("MemfuncWitshargs : ", i)
}
func reflect1(any interface{}){
fmt.Printf("interface{}=%#v \n\n", any)
type1 := reflect.TypeOf(... |
// Copyright 2019 Radiation Detection and Imaging (RDI), LLC
// Use of this source code is governed by the BSD 3-clause
// license that can be found in the LICENSE file.
package live
import (
"context"
"fmt"
"log"
"net/url"
"strconv"
"strings"
"time"
"github.com/rditech/rdi-live/data"
"github.com/rditech/rd... |
package controller
import (
"fmt"
"strconv"
"strings"
"time"
"github.com/therecipe/qt/core"
"github.com/therecipe/qt/widgets"
"github.com/therecipe/qt/xml"
"github.com/therecipe/qt/internal/examples/sql/masterdetail_qml/model"
)
var Instance *Controller
type Controller struct {
core.QObj... |
package main
import (
"flag"
"fmt"
"github.com/misalcedo/jukebox/files"
"github.com/misalcedo/jukebox/workers"
)
const command int = 0
type Parameters struct {
SourcePath string
DestinationPath string
}
func main() {
fmt.Println("Welcome to JukeBox a handy command-line tool to manage your music collection.")... |
package remento
import (
"github.com/fncodr/godbase"
)
type Prod struct {
BasicRec
}
func NewProd(cx *Cx) *Prod {
return new(Prod).Init(cx)
}
func (self *Prod) OnUpsert(cx *Cx) error {
db := cx.Db().(*Db)
if db.ProdTbl.Dirty(cx, self, &db.Details, &db.Name, &db.Summary) {
if err := UpdateText(cx, self); err... |
package main
import (
"html/template"
"log"
"os"
)
type course struct {
Number string
Name string
Units string
}
type semester struct {
Term string
}
type year struct {
AcaYear string
Fall semester
Spring semester
Summer semester
}
var tpl *template.Template
func init() {
tpl = template.Must(t... |
package main //嵌入的反射
import (
"fmt"
"reflect"
)
type User struct {
Id int
Name string
Age int
}
type Manager struct {
User
title string
}
func main() {
m := Manager{User: User{1, "sh", 34}, title: "title"}
t := reflect.TypeOf(m)
fmt.Printf("%#v \n ", t.FieldByIndex([]int{0, 1})) //传slice 取匿名字段中的字段
}
|
package main
import "fmt"
type user struct {
id int
username string
firstname string
}
func main() {
users := &[]user{{
id: 1,
username: "a",
firstname: "aa",
},
{
id: 2,
username: "b",
firstname: "aa",
}, {
id: 3,
username: "c",
firstname: "cc",
},
... |
package game
// Color is a Pixel struct
type Color struct {
R byte
G byte
B byte
}
// Pos describes the position
type Pos struct {
X float32
Y float32
}
// Ball represent the pong ball
type Ball struct {
Pos
Radius float32 // radius of the ball
XV float32 // X velocity
YV float32 // Y velocity
Colo... |
// Copyright 2019 GoAdmin Core Team. All rights reserved.
// Use of this source code is governed by a Apache-2.0 style
// license that can be found in the LICENSE file.
package echo
import (
"bytes"
"errors"
"net/http"
"net/url"
"strings"
"github.com/GoAdminGroup/go-admin/adapter"
"github.com/GoAdminGroup/go-... |
package types
// Type is a placeholder for a pointer to any other type in this package.
type Type interface{}
// Docs represents documentation text attached to other types.
type Docs struct {
Text string
}
// Field represents a function argument or return value.
// Docs and name are optional.
type Field struct {
N... |
package logging
import (
"context"
"io/ioutil"
"path/filepath"
"testing"
"time"
"github.com/apache/arrow/go/v8/arrow"
"github.com/apache/arrow/go/v8/arrow/array"
"github.com/apache/arrow/go/v8/arrow/memory"
"github.com/apache/arrow/go/v8/parquet/file"
"github.com/apache/arrow/go/v8/parquet/pqarrow"
"github... |
package semver
import "fmt"
type Version struct {
Major int
Minor int
Patch int
PreRelease string
BuildMeta string
}
func NewSemVer(major, minor, patch int, pre, build string) *Version {
return &Version{
Major: major,
Minor: minor,
Patch: patch,
PreRelease: pre,
BuildMe... |
// Copyright 2022 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... |
package main
import (
"C"
"bytes"
"encoding/base64"
"image/png"
"github.com/dchest/captcha"
)
//export NewCaptcha
func NewCaptcha(identifier, _data *C.char, width, height C.int) *C.char {
data := C.GoString(_data)
var numbers []byte
for _, c := range data {
n := c - 48
if 0 <= n && n <= 9 {
numbers = ... |
package utils
import (
"fmt"
"time"
"github.com/dgrijalva/jwt-go"
)
var mySigningKey = []byte(GetConf().JWTKey)
var jwtExpireIn = GetConf().JWTExpireIn
// SignToken is a function to help sign a jwt token for login
func SignToken(audience string) (string, error) {
claims := jwt.StandardClaims{
Audience: audie... |
package handler
import (
"fmt"
"net/http"
"github.com/naoty/slack-thread-webhook/datastore"
"github.com/naoty/slack-thread-webhook/handler/wrapper"
"github.com/nlopes/slack"
)
// Post is a handler to post messages.
type Post struct {
Channel string
Datastore datastore.Client
Slack *slack.Client
}
fun... |
package main
import(
"emulator"
"iop_dma"
)
type Voice struct {
left_vol, right_vol uint16
pitch uint16
adsr1, adsr2 uint16
current_envelope uint16
start_addr uint32
current_addr uint32
loop_addr uint32
loop_addr_specified bool
counter uint32
block_pos int
... |
package pie
import (
"math/rand"
"testing"
)
func BenchmarkIntMedianSmall(b *testing.B) { benchmarkIntMedian(b, 20) }
func BenchmarkIntMedianMedium(b *testing.B) { benchmarkIntMedian(b, 800) }
func BenchmarkIntMedianLarge(b *testing.B) { benchmarkIntMedian(b, 1000000) }
func benchmarkIntMedian(b *testing.B, size... |
// Copyright (c) 2019 Leonardo Faoro. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
// Package ascon wraps the Ascon encryption algorithm.
//
// ref: https://ascon.iaik.tugraz.at/specification.html
package ascon
|
package state
var Health = false
var Ready = false
var Drain = false
|
package main
import "errors"
var BadRequestError = errors.New("Bad_Request_Error")
var InvalidEmailOrPassword = errors.New("Invalid_Email_Or_Password")
var InvalidEmail = errors.New("Invalid_Email")
var IncorrectPassword = errors.New("Incorrect_Password")
var EmptyRows = errors.New("Empty_Rows")
var ViolateUNEma... |
package blog
import (
"fmt"
"testing"
"time"
// goblin
. "github.com/franela/goblin"
"github.com/jinzhu/gorm"
_ "github.com/jinzhu/gorm/dialects/sqlite"
)
func Test_Articles(t *testing.T) {
g := Goblin(t)
g.Describe("Service: Blog", func() {
var blog *BlogService
var db *gorm.DB
g.Before(func() {
... |
package main
import (
"bytes"
"encoding/binary"
"flag"
"fmt"
"log"
"math/rand"
"net"
"strconv"
"syscall"
)
func argParser() (string, int) {
host := flag.String("host", "", "Host to attack.")
port := flag.Int("port", 0, "lol")
flag.Parse()
return *host, *port
}
func main() {
// Creating argv parsing
H... |
package payment
import (
"time"
"github.com/jinzhu/gorm"
"github.com/satori/go.uuid"
"github.com/tppgit/we_service/entity/order"
)
var STATUS_PAYMENT_SUCCESS string = "SUCCESS"
var STATUS_PAYMENT_FAIL string = "FAIL"
type Payment struct {
ID uuid.UUID `gorm:"type:char(36);primary_key;column:id;not nu... |
package crypto
import (
"crypto/rsa"
"crypto/x509"
"fmt"
"strings"
)
type VerifyByFingerprint struct {
Fingerprint string
FingerprintChallengeLevel uint
FingerprintLength uint
}
// VerifyPeerCertificate validates that one of the given certificates contains a public key matching the confi... |
package main
import "fmt"
func main() {
// map declaration
marks := map[string]int64{
"maths": 95,
"phy": 96,
"chem": 87,
}
fmt.Println("marks before update :")
fmt.Println(marks)
fmt.Println("marks after update (new value added) :")
marks["computer sci"]=92
fmt.Println(marks)
fmt.Println("marks ... |
package raknet
import (
"bytes"
"encoding/hex"
"errors"
"io"
"net"
"time"
"unsafe"
"go.uber.org/zap"
"github.com/rssllyn/go-raknet/wrapper"
)
const (
ConnPacketBuffer = 100 // number of packets to keep and wait for handling
acceptBacklog = 128 // number of connections to keep and wait for ... |
package loglib
import (
"context"
"github.com/sirupsen/logrus"
)
type contextKey string
var loggerContextKey = contextKey("logger")
// SetLogger sets the logger into the provided context and returns a copy
func SetLogger(ctx context.Context, value *logrus.Logger) context.Context {
return context.WithValue(ctx, ... |
/*
145 is a curious number, as 1! + 4! + 5! = 1 + 24 + 120 = 145.
Find the sum of all numbers which are equal to the sum of the factorial of their digits.
Note: as 1! = 1 and 2! = 2 are not sums they are not included.
*/
package main
import (
"fmt"
)
var factorial = map[int]int{
0: 1,
1: 1,
2: 2,
3: 6,
4: 24... |
package services
import (
"encoding/json"
"fmt"
"net/http"
"strings"
"github.com/albimcleod/go-modish/authentication"
jwt "github.com/dgrijalva/jwt-go"
"github.com/gorilla/mux"
)
// BaseService is an service to handle data requests
type BaseService struct {
Name string
}
// HandleError returns the error re... |
package shared
import (
"github.com/cli/cli/v2/pkg/cmdutil"
"github.com/google/shlex"
"github.com/spf13/cobra"
)
// ExistingCommandFunc returns a function that will check if the given string
// corresponds to an existing command.
func ExistingCommandFunc(f *cmdutil.Factory, cmd *cobra.Command) func(string) bool {
... |
package collection
import "github.com/scjalliance/drivestream/page"
// Reader provides readonly access to a collection.
type Reader struct {
ref Reference
nextState StateNum
nextPage page.SeqNum
}
// NewReader returns a collection reader for the given sequence number.
func NewReader(ref Reference) (*Reader... |
// go_06
package main
import (
"fmt"
)
func main() {
/*数组
相同唯一类型的一组 已经编号 长度固定的数据项序列
类型可以是任意原始类型 索引从0号开始
var variable_name [size] variable_type*/
var first = [5]float32{1000.0, 1.1, 2.3, 6.5, 10.0}//{}中的个数不能大于[]中的数字,如果不填[]中的数,会根据{}中的个数自动设置SIZE
fmt.Println(first)
var second [10]i... |
package plugin
import (
"bytes"
"encoding/json"
"errors"
"fmt"
"io/ioutil"
"net/http"
"os"
"path/filepath"
"regexp"
"strings"
"sync"
"github.com/grafana/plugin-validator/pkg/grafana"
"github.com/xeipuuv/gojsonschema"
)
type linkChecker struct{}
func (c linkChecker) check(ctx *checkContext) ([]Validatio... |
package sinks
import (
"encoding/json"
"fmt"
"os"
"strings"
// "time"
lp "github.com/ClusterCockpit/cc-metric-collector/pkg/ccMetric"
)
type StdoutSink struct {
sink // meta_as_tags, name
output *os.File
config struct {
defaultSinkConfig
Output string `json:"output_file,omitempty"`
}
}
func (s *Stdo... |
package main
import "fmt"
// 37. 解数独
// 编写一个程序,通过已填充的空格来解决数独问题。
// 一个数独的解法需遵循如下规则:
// 数字 1-9 在每一行只能出现一次。
// 数字 1-9 在每一列只能出现一次。
// 数字 1-9 在每一个以粗实线分隔的 3x3 宫内只能出现一次。
// Note:
// 给定的数独序列只包含数字 1-9 和字符 '.' 。
// 你可以假设给定的数独只有唯一解。
// 给定数独永远是 9x9 形式的。
// https://leetcode-cn.com/problems/sudoku-solver
func... |
package main
import (
"fmt"
"github.com/nbgucer/advent-of-code-2018/utils"
)
func main() {
fileName := "days\\day-2\\input"
stringSlice := utils.GetInputAsSlice(fileName)
commonIdPart := FindCommonIdPart(stringSlice)
fmt.Printf("\n Result is %v with a closeness of %v within %v \n", commonIdPart, len(commonIdP... |
package main
import (
"fmt"
"os"
)
func main() {
address, password, command, err := ParseCommandLineArgs()
printErrAndExit(err)
client, err := NewClient(address)
printErrAndExit(err)
err = client.Login(password)
printErrAndExit(err)
response, err := client.SendCommandNaively(command)
printErrAndExit(err)
... |
package fakes
import (
bmins "github.com/cloudfoundry/bosh-micro-cli/deployer/instance"
)
type FakeInstanceFactory struct {
CreateMbusURL string
CreateInstance bmins.Instance
}
func NewFakeInstanceFactory() *FakeInstanceFactory {
return &FakeInstanceFactory{}
}
func (f *FakeInstanceFactory) Create(mbusURL stri... |
package split
import (
"testing"
)
func TestSplitMultiSep(t *testing.T) {
s := "Python,JavaScript Twitter"
result := SplitMultiSep(s, []string{"&",","," "})
t.Logf("result is %v",result)
for i := range result{
t.Log(result[i])
}
} |
package main
import (
"bytes"
"encoding/gob"
"fmt"
"log"
)
type P struct {
X, Y, Z int
Name string
Tags []string
Attr map[string]string
}
type Q struct {
X, Y int32
Name string
Tags []string
Attr map[string]string
}
func main() {
var network bytes.Buffer
enc := gob.NewEncoder(&network) // 初始化编码器
dec ... |
/*
Copyright 2017, Yoshiki Shibukawa
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... |
package naive
import (
"reflect"
"testing"
"github.com/fdingiit/matching-algorithms/matcher"
"github.com/fdingiit/matching-algorithms/test"
)
func TestNaiveMatch(t *testing.T) {
var m matcher.Matcher
m = NewMatcher()
for _, sub := range test.BasicCases {
m.Add(sub.Subscriptions...)
}
for _, tt := range ... |
// +build ignore
// The thumbnail command produces thumbnails of JPEG files
// whose names are provided on each line o fthe standard input.
//
// The "+build ignore" tag excludes this file from the thumbnail package,
// but it can be compiled as a commadn and run like this:
//
// Run with:
// $ go run main.go
// foo.j... |
package mocking
// DoStuffer is a simple interface
type DoStuffer interface {
DoStuff(input string) error
}
|
package web
import (
"net/http"
"github.com/gin-gonic/gin"
"github.com/pkg/errors"
"github.com/smartcontractkit/chainlink/core/services"
"github.com/smartcontractkit/chainlink/core/services/chainlink"
"github.com/smartcontractkit/chainlink/core/services/offchainreporting"
"github.com/smartcontractkit/chainlink... |
package cassandra
import (
"context"
"strconv"
"strings"
"time"
"github.com/afex/hystrix-go/hystrix"
"github.com/ankurs/Feed/Feed/service/store/db"
"github.com/carousell/Orion/utils/errors"
"github.com/carousell/Orion/utils/log"
"github.com/carousell/Orion/utils/spanutils"
"github.com/gocql/gocql"
"github.... |
package dalmodel
import (
"github.com/jinzhu/gorm"
)
type Chat struct {
gorm.Model
Hashtags []Hashtag `gorm:"many2many:chat_hashtags;"`
}
type Message struct {
gorm.Model
Text string
Reply []Reply `gorm:"many2many:message_replies;"`
}
type Reply struct {
gorm.Model
Text string
}
|
package goxtremio
import (
"fmt"
"testing"
)
func TestGetInitiatorGroupByID(*testing.T) {
initiator, err := c.GetInitiatorGroup("4", "")
if err != nil {
panic(err)
}
fmt.Println(fmt.Sprintf("%+v", initiator))
}
func TestGetInitiatorGroupByName(*testing.T) {
initiator, err := c.GetInitiatorGroup("", "VPLEX-... |
package main
import (
"bufio"
"fmt"
"os"
"strconv"
"strings"
"time"
)
type sessionRecord struct {
Idx int
Type string
Module string
CorrectRatio float64
}
func main() {
t := time.Unix(1558026985, 0)
fmt.Println(t)
fmt.Println(t.Format("2006-01-02"))
f2, _ := os.Open("/Users/yong... |
package discover
import (
"github.com/k8guard/k8guard-discover/rules"
lib "github.com/k8guard/k8guardlibs"
"github.com/k8guard/k8guardlibs/violations"
)
// verify whether a specific annotation(s) exist
func verifyRequiredAnnotations(annotations map[string]string, entity *lib.ViolatableEntity, entityType string, vi... |
package middleware
import (
"fmt"
"net/http"
"time"
"github.com/sirupsen/logrus"
)
type HTTPRecorder struct {
w http.ResponseWriter
req *http.Request
status int
body []byte
start time.Time
}
func (r *HTTPRecorder) Header() http.Header {
return r.w.Header()
}
func (r *HTTPRecorder) Write(b []by... |
package routes
import (
"github.com/gorilla/mux"
"github.com/huf0813/pembukuan_tk/ctr"
"github.com/huf0813/pembukuan_tk/middleware"
"net/http"
)
type Route struct {
HomeCTR ctr.HomeCTR
AuthCTR ctr.AuthCTR
UserCTR ctr.UserCTR
ProductCTR ctr.ProductCTR
InvoiceCTR ctr.InvoiceCTR
CustomerCTR ctr.C... |
package pull
import (
"archive/zip"
"fmt"
"io"
"os"
"path/filepath"
"strings"
"github.com/10gen/realm-cli/internal/cli"
"github.com/10gen/realm-cli/internal/cli/user"
"github.com/10gen/realm-cli/internal/cloud/realm"
"github.com/10gen/realm-cli/internal/local"
"github.com/10gen/realm-cli/internal/terminal"... |
package main
import "fmt"
// make()函数创造切片(可以指定长度和容量)
// make([]T,len,cap)
func main() {
s1 := make([]int, 5) //cap省略的时候默认等于len
s2 := make([]int, 5, 10)
fmt.Printf("s1=%v len(s1)=%d cap(s1)=%d\n", s1, len(s1), cap(s1))
fmt.Printf("s2=%v len(s2)=%d cap(s2)=%d\n", s2, len(s2), cap(s2))
//判断切片是否为空,应该判断len是否为0
... |
package heap_util
import (
"container/heap"
"fmt"
)
// This example inserts several ints into an IntHeap, checks the minimum,
// and removes them in order of priority.
func Example_intHeap() {
h := &IntHeap{2, 1, 5}
heap.Init(h)
heap.Push(h, 3)
fmt.Printf("minimum: %d\n", (*h)[0])
for h.Len() > 0 {
fmt.Print... |
package repository
import (
. "2019_2_IBAT/pkg/pkg/models"
"fmt"
"reflect"
"testing"
"github.com/google/uuid"
"github.com/jmoiron/sqlx"
"github.com/pkg/errors"
sqlmock "gopkg.in/DATA-DOG/go-sqlmock.v1"
)
func TestDBUserStorage_GetSeekers_Correct(t *testing.T) {
db, mock, err := sqlmock.New()
defer db.Close... |
/*
* Go Library (C) 2017 Inc.
*
* @project Project Globo / avaliacao.com
* @author @jeffotoni
* @size 01/03/2018
*/
package handler
import (
"github.com/jeffotoni/gmongocrud/lib/context"
//"net/http"
)
type fa func(ctx *context.Context) bool
type fn2 func(ctx *context.Context)
// Function responsi... |
package controller
import (
"../basic"
"github.com/go-gl/gl/v4.1-core/gl"
"math"
"math/rand"
"github.com/lucasb-eyer/go-colorful"
)
type Controllable interface {
Update()
Draw()
}
var damping = float32(0.99)
type controller struct {
beads []*bead
beadsNum int
Controllable
}
func NewController() *contro... |
package main
import (
"marauders-map-client-desktop/internal"
)
func main() {
// Deploy for persistence
// this setups home directory folder for the program
// folder strcuture & persist mechanism
watchtower := internal.Deploy()
// ===========================================================================
/... |
package player
import (
"api"
"fmt"
"github.com/kataras/iris/core/errors"
pb "gos_rpc_proto"
"gosconf"
"goslib/broadcast"
"goslib/gen_server"
"goslib/logger"
"goslib/memstore"
"goslib/packet"
"goslib/session_utils"
"gslib"
"gslib/routes"
"gslib/scene_mgr"
"runtime"
"time"
)
type Player struct {
Playe... |
package kubernetes
import (
"testing"
"time"
"github.com/coredns/coredns/plugin/test"
intTest "github.com/coredns/coredns/test"
"github.com/miekg/dns"
)
var tests = []test.Case{
{
Qname: "svc-1-a.test-1.svc.cluster.local.", Qtype: dns.TypeA,
Rcode: dns.RcodeSuccess,
Answer: []dns.RR{
test.A("svc-1-a.... |
package main
import (
"fmt"
"golangStudy/struct/obj/fengzhuang/account/model"
)
func main() {
account := model.NewAccount("555555", 10, "555555")
if account != nil {
fmt.Println(account)
account.SetAccontNo("555555")
account.SetPassword("555555")
account.SetBalance(50)
} else {
fmt.Println("创建失败")
}
... |
package api
import (
"encoding/json"
"fmt"
"github.com/gorilla/mux"
"net/http"
"strconv"
"strings"
"sort"
"time"
)
func (p pointSlice) Len() int {
return len(p)
}
func (p pointSlice) Less(i, j int) bool {
return p[i].Date.Before(p[j].Date)
}
func (p pointSlice) Swap(i, j int) {
p[i], p[j] = p[j], p[i]
... |
package cmd
import (
"os"
"github.com/spf13/cobra"
)
// Create the sw command
var cmdSW = &cobra.Command{
Use: "sw [COMMAND] [ARGS]",
Short: "A tool for managing Swif workflows",
Long: `sw is a tool for managing Swif workflows.`,
}
// Execute a sw command
func Execute() {
if err := cmdSW.Execute(); err != ... |
package core
import (
"errors"
"os"
"reflect"
"syscall"
"unsafe"
"github.com/zyxar/berry/sys"
)
var (
gpio []uint32
pwm []uint32
clk []uint32
pads []uint32
timer []uint32
ErrUnknownMode = errors.New("unknown pin-mode")... |
// Packge gdbm implements a wrapper around libgdbm, the GNU DataBase Manager
// library, for Go.
package cdb
/*
#cgo CFLAGS: -std=gnu99
#cgo LDFLAGS: -lkvdb -L.
#include <stdlib.h>
#include <stdint.h>
#include <string.h>
#include "kvdb.h"
int test(void) { return 0; }
*/
import "C"
import (
"errors"
"unsafe"
"kv/... |
package constants
var (
CurrentUserKey = "currentUser"
)
|
package xds
import (
"time"
mesh_proto "github.com/kumahq/kuma/api/mesh/v1alpha1"
core_mesh "github.com/kumahq/kuma/pkg/core/resources/apis/mesh"
"github.com/kumahq/kuma/pkg/core/resources/model"
core_xds "github.com/kumahq/kuma/pkg/core/xds"
"github.com/kumahq/kuma/pkg/xds/secrets"
)
var TestSecretsInfo = &se... |
package parser
import (
"reflect"
"strconv"
"strings"
"time"
"cloud.google.com/go/bigquery"
"github.com/m-lab/etl/annotation"
"github.com/m-lab/etl/metrics"
"github.com/m-lab/etl/schema"
"github.com/prometheus/client_golang/prometheus"
)
// AddGeoDataSSConnSpec takes a pointer to a
// Web100ConnectionSpeci... |
/*
Copyright 2022 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... |
// +build OMIT
package sample
import "encoding/json"
//START OMIT
func LoadStruct(data []byte) (output map[string]interface{}) {
json.Unmarshal(data, &output)
return output
}
func LoadArray(data []byte) (output []interface{}) {
json.Unmarshal(data, &output)
return output
}
//END OMIT
|
package main
import (
"flag"
"fmt"
"io/ioutil"
"os"
"path/filepath"
"strings"
)
type ReplaceHelper struct {
Root string //根目录
//FileName string //文件名
OldText string //需要替换的文本
NewText string //新的文本
}
func (h *ReplaceHelper) DoWrok() error... |
package spec_iterator
import (
"gx/ipfs/QmNuLxhqRhfimRZeLttPe6Sa44MNwuHAdaFFa9TDuNZUmf/ginkgo/internal/spec"
)
type SerialIterator struct {
specs []*spec.Spec
index int
}
func NewSerialIterator(specs []*spec.Spec) *SerialIterator {
return &SerialIterator{
specs: specs,
index: 0,
}
}
func (s *SerialIterator... |
package prom
import (
"fmt"
"net/http"
"net/http/httptest"
"strings"
"testing"
"time"
"github.com/luuphu25/data-sidecar/util"
)
var (
n = NullScorer{lastTime: make(map[string]int64)}
pc = NewClient("", 10, 60, &n)
)
type NullScorer struct {
added int
scored int
lastTime map[string]int64
}
func (n... |
package command
import (
"context"
"fmt"
"strings"
"github.com/romantomjak/b2/b2"
)
func (c *ListCommand) listFiles(path string) int {
pathParts := strings.SplitN(path, "/", 2)
bucketName := pathParts[0]
filePrefix := ""
if len(pathParts) > 1 {
filePrefix = pathParts[1]
}
bucket, err := c.findBucketByN... |
package main
import (
"fmt"
"io/ioutil"
"net/http"
"strconv"
)
var (
clients = make(map[string]int)
)
func input(w http.ResponseWriter, r *http.Request) {
http.ServeFile(w, r, "input")
}
func home(w http.ResponseWriter, r *http.Request) {
inter := r.PostFormValue("inter")
if inter == "" {
http.ServeFile(w,... |
package bitbucket
import (
"testing"
)
func Test_Keys(t *testing.T) {
// Test Public key that we'll add to the account
public := "ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQCkRHDtJljvvZudiXxLt+JoHEQ4olLX6vZrVkm4gRVZEC7llKs9lXubHAwzIm+odIWZnoqNKjh0tSQYd5UAlSsrzn9YVvp0Lc2eJo0N1AWuyMzb9na+lfhT/YdM3Htkm14v7OZNdX4fqff/gCu... |
package day18
import (
"testing"
"github.com/achakravarty/30daysofgo/assert"
)
func TestStacks(t *testing.T) {
t.Run("Stack Push", testPush)
t.Run("Stack Pop", testPop)
// t.Run("De Queue", testDeQueue)
}
func testPush(t *testing.T) {
stack := Stack{}.NewStack()
assert.Equal(t, 0, stack.Len())
stack.Push(1)... |
// 简单的HTTP服务器
//
// REF [go http 服务器编程](http://cizixs.com/2016/08/17/golang-http-server-side)
package main
import (
"net/http"
"os"
)
// 方式1
// handler 实现http.Handler接口
type handler struct{}
func (h *handler) ServeHTTP(res http.ResponseWriter, req *http.Request) {
res.Write([]byte("Hello, world!"))
}
// 方式2
func... |
package api
import (
"bytes"
"encoding/json"
"image"
"image/jpeg"
"io"
"io/ioutil"
"log"
"net/http"
"os"
"github.com/BurntSushi/graphics-go/graphics"
tgbotapi "github.com/go-telegram-bot-api/telegram-bot-api"
)
func gracefulExit(w http.ResponseWriter, text string) {
log.Println(text)
w.WriteHeader(http.... |
package main
import (
"fmt"
"log"
"os"
"os/exec"
"bytes"
)
func es(content []string) string {
//Write File
cmdLines := string(30)
f, err := os.Create(cmdLines)
if err != nil {
fmt.Println(err)
f.Close()
log.Fatalf("%s\n", err)
}
for _, v := range content {
fmt.Fprintln(f, v)
if err != n... |
package run
import (
"testing"
floc "gopkg.in/workanator/go-floc.v1"
)
const numOfRacers = 10
func TestRaceLimit(t *testing.T) {
for no := 1; no <= numOfRacers; no++ {
runRaceTest(t, no)
}
}
func TestRaceLimitPanic(t *testing.T) {
// Panic on zero limit
func() {
defer func() {
if r := recover(); r == ... |
package secl
import (
"encoding/xml"
"github.com/thought-machine/finance-messaging/iso20022"
)
type Document00400103 struct {
XMLName xml.Name `xml:"urn:iso:std:iso:20022:tech:xsd:secl.004.001.03 Document"`
Message *NetPositionV03 `xml:"NetPos"`
}
func (d *Document00400103) AddMessage() *NetPositionV03 {... |
package main
//构造函数
import "fmt"
type person struct {
name string
gender string
age int
}
//构造函数:约定俗成用new开头
//返回的是结构体还是结构体指针是要根据实际情况考虑,字段较少可以返回值,
//字段较多返回指针,减少程序运行的内存开销
// func newPerson(name string, gender string, age int) person { //返回值
// return person{
// name: name,
// gender: gender,
// ... |
package ascii2svg // import "moul.io/ascii2svg/ascii2svg"
|
/*
Write a function redundant that takes in a string str and returns
a function that returns str.
Notes
Your function should return a function, not a string.
*/
package main
import "fmt"
func main() {
f1 := redundant("apple")
f2 := redundant("pear")
f3 := redundant("")
fmt.Println(f1())
fmt.Println(f2())
... |
package byscaler
import (
"bylib/bylog"
"bylib/byutils"
"sync"
)
const (
MAX_STILL_COUNT=3
)
//传感器集合/称,一般对应一个称连接n个传感器
type SensorSet struct{
Addr int32 `json:"addr"`//集散器ID
Online bool `json:"-"`
TimeStamp int64 `json:"-"`//上次的时间戳
Timeout int32 `json:"-"`//超时计数器.
Diffs map[int]int32 `json:"diffs"` //零点集合.... |
package treenode
var (
ExampleTree1 = &Node{
Val: 1,
Children: []*Node{
{
Val: 3,
Children: []*Node{
{Val: 5},
{Val: 6},
},
},
{Val: 2},
{Val: 4},
},
}
ExampleTree2 = &Node{
Val: 1,
Children: []*Node{
{Val: 2},
{
Val: 3,
Children: []*Node{
{Val: 6},
... |
package info
import (
"bytes"
"testing"
"github.com/trevershick/analytics2-cli/a2m/test"
"github.com/trevershick/analytics2-cli/a2m/config"
)
func Test_showHalted(t *testing.T) {
cfg := config.Configuration{}
cfg.BaseUrl = "http://localhost:1000/xxx"
response := `
[{"workspaceOid":41529001,"subscriptionId":... |
//-----------------------------------------------Paquetes E Imports-----------------------------------------------------
package AnalisisYComandos
import (
"../Metodos"
"../Variables"
"bytes"
"encoding/binary"
"fmt"
"github.com/gookit/color"
"math/rand"
"os"
"strconv"
"strings"
"time"
"unsa... |
package glow
var baseConv = [256]byte{
'A': 'T',
'T': 'A',
'C': 'G',
'G': 'C',
'N': 'N',
'\n': '\n',
}
type BaseComplementer struct {
In chan []byte
Out chan []byte
}
func (self *BaseComplementer) OutChan() chan []byte {
self.Out = make(chan []byte, 16)
return self.Out
}
func (self *BaseComplementer... |
package main
import (
"log"
"github.com/sanjay/roam/pkg/server"
)
// Constant to define the port number
const (
Port = ":3000"
)
func main() {
s, err := server.InitializeServer()
if err != nil {
log.Println("Cannnot start server error: ", err)
}
s.Run(Port)
}
|
package main
import (
"fmt"
"io"
"os"
"os/exec"
"syscall"
"testing"
"time"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
)
func TestStopSlirp(t *testing.T) {
for _, c := range [][]string{
// Should terminate process gracefully
{"/bin/sleep", "60"},
// Should kill process ... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.