text stringlengths 11 4.05M |
|---|
package micro
import (
"fmt"
"gopkg.in/yaml.v2"
"mix/core/helper"
"mix/core/logger"
"mix/core/storage"
"mix/plugins/mysql"
"path/filepath"
"strings"
)
const (
MixYmlSuffix = ".mix.yml"
MixGoSuffix = ".mix.go"
MixXmlSuffix = ".mix.xml"
ProtoSuffix = ".proto"
ServiceSuffix = "service"
)
func MakeBas... |
package main
import (
"context"
"software/car_port/logic"
"software/car_port/pb_gen"
"software/common"
)
type carPortServer struct {
}
func newCarPortServer() pb_gen.CarPortServiceServer {
return new(carPortServer)
}
func (s *carPortServer) Park(ctx context.Context, req *pb_gen.ReqPark) (*pb_gen.RespPark, erro... |
package idbenchmark_test
import (
"errors"
"log"
"testing"
"go.etcd.io/bbolt"
)
func bboltConnect() (db *bbolt.DB, err error) {
bucketName := []byte(idbenchmarkKey)
db, err = bbolt.Open("bbolt.db", 0600, nil)
if err != nil {
log.Println(err)
return nil, err
}
err = db.Update(func(tx *bbolt.Tx) error {... |
package parameters
import (
"testing"
"github.com/stretchr/testify/assert"
)
// TestGetMeRequest tests
func TestGetMeRequest(t *testing.T) {
assert := assert.New(t)
assert.Implements((*Parameter)(nil), new(GetMeRequest))
assert.Implements((*RequestParameter)(nil), new(GetMeRequest))
var p GetMeRequest
p = G... |
package main
import (
"os"
"path/filepath"
"strings"
"sync"
"time"
"github.com/Cloud-Foundations/Dominator/fleetmanager/topology"
"github.com/Cloud-Foundations/Dominator/lib/log"
"github.com/Cloud-Foundations/Dominator/lib/mdb"
)
type topologyGeneratorType struct {
eventChannel chan<- struct{}
logger ... |
package decode
import (
"crypto/rand"
"crypto/rsa"
"crypto/x509"
"encoding/pem"
"errors"
"io/ioutil"
"os"
"sync"
"github.com/golang/go/src/fmt"
"crypto"
)
//rsa
type rsaUtils struct {
PrivateKey []byte
PublicKey []byte
}
//当前类的指针
var rasUtilsClass *rsaUtils
//同步锁
var rasUtilsClassonce sync.Once
//rsa工... |
package leetcode
import (
"reflect"
"testing"
)
func TestAllCellsDistOrder(t *testing.T) {
ans1 := allCellsDistOrder(1, 2, 0, 0)
if !reflect.DeepEqual(ans1, [][]int{[]int{0, 0}, []int{0, 1}}) {
t.Fatal()
}
}
|
// Copyright 2020 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... |
/*
# Chronograf
launch with volume:
$ docker run -d -p 8888:8888 \
-v chronograf-storage:/var/lib/chronograf \
chronograf:tag
# Influxdb
launch with volume:
$ docker run -d --name=influxdb -p 8086:8086 \
-v influxdb-storage:/var/lib/influxdb \
influxdb:tag
use docker network:
$ docker... |
package lib
import (
"sort"
"strings"
)
type NGramPos struct {
workIndex int
start int
end int
}
type NGramMap = map[string]*[]NGramPos
type NGramRule struct {
name string
nGramMap *NGramMap
n int
score int
sortedTokens *[]string
}
func (g *NGramRule) AppendToken(w... |
// Copyright 2019-2023 The sakuracloud_exporter 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 appl... |
package main
import (
"fmt"
"time"
"github.com/samuel/go-zookeeper/zk"
)
var content string
func main() {
unstop := make(chan int)
c, _, err := zk.Connect([]string{"10.96.90.6"}, time.Second) //*10)
if err != nil {
panic(err)
}
bytes, _, ch, err := c.GetW("/didi")
if err != nil {
panic(err)
}
content... |
package services
import (
"iv-code-challenge/api/domain"
"iv-code-challenge/api/db"
"gopkg.in/mgo.v2"
)
type SubmissionService struct {
collection *mgo.Collection
}
type ISubmissionService interface {
Create(s *domain.Submission) error
}
func newSubmissionModel(s *domain.Submission) *domain.SubmissionModel... |
package main
import (
"fmt"
"math"
_ "net/http/pprof"
// "github.com/davecgh/go-spew/spew"
)
type Range struct {
start float64
end float64
step float64
profitStart float64
profitEnd float64
safetyStart float64
safetyEnd float64
}
type Result struct {
symbol string
currentPrice float64
lotSize float64... |
package server
import (
"context"
"fmt"
"net/http"
"github.com/gorilla/websocket"
"github.com/lillilli/logger"
"github.com/lillilli/graphex/config"
"github.com/lillilli/graphex/server/handler"
"github.com/lillilli/graphex/server/hub"
"github.com/lillilli/graphex/watcher"
)
var upgrader = websocket.Upgrader... |
package saturn
import (
"errors"
"io/ioutil"
"net/url"
"path/filepath"
"strings"
"github.com/mgenware/cf-saturn/v2/lib"
"github.com/mgenware/cf-saturn/v2/manager"
"github.com/mgenware/go-packagex/iox"
)
var (
ErrPathNotFound = errors.New("The path you requested does not exist")
)
type Builder struct {
Ro... |
package format4
type Handler interface {
Handle(Message) error
}
|
// +build integration
package sshserver
import (
"net/url"
"github.com/rwool/ex/log"
"github.com/gliderlabs/ssh"
)
// OpenSSHDocker wraps the Info method for getting information about a generic SSH
// server.
type SSHServer interface {
Host() string
Port() uint16
Info() *ServerInfo
}
// ServerType is a type... |
package socket
import (
"KServer/library/kiface/isocket"
"fmt"
)
type Handle struct {
Id uint32
//Msg map[uint32]func(response ziface.IResponse)
Handle map[uint32]isocket.IHandle //存放每个Id 所对应的处理方法的map属性
//Response ziface.IResponse
}
func NewIAgreement(id uint32, handle isocket.IHandle) *Handle {
a := &Ha... |
package router
import (
"GP/constant"
"GP/utils"
"fmt"
"github.com/dgrijalva/jwt-go"
"net/http"
)
func TokenCheck(next http.HandlerFunc) http.HandlerFunc {
return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
fb := utils.NewFeedBack(w)
/*body, err := ioutil.ReadAll(r.Body)
if err != nil ... |
package handlers
import (
"context"
"fmt"
)
func HandlerFunc(ctx context.Context, input string) (string, error) {
return fmt.Sprintf("Path %s!", input), nil
}
|
package lru
import "container/list"
type Cache struct {
maxBytes int64 //允许使用最大内存
nBytes int64 //当前内存
linkedList *list.List //使用Go自带的双向链表
cache map[string]*list.Element //hash表连接每一个list元素
OnDelete func(key string, value Value) //被移除时的回调函数... |
package main
import (
"fmt"
)
func main1() {
var m map[string]int
m = make(map[string]int)
m["route"] = 3
m["abc"] = 5
m["birdy"] = -1
m["eagle"] = -2
fmt.Println(m)
i:=m["birdy111"]
fmt.Println(i)
fmt.Println("map length", len(m))
delete(m, "abc")
fmt.Println(m)
}
func main() {
typ... |
/*
* @lc app=leetcode.cn id=78 lang=golang
*
* [78] 子集
*/
package main
import "fmt"
// @lc code=start
func backtracking1(nums []int, start int, c []int, res *[][]int) {
*res = append(*res, append([]int{}, c...))
for i := start; i < len(nums); i++ {
c = append(c, nums[i])
backtracking1(nums, i+1, c, res)
c... |
package main
import "fmt"
//import "time"
//import "sync"
//var wg = sync.WaitGroup{}
func main() {
ch := make(chan string)
ch1 := make(chan string)
//wg.Add(2)
go sender(ch)
go reciever(ch, ch1)
// wg.Wait()
fmt.Println(<-ch1)
}
func reciever(ch <- chan string, ch1 chan <- string ) {
p := <-ch
c... |
package db
import (
"bytes"
//"fmt"
"strings"
)
//获取【存储过程】的名称、所属库名、所需参数等信息
func GetParamData() (Table, error) {
var buf bytes.Buffer
buf.WriteString("SELECT T.SPECIFIC_SCHEMA,T.SPECIFIC_NAME,MAX(PARAMETERS)PARAMETERS FROM (")
buf.WriteString("SELECT t1.SPECIFIC_SCHEMA,t1.SPECIFIC_NAME,GROUP_CO... |
package main
import (
"testing"
"net/http/httptest"
"net/http"
)
func Test_sendPayload(t *testing.T) {
ts := httptest.NewServer(http.HandlerFunc(IdHandler))
defer ts.Close()
}
|
package node
import (
"fmt"
"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/common/hexutil"
"github.com/hyperorchidlab/go-miner-pool/account"
"github.com/hyperorchidlab/go-miner-pool/network"
)
type SetupData struct {
IV network.Salt
MainAddr common.Address
SubAddr account.ID
... |
package stack_test
import (
"fmt"
"testing"
"github.com/ardanlabs/gotraining/topics/go/algorithms/data/stack"
)
const succeed = "\u2713"
const failed = "\u2717"
// TestPush validates the Push functionality.
func TestPush(t *testing.T) {
t.Log("Given the need to test Push functionality.")
{
const items = 5
... |
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT license.
package engine
import (
"fmt"
"github.com/Azure/aks-engine/pkg/api"
"github.com/Azure/azure-sdk-for-go/services/network/mgmt/2018-08-01/network"
"github.com/Azure/go-autorest/autorest/to"
)
// CreateMasterVMNetworkIn... |
package Ball
import (
"fmt"
"github.com/veandco/go-sdl2/img"
"github.com/veandco/go-sdl2/sdl"
)
type Ball struct {
texture *sdl.Texture
position position
move move
width int32
height int32
}
type position struct {
x int32
y int32
}
type move struct {
x int32
y int32
}
func defaultValues() (po... |
package main
import (
"fmt"
"github.com/Sunandan-Sarkar/GoLang-Exercise/ExampleTests/01/acdc"
)
func main(){
fmt.Println(acdc.Sum(2,3,4,5))
fmt.Println(acdc.Sum(2,3,4,5,6,7,8,9))
}
|
package alongside
import (
"testing"
"github.com/stretchr/testify/assert"
)
type TestAnnotatable map[string]string
func (a TestAnnotatable) GetAnnotations() map[string]string {
return a
}
func (a *TestAnnotatable) SetAnnotations(v map[string]string) {
*a = v
}
func TestAnnotatorFromObject(t *testing.T) {
for... |
package sort
import (
"github.com/sko00o/leetcode-adventure/queue-stack/stack"
)
/*
Notes:
选定枢轴,将数组分成大于枢轴和小于枢轴的两个区间,递归完成排序。
优化:
1. 小规模时用直接插入排序
2. 对于大量重复值的优化:三向切分,维护小于/等于/大于枢轴的三个区间。见 quickSort1 。
3. 栈空间优化:递归优化,先排序较小区间。见 quickSort2 。
非递归版本:使用辅助栈。见 quickSort3 。
*/
func quickSort(nums []int) {
if len(nums) == 0 {
re... |
package indexer
const (
StringType = "string"
TextType = "text"
IntegerType = "integer"
FloatType = "float"
BooleanType = "boolean"
DateType = "date"
ObjectType = "object"
)
type Field struct {
Name string `json:"name"`
Type string `json:"type"`
Signed bool ... |
package main
import "fmt"
func main() {
// 変数nに数値100を格納
var n int
n = 100
// 変数nを出力
fmt.Println(n) // 100が出力される
// &を先につけることで変数があるメモリのアドレスを指定する
fmt.Println(&n) // メモリのアドレスが表示される
// 変数pに*でintのポインタ型にして、&nを格納する
var p *int
p = &n
// メモリのアドレスが表示される
fmt.Println(p)
// *pにすることで中身を参照する
fmt.Println(*p) // 10... |
// Integration test of psqldef command.
//
// Test requirement:
// - go command
// - `psql -Upostgres` must succeed
package main
import (
"log"
"os"
"os/exec"
"regexp"
"strings"
"testing"
)
const (
applyPrefix = "-- Apply --\n"
nothingModified = "-- Nothing is modified --\n"
)
func TestPsqldefCreateT... |
package model
import (
"log"
"time"
)
type Order struct {
ID uint `gorm:"primary_key"`
ProductId uint `gorm:"column:product_id"`
ProductName string `gorm:"column:product_name"` // 商品名字
RedId string `gorm:"column:redid"` // 用户唯一标识
StuNum string `gorm:"column:stunum"`
Status ... |
package secrets
import (
"encoding/json"
"strings"
)
const (
// SecretsGetSecrets is a string representation of the current endpoint for getting secrets
SecretsGetSecrets = "v1/metadata/getSecrets"
)
// Secret is a struct containing matching data for a secret found in text
type Secret struct {
// Rule - the def... |
package database
import (
"errors"
"fmt"
)
type BookLoanRequest struct {
Id int `xorm:"id pk autoincr" json:"id"`
UserId int `xorm:"user_id" json:"user_id"`
BookId int `xorm:"book_id" json:"book_id"`
Status string `xorm:"status" json:"status"`
}
func (BookLoanRequest) T... |
// SPDX-FileCopyrightText: (c) 2018 Daniel Czerwonk
//
// SPDX-License-Identifier: MIT
package config
import (
"bytes"
"os"
"testing"
"github.com/stretchr/testify/assert"
)
func TestLoad(t *testing.T) {
tests := []struct {
name string
configFile string
expected *Config
wantsFail bool
}{
{
... |
package query
import (
"bytes"
"fmt"
"io/ioutil"
"net/http"
"strings"
"time"
"github.com/gin-gonic/gin"
)
/**
* @desc 查询参数并绑定到结构体
* @author Ipencil
* @create 2019/3/16
*/
type Person struct {
Name string `xml:"name" form:"name"`
Address string `xml:"address" form:"address"`
Birthday time.Tim... |
package main
import (
"fmt"
"github.com/ys-zhao/jsonlib"
)
var xmlStr = `
<?xml version="1.0" encoding="UTF-8"?>
<breakfast_menu>
<food>
<name>Belgian Waffles</name>
<price>$5.95</price>
<description>Two of our famous Belgian Waffles with plenty of real maple syrup</description>
<calories>650</ca... |
/*
This file supports the DVID REST API, breaking down URLs into
commands and massaging attached data into appropriate data types.
*/
package server
import (
"fmt"
"net/http"
"path/filepath"
"strings"
"github.com/janelia-flyem/dvid/datastore"
"github.com/janelia-flyem/dvid/dvid"
)
const webClientUnavailable... |
package tpl
import (
"bytes"
"github.com/PuerkitoBio/goquery"
)
func Shim(in bytes.Buffer) (out bytes.Buffer, err error) {
reader := bytes.NewReader(in.Bytes())
doc, err := goquery.NewDocumentFromReader(reader)
if err != nil { return }
shims := doc.Find("[shim]")
shims.Each(func(i int, ele *goquery.Sel... |
package policymaker
import (
"context"
"encoding/json"
"fmt"
"io/ioutil"
"net/url"
"os"
"path/filepath"
"regexp"
"strings"
"github.com/google/go-github/github"
getter "github.com/hashicorp/go-getter"
)
// ProviderParser downloads and parses the source code for a given provider
type ProviderParser struct {... |
package _520_Detect_Capital
func detectCapitalUse(word string) bool {
var (
allCapital = true
allNotCapital = true
onlyFirstCapital = true
)
for idx, b := range word {
if idx == 0 {
if b >= 'a' && b <= 'z' {
onlyFirstCapital = false
allCapital = false
} else {
allNotCapital = fal... |
// Copyright (c) 2016 Readium Foundation
//
// Redistribution and use in source and binary forms, with or without modification,
// are permitted provided that the following conditions are met:
//
// 1. Redistributions of source code must retain the above copyright notice, this
// list of conditions and the following... |
package middleware
import (
"net/http"
)
// NewMethod - adds a middleware to allow only a single HTTP method
// to be used for the endpoint
func NewMethod(method string) func(http.Handler) http.Handler {
return func(next http.Handler) http.Handler {
return http.HandlerFunc(func(rw http.ResponseWriter, r *http.Req... |
package stmanager
import(
"download"
"entity/stentity"
"parser/shseparser"
"time"
//"fmt"
)
type SHSECompanyManager struct {
CompanyManagerBase
}
func (m *SHSECompanyManager) Process() {
companies := m.GetCompanies()
m.InsertDB(companies)
}
func (m *SHSECompanyManager) GetCompanies()... |
package user
import (
"camp/lib"
"camp/week2/api"
"camp/week2/service"
"encoding/json"
"github.com/globalsign/mgo/bson"
"github.com/simplejia/clog/api"
"net/http"
)
type RegisterReq struct {
Nick string `json:"nick"`
Sex byte `json:"sex"`
Email string `json:"email"`
Password string `json:"password"... |
package fakes
import (
"fmt"
bminstall "github.com/cloudfoundry/bosh-micro-cli/install"
bmrel "github.com/cloudfoundry/bosh-micro-cli/release"
bmtestutils "github.com/cloudfoundry/bosh-micro-cli/testutils"
)
type JobInstallInput struct {
Job bmrel.Job
}
type jobInstallOutput struct {
installedJob bminstall.In... |
package client
import (
"encoding/json"
"io/ioutil"
"log"
"net/http"
)
type Api struct {
Uri string
}
type PlayerList []string
type ApiResponse map[string]PlayerList
func Connect(uri string) (*Api) {
log.Printf("Connecting to %v\n", uri)
return &Api{
Uri: uri,
}
... |
//go:build go1.20
package errors
import stderrors "errors"
// TODO(a.garipov): Move to errors.go and add examples once golibs switches to
// Go 1.20.
// WrapperSlice is a copy of the hidden wrapper interface added to the Go standard
// library in Go 1.20. It is added here for tests, linting, etc.
type WrapperSlice... |
package main
import (
"fmt"
"math"
)
func main() {
fmt.Println(math.Floor(2.4))
fmt.Println(math.Ceil(2.7))
fmt.Println(math.Sqrt(4 * 4))
}
|
package main
import (
"github.com/mombe090/utils/mongo_utils"
"go.mongodb.org/mongo-driver/bson"
"testing"
)
// testing
const (
db = "test"
collection = "test-mongo_utils-go-driver"
field = "from testing go test"
fieldUpdate = "from testing go test update"
)
type TestingS struct {
Val string `... |
package main
import (
"fmt"
"nplus/linkedNumber"
)
func main() {
init := linkedNumber.Init(1)
for i := 1; i <= 100; i++ {
init.Multiply(i)
}
fmt.Println(init.String())
fmt.Println("93326215443944152681699238856266700490715968264381621468592963895217599993229915608941463976156518286253697920827223758251185210... |
package main
import (
"io"
"sync"
)
const (
DefaultDownloadPartSize = 1024 * 1024 * 5 // 5mb
DefaultDownloadConcurrency = 5 // spins 5 go-routines
)
// Downloader provides public options to configure.
type Downloader struct {
PartSize int64
Concurrency int
// missing download API
}
type d... |
package crypto
import (
. "github.com/onsi/ginkgo"
. "github.com/onsi/gomega"
"gx/ipfs/QmU44KWVkSHno7sNDTeUcL4FBgxgoidkFuTUyTXWJPXXFJ/quic-go/internal/protocol"
)
var _ = Describe("NullAEAD using AES-GCM", func() {
// values taken from https://github.com/quicwg/base-drafts/wiki/Test-Vector-for-the-Clear-Text-AEAD... |
package main
import "fmt"
func main() {
var a int
fmt.Println("please input for a")
// program will wait for the user to input
fmt.Scan(&a)
fmt.Println("please input for a gain")
fmt.Scanf("%d", &a)
fmt.Println("a = ", a)
}
|
package gosnowth
import (
"bytes"
"context"
"encoding/json"
"fmt"
"io"
"strings"
)
// CAQLQuery values represent CAQL queries and associated parameters.
type CAQLQuery struct {
Explain bool `json:"explain"`
IgnoreDurationLimits bool `json:"ignore_duration_limits,omitempty"`
Debug ... |
package iterator
import (
"github.com/yulyulyharuka/todo2/model"
)
type TodoCollection struct {
Todos map[int32]model.Todo
}
func (o TodoCollection) CreateIterator() Iterator {
return todoIterator{
todos: o.Todos,
}
}
|
// Copyright 2018 Diego Bernardes. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
package mongodb
import (
"fmt"
"time"
"github.com/pkg/errors"
mgo "gopkg.in/mgo.v2"
)
// Client is used to interact with MongoDB.
type Client struct {
... |
package test
import (
"MainApplication/internal/User/UserRepository"
"MainApplication/internal/User/UserUseCase"
mock "MainApplication/test/mock_UserRepository"
"github.com/golang/mock/gomock"
"testing"
)
func TestLogout(t *testing.T) {
ctrl := gomock.NewController(t)
defer ctrl.Finish()
var sid []rune
sid ... |
package strmap
type (
Key interface{}
Value interface{}
)
func empty() map[Key]Value {
return make(map[Key]Value)
}
func cp(dst map[Key]Value, src map[Key]Value) {
for k, v := range src {
dst[k] = v
}
}
func dup(src map[Key]Value) map[Key]Value {
dst := make(map[Key]Value, len(src))
cp(dst, src)
return ... |
// Generated from AdlWo.g4 by ANTLR 4.7.
package adlwo // AdlWo
import "github.com/wxio/goantlr"
// Struct of Handlers
type AdlWoHandlers struct {
EnterEveryRule func(ctx antlr.RuleNode)
ExitEveryRule func(ctx antlr.RuleNode)
Adl func(ctx IAdlContext, this *AdlWoHandlers, args ...interface{}) (res... |
package v1
import "k8s.io/apimachinery/pkg/runtime/schema"
// SchemeGroupVersion is group version used to register these objects.
var SchemeGroupVersion = GroupVersion
// Resource takes an unqualified resource and returns a Group-qualified GroupResource.
func Resource(resource string) schema.GroupResource {
return ... |
package common
import (
"context"
"fmt"
"time"
"go.mongodb.org/mongo-driver/mongo"
"go.mongodb.org/mongo-driver/mongo/options"
)
func Connect() (*mongo.Client, error) {
dbOpts := options.Client().ApplyURI("mongodb://mongo:27017")
fmt.Println("Start connect")
ctx, cancel := context.WithTimeout(context.Backgro... |
package controller
import (
"net/http"
"oauth-server-lite/controller/midd"
"oauth-server-lite/g"
"oauth-server-lite/models/oauth"
"github.com/gin-gonic/gin"
"github.com/jinzhu/copier"
log "github.com/sirupsen/logrus"
)
type OauthClient struct {
ClientID string `json:"client_id"`
ClientSecret string `js... |
package schedule
import (
"time"
"errors"
"github.com/att/deadline/notifier"
"github.com/att/deadline/common"
)
func (e Event) ValidateEvent() error {
if e.Name == "" {
return errors.New("Name cannot be empty.")
} else {
return nil
}
}
func (e *Event) EvaluateTime(h notifier.NotifyHandler) bool {
byTim... |
package btf
import (
"bytes"
"strings"
"testing"
qt "github.com/frankban/quicktest"
)
func TestStringTable(t *testing.T) {
const in = "\x00one\x00two\x00"
const splitIn = "three\x00four\x00"
st, err := readStringTable(strings.NewReader(in), nil)
if err != nil {
t.Fatal(err)
}
var buf bytes.Buffer
if e... |
package src
import (
"fmt"
"os"
)
/*
simple debug wrapper for debugging interfaces
*/
func Log(msg ...interface{}) {
fmt.Println(msg...)
}
/*
if the assertion condition is false, then we have an error
*/
func Assert(assertion bool, msg ...string) {
if !assertion {
fmt.Fprintln(os.Stderr, msg)
os.Exit(2)
}
}... |
package mybinarysearch
import (
"fmt"
"testing"
)
func TestBinarySearch(t *testing.T) {
fmt.Println("======test BinarySearch")
s := []string{"a", "b", "c", "d", "e", "gg"}
exist, index := BinarySearch(s, "d")
if exist {
fmt.Println("exist,index is:", index)
} else {
fmt.Println("not exist")
}
}
func Test... |
package client
import "C"
import (
"log"
"checker_core/model"
"github.com/emersion/go-imap"
)
// DeleteEmail set flag 'deleted' for email in remote box and delete email from application email list
func DeleteEmail(cfg *model.Config, email string, id int) {
if err := SetFlag(cfg, email, id, imap.DeletedFlag); er... |
package bigmux
import (
"io"
"net"
"time"
)
type timeoutable interface {
Timeout() bool
}
func isTimeout(err error) bool {
if timeout, ok := err.(timeoutable); ok {
return timeout.Timeout()
}
return false
}
func copyWithTimeout(src, dst net.Conn, maxWait time.Duration) (int64, error) {
var err error
var... |
package main
import (
"fmt"
"io/ioutil"
"os"
"testing"
"github.com/kubernetes-csi/csi-test/v4/pkg/sanity"
)
func TestSanity(t *testing.T) {
sanityTest = true
endpoint := "unix://" + os.TempDir() + "/onlineconf-csi.sock"
d := newDriver()
d.initControllerServer()
d.initNodeServer("1234567890", os.TempDir()+... |
package editthiscookie
import (
"net/http"
"strings"
"time"
)
type Entry struct {
Domain string `json:"domain"`
ExpirationDate float64
HostOnly bool `json:"hostOnly"`
HttpOnly bool `json:"httpOnly"`
Name string `json:"name"`
Path string `json:"path"`
SameSite ... |
package senders
import (
"context"
"fmt"
"net/http"
"time"
"github.com/Laisky/go-fluentd/libs"
utils "github.com/Laisky/go-utils"
"github.com/Laisky/zap"
"github.com/pkg/errors"
)
type HTTPSenderCfg struct {
Name, Addr string
Tags []st... |
package main
import "fmt"
// NOTE: this is not a real way to do things.
// It's all illustrative.
// fibonacci is a function that returns
// a function that returns an int.
// it uses the function closer as well as the recursive implementation of fibonacci.
func fibonacci() func(i int) int {
return func(i int) i... |
package middle
import (
"testing"
. "github.com/bborbe/assert"
io_mock "github.com/bborbe/io/mock"
"github.com/bborbe/server/renderer"
"github.com/bborbe/server/renderer/content"
"github.com/bborbe/server/renderer/tablecell"
)
func TestImplementsRenderer(t *testing.T) {
r := NewMiddleRenderer()
var i (*rende... |
/*
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 main
import (
"fmt"
repository2 "github.com/alexgtn/esi2021-lab5/pkg/repository"
"github.com/alexgtn/esi2021-lab5/pkg/service"
http2 "github.com/alexgtn/esi2021-lab5/pkg/transport/http"
ws "github.com/alexgtn/esi2021-lab5/pkg/transport/websocket"
"github.com/gorilla/mux"
log "github.com/sirupsen/logrus"... |
package main
import (
"encoding/json"
"fmt"
"github.com/nu7hatch/gouuid"
"github.com/shopspring/decimal"
"time"
)
type Sms struct {
Message string
Sender *Sender
Receiver *Receiver
App *App
Pricing *Pricing
}
type Receiver struct {
PhoneNumber string
}
type Sender struct {
PhoneNumber string
}
... |
package gbinterface
type IMsgHandler interface {
//添加待处理的方法 消息id 和 处理函数
AddRouter(uint32,IRouter)
//消息处理
DoRouter(IRequest)
//启动工作池
StartWorkPool()
//给chan增加request
AddReqToQueue(IRequest)
}
|
package cassandra
import (
"context"
"encoding/json"
"io/ioutil"
"strings"
"time"
"github.com/gocql/gocql"
"github.com/sirupsen/logrus"
"github.com/streadway/amqp"
pkglog "github.com/Juniper/contrail/pkg/log"
"github.com/Juniper/contrail/pkg/services"
)
const (
defaultCassandraVersion = "3.4.4"
default... |
package main
import (
"bufio"
"context"
"flag"
"fmt"
"log"
"net"
"os"
"strings"
"time"
linijka "github.com/kubaraczkowski/linijka/pkg"
)
const version string = "0.2.1"
type param struct {
permanent *bool
font *int
speed *int
pojawienie *bool
gora *bool
dol *bool
flash ... |
package command
import (
"fmt"
"github.com/spf13/cobra"
"go.mercari.io/hcledit"
)
func NewCmdUpdate() *cobra.Command {
return &cobra.Command{
Use: "update <query> <value> <file>",
Short: "Update the given field with a value",
Long: `Runs an address query on a hcl file and update the given field with a ... |
package reader
import (
"strings"
"testing"
)
func TestXmlResult_Unmarshal(t *testing.T) {
testObject := struct {
Hello string `xml:"hello"`
}{}
io := strings.NewReader("<testObject><hello>world</hello></testObject>")
result := &xmlReader{
input: io,
}
err := result.Unmarshal(&testObject)
if err != n... |
package vote
import (
"context"
"fmt"
"go_solidity/solidity"
"math/big"
"time"
"github.com/ethereum/go-ethereum/accounts/abi/bind"
"github.com/ethereum/go-ethereum/common"
)
func NowString() string {
return time.Now().Format("2006-01-02 15:04:05")
}
func Message(session *solidity.ContractSession, contract *... |
package _006_zigzag_conversion
import (
"github.com/stretchr/testify/assert"
"testing"
)
func Test_Convert(t *testing.T) {
s := convert("PAYPALISHIRING", 3)
assert.Equal(t, "PAHNAPLSIIGYIR", s)
}
|
package sese
import (
"encoding/xml"
"github.com/thought-machine/finance-messaging/iso20022"
)
type Document00300101 struct {
XMLName xml.Name `xml:"urn:iso:std:iso:20022:tech:xsd:sese.003.001.01 Document"`
Message *TransferOutConfirmation `xml:"sese.003.001.01"`
}
func (d *Document00300101) Add... |
package actions
import (
"fmt"
"os"
"github.com/gobuffalo/buffalo"
"github.com/gobuffalo/buffalo/render"
forcessl "github.com/gobuffalo/mw-forcessl"
paramlogger "github.com/gobuffalo/mw-paramlogger"
sessions "github.com/gobuffalo/x/sessions"
"github.com/gomods/athens/pkg/config"
"github.com/gomods/athens/pkg... |
package learnstrings
import (
"reflect"
"testing"
"strings"
)
func TestStringBuilderWirte(t*testing.T){
var builderTemp strings.Builder
// res ,err := builderTemp.Write([]byte("hello"))
res ,err := builderTemp.Write([]byte("世界"))
// res ,err := builderTemp.WriteRune('h')
// res, err := builderTemp.WriteByt... |
package main
import (
"encoding/json"
"fmt"
"io/ioutil"
"os"
homedir "github.com/mitchellh/go-homedir"
"github.com/urfave/cli"
)
type contestInfo struct {
Id string `json:"id"`
Title string `json:"title"`
Timestamp string `json:"start_epoch_second"`
Rated string `json:"rate_change"`
}
type ... |
package main
import (
crand "crypto/rand"
"errors"
"flag"
"fmt"
"math/rand"
"os"
"time"
randomfiles "gx/ipfs/QmbyJLe6SdVR5VLjtcoLdKhUuV4RT9a1FxX28zaWnY34d8/go-random-files"
ringreader "gx/ipfs/QmbyJLe6SdVR5VLjtcoLdKhUuV4RT9a1FxX28zaWnY34d8/go-random-files/ringreader"
)
var usage = `usage: %s [options] <path... |
package sudoku
import (
"fmt"
"math/rand"
)
//Different instantiations of this technique represent naked{pair,triple}{row,block,col}
type hiddenSubsetTechnique struct {
*basicSolveTechnique
}
func (self *hiddenSubsetTechnique) humanLikelihood(step *SolveStep) float64 {
return self.difficultyHelper(120.0)
}
func... |
package ua
import (
"fmt"
"reflect"
"h12.io/gombi/parse"
ogdl "github.com/ogdl/flow"
)
var (
term = parse.Term
rule = parse.Rule
or = parse.Or
con = parse.Con
self = parse.Self
)
func op(v interface{}) {
buf, _ := ogdl.MarshalIndent(v, " ", " ")
typ := ""
if v != nil {
typ = reflect.TypeOf(v)... |
package container
import (
"bufio"
"context"
"errors"
"fmt"
"github.com/emicklei/go-restful"
"github.com/gorilla/websocket"
"github.com/weibaohui/mesh/pkg/server"
"golang.org/x/sync/errgroup"
"io"
v1 "k8s.io/api/core/v1"
"k8s.io/client-go/kubernetes/scheme"
"log"
"net/http"
)
var upgrader = websocket.Upg... |
package id
import (
"encoding/hex"
"testing"
)
type vec struct {
WRS string
RS string
S string
}
var (
vector1 = vec{
WRS: "B76BogapG9DGadhsuUd1ikteJKo7iAnMKNjHtAf8KA626SnWuuiVCQaUftG5cGRWUCGFGegTnmRRourTX6WwHor8",
RS: "j4vDxToJfvocsC1BL6pjoYDP8DjugsUWHVyQ6kFHQmh2",
S: "2KqymCfosgEQi3Q6zYLSoqsJSz4m... |
package template
import (
messenger "github.com/hellowearemito/go-messenger-structs"
)
// ButtonType defines the behavior of the button in the ButtonTemplate
type ButtonType string
const (
ButtonTypeWebURL ButtonType = "web_url"
ButtonTypePostback ButtonType = "postback"
ButtonTypePhoneNumber Butto... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.