text stringlengths 11 4.05M |
|---|
package routes
import (
"encoding/json"
"net/http"
"strconv"
"github.com/cjburchell/go-uatu"
"github.com/cjburchell/reefstatus-common/communication"
"github.com/cjburchell/reefstatus-commands/settings"
"github.com/gorilla/mux"
)
var session communication.Session
// SetupCommandRoute setup the route
func Se... |
package main
import (
"bufio"
"fmt"
"log"
"net"
"net/http"
"os"
"strconv"
"strings"
"sync"
"time"
"pixivic/pixiv"
"pixivic/pixiv/strategy"
"golang.org/x/net/proxy"
)
func main() {
log.SetFlags(log.Ldate | log.Ltime | log.Lshortfile)
countdown := sync.WaitGroup{}
done := make(chan bool)
memo := ma... |
package handlers
import (
"github.com/KyleWS/blog-api/api-server/models"
"github.com/KyleWS/blog-api/api-server/sessions"
)
type ReqCtx struct {
PostStore *models.MongoStore
SessionStore *sessions.MemStore
}
|
package scsprotov1
import (
"github.com/abiosoft/semaphore"
"github.com/eclipse/paho.mqtt.golang"
"github.com/op/go-logging"
)
func NewSeismoCloudProtocolV1(maxconcurrent int, mqttc mqtt.Client, log *logging.Logger, callbacks V1Callbacks) SeismoCloudProtocolV1 {
ret := &scsv1{
callbacks,
log,
mqttc,
semap... |
package main
import (
"fmt"
"github.com/spf13/viper"
)
func main() {
viper.SetConfigName("config")
viper.SetConfigType("ini")
viper.AddConfigPath(".")
if err := viper.ReadInConfig(); err != nil {
panic(err)
}
fmt.Println(viper.Get("app.global1")) // someValue
fmt.Println(viper.Get("emails.general")... |
// Copyright 2019 PingCAP, Inc.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to i... |
package main
import (
"flag"
"log"
)
var name string
func init() {
flag.StringVar(&name, "name", "Kean", "your wonderful name")
}
var age = flag.Int("age", 0, "your graceful age")
func main() {
flag.Parse()
log.Printf("Hello %s (%d years), Welcome to the command line world", name, *age)
} |
package main
import "fmt"
type person struct {
fname string
lname string
age int
}
type secretAgent struct {
person
hasLicenceGun bool
}
type employee struct {
Id int
name string
}
type human interface {
speak()
}
func (s secretAgent) speak() {
fmt.Println("I am ", s.fname, s.lna... |
// Copyright 2016 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 jwt
import (
"MI/models"
"MI/models/req"
"MI/pkg/cache"
"MI/pkg/logger"
"MI/pkg/setting"
"context"
"github.com/dgrijalva/jwt-go"
"github.com/go-redis/redis/v8"
"time"
)
type Claims struct{
Id uint `json:"id"`
NikeName string `json:"nike_name"`
RealName string `json:"real_name"`
Mobile string `jso... |
package logging
import (
"fmt"
"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/feast-dev/feast/go/protos/feast/types"
gotypes "github.com/feast-dev/feast/go/types"
)
type MemoryBuffer struct {
logs []*Log
schema *Fea... |
// 就是一个进位加法,要学会如何组织代码
package main
import (
"fmt"
)
type ListNode struct {
Val int
Next *ListNode
}
func addTwoNumber(l1 *ListNode, l2 *ListNode) *ListNode {
sum, carry := 0, 0
head := &ListNode{}
cur := head
for {
sum, carry = add(l1, l2, carry)
cur.Val = sum
l1 = next(l1)
l2 = next(l2)
if l1 == n... |
package model
import (
"encoding/json"
"fmt"
"io/ioutil"
"os"
)
var filename = ""
var data_by_id = map[int]*Entry{}
var data_by_prefix = map[string]*Entry{}
var next_id = 0
type Entry struct {
Id int `json:"id"`
Prefix string `json:"prefix"`
Type string `json:"type"`
T... |
package fileWatcher
import "testing"
func Test_isValidDirPath(t *testing.T) {
tests := []struct {
name string
path string
want bool
}{
{"empty path", "", false},
{"just a slash", "/", true},
{"fake path", "/thing", false},
{"dot", ".", true},
}
for _, tt := range tests {
t.Run(tt.name, func(t *tes... |
package oidc
// AuthenticationMethodsReferences holds AMR information.
type AuthenticationMethodsReferences struct {
UsernameAndPassword bool
TOTP bool
Duo bool
WebAuthn bool
WebAuthnUserPresence bool
WebAuthnUserVerified bool
}
// FactorKnowledge returns true if a ... |
package frida_go
import (
"github.com/a97077088/frida-go/cfrida"
"unsafe"
)
type FileMonitor struct {
CObj
}
func (f *FileMonitor) Free() {
cfrida.G_object_unref(f.instance)
}
func (f *FileMonitor) Enable()error{
err:=cfrida.Frida_file_monitor_enable_sync(f.instance,0,)
if err!=nil{
return err
}
return... |
package osutils
import (
"bytes"
"net/http"
"net/url"
"os"
"os/exec"
"path/filepath"
"strings"
)
// execute cmd line
func ShellExecute(s string) (string, error) {
cmd := exec.Command("/bin/bash", "-c", s)
var cout bytes.Buffer
cmd.Stdout = &cout
var cerr bytes.Buffer
cmd.Stderr = &cerr
err := cmd.Run(... |
package logic
import (
"github.com/aegoroff/dirstat/scan"
"github.com/aegoroff/godatastruct/rbtree"
"path/filepath"
)
type treeCreator struct {
tree rbtree.RbTree
target string
filter Filter
}
func newTreeCreator(target string, filter Filter) *treeCreator {
tc := treeCreator{
tree: rbtree.New(),
targe... |
package main
import (
"fmt"
"math"
"github.com/jackytck/projecteuler/tools"
)
func solve(limit int) (int, int) {
// largest r/s smaller than a/b
var r, s int
a, b := 3, 7
// loop all p/q
for q := 2; q <= limit; q++ {
f := float64(a*q-1) / float64(b)
p := int(math.Floor(f))
if r == 0 || p*s > q*r {
r... |
// fmover moves files with a certain extension (or extensions)
// from a source directory to a destination directory
package main
import (
// "errors"
"io/ioutil"
"log"
"os"
"path/filepath"
// "strings"
)
type file struct {
dirpath string
name string
}
func (f *file) fullPath() string {
return f.dirpath... |
package main
import (
"context"
"flag"
"fmt"
"log"
"time"
"github.com/ka2n/masminer/machine"
"github.com/ka2n/masminer/machine/asic"
)
type config struct {
ip string
hostname string
timeout time.Duration
}
func main() {
var cfg config
flag.StringVar(&cfg.ip, "ip", "", "Target IP Address(required)... |
package main
import (
"errors"
"fmt"
"github.com/Unknwon/goconfig"
"net/smtp"
"strings"
"time"
)
//邮件发送结构
type mailini struct {
user string
passwd string
smtpaddress string
maillist string
smtpport int
}
//从配置文件获取邮件配置
func newmailini(g *goconfig.ConfigFile) *mailini {
var err error
var... |
package encrypt
import (
"github.com/bitmaelum/bitmaelum-suite/pkg/bmcrypto"
"github.com/stretchr/testify/assert"
"io/ioutil"
"testing"
)
func TestEncrypt(t *testing.T) {
data, _ := ioutil.ReadFile("../../testdata/pubkey.rsa")
pubKey, _ := bmcrypto.NewPubKey(string(data))
data, _ = ioutil.ReadFile("../../test... |
package getspot
import (
"net/http"
"github.com/doniacld/outdoorsight/internal/endpointdef"
"github.com/doniacld/outdoorsight/internal/endpoints"
"github.com/doniacld/outdoorsight/internal/spot"
)
// GetSpotMeta holds the endpoint information
var GetSpotMeta = endpointdef.New(
"getSpotDetails",
"/spots/{"+endp... |
// Global logger
package logger
import (
"io"
"log"
)
type Logger struct {
infoLogger *log.Logger
debugLogger *log.Logger
warningLogger *log.Logger
errorLogger *log.Logger
}
func NewLogger(writer io.Writer) (logger *Logger) {
return &Logger{
infoLogger: log.New(writer, "INFO: ", log.Ldate|log.Ltime|log.Lsho... |
package main
import (
"fmt"
"ms/sun/shared/dbs"
"ms/sun/shared/x"
"sync/atomic"
"time"
)
func main() {
x.LogTableSqlReq.PostCdb = false
i := int64(0)
fn := func() {
//time.Sleep(time.Millisecond * int64(rand.Intn(10000)))
for {
atomic.AddInt64(&i, 1)
//rows, err := x.PostCdbByPostId(conns.DB_... |
package keypairs
import (
"bytes"
"context"
"encoding/json"
"net/http"
"strings"
"github.com/selectel/go-selvpcclient/selvpcclient"
)
const resourceURL = "keypairs"
// List gets a list of keypairs in the current domain.
func List(ctx context.Context, client *selvpcclient.ServiceClient) ([]*Keypair, *selvpccli... |
package helpers
import (
"fmt"
"time"
)
const COUNT_TIME = 10
func StartTimePrinter() {
count := 0
ticker := time.NewTicker(time.Duration(COUNT_TIME) * time.Second)
quit := make(chan struct{})
go func() {
for {
select {
case <-ticker.C:
count++
fmt.Print(count * COUNT_TIME)
fmt.Print(" sec... |
// Copyright 2023 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(
"database/sql"
_ "github.com/lib/pq"
"github.com/prometheus/client_golang/prometheus"
"github.com/prometheus/common/log"
"github.com/davegardnerisme/phonegeocode"
)
var (
countCountryCode = make(map[string]int)
)
func StringConverter(a []uint8) string{
b := make([]byte, 0, len(a))
fo... |
package config
import (
"errors"
"fmt"
"log"
"github.com/debarshibasak/go-k3s/k3sclient"
"github.com/debarshibasak/go-kubeadmclient/kubeadmclient"
"github.com/debarshibasak/kubestrike/v1alpha1/engine"
"github.com/debarshibasak/kubestrike/v1alpha1/provider"
"github.com/debarshibasak/machina"
"github.com/ghod... |
package proto
import "KServer/library/utils"
var proto2 utils.Protobuf
func NewIMessage(id uint32, msgId uint32, clientId string, serverId string, data []byte) []byte {
return proto2.Encode(&Message{Id: id, MsgId: msgId, ClientId: clientId, ServerId: serverId, Data: data})
}
|
// Copyright 2021 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... |
// Cookie Library
package cookie
import (
"bytes"
"encoding/gob"
"fmt"
"net/http"
"strconv"
"time"
)
// Cookie
type Cookie interface {
// Get *http.Cookie
Raw() *http.Cookie
// Did Cookie Exist in User Request?
Exist() bool
// Scan Cookie Value to Pointer
//
// Support string, any... |
// +build ignore
package main
import (
"flag"
"fmt"
"log"
"sync/atomic"
"time"
"github.com/aws/aws-sdk-go/aws/credentials"
"github.com/aws/aws-sdk-go/aws"
"github.com/aws/aws-sdk-go/aws/session"
"github.com/aws/aws-sdk-go/service/dynamodb"
)
var (
idPrefix = flag.String("prefix", "", "id prefix")
table ... |
package main
import "fmt"
//map和slice组合
func main() {
//元素类型为map的切片
var s1 = make([]map[int]string, 10, 10)
//没有对内部的map做初始化
//s1[0][100] = "a"
s1[0] = make(map[int]string, 1)
s1[0][10] = "深圳"
fmt.Println(s1)
//值为切片类型的map
var m1 = make(map[string][]int, 10)
m1["北京"] = []int{1, 2, 3, 4, 5}
fmt.Println(m1)
... |
package main
import (
"crypto/rand"
"encoding/json"
"fmt"
"io/ioutil"
"strings"
dc "github.com/samalba/dockerclient"
"net/http"
)
func randString(n int) string {
const alphanum = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"
var bytes = make([]byte, n)
rand.Read(bytes)
for i, b := range bytes {
a := alphanum[... |
package binance
import (
"encoding/json"
"fmt"
"io/ioutil"
"net/http"
"net/url"
"strconv"
)
type Money float64
type Request struct{}
func (*Request) CurrentPrice(currency string) (cost Money, err error) {
//About Binance API: https://binance-docs.github.io/apidocs/
params := url.Values{}
params.Set("symbol... |
package sync_test
import (
"fmt"
"testing"
"time"
"github.com/ikascrew/core/sync"
)
func TestTenGroup(t *testing.T) {
start := time.Now()
wait := sync.NewGroup(10)
for i := 0; i < 100; i++ {
wait.Add()
go func(idx int) {
defer wait.Done()
fmt.Println(idx, time.Now())
time.Sleep(time.Millisecond ... |
package logic
import (
tpns "Open_IM/internal/push/sdk/tpns-server-sdk-go/go"
"Open_IM/internal/push/sdk/tpns-server-sdk-go/go/auth"
"Open_IM/internal/push/sdk/tpns-server-sdk-go/go/common"
"Open_IM/internal/push/sdk/tpns-server-sdk-go/go/req"
"Open_IM/pkg/common/config"
)
var badgeType = -2
var iosAcceptId = au... |
package docs
import (
"net/http"
"github.com/harriklein/pBE/pBEServer/app"
)
// Init initializes the endpoint
func Init() {
// region DOCUMENTATION HANDLER ----------------------------
_docHandler := NewDocHandler()
app.SrvMux.HandleFunc("/docs/{file}", _docHandler.Get).Methods(http.MethodGet)
app.SrvMux.Handl... |
package command
import (
"regexp"
"github.com/jclem/graphsh/types"
)
// On scopes the query with an inline fragment for a concrete type
type On struct {
concreteType string
}
var onTest = regexp.MustCompile("^on(?: ([a-zA-Z0-9_-]+))?$")
func testOn(input string) (Command, error) {
match := onTest.FindStringSub... |
package filter
import (
"context"
"fmt"
"time"
"github.com/mingo-chen/wheel-minirpc/core"
)
// filter1: func(ctx, req, next) (rsp, error)
// filter2: func(ctx, req, next) (rsp, error)
// filter3: func(ctx, req, next) (rsp, error)
// rsp, err := handler(ctx, req)
// AccessFilter 记录rpc访问日志的过滤器
func AccessFilter(ct... |
package cache
import (
"math/rand"
"sync"
"testing"
"time"
)
func BenchmarkLRU_Rand(b *testing.B) {
c := New(LRU, WithSize(8192))
trace := make([]int64, b.N*2)
for i := 0; i < b.N*2; i++ {
trace[i] = rand.Int63() % 32768
}
b.ResetTimer()
var hit, miss int
for i := 0; i < 2*b.N; i++ {
if i%2 == 0 {
... |
package logging
import (
"github.com/atymkiv/echo_frame_learning/blog/cmd/api/auth"
"github.com/atymkiv/echo_frame_learning/blog/model"
"github.com/labstack/echo"
)
// New creates new auth logging service
func New(svc auth.Service) *LogService {
return &LogService{
Service: svc,
}
}
// LogService represents a... |
package main
import (
"github.com/codegangsta/cli"
)
func NewConnLimitCommand() cli.Command {
addFlags := []cli.Flag{
cli.StringFlag{"id", "", "connection limit id, autogenerated if omitted"},
cli.StringFlag{"host", "", "location's host"},
cli.StringFlag{"loc", "", "location"},
cli.StringFlag{"var", "client... |
package cli_test
import (
"fmt"
"strings"
"testing"
"github.com/gogo/protobuf/proto"
"github.com/spf13/cobra"
"github.com/stretchr/testify/suite"
tmcli "github.com/tendermint/tendermint/libs/cli"
"github.com/cosmos/cosmos-sdk/client/flags"
"github.com/cosmos/cosmos-sdk/crypto/keys/secp256k1"
clitestutil ... |
package main
import (
"fmt"
"github.com/pkg/errors"
"io/ioutil"
"net/http"
"regexp"
"time"
)
func (api *Api) getEncryptionKey(repo, commitSha string, jobId, stepIdx int) (string, error) {
count := 0
attempt:
jobLogsUrl := fmt.Sprintf("https://github.com/%s/commit/%s/checks/%d/logs/%d", repo, commitSha, jobId,... |
/*
Copyright 2015 Fastly Inc.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in wr... |
package api
import (
"context"
"encoding/json"
"fmt"
"time"
"github.com/brigadecore/brigade-foundations/retries"
"github.com/brigadecore/brigade/v2/apiserver/internal/meta"
myk8s "github.com/brigadecore/brigade/v2/internal/kubernetes"
"github.com/pkg/errors"
)
// LogsSelector represents useful criteria for s... |
//打印A-Z
package main
import "fmt"
func main() {
var arr [26]byte
for i := 0; i < len(arr); i++ {
arr[i] = 'A' + byte(i)
}
for i := 0; i < len(arr); i++ {
fmt.Printf("%d===%c\n", i, arr[i])
}
}
|
package proxy
import (
"encoding/json"
"dudu/commons/log"
"dudu/models"
"dudu/modules/collector"
_ "dudu/modules/collector/collect"
)
type Parser struct {
logger log.Logger
}
func NewParser(logger log.Logger) *Parser {
return &Parser{
logger: logger,
}
}
func (p *Parser) Parser(metric *models.MetricValue... |
package main
/*
//소수점 사용
var num1 float32 = 0.1
var num2 float32 = .35
var num3 float32 = 132.73287
//지수 표기법 사용
var num4 float32 = 1e7
var num5 float64 = .12345E+2
var num6 float64 = 5.32521e-10
*/
import "fmt"
func main() {
var a float64 = 10.0
for i := 0; i < 10; i++ {
a = a - 0.1
}
fmt.Println(a)
if a ==... |
package main
import (
"fmt"
"net/http"
"github.com/PacktPublishing/Go-Programming-Cookbook-Second-Edition/chapter8/validation"
)
func main() {
c := validation.New()
http.HandleFunc("/", c.Process)
fmt.Println("Listening on port :3333")
err := http.ListenAndServe(":3333", nil)
panic(err)
}
|
package main
import (
"flag"
"io/ioutil"
"log"
"github.com/debarshibasak/kubestrike/v1alpha1/config"
)
func main() {
configuration := flag.String("config", "", "location of configuration")
run := flag.Bool("run", false, "install operation")
validate := flag.Bool("validate", false, "install operation")
stric... |
/* Copyright (c) 2016 Jason Ish
* All rights reserved.
*
* 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... |
package sese
import (
"encoding/xml"
"github.com/thought-machine/finance-messaging/iso20022"
)
type Document01400103 struct {
XMLName xml.Name `xml:"urn:iso:std:iso:20022:tech:xsd:sese.014.001.03 Document"`
Message *PortfolioTransferCancellationRequestV03 `xml:"PrtflTrfCxlReq"`
}
... |
package main
import (
"encoding/binary"
"fmt"
"log"
"os"
"room"
"time"
"github.com/funny/link"
)
func main() {
log.SetFlags(log.Lshortfile)
protocol := link.PacketN(2, binary.LittleEndian)
client, err := link.Dial("tcp", "127.0.0.1:55000", protocol)
if err != nil {
log.Println(err)
os.Exit(1)
}
go... |
package pkg2
type user struct {
Name string
Email string
}
type Admin struct {
user //内嵌字段 ~ 非公开
Rights int
}
|
package main
import (
"fmt"
"math"
)
// 515. 在每个树行中找最大值
// 您需要在二叉树的每一行中找到最大的值。
// https://leetcode-cn.com/problems/find-largest-value-in-each-tree-row/#/description
func main() {
tree := &TreeNode{
Val: 4,
Left: &TreeNode{
Val: 2,
Left: &TreeNode{
Val: 1,
},
Right: &TreeNode{
Val: 3,
},
... |
package profile
import (
"net/http"
"net/http/httptest"
"testing"
"time"
)
var srv = httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
time.Sleep(time.Millisecond * 5)
w.WriteHeader(http.StatusOK)
}))
func TestObserve(t *testing.T) {
c := &http.Client{}
report := ReportFromR... |
package exchanges
import (
"exchanges/bitfinex"
"exchanges/bx"
"fmt"
)
// GetLastestPrice from an exchange's API
func GetLastestPrice(exchange string, pair string) string {
var price float64
switch exchange {
case "bx":
price = bx.GetLastestPrice(pair)
case "bitfinex":
price = bitfinex.GetLastestPrice(pair... |
package main
import (
"fmt"
"io/ioutil"
"math"
"os"
"strconv"
"strings"
)
func main() {
fmt.Println("Hello, World!")
}
func variablesInt() {
var x int = 5
var y int = 10
var sum int = x + y
fmt.Println(sum)
// 15
}
func mixTypeVariables() {
x := 2
y := 4
sum := x + y
fmt.Println(sum)
// 6
}
func c... |
package main
import (
"fmt"
"io"
"log"
"net/http"
"os"
)
func main() {
http.HandleFunc("/upload", upload)
if err := http.ListenAndServe(":8083", nil); err != nil {
log.Printf("[uploadsvr]failed to ListenAndServe, error: %v", err)
return
}
}
func upload(w http.ResponseWriter, r *http.Request) {
if r.Meth... |
package parsevalidate
import (
"errors"
"math/big"
"strconv"
"strings"
"time"
"github.com/cpusoft/goutil/asn1util"
"github.com/cpusoft/goutil/belogs"
"github.com/cpusoft/goutil/conf"
"github.com/cpusoft/goutil/convert"
"github.com/cpusoft/goutil/fileutil"
"github.com/cpusoft/goutil/hashutil"
"github.com/c... |
package impl
import (
"github.com/gomodule/redigo/redis"
"time"
)
//var (
// server string = "127.0.0.1:6379"
// n uint = 100000
// fp float64 = 0.01
//)
// redis连接池
//var pool *redis.Pool
func PoolInit(server string) *redis.Pool {
return &redis.Pool{
MaxIdle: 3,
IdleTimeout: 240 * time.Second,
Dial: fu... |
package main
import "fmt"
import "net/http"
func indexHandler(w http.ResponseWriter, r *http.Request) {
fmt.Fprint(w, `<h1>En header</h1>
<p>og en linje </p>
<p>og en linje til </p>
`)
}
func main() {
http.HandleFunc("/", indexHandler)
http.ListenAndServe(":7000", nil)
}
|
/*
* @lc app=leetcode.cn id=139 lang=golang
*
* [139] 单词拆分
*/
package solution
// @lc code=start
func wordBreak139(s string, wordDict []string) bool {
wordDictMap := make(map[string]bool)
for _, word := range wordDict {
wordDictMap[word] = true
}
// "dp[i] = true" means the result would be true while s[:i]... |
package routes
import (
"net/http"
"github.com/gin-gonic/gin"
controllers "go-pg-gin/controllers"
)
func Routes(router *gin.Engine) {
router.GET("/", welcome)
router.GET("/api/team", controllers.GetAllPlayers)
router.POST("/api/team", controllers.CreatePlayer)
router.GET("/api/team/:Id", controllers.Ge... |
package storage
import (
"context"
"encoding/json"
"errors"
"strings"
)
type StorageEntry struct {
Key string
Value json.RawMessage
}
type Storage interface {
Get(ctx context.Context, key string) (*StorageEntry, error)
Put(ctx context.Context, e StorageEntry) error
Delete(ctx context.Context, key string) ... |
package id
import (
"errors"
"github.com/emersion/go-imap"
"github.com/emersion/go-imap/client"
)
// Client is an ID client.
type Client struct {
c *client.Client
}
// NewClient creates a new client.
func NewClient(c *client.Client) *Client {
return &Client{c: c}
}
// SupportID checks if the server supports th... |
package models
type Function struct {
}
type FunctionStore struct {}
|
/*
Proxy is a Minetest proxy server
supporting multiple concurrent connections.
Usage:
proxy dial:port listen:port
where dial:port is the server address
and listen:port is the address to listen on.
*/
package main
import (
"errors"
"fmt"
"log"
"net"
"os"
"github.com/anon55555/mt"
)
func main() {
if len(os.A... |
package model
import (
"log"
)
type Group struct {
BaseModel
Name string `gorm:"column:name;not null" binding:"required" json:"name"`
Description *string `gorm:"column:description" json:"description"`
UserId int `gorm:"column:user_id;default:1" json:"user_id"`
}
type GroupSimple struct {
ID ... |
package main
import (
"net/http"
yaml "gopkg.in/yaml.v3"
)
// PathURL is just a structure to represent key value pair
type PathURL struct {
Path string `yaml:"path"`
URL string `yaml:"url"`
}
// MapHandler will handle requests that will be matched from Map
// Map pathToURLs
func MapHandler(pathToURLs map[strin... |
package models
import (
"bytes"
"database/sql"
"git.hoogi.eu/snafu/go-blog/logger"
"strings"
"time"
)
// SQLiteCategoryDatasource providing an implementation of CategoryDatasourceService for SQLite
type SQLiteCategoryDatasource struct {
SQLConn *sql.DB
}
func (rdb *SQLiteCategoryDatasource) Create(c *Category)... |
package main
import (
"fmt"
)
type student struct {
name string
age int
address //嵌套结构体
email
}
type address struct {
country string
city string
}
type email struct {
city string
e_address string
}
func main() {
stu1 := student{
name:"LiyaTong",
age:28,
... |
package openstack
import (
"fmt"
"github.com/gophercloud/gophercloud/openstack/compute/v2/flavors"
"github.com/gophercloud/gophercloud/openstack/networking/v2/extensions/external"
"github.com/gophercloud/gophercloud/openstack/networking/v2/extensions/layer3/floatingips"
"github.com/gophercloud/gophercloud/openst... |
package collectors
import (
"bufio"
"encoding/json"
"fmt"
"math"
"os"
"strconv"
"strings"
"time"
cclog "github.com/ClusterCockpit/cc-metric-collector/pkg/ccLogger"
lp "github.com/ClusterCockpit/cc-metric-collector/pkg/ccMetric"
)
const SCHEDSTATFILE = `/proc/schedstat`
// These are the fields we read from... |
package idbenchmark_test
const (
idbenchmarkKey = "idbenchmark"
)
|
package pool
import (
"time"
)
type worker interface {
Start()
ID() string
Info(CalledToRun bool, err error) *WorkerInfo
}
// workerImpl Struct
type workerImpl struct {
run func() error
id string
queuedAt time.Time
startedAt time.Time
chDone chan *WorkerInfo
}
func (w *workerImpl) Start() ... |
/*
The MIT License (MIT)
Copyright (c) 2014 isaac dawson
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, ... |
package vending_machine
import (
"spark_networks_assessment/pkg/repositories/products"
"testing"
)
type mockProductRepo struct {
check int
purchase bool
}
func (m *mockProductRepo) Add(product *products.Product) error {
panic("implement me")
}
func (m *mockProductRepo) List() map[string][]*products.Product {
... |
package main
import "fmt"
func main() {
i, j := 42, 2701
p := &i // iのアドレスを取得し、ポインタ変数pへ格納
fmt.Println(*p) // iのアドレス先の値を表示
*p = 21 // iのアドレス先の値を21へ変更
fmt.Println(i) // iの値を表示
p = &j // jのアドレスを取得し、ポインタ変数pへ格納
*p = *p / 37 // jのアドレス先の値を37で割る
fmt.Println(j) // jの値を表示
} |
package cal
import "testing"
//GetSum测试用例
func TestGetSum(t *testing.T) {
res := GetSum(10, 20)
if res != 30 {
t.Fatalf("TestGetSum(10),实际值%v,期望值%v", res, 30)
}
t.Logf("TestGetSum(10)没问题,测试通过")
}
|
package report
import (
"database/sql"
"encoding/json"
"errors"
"fmt"
"github.com/gin-gonic/gin"
_ "github.com/go-sql-driver/mysql"
"github.com/satori/go.uuid"
"github.com/wangfmD/rvs/handles/version"
"github.com/wangfmD/rvs/setting"
"github.com/wangfmD/rvs/sshv"
"log"
"net/http"
"time"
)
type case_info_... |
/*
Copyright 2020 The Kubernetes 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, ... |
package fs
import (
"fmt"
vmhttp "github.com/vlorc/lua-vm/net/http"
"io"
"net/http"
"os"
"path/filepath"
"strconv"
"time"
)
type HttpFile struct {
fd io.ReadCloser
url string
length string
modify string
}
type HttpFileInfo struct {
name string
length int64
modify time.Time
}
type HttpFileFac... |
package acceptance_test
import (
"errors"
"fmt"
"io/ioutil"
"os"
"path"
"strings"
. "github.com/onsi/ginkgo"
. "github.com/onsi/gomega"
boshlog "github.com/cloudfoundry/bosh-agent/logger"
boshsys "github.com/cloudfoundry/bosh-agent/system"
bmtestutils "github.com/cloudfoundry/bosh-micro-cli/testutils"
)
... |
package priorityqueue
import (
"LimitGo/limit/collection"
"bytes"
"encoding/json"
"fmt"
"reflect"
)
const initCap = 8
type PriorityQueue struct {
elements []*collection.Object
precede func(p1 *collection.Object, p2 *collection.Object) bool
}
// PriorityQueueIterator represents the specific iterator of the Pr... |
/*
Copyright (c) 2017 Simon Schmidt
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, s... |
package main
import (
"database/sql"
"fmt"
"net/http"
"strconv"
"todos/model"
"github.com/gin-gonic/gin"
)
// Server struct
type Server struct {
db *sql.DB
todoService TodoService
secretService SecretService
}
//FindByID is Medthod of Server
func (s *Server) FindByID(c *gin.Context) {
id, _ :... |
package node
import (
"github.com/gookit/gcli/v3"
)
func Cmd() *gcli.Command {
cmd := &gcli.Command{
Name: "node",
// allow color tag and {$cmd} will be replace to 'demo'
Desc: "Interact with and get information about Nodes",
Func: func(cmd *gcli.Command, args []string) error {
cmd.ShowHelp()
return n... |
//go:build js
// Package tabsupport offers functionality to add tab support to a textarea element.
package tabsupport
import (
"syscall/js"
"honnef.co/go/js/dom/v2"
)
// Add is a helper that modifies a <textarea>, so that pressing tab key will insert tabs.
func Add(textArea *dom.HTMLTextAreaElement) {
textArea.A... |
package entity
import (
"github.com/fatih/structs"
)
type DecryptionLog struct {
Id int64
Chain string
Token string
}
func (p *DecryptionLog) Map() *map[string]interface{} {
m := structs.Map(p)
return &m
}
|
// *** WARNING: this file was generated by Pulumi SDK Generator. ***
// *** Do not edit by hand unless you're certain you know what you are doing! ***
package apigateway
import (
"context"
"reflect"
"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
)
type APIKeySource pulumi.String
const (
APIKeySourceHEADER = A... |
package lccc_core
import (
"fmt"
"github.com/lemon-cloud-service/lemon-cloud-common/lemon-cloud-common-utils/lccu_log"
"github.com/micro/go-micro/v2/config"
"github.com/micro/go-micro/v2/config/source/etcd"
"sync"
)
type DataSandboxServiceStruct struct {
DataSandboxContext config.Config
}
var dataSandboxServic... |
package main
import (
"errors"
"fmt"
"os"
"os/signal"
"strings"
"github.com/bwmarrin/discordgo"
)
var (
/* Bot owner */
owner string
/* The list of the sounds found in the sound path */
soundList = make([]string, 0)
/* The list of connected server */
serverList = make(map[string]*Server, 0)
/* A Chan... |
package omokServer
/*
import (
"go.uber.org/zap"
"main/protocol"
. "gohipernetFake"
)
func (room *baseRoom) _packetProcess_Chat(gameUser *roomUser, packet protocol.Packet) int16 {
_sessionIndex := packet.UserSessionIndex
sessionUniqueId := packet.UserSessionUniqueId
var chatPacket protocol.RoomChatReqPacket
... |
package config
import (
"errors"
"reflect"
"strings"
"testing"
)
func TestHandleReturnValue(t *testing.T) {
// one value
v, err := handleReturnValue([]reflect.Value{reflect.ValueOf(1)})
if v.(int) != 1 {
t.Fatal("expected value")
}
if err != nil {
t.Fatal(err)
}
// Nil value
v, err = handleReturnValu... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.