text stringlengths 11 4.05M |
|---|
package LICY_BLC
import "fmt"
func (cli *Licy_CLI) Licy_getBalance(address string) {
blockchain := Licy_GetBlochChainObject()
defer blockchain.Licy_DB.Close()
utxoSet := &Licy_UTXOSet{blockchain}
amount := utxoSet.Licy_GetBalance(address)
fmt.Printf("%s一共有%d个Token\n",address,amount)
} |
package main
import (
"log"
"time"
confluent "github.com/confluentinc/confluent-kafka-go/kafka"
"github.com/etf1/kafka-transformer/pkg/instrument"
"github.com/prometheus/client_golang/prometheus"
)
type promCollector struct {
name ... |
package main
import "fmt"
func main() {
mySlice := []int{42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52}
fmt.Println(mySlice[:5])
fmt.Println(mySlice[5:10])
fmt.Println(mySlice[2:7])
fmt.Println(mySlice[1:6])
}
|
package states
import (
"context"
"errors"
"fmt"
"time"
derrors "github.com/direktiv/direktiv/pkg/flow/errors"
log "github.com/direktiv/direktiv/pkg/flow/internallogger"
"github.com/direktiv/direktiv/pkg/model"
"github.com/senseyeio/duration"
)
func init() {
RegisterState(model.StateTypeDelay, Delay)
}
typ... |
package bsutils
import (
"strconv"
"time"
)
func StringToIntWithDefault(s string, def int) int {
i, err := strconv.Atoi(s)
if err != nil {
return def
}
return i
}
func StringToInt64WithDefault(s string, def int64) int64 {
i, err := strconv.ParseInt(s, 10, 64)
if err != nil {
return def
}
return i
}
fu... |
// Copyright (c) 2020 by meng. All rights reserved.
// Use of this source code is governed by an MIT-style
// license that can be found in the LICENSE file.
/**
* @Author: meng
* @Description:
* @File: behavior_Work
* @Version: 1.0.0
* @Date: 2020/4/15 01:05
*/
package base_behavior
import (
"fmt"
"github... |
package render
import (
"fmt"
"github.com/spf13/cobra"
"github.com/werf/werf/cmd/werf/common"
"github.com/werf/werf/pkg/config"
"github.com/werf/werf/pkg/git_repo"
"github.com/werf/werf/pkg/git_repo/gitdata"
"github.com/werf/werf/pkg/true_git"
"github.com/werf/werf/pkg/werf"
)
var commonCmdData common.CmdDa... |
package gherkin
import (
"testing"
. "github.com/tychofreeman/go-matchers"
"io"
)
type MockScenario struct {
rpt Report
}
func (ms MockScenario) AddStep(s step) {
}
func (ms MockScenario) Last() *step {
return nil
}
func (ms MockScenario) Execute([]stepdef, io.Writer, interface{}) Report {
ret... |
// @SubApi 喵喵喵 [/Cat]
package api
import (
"bytes"
"net/http"
"strconv"
ren "github.com/hmgle/swagger-demo/src/render"
)
// @Title api.Miao
// @Description 喵
// @Resource Cat
// @Accept json
// @Param count query int false "喵几声?"
// @Success 200 {string} string "返回"
// @Router ... |
package main
import (
"bufio"
"bytes"
"fmt"
"math"
"os"
"strconv"
"strings"
)
func main() {
s := bufio.NewScanner(os.Stdin)
buff := new(bytes.Buffer)
max := int(math.Pow(10, 5))
buff.Grow(max)
s.Buffer(buff.Bytes(), max)
s.Scan()
temp := strings.Split(s.Text(), " ")
L, _ := strconv.Atoi(temp[0])
R, _ ... |
package main
import (
"net/http"
"github.com/souhub/wecircles/pkg/route"
)
func main() {
files := http.FileServer(http.Dir("web/"))
http.Handle("/static/", http.StripPrefix("/static/", files))
// CSS読み込み用
http.Handle("/resources/", http.StripPrefix("/resources/", http.FileServer(http.Dir("web/css/"))))
http... |
package main
import (
"bufio"
"errors"
"flag"
"fmt"
"html/template"
"net"
"net/http"
"net/rpc"
"os"
"os/exec"
"runtime/pprof"
"strings"
"sync"
"sync/atomic"
"syscall"
"time"
"github.com/garyburd/redigo/redis"
"github.com/gorilla/websocket"
"github.com/sirupsen/logrus"
)
const (
HEAD_LEN = 64... |
package main
import (
_ "fmt"
"github.com/gin-gonic/gin"
"net/http"
"os/exec"
)
func main() {
// updates everything from github
pullFromGithub := exec.Command("git", "pull")
pullFromGithub.Run()
router := gin.Default()
// serves all the html, css, and javascript files to the browser
router.StaticFile("/",... |
package routers
import (
"github.com/barrydev/api-3h-shop/src/common/response"
"github.com/barrydev/api-3h-shop/src/controllers"
"github.com/gin-gonic/gin"
)
func BindProductItem(router *gin.RouterGroup) {
router.GET("", func(c *gin.Context) {
handle := response.Handle{Context: c}
handle.Try(controllers.Get... |
package main
const (
START = iota
UPDATE
STARTCHECKPOINT
ENDCHECKPOINT
)
// Undolog record format
// {START, tID, 0, 0}
// {UPDATE, tID, userID, cash}
// {STARTCHECKPOINT, 0, 0, 0}
// {ENDCHECKPOINT, 0, 0, 0}
type Record struct {
Op int
TranscationId int
UserId int
Cash int
}
|
package main
import (
"fmt"
"net/http"
)
// Handler function that responds with Hello World
func helloWorld(w http.ResponseWriter, r *http.Request) {
fmt.Fprintf(w, "Hello world")
fmt.Println("See actions in action?")
}
func main() {
// Register handler function on server route
http.HandleFunc("/ap... |
package topic
import (
"testing"
. "github.com/smartystreets/goconvey/convey"
)
func TestValidate(t *testing.T) {
Convey(`Testing the Topic validation`, t, func() {
So(Validate("", true), ShouldEqual, errInvalidLength) // All Topic Names and Topic Filters MUST be at least one character long [MQTT-4.7.3-1]
So... |
package main
import (
"fmt"
"net"
)
func main() {
addr := net.JoinHostPort("0.0.0.0","0")
fmt.Println ("About to listen on ", addr)
ln, err := net.Listen("tcp4", addr)
if err != nil {
fmt.Println("Error, listening: ", err)
return
}
fmt.Println("Listening ", ln.Addr().String())
}
|
package operands
import (
"errors"
"os"
"reflect"
monitoringv1 "github.com/prometheus-operator/prometheus-operator/pkg/apis/monitoring/v1"
corev1 "k8s.io/api/core/v1"
v1 "k8s.io/api/core/v1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/runtime"
"k8s.io/apimachinery/pkg/util/intstr"
... |
package mop
func NewQuotes(market *Market, profile *Profile) *Quotes {
return &Quotes{
market: market,
profile: profile,
errors: ``,
}
}
func (quotes *Quotes) Fetch() (self *Quotes) {
qs, _ := quotes.market.OnDemand.Quote(quotes.profile.Tickers,
[]string{"bid", "fiftyTwoWkHigh", "dividendRateAnnual", "d... |
package builder
import (
"errors"
"fmt"
"sort"
"github.com/prometheus/client_golang/prometheus"
)
// MetricBuilder is the basic metric type that must be used by any potential metric added to
// the system. It allows user to create a prom collector which will be used to push.
type MetricBuilder struct {
// label... |
package main
import (
"fmt"
)
/*
GenDisplaceFn is function generate the
*/
func GenDisplaceFn(a, v0, s0 float64) func(float64) float64 {
return func(t float64) float64 {
return (0.5)*a*t*t + v0*t + s0
}
}
func main() {
var a, v0, s0, t float64
fmt.Println("Enter the initial values...")
fmt.Printf("accelerat... |
package main
import (
ussd "../ussd"
"log"
"net/http"
)
func main() {
// service binding
mux := http.NewServeMux()
ussd.RegisterService(mux)
log.Println("hub is started...")
//http.ListenAndServeTLS(":4002", "cert.pem", "key.pem", mux)
http.ListenAndServe(":8080", mux)
log.Println("hub is stopped.")
}
|
/***
# File Name: ../../adapter/gear/gear.go
# Author: eavesmy
# Email: eavesmy@gmail.com
# Created Time: 2021年06月03日 星期四 19时05分06秒
***/
package gear
import (
"bytes"
"errors"
"net/http"
"net/url"
"regexp"
"strings"
"github.com/GoAdminGroup/go-admin/adapter"
"github.com/GoAdminGroup/go-admin/context"
"githu... |
package filters
import (
"net"
"github.com/jlorgal/odor/odor"
)
// AdBlocking filter.
type AdBlocking struct {
blacklist []*net.IPNet
}
// NewAdBlocking creates a Malware filter
func NewAdBlocking(config *odor.Config) (*AdBlocking, error) {
blacklist, err := odor.GetBlacklist("adBlocking", config)
return &AdBl... |
package command
import (
"context"
"github.com/opsgenie/opsgenie-go-sdk-v2/team"
gcli "github.com/urfave/cli"
"os"
"strconv"
"strings"
)
func NewTeamClient(c *gcli.Context) *team.Client {
teamCli, cliErr := team.NewClient(getConfigurations(c))
if cliErr != nil {
message := "Can not create the team client. ... |
package tool
import (
"crypto/rand"
"crypto/sha256"
"net"
"os"
"time"
)
//FillBytesToFront 把数据截取/填充到指定长度
func FillBytesToFront(data []byte, totalLen int) []byte {
if len(data) < totalLen {
delta := totalLen - len(data)
appendByte := []byte{}
for delta != 0 {
appendByte = append(appendByte, 0)
delta-... |
package main
import (
"crypto/tls"
"crypto/x509"
"encoding/json"
"flag"
"fmt"
"io/ioutil"
"time"
MQTT "github.com/eclipse/paho.mqtt.golang"
)
// Config holds all the AQS IoT properties
type Config struct {
Host string `json:"host"`
Port int `json:"port"`
CaCert string `json:"caCert"`
C... |
package main
import (
"fmt"
"net"
)
const HOST = "localhost"
const PORT = "52535"
func main() {
fmt.Println("Starting Server")
listener, err := net.Listen("tcp", HOST+":"+PORT)
if err != nil {
fmt.Println("Error Listening", err.Error())
panic(err)
}
for {
conn, err := listener.Accept()
if err != nil {... |
package main
import (
"html/template"
)
var tmpl = make(map[string]*template.Template)
func init() {
m := template.Must
p := template.ParseFiles
tmpl["index"] = m(p("templates/index.gohtml", "templates/layout.gohtml"))
tmpl["event-detail"] = m(p("templates/event-detail.gohtml", "templates/layout.gohtml"))
tmpl... |
// Copyright 2018 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 (
"encoding/csv"
"fmt"
"io"
"os"
)
func main() {
// Open unprocessed csv file
infile, err := os.Open("unprocessed_data.csv")
if err != nil {
panic(err)
}
defer infile.Close()
// Create reader for unprocessed csv file
reader := csv.NewReader(infile)
// Create new csv for parsed data... |
package main
import (
"strings"
"fmt"
)
func simplifyPath(path string) string {
str := strings.Split(path, "/")
res := make([]string, 0) // spilt path without /
for _,v := range str {
if v != "" {
res = append(res, v)
}
}
size := len(res)
stack := make([]string,size)
top := 0
for i:=0;i<size;i++{
v... |
// time: O(n), space: O(1)
func myPow(x float64, n int) float64 {
return sol2(x, n)
}
// time: O(log(n)), space: O(1)
func sol2(x float64, n int) float64 {
if n == 0 {
return 1
}
nn := n
if n < 0 {
nn = -n
}
res := p(x, nn)
if n < 0 {
return 1/res
}
retur... |
package controllers
import "github.com/w2hhda/candy/models"
var (
successReturn = &models.Response{0, "success", new(interface{})}
errParams = &models.Response{10001, "输入的参数不正确", new(interface{})}
errDB = &models.Response{10002, "数据库错误", new(interface{})}
errParse = &models.Response{10003, "数据解析失... |
package requests
type KeyStruct struct {
Key string `json:"key"`
}
type GetBookByISBN struct {
Publisher []string `json:"publishers"`
Title string `json:"title"`
NumberOfPages uint `json:"number_of_pages"`
PublishDate string `json:"publish_date"`
AuthorId []KeyStruct `json... |
package todo
import (
"github.com/jinzhu/gorm"
"mingchuan.me/api"
)
// TodoService -
type TodoService struct {
*gorm.DB
Version uint16
}
// Todo - TODO model
type Todo struct {
ID int64 `gorm:"primary_key" json:"id"`
Content string `gorm:"type:text; not null" json:"content"`
}
// NewService -
func NewSe... |
package main
import (
"database/sql"
"fmt"
"github.com/gofrs/uuid"
"golang.org/x/crypto/bcrypt"
)
//Login func retrives user ID from login input credentials
func (d *DBDriver) Login(email string, password string) (string, error) {
var data SignInCreds
err := d.Conn.Get(&data, `SELECT id, password_hash FROM use... |
//go:build linux
// +build linux
package envoy
import (
"context"
"os"
"strconv"
"sync"
"syscall"
"time"
"go.opencensus.io/stats/view"
"github.com/pomerium/pomerium/internal/log"
"github.com/pomerium/pomerium/internal/telemetry/metrics"
)
const baseIDPath = "/tmp/pomerium-envoy-base-id"
var restartEpoch ... |
package main
import (
"fmt"
"strings"
)
func loaddata2(input string, elfpower int) ([]unit, grid, int, int) {
grid := grid{}
units := []unit{}
x := 0
y := 0
maxx := 0
maxy := 0
for _, line := range strings.Split(input, "\n") {
line = strings.TrimSpace(line)
if line == "" {
continue
}
for _, r := r... |
package cmd
import (
"os"
"strings"
"testing"
"github.com/stretchr/testify/assert"
"github.com/instructure-bridge/muss/config"
"github.com/instructure-bridge/muss/testutil"
)
func testRootCmd(args ...string) (int, string, string) {
var stdout, stderr strings.Builder
cfg, _ := config.NewConfigFromMap(nil)
... |
package main
import (
"final-project/config/postgres"
"final-project/http/routes"
todos "final-project/repository/postgres"
"fmt"
"log"
"os"
"os/signal"
"syscall"
"github.com/subosito/gotenv"
)
func init() {
log.SetFlags(log.Lshortfile | log.LstdFlags)
if err := gotenv.Load(); err != nil {
log.Println(... |
package install_test
import (
"errors"
"os"
"path/filepath"
"time"
. "github.com/onsi/ginkgo"
. "github.com/onsi/gomega"
bmeventlog "github.com/cloudfoundry/bosh-micro-cli/eventlogging"
bmrel "github.com/cloudfoundry/bosh-micro-cli/release"
bmtempcomp "github.com/cloudfoundry/bosh-micro-cli/templatescompile... |
package epic
import (
"fmt"
"log"
"github.com/google/go-github/github"
"github.com/karen-irc/popuko/operation"
"github.com/karen-irc/popuko/queue"
"github.com/karen-irc/popuko/setting"
)
func CheckAutoBranch(client *github.Client, autoMergeRepo *queue.AutoMergeQRepo, ev *github.StatusEvent) {
log.Println("inf... |
package semt
import (
"encoding/xml"
"github.com/thought-machine/finance-messaging/iso20022"
)
type Document01600101 struct {
XMLName xml.Name `xml:"urn:iso:std:iso:20022:tech:xsd:semt.016.001.01 Document"`
Message *IntraPositionMovementPostingReportV01 `xml:"IntraPosMvmntPstngRpt"`... |
package main
import (
"encoding/json"
"fmt"
"os"
)
type (
// buoyCondition contains information for an individual station.
buoyCondition struct {
WindSpeed float64 `json:"wind_speed_milehour"`
WindDirection int `json:"wind_direction_degnorth"`
WindGust float64 `json:"gust_wind_speed_milehour"`... |
package controllers
import (
"encoding/json"
"fmt"
"github.com/astaxie/beego"
)
func init() {
}
type baseApiController struct {
beego.Controller
}
func (this *baseApiController) GetCurrentUser(auth string) (auth_str map[string]string, err error) {
return map[string]string{"id": "1"}, nil
}
func (this *baseAp... |
package server
import (
"net/http"
"os"
"time"
log "github.com/sirupsen/logrus"
"github.com/arthur404dev/api/restream"
"github.com/arthur404dev/api/websocket"
"github.com/labstack/echo/v4"
"github.com/labstack/echo/v4/middleware"
)
func Start(port string, hub *websocket.Hub) {
e := echo.New()
e.Use(middle... |
package bmlog_test
import (
"github.com/alfredyang1986/blackmirror/bmlog"
"os"
)
func ExampleStandardLogger() {
os.Setenv("LOGGER_USER", "example")
os.Setenv("LOGGER_DEBUG", "false")
os.Setenv("LOG_PATH", "/home/jeorch/work/test/temp/go.log")
bmlog.StandardLogger().Info("Example Test Info")
}
|
package controller
import (
"github.com/GoAdminGroup/go-admin/context"
"github.com/GoAdminGroup/go-admin/modules/file"
"github.com/GoAdminGroup/go-admin/plugins/admin/modules/constant"
"github.com/GoAdminGroup/go-admin/plugins/admin/modules/guard"
"github.com/GoAdminGroup/go-admin/plugins/admin/modules/response"
... |
package pelichan
import (
"github.com/beeker1121/goque"
"log"
"math/rand"
"net/http"
_ "net/http/pprof"
"os"
"strconv"
"sync"
"testing"
"time"
)
// TODO: DeqErrCB and DecErrCB tests
func init() {
go func() {
log.Println(http.ListenAndServe("localhost:6060", nil))
}()
rand.Seed(time.Now().UnixNano())
}... |
package database
import (
"context"
"io/ioutil"
"os"
kciv1alpha1 "github.com/kloeckner-i/db-operator/pkg/apis/kci/v1alpha1"
"github.com/kloeckner-i/db-operator/pkg/utils/kci"
"github.com/sirupsen/logrus"
k8serrors "k8s.io/apimachinery/pkg/api/errors"
)
func (r *ReconcileDatabase) createInstanceAccessSecret(... |
package main
import "sync"
func main() {
mu := &sync.Mutex{}
mu.Lock()
}
|
/*
* @File: models.token.go
* @Description: Define quais informações de erro serão retornadas aos clientes
* @Author: Carlos Henrique Lemos (chenriquelemos@gmail.com)
*/
package models
type Error struct {
Code int `json:"código" exemplo:"27"`
Message string `json:"mensagem" exemplo:"Mensagem de Er... |
package main
import "fmt"
type intSet struct {
size int
elements map[int]struct{}
}
func NewIntSet() intSet {
return intSet{size: 0, elements: make(map[int]struct{})}
}
func (s *intSet) Add(elem int) {
if _, exists := s.elements[elem]; !exists {
s.elements[elem] = struct{}{}
s.size++
}
return
}
func... |
package parsevalidate
import (
"errors"
"sync"
"time"
"github.com/cpusoft/goutil/belogs"
"github.com/cpusoft/goutil/jsonutil"
"github.com/cpusoft/goutil/xormdb"
model "rpstir2-model"
"xorm.io/xorm"
)
// add
func addRoasDb(syncLogFileModels []SyncLogFileModel) error {
belogs.Info("addRoasDb(): will insert le... |
package attacher
import (
"github.com/Huawei/eSDK_K8S_Plugin/src/utils/log"
)
type MetroAttacher struct {
localAttacher AttacherPlugin
remoteAttacher AttacherPlugin
protocol string
}
func NewMetroAttacher(localAttacher, remoteAttacher AttacherPlugin, protocol string) *MetroAttacher {
return &MetroAttache... |
package ssubnetting
import (
"sort"
"strconv"
"strings"
"os"
)
// Llena de lo que se indique, en el rango que se indique, un arreglo
// de enteros de tamaño 4.
func FillArr(arr *[4]int, v, begin, end int) {
for i := begin; i < end; i++ {
arr[i] = v
}
}
// Ordena en orden ascendente o ascendente las r... |
/*
The MIT License (MIT)
Copyright (c) 2015 tSURooT <tsu.root@gmail.com>
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,... |
package platform
import (
"fmt"
"image"
"log"
"unicode/utf8"
"github.com/jcorbin/anansi"
"github.com/jcorbin/anansi/ansi"
)
// Events holds a queue of input events that were available at the start of the
// current frame's time window.
type Events struct {
Type []EventType
esc []ansi.Escape
arg [][]byt... |
/*
* Copyright 2017 StreamSets 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... |
package greet
import "fmt"
func SayHello() {
fmt.Println("Hello !")
}
func Greet(name string) string {
return fmt.Sprintf("Hello %s", name)
}
|
package quic
import (
"errors"
"github.com/golang/mock/gomock"
. "github.com/onsi/ginkgo"
. "github.com/onsi/gomega"
"gx/ipfs/QmU44KWVkSHno7sNDTeUcL4FBgxgoidkFuTUyTXWJPXXFJ/quic-go/internal/protocol"
"gx/ipfs/QmU44KWVkSHno7sNDTeUcL4FBgxgoidkFuTUyTXWJPXXFJ/quic-go/internal/wire"
"gx/ipfs/QmU44KWVkSHno7sNDTeUcL4... |
package telemetry
import (
"testing"
"github.com/stretchr/testify/assert"
)
func Test_ServiceName(t *testing.T) {
t.Parallel()
tests := []struct {
name string
servicesOpt string
want string
}{
{"all", "all", "pomerium"},
{"proxy", "proxy", "pomerium-proxy"},
{"missing", "", "pomerium"}... |
package master
func InitMaster(filePath string) error {
return nil
}
|
package permission
type MenuRole struct {
Menu string `json:"menu"`
Roles []string `json:"roles"`
}
type UserMenu struct {
ProjectName string `json:"projectName"`
ProjectId string `json:"projectId"`
Menus []string `json:"menus"`
}
var MenuRoles = `
[
{
"menu": "PROJECT",
"roles": ... |
package oauth1
import (
"net/url"
"strconv"
"testing"
)
// Test the ability to parse a URL query string and unmarshal to a RequestToken.
func TestParseRequestTokenStr(t *testing.T) {
oauth_token:="c0cf8793d39d46ab"
oauth_token_secret:="FMMj3w7plPEyhK8ZZ9lBsp"
oauth_callback_confirmed:=true
values := url.Value... |
package array
import (
"fmt"
"testing"
)
func TestRotate(t *testing.T) {
//source := [][]int { { 1,2,3 } , { 4,5,6 } , { 7,8,9 }}
source := [][]int{{5, 1, 9, 11}, {2, 4, 8, 10}, {13, 3, 6, 7}, {15, 14, 12, 16}}
Rotate(source)
fmt.Println(source)
}
// 我太难了
func Rotate(matrix [][]int) {
// mid := (len(matrix)... |
package test
import (
"fmt"
"git-get/pkg/run"
"io/ioutil"
"os"
"path/filepath"
"testing"
)
// TempDir creates a temporary directory inside the parent dir.
// If parent is empty, it will use a system default temp dir (usually /tmp).
func TempDir(t *testing.T, parent string) string {
dir, err := ioutil.TempDir(p... |
package worder
type History struct {
UserID string
OrderID string
StatusID uint64
}
|
package ast
// Node is a generic representation of an element in the SQL AST.
type Node interface {
// BuildQuery creates a valid SQL query from the AST node.
BuildQuery() string
}
|
package connrt
import (
"fmt"
"sort"
"strconv"
"strings"
"time"
"github.com/gookit/event"
"github.com/kbence/conndetect/internal/connlib"
"github.com/kbence/conndetect/internal/utils"
)
type ExpiringConnection struct {
connlib.DirectionalConnection
ExpiresAt time.Time
}
type ExpiringConnectionList []Expi... |
package discord
import (
"fmt"
"strconv"
"strings"
"time"
"github.com/bwmarrin/discordgo"
)
const leftArrow = "⬅️"
const rightArrow = "➡️"
type reactionMsg struct {
Type reactionMsgType
Metadata map[string]interface{}
Handler func(*discordgo.MessageReactionAdd)
}
func (b *Bot) ldbPageSwitcher(r *disco... |
package kvs_test
import (
"errors"
"fmt"
"time"
. "github.com/bryanl/dolb/kvs"
. "github.com/onsi/ginkgo"
. "github.com/onsi/gomega"
)
var _ = Describe("Cluster", func() {
var (
err error
kvs *MockKVS
checkTTL = time.Millisecond * 10
cluster *Cluster
failErr = errors.New("fail")
)
B... |
package redis_test
import (
"os"
"testing"
"time"
"github.com/caarlos0/env"
"github.com/go-redis/redis"
. "web-layout/utils/redis"
)
func TestConnect(t *testing.T) {
os.Setenv("REDIS_ADDRS", "127.0.0.1:6379")
os.Setenv("REDIS_PWD", "")
os.Setenv("REDIS_POOL_SIZE", "100")
os.Setenv("REDIS_DB", "1")
c := ... |
package main
import (
"os"
"fmt"
"github.com/secsy/goftp"
"bytes"
"log"
"io/ioutil"
"time"
// "path"
)
func getEnv(key, fallback string) string {
var value string
value, exists := os.LookupEnv(key)
if !exists {
value = fallback
}
return value
}
fu... |
package datastore
import (
"github.com/jakewitcher/pos-server/graph/model"
)
var (
Customers CustomerProvider
Stores StoreProvider
Employees EmployeeProvider
Users UserProvider
)
type CustomerProvider interface {
CreateCustomer(newCustomer model.NewCustomerInput) (*model.Customer, error)
UpdateCustomer... |
package main
import (
"crypto/sha256"
"encoding/hex"
"fmt"
"strconv"
"strings"
"time"
)
// Block struct
type Block struct {
Index int
Timestamp string
Transactions []Taction
Hash string
PrevHash string
Difficulty int
//in real bitcoin, nonce is 4 bytes
//string in golang is poin... |
package logic
import (
"context"
"github.com/just-coding-0/learn_example/micro_service/zero/rpc/history/history"
"github.com/just-coding-0/learn_example/micro_service/zero/internal/svc"
"github.com/just-coding-0/learn_example/micro_service/zero/internal/types"
"github.com/tal-tech/go-zero/core/logx"
)
type Get... |
package integration_test
import (
"github.com/cloudfoundry/libbuildpack/cutlass"
. "github.com/onsi/ginkgo"
. "github.com/onsi/gomega"
)
var _ = Describe("running supply buildpacks before the staticfile buildpack", func() {
var app *cutlass.App
AfterEach(func() {
if app != nil {
app.Destroy()
}
app = n... |
package database
import (
"reflect"
"testing"
"github.com/ubclaunchpad/pinpoint/protobuf/models"
)
var club = &models.Club{
ClubID: "1234",
Description: "1337 h4x0r",
}
var user = &models.ClubUser{
ClubID: "1234",
Email: "abc@def.com",
Role: "Artist",
}
func TestDatabase_AddNewEvent_GetEvent(t *test... |
package command
import (
"fmt"
"data-importer/mq/dataworker"
)
func (c *APICommand) SubScribeTaskInfo(hub *Hub) {
go func() {
msgs, err := c.MsgQueue.ConsumeMessage(dataworker.TASKMESSAGE)
if err != nil {
return
}
for d := range msgs {
fmt.Println("Receive msg, time:", d.Timestamp, "body: ", string(... |
package main
import (
"bufio"
"compress/gzip"
"fmt"
"io"
"io/ioutil"
"os"
"strings"
)
func readFromConsole() {
reader := bufio.NewReader(os.Stdin)
for {
val, err := reader.ReadString('\n')
if err != nil {
fmt.Println(err)
}
if strings.Trim(val, "\n") == "end" {
break
}
fmt.Println(val)
... |
package script
type Value interface {
T() Type
AnyValue
}
type AnyValue interface {
ValueFromCtx(AnyCtx) Value
}
type Values []Value
//Runtime retrieved the runtime values.
func (values Values) Runtime() (result []interface{}) {
for _, value := range values {
result = append(result, value.T().Get())
}
retur... |
package main
import (
"fmt"
"math"
)
// 818. 赛车
// 你的赛车起始停留在位置 0,速度为 +1,正行驶在一个无限长的数轴上。(车也可以向负数方向行驶。)
// 你的车会根据一系列由 A(加速)和 R(倒车)组成的指令进行自动驾驶 。
// 当车得到指令 "A" 时, 将会做出以下操作: position += speed, speed *= 2。
// 当车得到指令 "R" 时, 将会做出以下操作:如果当前速度是正数,则将车速调整为 speed = -1 ;否则将车速调整为 speed = 1。 (当前所处位置不变。)
// 例如,当得到一系列指令 "AAR" 后, 你的车将... |
package main
import (
"bufio"
"fmt"
"os"
"day3/bag"
)
func getInput(path string) []bag.Bag {
file, _ := os.Open(path)
defer file.Close()
var bags []bag.Bag
scanner := bufio.NewScanner(file)
for scanner.Scan() {
curr := bag.NewBag(scanner.Text())
bags = append(bags, curr)
}
return bags
}
func assignG... |
// 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... |
package repository
import "errors"
var (
// ErrDateBusy busy date
ErrDateBusy = errors.New("time is already taken by another event")
// ErrEventNotFound event not found
ErrEventNotFound = errors.New("event not found")
// ErrStorageUnavailable storage unavailable
ErrStorageUnavailable = errors.New("storage unava... |
package main
import (
"github.com/WIZARDISHUNGRY/golinters/pkg/analyzer"
"golang.org/x/tools/go/analysis/singlechecker"
)
func main() {
singlechecker.Main(analyzer.InterfaceMustBePtr)
}
|
/*
Create a RegExp myRegExp to test if a string is a valid pin or not.
A valid pin has:
Exactly 4 or 6 characters.
Only numerical characters (0-9).
No whitespace.
Examples
myRegExp.test("1234") ➞ true
myRegExp.test("45135") ➞ false
myRegExp.test("89abc1") ➞ false
myRegExp.test("900876") ➞ true
myRe... |
package main
import "fmt"
func main() {
name := "Ramesh"
convertedToSlice := []byte(name)
convertedSliceToString := string(convertedToSlice)
fmt.Println("Name --------> ", name) // --> string of a name
fmt.Println(name, "Byte array(Slice) ----> ", convertedToSlice)
fmt.Println(convertedToSlice, "convertedSli... |
package main
import (
"fmt"
"io/ioutil"
"strings"
"os"
"strconv"
"math/rand"
"net/http"
"net/url"
"log"
"time"
// "bytes"
"crypto/tls"
)
func main() {
rand.Seed(time.Now().UnixNano())
args := os.Args
var _URL, _PROXIES_FILE, _UAS_FILE, _METHOD, _POSTDATA, _COOKIE string
var _TIME, _RAT... |
package pdexv3
import (
"encoding/json"
"incognito-chain/common"
metadataCommon "incognito-chain/metadata/common"
"incognito-chain/privacy"
)
// AddOrderRequest
type AddOrderRequest struct {
TokenToSell common.Hash `json:"TokenToSell"`
PoolPairID string ... |
package binance
import (
"context"
bin "github.com/adshao/go-binance"
"github.com/mhereman/cryptotrader/logger"
"github.com/mhereman/cryptotrader/types"
)
// GetSeries executes the get series request
func (b Binance) GetSeries(ctx context.Context, symbol types.Symbol, timeframe types.Timeframe) (series types.Ser... |
package transformer
import (
"github.com/confluentinc/confluent-kafka-go/kafka"
)
// Transformer is an interface which is used by Kafka.Transformer
// in order to transform a kafka Message.
// If nil is returned the message will be ignored
type Transformer interface {
Transform(src *kafka.Message) []*kafka.Message
... |
package graphkb
import "github.com/clems4ever/go-graphkb/internal/utils"
type RecurrentTask = utils.RecurrentTask
var NewRecurrentTask = utils.NewRecurrentTask
|
package serverconfigs
import "strings"
type ServerGroup struct {
fullAddr string
Servers []*ServerConfig
}
func NewServerGroup(fullAddr string) *ServerGroup {
return &ServerGroup{fullAddr: fullAddr}
}
// 添加服务
func (this *ServerGroup) Add(server *ServerConfig) {
this.Servers = append(this.Servers, server)
}
//... |
package keeper
import (
abci "github.com/tendermint/tendermint/abci/types"
"github.com/cosmos/cosmos-sdk/codec"
sdk "github.com/cosmos/cosmos-sdk/types"
sdkerrors "github.com/cosmos/cosmos-sdk/types/errors"
"github.com/irisnet/irismod/modules/coinswap/types"
)
// NewQuerier creates a querier for coinswap REST ... |
package security
import (
"html/template"
"net/http"
"strings"
"time"
)
// Serve a generic html page that does not need any variables inserted into it
func GenericPage(t *template.Template, name string, title string) func(w http.ResponseWriter, r *http.Request) {
return func(w http.ResponseWriter, r *http.Reques... |
package web
import (
"context"
"crypto/md5"
"fmt"
"github.com/gorilla/websocket"
"io"
"log"
"math/rand"
"net/http"
"strconv"
"sync"
"time"
)
var upgrader = websocket.Upgrader{}
func WsHandler(msgch *chan string, cm *Cmap) func(w http.ResponseWriter, r *http.Request) {
return func(w http.ResponseWriter, r... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.