text stringlengths 11 4.05M |
|---|
package main
import (
"flag"
"fmt"
"os"
"path/filepath"
"github.com/takatoh/mkdocindex/indexmaker"
)
const (
progVersion = "v0.6.0"
)
func main() {
flag.Usage = func() {
fmt.Fprintf(os.Stderr,
`Usage:
%s [options] [dir]
Options:
`, os.Args[0])
flag.PrintDefaults()
}
opt_distributed := flag.Bool("... |
package session
import (
"os"
"strings"
"testing"
"time"
"github.com/aws/aws-sdk-go/aws"
"github.com/aws/aws-sdk-go/aws/credentials"
"github.com/btnguyen2k/prom"
)
func _createAwsDynamodbConnect(t *testing.T, testName string) *prom.AwsDynamodbConnect {
awsRegion := strings.ReplaceAll(os.Getenv("AWS_REGION"),... |
package mysql
type Mysql struct {
}
func (this *Mysql) Connect(host string, port int) {
}
|
/*
Package edf aims to implement an interface to the EDF+ standard as described
on http://www.edfplus.info/ for the Go language. The objective is to read a
file and provide some kind of access to the stored data stored. It was written
by Cristiano Silva Jr. while working at the Laboratory of Neuroscience and
Behavior f... |
package mill
import (
"bytes"
"encoding/json"
"image"
"path/filepath"
"strings"
"time"
"github.com/rwcarlsen/goexif/exif"
)
type ImageExifSchema struct {
Created time.Time `json:"created,omitempty"`
Name string `json:"name"`
Ext string `json:"extension"`
Width int `json:"width... |
package main
import "fmt"
var soma = func(x, y int) int {
return x + y
}
var subtracao = func(x, y int) int {
return x - y
}
func main() {
fmt.Println(soma(5, 9))
fmt.Println(subtracao(5, 9))
}
|
package main
import (
"crypto/tls"
"mumbletest/mumblebot"
"os"
)
func main() {
mumbleServerAddress := os.Getenv("MUMBLETEST_SERVER_ADDR")
mumbleUsername := os.Getenv("MUMBLETEST_USERNAME")
mumblePassword := os.Getenv("MUMBLETEST_PASSWORD")
tlsConfig := &tls.Config{
InsecureSkipVerify: true,
}
mumbleBot :... |
// Copyright 2018 Lars Hoogestraat
// Use of this source code is governed by a MIT-style
// license that can be found in the LICENSE file.
package handler_test
import (
"bytes"
"context"
"database/sql"
"fmt"
"io"
"io/ioutil"
"log"
"mime/multipart"
"net/http"
"net/http/httptest"
"net/url"
"os"
"path/filep... |
package main
import (
"bytes"
"flag"
"io"
"log"
"os"
"os/exec"
"path/filepath"
)
func main() {
dir := flag.String("dir", "/tmp/bench", "Benchmark dir")
flag.Parse()
err := os.MkdirAll(*dir, 0775)
if err != nil {
log.Fatalf("error: %s", err)
}
if len(os.Args) == 1 {
log.Fatalf("<name> required")
}
... |
package file
import (
"fmt"
"os"
"path/filepath"
"strings"
)
var scanFileSuffixes = []string{".v", ".sv", ".svkey"}
var fileChannel = make(chan PathedFile, 100)
var scanCompleteChannel = make(chan bool, 1)
type PathedFile struct {
info os.FileInfo
path string
}
func Scan(path string) (*chan PathedFile, *chan ... |
package user
import (
"encoding/json"
"math"
"reflect"
"sync"
"sync/atomic"
"testing"
"github.com/Quaqmre/mirjmessage/logger"
"github.com/Quaqmre/mirjmessage/mock"
)
func TestNewUser(t *testing.T) {
var mockedlogger logger.Service = mock.NewMockedLogger()
var u *UserService = newUserService(mockedlogger)
... |
package main
import (
"bufio"
"database/sql"
"fmt"
_ "github.com/go-sql-driver/mysql"
"github.com/moraes/config"
"os"
"time"
)
func Query(instruction *string, db *sql.DB) (string, error) {
query, err := db.Query(*instruction)
if err != nil {
return "", err
}
var dbRes string
for query.Next() {
query... |
package main
import (
"os"
"path/filepath"
"reflect"
"testing"
"time"
"k8s.io/apimachinery/pkg/runtime"
"k8s.io/client-go/kubernetes/fake"
"github.com/stretchr/testify/assert"
v1 "k8s.io/api/apps/v1"
batchv1 "k8s.io/api/batch/v1"
"k8s.io/apimachinery/pkg/util/clock"
metav1 "k8s.io/apimachinery/pkg/apis... |
package app
///go:generate mockgen -destination=testing.generated.go -package=app -source=app.go App
///go:generate mockgen -destination=testing.generated.go -package=app github.com/powerman/bug-gomock/app App
///go:generate mockgen -destination=testing.generated.go -package=app -self_package=github.com/powerman/bug-g... |
package channels
import (
"fmt"
"sync"
"time"
)
// InitSync2 init
func InitSync2() {
var wg sync.WaitGroup
wg.Add(1) // waiting for one go routine
go func() {
var value = 10
var result = 0
goChan := make(chan int)
mainChan := make(chan string)
calculateSquare := func() {
time.Sleep(time.Second * 3... |
package main
import (
b64 "encoding/base64"
"encoding/json"
"flag"
"fmt"
"log"
"net/http"
"os"
"strings"
"time"
"github.com/ckin-it/minedive/minedive"
"github.com/go-redis/redis"
"github.com/gorilla/handlers"
"github.com/gorilla/mux"
)
var s minedive.MinediveServer
var port int
var rdb *redis.Client
var... |
package bgo
import (
"os"
stack "github.com/Gurpartap/logrus-stack"
tf "github.com/pickjunk/bgo/text_formatter"
log "github.com/sirupsen/logrus"
)
// Logger struct
type Logger struct {
*log.Logger
}
// Log instance
var Log = initLogger()
func initLogger() *Logger {
if os.Getenv("ENV") == "... |
package main
import(
"fmt"
"hashtable"
"strconv"
)
func main(){
var ht hashtable.HashTable
ht.InitHashtable(4,1)
fmt.Println()
fmt.Println("------------------------------------------------------------------------------------")
for i:=0;i<10;i++{
ht.Put(i,strconv.Itoa(i)+" hello")
fmt.Println()
fmt.Printl... |
package config
import (
"github.com/spf13/viper"
)
// ViperProvider represents the structure to manage
// configurations based on github.com/spf13/viper
type ViperProvider struct {
v *viper.Viper
}
// NewViperProvider creates a new configuration provider
// based on github.com/spf13/viper
func NewViperProvider(v *... |
package main
import (
"net/http"
)
func main() {
http.HandleFunc("/", DisplayHandler)
http.ListenAndServe(":5000", nil)
}
|
package main
type obj = map[string]interface{}
type array = []interface{}
|
/*
* Tencent is pleased to support the open source community by making 蓝鲸 available.
* Copyright (C) 2017-2018 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 a copy of the Li... |
package controller
import (
"encoding/json"
"log"
"net/http"
service "github.com/darkarchana/darkarchana-backend/service/serviceimpl"
"github.com/darkarchana/darkarchana-backend/view"
)
// Heroes : Heroes API
func Heroes() http.HandlerFunc {
return func(w http.ResponseWriter, r *http.Request) {
var clientReq... |
package controllers
import (
"log"
"mick/models"
"github.com/jinzhu/gorm"
)
func ConnDataBase() (*gorm.DB, error) {
db, err := gorm.Open("sqlite3", "./photos.db")
if err != nil {
log.Println(err)
}
// init
db.DB()
db.DB().Ping()
db.DB().SetMaxIdleConns(10)
db.DB().SetMaxOpenConns(100)
db.LogMode(true... |
// Package tokens generates and validates JSON Web Signatures
package tokens
import (
"crypto/rsa"
"encoding/json"
"fmt"
"io"
"io/ioutil"
"time"
"gopkg.in/square/go-jose.v1"
)
// Encoder helps create JSON Web Signatures for any payload.
type Encoder struct {
signer jose.Signer
pub *rsa.PublicKey
}
// Ne... |
package mod
import (
"flag"
"fmt"
"github.com/beego/bee/cmd/commands"
"github.com/beego/bee/cmd/commands/version"
"github.com/beego/bee/utils"
"os"
"path"
"path/filepath"
"strings"
)
var m = `
module {{.appname}}
go 1.12
`
var mod = &commands.Command{
CustomFlags: true,
UsageLine: "mod",
Short: ... |
package main
import (
"cm_liveme_im/libs/bufio"
"cm_liveme_im/libs/bytepool"
"cm_liveme_im/libs/bytes"
aesext "cm_liveme_im/libs/crypto/aes"
rsaext "cm_liveme_im/libs/crypto/rsa"
"cm_liveme_im/libs/define"
"cm_liveme_im/libs/proto"
itime "cm_liveme_im/libs/time"
"encoding/json"
"fmt"
pb "github.com/golang/p... |
package lib
import (
"bufio"
"errors"
"os"
"encoding/json"
"fmt"
"github.com/goml/gobrain"
)
// private method
func bin(n int) []float64 {
f := [8]float64{} // MAX model 8개
for i := uint(0); i < 8; i++ {
f[i] = float64((n >> i) & 1) // shift로 이진수 형태로 저장
}
return f[:] // 전체 내용을 출력하기위해 [:]사용(기존 형태는 [8]로 지... |
package slack
import (
"encoding/json"
"net/http"
"testing"
)
func TestListEventAuthorizations(t *testing.T) {
http.HandleFunc("/apps.event.authorizations.list", testListEventAuthorizationsHandler)
once.Do(startServer)
api := New("", OptionAppLevelToken("test-token"), OptionAPIURL("http://"+serverAddr+"/"))
... |
// Copyright 2023 Google LLC. 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 applica... |
// Copyright 2020-2021 Buf Technologies, 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... |
package main
import (
"fmt"
"math"
)
func main() {
intSize := 32 << (^uint(0) >> 63) // 32 or 64
MaxInt := 1<<(intSize-1) - 1
fmt.Println(intSize)
fmt.Println(MaxInt)
fmt.Println(math.Pow(2, 63))
fmt.Println(math.MaxInt)
fmt.Println(math.MinInt)
fmt.Println(frogPosition(3, [][]int{
{2, 1},
{3, 2},
... |
// Copyright 2019 John Papandriopoulos. All rights reserved.
// Use of this source code is governed by a MIT-style
// license that can be found in the LICENSE file.
package zydis
// AddressWidth is an enum of processor address widths.
type AddressWidth int
// AddressWidth enum values.
const (
AddressWidth16 Addres... |
package main
import "fmt"
// 把函数赋值给一个变量, 该变量也可以调用方法
func getSum(n1 int, n2 int) int {
return n1 + n2
}
// 函数也是一种数据类型, 因此可以作为参数传入, 并且调用
func myFunc(func1 func(int, int) int, num1 int, num2 int) int {
return func1(num1, num2)
}
type myFuncType func(int, int) int
func myFunc2(func1 myFuncType, num1 int, num2 int) in... |
package test
import (
"database/sql"
"testing"
)
func TestTransactiontest(t *testing.T) {
db, err := sql.Open("mysql", "root@/test")
if err != nil {
panic(err)
}
db.Begin()
}
|
package card
type Card struct {
Issuer string
Balance int64
Currency string
Number string
}
type Service struct {
BankName string
Cards []*Card
}
func NewService(bankname string) *Service {
return &Service {
BankName : bankname,
}
}
func (s *Service) GetNewCard(issuer string, balance int64, currency stri... |
package model
import (
"time"
)
type StressHttpTestCase struct {
HttpTestCase
Duration time.Duration
Concurrency int64
RPS int64
}
var _ TestCase = &StressHttpTestCase{}
func (tc StressHttpTestCase) GetName() string {
return tc.Name
}
func (tc StressHttpTestCase) Run() TestResult {
panic("impleme... |
package main
import (
"bufio"
"bytes"
"fmt"
"html/template"
"log"
"net"
"strings"
)
func main() {
listener, err := net.Listen("tcp", ":8080")
if err != nil {
log.Fatalln(err)
}
defer listener.Close()
for {
conn, err := listener.Accept()
if err != nil {
fmt.Println(err)
}
go handleConnection(... |
package restclient
import (
"context"
"encoding/json"
"errors"
"net/http"
"time"
)
type RestClient struct {
HTTPClient *http.Client
}
type Header struct {
Key string
Value string
}
func NewRestClient(time time.Duration) RestClient {
return RestClient{
HTTPClient: &http.Client{
Timeout: time,
},
}... |
package 动态规划
import "fmt"
// -------------------- 贪心动态规划(使用前缀、后缀最小值) ----------------------
const INF = 1000000000
func minFallingPathSum(arr [][]int) int {
rows, cols := getRowsAndCols(arr)
minSum := get2DSlice(rows, cols)
for t := 0; t < cols; t++ {
minSum[0][t] = arr[0][t]
}
for i := 1; i < rows; i++ {
p... |
package helpers
import (
"log"
"time"
)
// LogStep calls Output to print to the standard logger with the provided message.
func LogStep(v ...interface{}) {
log.Println(time.Now().Format("02-Jan-2006"), "---- ", v)
}
// LogError is equivalent to LogStep() followed by a call to os.Exit(1).
func LogError(v ...interf... |
package jarviscore
import (
"context"
"fmt"
"io/ioutil"
"math/rand"
"os"
"sync"
"testing"
"time"
jarvisbase "github.com/zhs007/jarviscore/base"
coredbpb "github.com/zhs007/jarviscore/coredb/proto"
jarviscorepb "github.com/zhs007/jarviscore/proto"
"go.uber.org/zap"
)
func sendfile2node(ctx context.Contex... |
// 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... |
package clientserverpair_test
import (
"context"
"fmt"
"net"
"testing"
"time"
"github.com/rwool/ex/test/helpers/goroutinechecker"
"github.com/rwool/ex/log"
"github.com/rwool/ex/test/helpers/testlogger"
"github.com/rwool/ex/test/helpers/clientserverpair"
"github.com/stretchr/testify/assert"
"github.com/st... |
package utils
import (
"encoding/base64"
"github.com/riposa/utils/log"
"testing"
)
const (
key = "henghajiangwillbeonlineatshanghaiin20180912"
)
var (
pkcsLogger = log.New()
)
func TestEncrypt(t *testing.T) {
byteKey, err := base64.StdEncoding.DecodeString(key + "=")
if err != nil {
pkcsLogger.Exception(er... |
package main
import (
"testing"
"github.com/brigadecore/brigade/sdk/v3/restmachinery"
"github.com/brigadecore/brigade/v2/scheduler/internal/lib/queue/amqp"
"github.com/stretchr/testify/require"
)
// Note that unit testing in Go does NOT clear environment variables between
// tests, which can sometimes be a pain,... |
package main
import "fmt"
func verifyClaims(q quilt, claims []claim) {
for _, c := range claims {
valid := true
for y := c.yoffset; y < (c.yoffset + c.height); y++ {
for x := c.xoffset; x < (c.xoffset + c.width); x++ {
if q.grid[coord{x: x, y: y}] > 1 {
valid = false
break
}
}
if !vali... |
package redis
import (
"crypto/tls"
"time"
)
type config struct {
tls *tls.Config
expiry time.Duration
}
// Option customizes a Backend.
type Option func(*config)
// WithTLSConfig sets the tls.Config which Backend uses.
func WithTLSConfig(tlsConfig *tls.Config) Option {
return func(cfg *config) {
cfg.tls ... |
package ccache
import (
"time"
)
type Entry struct {
Key string
Value interface{}
Expiration *time.Time
}
// Returns true if the entry has expired.
func (entry *Entry) Expired() bool {
if entry.Expiration == nil {
return false
}
return entry.Expiration.Before(time.Now())
}
|
package main
// Scan a directory of SGF files for illegal moves. Recursive.
import (
"fmt"
"os"
"path/filepath"
sgf ".."
)
func main() {
if len(os.Args) < 2 {
fmt.Printf("Usage: %s <dir>\n", filepath.Base(os.Args[0]))
return
}
filepath.Walk(os.Args[1], handle_file)
}
func handle_file(path string, _ os.F... |
package common
import (
"os"
"os/signal"
"syscall"
"time"
log "github.com/cihub/seelog"
)
type ExeInterface interface {
LogInit()
ChooseStrategy()
ExeInit()
RocketMQStart()
}
type ExeCommon struct {
CfgFilename string
RebuildFilename string
StrategyInterface Strategies
}
func RegisterExitSignal() {
sig... |
package bench
import (
"database/sql"
"fmt"
)
func sampleFunc() {
fmt.Println("Hello World!")
}
func RunExhaustive(db *sql.DB) (err error) {
//Simple select from the tables
selectFromEmployee := "select * from employee"
rows, err := db.Query(selectFromEmployee)
if err != nil {
return err
}
defer rows.Clo... |
package utils
import (
"runtime"
"sync"
"time"
)
var statsMux sync.Mutex
var startTime = time.Now().Unix()
func GetMemory() uint64 {
var mem runtime.MemStats
runtime.ReadMemStats(&mem)
return mem.Sys
}
func GetUptime() uint64 {
return uint64(time.Now().Unix() - startTime)
}
func GetNumGoRoutine() uint64 {
... |
package main
import (
"fmt"
)
// 定义学生的结构体
type Student struct {
id int
name string
age byte
addr string
}
func main() {
// 方法一:顺序初始化,每个元素都得初始化
s1 := Student{101, "neil", 'm', "wuhan"}
fmt.Println("s1 = ", s1)
// 方法二:部分元素初始化,未初始化的值是该类型的默认值
s2 := Student{id: 101, addr: "wuhan"}
fmt.Println("s2 = ", s2)
... |
// Package trivial provides trivial functionality. ^_^
package trivial
func StringsContain(s []string, e string) bool {
for _, x := range s {
if x == e {
return true
}
}
return false
}
|
package depot
import (
"testing"
)
func TestAddStock(t *testing.T) {
reset()
sg := Stock{Name: "Google"}
sa := Stock{Name: "Amazon"}
sn := Stock{Name: "Netflix"}
ss := Stock{Name: "Siemens"}
if len(Get()) > 0 {
t.Errorf("List of stocks should be empty at the beginning! Got a length of %v ", len(Get()))
}
... |
package main
import (
firestore "cloud.google.com/go/firestore"
"context"
"encoding/json"
firebase "firebase.google.com/go"
"fmt"
"github.com/gorilla/mux"
"google.golang.org/api/option"
"log"
"net/http"
"os"
"time"
)
const FulfillmentCol = "fulfillments"
const HomeAutoCol = "home-automation"
var opt = opt... |
//Author: Shenung Fouamvung
package main
//MIPS processor simulation writen in Go Lang
//must have Go Lang installed to compile and run
//takes in 2 16bit binary values and computes them using logic gates to come to a result
//to run, CD to the file directory and use the command in command line terminal "go run main.... |
package ch01
// Find the largest element in the list
func Largest(in []int) int {
var max int
if len(in) == 0 {
return -1
}
for _, value := range in {
if value > max {
max = value
}
}
return max
}
|
package heap
func LookupMethodInClass(class *Class, name, descriptor string) *Method {
for c:=class;c!=nil;c=c.superClass{
for _,method := range c.methods{
if method.name == name && method.descriptor == descriptor {
return method
}
}
}
return nil
}
func lookupMethodInInterfaces(ifaces []*Class, name,... |
func isInterleave(s1 string, s2 string, s3 string) bool {
if len(s1)+len(s2)!=len(s3){
return false
}
var dfs func(c1, c2, c3 int) bool
dfs = func(c1, c2, c3 int) bool {
if c3 == len(s3) {
return true
}
if (c1 == len(s1) && s3[c3] != s2[c2]) || (c2 == len(s2) && s3[c3] != s1[c1]) {
return false
}... |
package mycocontext
// key is used for setting and getting from mycocontext.Context in this project.
type key int
// These are keys for the context that floats around.
const (
// keyHyphaName is for storing current hypha name as a string here.
keyHyphaName key = iota
// keyInputBuffer is for storing *bytes.Buffer ... |
package config
import (
"os"
"path"
"testing"
"time"
"github.com/stretchr/testify/assert"
"github.com/instructure-bridge/muss/testutil"
)
func TestSecretCommands(t *testing.T) {
var secretCmdPath string
if dir, err := os.Getwd(); err != nil {
t.Fatalf("failed to get working dir: %s", err)
} else {
secr... |
package snap_test
import (
"context"
"testing"
"time"
"github.com/imrenagi/go-payment"
"github.com/imrenagi/go-payment/gateway/midtrans/snap"
"github.com/imrenagi/go-payment/invoice"
midsnap "github.com/midtrans/midtrans-go/snap"
"github.com/stretchr/testify/assert"
)
func baseCreditCardInvoice() *invoice.In... |
package test
import (
"core"
"entity"
"testing"
)
func Test_Open(t *testing.T) {
t.Run("open should fail", func(t *testing.T) {
pda := core.PdaProcessor{}
str := "{a = a}"
isParsingSuccess := pda.Open([]byte(str))
if isParsingSuccess != false {
t.Errorf("output for %s is \n %t; want false", str, isPars... |
/*
* Copyright 2015 Manish R Jain <manishrjain@gmail.com>
*
* 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 appl... |
package huffman
import "testing"
func TestByte2BinString(t *testing.T) {
t.Log(Byte2BinString(143))
}
|
package main
import (
"fmt"
"io/ioutil"
"os"
)
const (
debug = false
)
func must(err error) {
if err != nil {
panic(err)
}
}
//TODO: publish, CHANGE NAME!!!
//TODO: make a change to test_mac.sh and check that it works remotely (git stash; check; git stash pop)
func slurp(path string) string {
buf, err := ... |
package main
import (
"bytes"
"fmt"
"generate/execute"
"generate/fetcher"
"os"
"text/template"
)
func main() {
conf := fetcher.InitConfigFromJson()
tems := execute.GetTemplate(conf)
//os.Mkdir("test1/haha", os.ModePerm)
for _, tem := range tems {
tmpl, err := template.ParseFiles("input/wxworkDao.php")
i... |
package _897_Increasing_Order_Search_Tree
import "fmt"
/**
* Definition for a binary tree node.
* type TreeNode struct {
* Val int
* Left *TreeNode
* Right *TreeNode
* }
*/
func increasingBST(root *TreeNode) *TreeNode {
var (
s = []*TreeNode{}
ol = []int{}
node = root
head = &TreeNode... |
package main
import(
"log"
"container/list"
)
func main(){
//stack
l := list.New()
l.PushBack(1)
l.PushBack(2)
l.PushBack(3)
log.Println(l)
stackEle := l.Back()
l.Remove(stackEle)
log.Println(stackEle,l)
//queue
q := list.New()
q.PushBack("a")
q.PushBack("b")
q.PushBack("c")
queueEle:=q.Front()
... |
package nacellepg
import (
"fmt"
"math"
"github.com/jmoiron/sqlx"
)
type (
PageMeta struct {
Page int
PageSize int
}
PagedResultMeta struct {
NumPages int `json:"num_pages"`
NumResults int `json:"num_results"`
}
)
func (m *PageMeta) Limit() int {
return m.PageSize
}
func (m *PageMeta) Offset... |
// +build !windows
package internal
import (
"github.com/sirupsen/logrus"
logrus_syslog "github.com/sirupsen/logrus/hooks/syslog"
"log/syslog"
)
func setupSyslogHook(proto, host string) (logrus.Hook, error) {
return logrus_syslog.NewSyslogHook(proto, host, syslog.LOG_DAEMON, "BitMaelum")
}
|
package main
import (
"encoding/json"
"sub_account_service/number_server/models"
"flag"
"sub_account_service/number_server/config"
"github.com/nsqio/go-nsq"
. "sub_account_service/number_server/pkg/nsq"
)
type MessageHandler struct {
data chan *nsq.Message
}
func (m *MessageHandler) HandleMessage(message *n... |
package auth
import (
"crypto/hmac"
"crypto/sha256"
"encoding/base64"
b64 "encoding/base64"
"encoding/hex"
"fmt"
"net/http"
"strconv"
"time"
)
type Auther struct {
AccessID string
SecretKey string
}
var UseSignAuthored = true
func (a *Auther) Auth(req *http.Request, useSignAuthored bool, auth Auther, re... |
package boom
import (
"sync"
"go.mercari.io/datastore/v2"
)
// Batch can queue operations on Datastore and process them in batch.
// Batch does nothing until you call Exec().
// This helps to reduce the number of RPCs.
type Batch struct {
m sync.Mutex
bm *Boom
b *datastore.Batch
earlyErrors []error
}
// Bo... |
package main
import (
"fmt"
"os"
"sort"
"strings"
"text/template"
)
type component struct {
Name string
Doc string
Modifiers []modifier
Parts []part
Elem string
Option bool
}
type modifier struct {
Name string
Class string
Doc string
}
type part struct {
Name string
Req... |
package main
import "fmt"
func test2() {
fmt.Println("小小雪第一次提交")
fmt.Println("0609初始化")
fmt.Println("小雪开发第a个功能")
fmt.Println("小雪开发第b个功能")
}
|
package fitbit
import (
"testing"
)
func TestErrorResponse(t *testing.T) {
}
|
package main
import (
"bufio"
"fmt"
"github.com/glenbolake/aoc2018"
"math"
"os"
"strconv"
"strings"
)
type Nanobot struct {
id int
x, y, z int
r int
}
func (n Nanobot) String() string {
return fmt.Sprintf("(%d,%d,%d)%d", n.x, n.y, n.z, n.r)
}
func (n Nanobot) distTo(other Nanobot) int {
retur... |
package ziface
type IRequest interface {
GetConnection() IConnect
GetData() []byte
}
|
package main
import (
"context"
"math/rand"
"strconv"
"github.com/aws/aws-lambda-go/lambda"
)
func main() {
lambda.Start(handler)
}
type Event struct {
BankInfo struct {
MinCreditScore string `json:"minCreditScore,omitempty"`
BaseRate string `json:"baseRate,omitempty"`
MaxLoanAmount string `json:... |
package main
import "fmt"
func main() {
var n int
fmt.Scan(&n)
a := 0
b := 1
for b < n {
fmt.Println(b)
a, b = b, a+b
}
}
|
package main
import "log"
type State interface {
WriteProgram(work Work)
}
type Work struct {
hour int
current State
finish bool
}
func(w *Work)SetState(s State){
w.current = s
}
func (w *Work)SetHour(hour int){
w.hour = hour
}
func(w *Work)SetFinishState(finish bool){
w.finish = finish
}
func (w Work)WritePr... |
package chat_server
import (
"context"
"encoding/json"
"fmt"
"github.com/go-redis/redis/v8"
)
type Command struct {
Command string `json:"command"`
Data map[string](interface{}) `json:"data"`
}
type MessageListReply struct {
Command string `json:"command"`
Messages []Message `json:"messages"`
}
type Control... |
package queue
type Queue interface {
Length() int
Capacity() int
Front() *Node
Rear() *Node
Enqueue(value interface{}) bool
Dequeue() interface{}
}
|
// Copyright 2017 The OpenSDS 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... |
// Copyright 2020 Readium Foundation. All rights reserved.
// Use of this source code is governed by a BSD-style license
// that can be found in the LICENSE file exposed on Github (readium) in the project repository.
package transactions
import (
"database/sql"
"errors"
"log"
"strings"
"time"
"github.com/readi... |
package messaging
//Queue which can send and receive message
type Queue interface {
//GetName give the queue name
GetName() string
//Receive a message from the queue
Receive() (WorkItem, error)
//Send a message to the destination queue
Send(destination string, message WorkItem) error
}
|
package logging
import (
"io"
"os"
"strings"
"time"
logrus_stack "github.com/Gurpartap/logrus-stack"
"github.com/sirupsen/logrus"
"github.com/authelia/authelia/v4/internal/configuration/schema"
)
// Logger returns the standard logrus logger.
func Logger() *logrus.Logger {
return logrus.StandardLogger()
}
/... |
package container
import (
"go/internal/pkg/config"
"github.com/gin-gonic/gin"
"go.uber.org/dig"
)
func BuildConfigContainer(container *dig.Container) error {
//debug mode
if err := container.Provide(config.NewAppConfig); err != nil {
return err
}
if err := container.Provide(config.NewDatabase); err != n... |
package api
// Skel 用于示例
type Skel struct {
ID int64 `json:"id" bson:"_id"`
}
// NewSkel 生成skel对象
func NewSkel() *Skel {
return &Skel{}
}
|
package datastore
import (
"testing"
"github.com/google/uuid"
"github.com/RicardoCampos/goauth/oauth2"
"github.com/stretchr/testify/assert"
)
func getToken() oauth2.ReferenceToken {
expiry := oauth2.GetNowInEpochTime() + 300000
token, _ := oauth2.NewReferenceToken(uuid.New().String(), "myclient", expiry, "an_a... |
package main
import (
"fmt"
"strings"
shared "github.com/corymurphy/adventofcode/shared"
)
func main() {
input := shared.ReadInput("input")
part1 := part1(input)
part2 := part2(input)
fmt.Printf("\nPart 1 answer: %d\n\n", part1)
fmt.Printf("\nPart 2 answer: %d\n\n", part2)
}
func NewGrid(size int) [][]int... |
package compute
import (
"encoding/json"
"encoding/xml"
"fmt"
"net/http"
"net/url"
)
// ServerAntiAffinityRule represents an anti-affinity rule between 2 servers.
type ServerAntiAffinityRule struct {
// The anti-affinity rule Id.
ID string `json:"id"`
// The 2 servers that the rule relates to.
//
// Only e... |
package db
import (
// mysql 驱动
_ "github.com/go-sql-driver/mysql"
//gorm 驱动
_ "github.com/jinzhu/gorm/dialects/mysql"
"github.com/golang/glog"
"github.com/jinzhu/gorm"
"sync"
"time"
"sub_account_service/app_server_v2/model"
)
//DbClient 数据库客户端
var DbClient *Db
//Db db对象
type Db struct {
addr string ... |
package main
import (
"github.com/beego/beego/v2/server/web"
)
func main() {
web.Router("/abort", &AbortController{})
web.Run()
}
type AbortController struct {
web.Controller
}
func (a *AbortController) Get() {
a.Abort("401")
// None of the following
user := a.GetString("user")
if user != "" {
a.Ctx.Write... |
package main
import (
"encoding/json"
"er"
"net/http"
"strconv"
"sutil"
"github.com/gorilla/mux"
)
type conf struct {
Port int
}
func main() {
_log.Inf("Init SGAS")
router := mux.NewRouter()
c := conf{}
if e := loadConf(&c); e != nil && (e.Code()&er.E_IMPORTANCE) >= er.IMPT_UNRECOVERABLE {
_log.Inf("... |
// This file was generated for SObject KnowledgeableUser, API Version v43.0 at 2018-07-30 03:47:26.0731645 -0400 EDT m=+12.416236830
package sobjects
import (
"fmt"
"strings"
)
type KnowledgeableUser struct {
BaseSObject
Id string `force:",omitempty"`
RawRank int `force:",omitempty"`
Syst... |
/////////////////////////////////////////////////////////////////////
// arataca89@gmail.com
// 20210417
//
// func TrimLeftFunc(s string, f func(rune) bool) string
//
// Retorna s removendo os caracteres especificados conforme a função
// f() do início.
//
package main
import (
"fmt"
"strings"
"uni... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.