text stringlengths 11 4.05M |
|---|
package tmc
import (
"github.com/baocaixiong/taobaosdk-go/agent"
)
type Tmc struct {
*agent.TaobaoAgent
}
// 为已开通用户添加用户分组
func (t *Tmc) GroupAdd(groupName string, nicks []string) *agent.JsonResponse {
params := map[string]string{
"group_name": groupName,
"nicks": t.Joins(nicks),
}
return t.Request("ta... |
package middleware
import (
"bytes"
"context"
"io"
"io/ioutil"
"net/http"
"testing"
"github.com/dennor/go-paddle/events"
"github.com/dennor/go-paddle/events/alerts"
"github.com/dennor/go-paddle/events/subscription"
"github.com/dennor/go-paddle/mime"
"github.com/stretchr/testify/assert"
"github.com/stretch... |
package auth
import (
"crypto/sha256"
"encoding/hex"
"math/rand"
"unicode"
)
func VerifyPassword(s string) bool {
var (
hasMinLen = false
hasMaxLen = false
hasUpper = false
hasLower = false
hasNumber = false
//hasSpecial = false
)
if len(s) >= 10 {
hasMinLen = true
}
if len(s) <= 64 {
hasMa... |
package main
import (
"bug1"
"bug2"
"many2many"
"oracle"
)
func main() {
bug1.Main()
bug2.Main()
many2many.Main()
oracle.Main()
}
|
package backend
import (
"time"
"github.com/gorilla/websocket"
"github.com/pkg/errors"
)
// QueueConn represents a connection to the queue.
type QueueConn struct {
Conn
User
Send chan MessageQueueResponse
}
// forwarder fetches messages from user interface and forwards it to Handler.
func (q *QueueConn) forw... |
package bot
import (
"log"
"bot/comm"
"math/rand"
)
func (c *Context) onInline(i *Inline) {
c.log.info("Context::onInline START")
c.log.info("Context::lock")
c.lock.Lock()
defer func() {
c.log.info("Context::unlock")
c.lock.Unlock()
}()
c.Inline = i
if inlineHandler != nil {
c.sendInlineAnswer(inline... |
/*
* AppManager API
*
* HTTP REST API to connect to the AppManager
*
* API version: 1.0
* Generated by: Swagger Codegen (https://github.com/swagger-api/swagger-codegen.git)
*/
package appManagerApiClient
import (
"time"
)
type LicenseMetadata struct {
Id string `json:"id,omitempty"`
Cre... |
package contact
import (
"net/http"
"sort"
"github.com/bborbe/log"
"github.com/bborbe/server/handler/base"
"github.com/bborbe/server/view"
"github.com/bborbe/www/config"
"github.com/bborbe/www/renderer/contact"
"github.com/bborbe/www/renderer/contentimage"
"github.com/bborbe/www/renderer/end"
"github.com/bb... |
package dashboard
import (
"github.com/labstack/echo/v4"
)
func chainsInit(e *echo.Echo, r renderer) Tab {
tab := initChainList(e, r)
initChain(e, r)
initChainAccount(e, r)
initChainBlob(e, r)
initChainContract(e, r)
return tab
}
|
// This file was generated for SObject EmailTemplate, API Version v43.0 at 2018-07-30 03:47:54.2332133 -0400 EDT m=+40.577342306
package sobjects
import (
"fmt"
"strings"
)
type EmailTemplate struct {
BaseSObject
ApiVersion float64 `force:",omitempty"`
Body string `force:",omitempty"`
Bran... |
package defaults
import (
"github.com/containers-ai/alameda/internal/pkg/database/common"
"github.com/containers-ai/alameda/internal/pkg/database/influxdb/schemas"
)
func SchemaMetricKafkaTopic() *schemas.Schema {
// Kafka topic
schema := schemas.NewSchema(schemas.Metric, "kafka", "topic")
measurement := schemas... |
package main
import (
"bufio"
"fmt"
"os"
"strconv"
"strings"
)
func solution(arr []int, size, money int) int{
dpSum := make([]int, size)
dpCnt := make([]int, size)
maxCnt := 0
for i := range arr {
dpSum[i] = arr[i]
dpCnt[i] = 1
if arr[i] < money {
maxCnt = 1
}
}
for j := 1; j < len(arr); j++ {
... |
/*
* 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 main
import (
"fmt"
"path/filepath"
helpers "github.com/jraams/aoc-2020/helpers"
)
func main() {
inputPath, _ := filepath.Abs("input")
stringInputValues := helpers.GetInputValues(inputPath)
intEntries := helpers.TranslateStringArrToIntArr(stringInputValues)
// Part 1
matchingEntries1, _ := helpers.G... |
package main
import (
"errors"
"fmt"
"net"
"time"
"github.com/Sirupsen/logrus"
"github.com/fasthall/gochariots/maintainer/adapter/mongodb"
"github.com/fasthall/redis-cache-for-lowgo/cache"
"github.com/fasthall/redis-cache-for-lowgo/config"
"github.com/go-redis/redis"
context "golang.org/x/net/context"
"go... |
package main
import (
"fmt"
"github.com/astaxie/beego"
"net/http"
"os"
"tokensky_bg_admin/manage_balance/controllers"
_ "tokensky_bg_admin/manage_balance/sysinit"
)
func main() {
defer func() { select {} }()
http.HandleFunc("/balance/one", controllers.SetBalanceOne)
http.HandleFunc("/balance/multi", controll... |
package main
import (
"fmt"
"log"
"os"
"strconv"
)
func main() {
var repeatCount int
var err error
if len(os.Args) >= 2 {
repeatCount, err = strconv.Atoi(os.Args[1])
if err != nil {
log.Fatal(err)
}
for i := 0; i < repeatCount; i++ {
fmt.Println("Hello Gopher!")
}
}
}
|
package evaluator
// PolicyEvaluator defines methods that a policy evaluator will implement
type PolicyEvaluator interface {
EvalPositive() error
EvalNegative() error
}
|
package internal
var Build string = ""
var Branch string = ""
|
// This is a cache of Envoy clusters
//
// To figure out the Envoy clusters that we need to set in the Envoy config, we
// check the Ingress. However, there's a case where there are old clusters being
// used that cannot be extracted from the Ingress.
//
// Imagine a scenario where a revision of a Knative Serving is de... |
package base
import (
"context"
"net"
"github.com/ka2n/masminer/cgminerproxy"
"github.com/ka2n/masminer/sshutil"
"golang.org/x/crypto/ssh"
)
type Dialer interface {
Dial(n, addr string) (net.Conn, error)
}
func OutputRemoteShell(ctx context.Context, client *ssh.Client, in string) ([]byte, error) {
sess, err... |
package completion
import (
"os"
"github.com/spf13/cobra"
)
//NewCompletionCmd creates a new completion command
func NewCmd() *cobra.Command {
var completionCmd = &cobra.Command{
Use: "completion",
Short: "Generates bash completion scripts.",
Long: `Use this command to display the shell completion code us... |
// +build windows
package netstat
import (
"bytes"
"encoding/binary"
"errors"
"fmt"
"net"
"reflect"
"syscall"
"unsafe"
)
const (
errInsuffBuff = syscall.Errno(122)
Th32csSnapProcess = uint32(0x00000002)
InvalidHandleValue = ^uintptr(0)
MaxPath = 260
)
var (
errNoMoreFiles = errors.New("no ... |
package rpcd
import (
"os/exec"
"strings"
)
func (t *rpcType) generateNote() (string, error) {
if t.config.NoteGeneratorCommand == "" {
return "", nil
}
cmd := exec.Command(t.config.NoteGeneratorCommand)
if output, err := cmd.Output(); err != nil {
return "", err
} else if length := len(output); length > 0... |
package gortex
import (
"strings"
"fmt"
"unicode"
)
//Tokenizer interface to string tokenizer
type Tokenizer interface {
Split(str string) []string
}
//WhiteSpaceSplitter space delimited tokens
type WhiteSpaceSplitter struct{}
func (s WhiteSpaceSplitter) Split(str string) []string {
return strings.Fields(str)
... |
package maps
import "errors"
type Dictionary map[string]string
const (
wordNotFoundErrorMessage string = "could not find the word you were looking for"
keyAlreadyExistsErrorMessage string = "key already exists!"
)
var (
WordNotFoundError = errors.New(wordNotFoundErrorMessage)
KeyAlreadyExistsError = err... |
/*****************************************************************************/
/**
* \file fwd.go
* \author gaoxj
* \date 2018/05/31
* \brief 本地任务控制
* \note Copyright (c) 2000-2020 赛特斯信息科技股份有限公司
* \remarks 修改日志
*****************************************************************************... |
// 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 main
import (
"flag"
"os"
"github.com/BeameryHQ/kubeaware/manager"
"github.com/MovieStoreGuy/artemis"
// Needed to register subprocesses of the coordinator
_ "github.com/BeameryHQ/kubeaware/manager/process"
_ "github.com/BeameryHQ/kubeaware/manager/server"
)
var (
confPath = os.Getenv("CONFIG_PATH")... |
// Copyright 2019-present 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 agr... |
// Copyright (C) Microsoft Corporation.
package main
import (
"database/sql"
"errors"
"flag"
"fmt"
"log"
"math"
"os"
"regexp"
"strconv"
"strings"
"time"
mssql "github.com/denisenkom/go-mssqldb"
"mssqlcommon"
mssqlag "mssqlcommon/ag"
mssqlocf "mssqlcommon/ocf"
)
const (
// promotionScoreCurrentMaste... |
package room
import (
"encoding/binary"
"encoding/json"
"fmt"
"log"
"os"
"strconv"
"strings"
"time"
"github.com/funny/link"
)
type RoomSysInfo struct {
Pid int
Addr string
StartTime int64
}
func NewRoomSysInfo(pid int, addr string, startTime int64) RoomSysInfo {
return RoomSysInfo{
pid,
... |
package tools
import "testing"
// TestCase represents a simple int in int out test case.
type TestCase struct {
In int
Out int
}
// TestIntInt tests a simple func(int) int function.
func TestIntInt(t *testing.T, cases []TestCase, f func(int) int, name string) {
for _, c := range cases {
v := f(c.In)
if v != ... |
package grapheme
import (
"fmt"
"io"
"math"
"unicode/utf8"
"github.com/gioui/uax"
"github.com/gioui/uax/internal/tracing"
"github.com/gioui/uax/segment"
)
// String is a type to represent a graheme string, i.e. a sequence of
// “user perceived characters” as defined by Unicode.
// A grapheme string is a read-... |
package config_provider
import (
"github.com/kataras/iris/context"
)
type DBConfig struct {
DB_USER string `json:"db_user"`
DB_PASS string `json:"db_pass"`
DB_NAME string `json:"db_name"`
DB_HOST string `json:"db_host"`
DB_PORT string `json:"db_port"`
}
type ConfigProvider struct {
DBConfig *DBConfig
}
func ... |
package seccomp
import "testing"
func TestError(t *testing.T) {
msg := "some error message"
err := Error(msg)
if msg != err.Error() {
t.Errorf("wanted '%s', but got '%s'", msg, err.Error())
}
}
|
package main
import (
"database/sql"
"net"
"sync"
"time"
"github.com/go-sql-driver/mysql"
"github.com/tideland/golib/redis"
)
type Bans struct {
users map[Userid]time.Time
userlock sync.RWMutex
ips map[string]time.Time
userips map[Userid][]string
iplock sync.RWMutex // protects... |
// Copyright © 2018 Inanc Gumus
// Learn Go Programming Course
// License: https://creativecommons.org/licenses/by-nc-sa/4.0/
//
// For more tutorials : https://learngoprogramming.com
// In-person training : https://www.linkedin.com/in/inancgumus/
// Follow me on twitter: https://twitter.com/inancgumus
package main
... |
package main
import "fmt"
func main() {
fmt.Println(increasingTriplet([]int{
1, 2, 3, 4, 5,
}))
fmt.Println(increasingTriplet([]int{
5, 4, 3, 2, 1,
}))
fmt.Println(increasingTriplet([]int{
2, 1, 5, 0, 4, 6,
}))
}
func increasingTriplet(nums []int) bool {
ln := len(nums)
dpmin := make([]int, ln)
dpma... |
package main
import (
"flag"
"fmt"
"github.com/coraldane/dns-agent/cron"
"github.com/coraldane/dns-agent/g"
"github.com/toolkits/logger"
"log"
"os"
)
func main() {
cfg := flag.String("c", "cfg.json", "configuration file")
version := flag.Bool("v", false, "show version")
flag.Parse()
if *version {
fmt.P... |
// 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 law or agreed to in writing... |
package stat
import "context"
type PoolAdds struct {
AssetE8Total int64
RuneE8Total int64
}
func PoolAddsLookup(ctx context.Context, pool string, w Window) (*PoolAdds, error) {
const q = `SELECT COALESCE(SUM(asset_e8), 0), COALESCE(SUM(rune_e8), 0)
FROM add_events
WHERE pool = $1 AND block_timestamp >= $2 AND bl... |
package problem0647
func countSubstrings(s string) int {
dp := make([][]bool, len(s))
for i := 0; i < len(s); i++ {
dp[i] = make([]bool, len(s))
dp[i][i] = true
}
count := len(s)
for i := 1; i < len(s); i++ {
if s[i] == s[i-1] {
dp[i-1][i] = true
count++
}
}
for size := 3; size <= len(s); size++ {... |
package main
import "fmt"
//算術演算子
func main() {
fmt.Println(1 + 2)
fmt.Println(1 - 3)
fmt.Println(5 * 22)
fmt.Println(6 / 2)
n := 0
n += 4
n++
fmt.Println(n)
n--
fmt.Println(n)
} |
package graph
import (
"fmt"
"testing"
)
func TestCreateGraph(t *testing.T) {
PrintGraph(CreateDirectedGraph())
PrintGraph(CreateUndirectedGraph())
PrintGraph(CreateAOE())
}
func TestBreadthFirstSearch(t *testing.T) {
g := CreateUndirectedGraph()
PrintGraph(g)
fmt.Println("BFS的顺序为: ", BreadthFirstSearch(g, 1... |
/**
* (c) 2014, Caoimhe Chaos <caoimhechaos@protonmail.com>,
* Ancient Solutions. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* * Redistributions of source code must retain ... |
package main
import (
"flag"
"fmt"
"os"
"os/exec"
)
const (
INDENT = " "
)
var basePath string
func init() {
flag.StringVar(&basePath, "p", "", "path you want to show")
}
func gitDrop() error {
err := execCommand("git", "add", ".")
if err != nil {
return err
}
err = execCommand("git", "stash")
if err... |
package main
import "fmt"
import "time"
func main() {
fmt.Println("START 1")
for i := 0; i < 3; i++ {
foo(i)
}
fmt.Println("END 1")
fmt.Println("START 2")
for i := 0; i < 3; i++ {
go foo(i)
}
fmt.Println("END 2")
time.Sleep(1 * time.Second)
}
func foo(i int) {
time.Sleep(1)
fmt.Printf("Call index: %... |
package main
import (
"fmt"
)
func troca(p1, p2 int) (segundo int, primeiro int) {
segundo = p2
primeiro = p1
return
}
func main() {
x, y := troca(1, 2)
fmt.Println(x)
fmt.Println(y)
primeiro, segundo := troca(5, 7)
fmt.Println(primeiro)
fmt.Println(segundo)
}
|
package main
import (
"bufio"
"fmt"
"gosearch/pkg/crawler"
"log"
"os"
"strings"
"net/rpc/jsonrpc"
)
type Query struct {
Data string
}
func main() {
host := "0.0.0.0"
port := "8001"
conn, err := jsonrpc.Dial("tcp", host+":"+port)
if err != nil {
log.Fatal(err.Error())
}
defer conn.Close()
enter :=... |
package events
import (
"testing"
"encoding/hex"
"encoding/base64"
"strings"
)
func TestEventID_Parse(t *testing.T) {
in := "952822DE6A627EA459E1E7A8964191C79FCCFB14EA545D93741B5CF3ED71A09A"
id := NewEventID()
id.Parse(in)
expected := [32]byte{
149, 40, 34, 222, 106, 98, 126, ... |
package common
import (
"github.com/ActiveState/log"
"github.com/ActiveState/tail"
"os"
"os/signal"
"syscall"
)
func cleanup() {
log.Info("cleanup: closing open inotify watches")
tail.Cleanup()
}
// Fatal is like log.Fatal, but invokes cleanup (tail) before exiting.
func Fatal(format string, v ...interface{})... |
package chat_server
import (
"fmt"
"log"
"net/http"
"github.com/gorilla/websocket"
)
var upgrader = websocket.Upgrader{
ReadBufferSize: 1024,
WriteBufferSize: 1024,
}
func checkOrigin(r *http.Request) (bool) {
return true
}
// serveWs handles websocket requests from the peer.
func ServeWs(hub *Hub, w http.... |
// ReadiniInfo
package DaeseongLib
import (
"bufio"
_ "fmt"
"os"
"strconv"
"strings"
)
type ReadiniInfo struct {
data map[string]string
}
func newReadiniInfo() *ReadiniInfo {
ret := new(ReadiniInfo)
ret.data = make(map[string]string)
return ret
}
func LoadiniConfig(sPath string) *ReadiniInfo {
ret := new... |
package tuning
import "strings"
func join(vals ...string) string {
c := strings.Join(vals, " ")
return c
}
|
package rancher
import (
"golang.org/x/net/context"
"github.com/docker/libcompose/config"
"github.com/docker/libcompose/project"
)
type Sidekick struct {
project.EmptyService
name string
serviceConfig *config.ServiceConfig
context *Context
}
func NewSidekick(name string, serviceConfig *config... |
package problem0257
import "testing"
func TestBinaryTree(t *testing.T) {
root := &TreeNode{Val: 1}
root.Left = &TreeNode{Val: 2}
root.Right = &TreeNode{Val: 3}
root.Left.Right = &TreeNode{Val: 5}
t.Log(binaryTreePaths(root))
}
|
package main
import "fmt"
// If you use "int" as the variable type, GoLang will automatically decide whether to
// use int32 or int64 based on the architecture of the system. Same goes with uint
// "byte" is an alias for "int8"
func main() {
x := 24
y := 42.2345
fmt.Println("Value of 'x' :: ", x)
fmt.Printf("Ty... |
package index
import (
"go.core/lesson5/pkg/crawler"
"testing"
)
func TestService_inArray(t *testing.T) {
s := New()
type args struct {
slice []int
val int
}
tests := []struct {
name string
args args
want bool
}{
{"1", args{[]int{1, 2, 3, 4, 5}, 5}, true},
{"2", args{[]int{1, 2, 3, 4}, 5}, fa... |
package main
import (
"bufio"
"encoding/json"
"fmt"
dcli "github.com/fsouza/go-dockerclient"
"github.com/garyburd/redigo/redis"
"io"
"log"
"net/http"
"time"
)
func main() {
redisPool := redis.NewPool(func() (redis.Conn, error) {
return redis.Dial("tcp", ":6379")
}, 5)
s := &Server{
broker: NewBrok... |
package main
import (
"errors"
"flag"
"fmt"
"io/ioutil"
"log"
"net/http"
"os"
"path/filepath"
"strings"
)
type requestData struct {
url string
method string
}
type responseData struct {
headers map[string]string
body string
}
var cache = make(map[requestData]responseData)
var lineBreak = "##"
fu... |
package models
import (
"github.com/jinzhu/gorm"
)
const (
TagStatusOk = 0
TagStatusDisabled = 1
)
// 标签
type Tag struct {
gorm.Model
Name string `gorm:"size:32;unique;not null" json:"name" form:"name"`
Description string `gorm:"size:1024" json:"description" form:"description"`
Status int ... |
package gdw
// Job interface defines a method through which gdw can execute requested jobs.
type Job interface {
DoWork()
}
type batchedJob struct {
batched Job
name string
}
|
package registry
import (
"github.com/feast-dev/feast/go/protos/feast/core"
)
// A RegistryStore is a storage backend for the Feast registry.
type RegistryStore interface {
GetRegistryProto() (*core.Registry, error)
UpdateRegistryProto(*core.Registry) error
Teardown() error
}
|
// Copyright (C) 2019 Cisco Systems 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 agr... |
package main
import (
"context"
"encoding/binary"
"encoding/json"
"fmt"
"math/big"
"net/http"
"strconv"
"github.com/gin-gonic/gin"
"github.com/meshplus/bitxhub-kit/crypto/asym/ecdsa"
"github.com/meshplus/bitxhub-kit/types"
)
type response struct {
IsPass bool `json:"is_pass"`
Data []byte `json:"data"... |
package function
import (
"encoding/json"
"net/http"
)
func respond(httpStatus int, responseJSON interface{}, w http.ResponseWriter) {
w.Header().Set("Content-Type", "application/json")
w.WriteHeader(httpStatus)
_ = json.NewEncoder(w).Encode(responseJSON)
}
// responds just with a status
func respondStatus(http... |
package timeline
import (
"testing"
)
func TestPreflightAsset(t *testing.T) {
jsonFileMock := "mock.json"
yamlFileMock := "mock.yaml"
//byte slices
invalidUtf8 := []byte{0xff, 0xfe, 0xfd}
xmlMarkup := []byte("<?xml version='1.0' encoding='UTF-8' standalone='yes'?><root/>")
validJson := []byte("{ \"foo\": [\"b... |
package datasets
import (
"fmt"
"strings"
"time"
)
type ISODate time.Time
const formatTemplate = "2006-01-02"
func (i *ISODate) UnmarshalJSON(b []byte) error {
s := strings.Trim(string(b), "\"")
t, err := time.Parse(formatTemplate, s)
if err != nil {
return err
}
*i = ISODate(t)
return nil
}
func (i ... |
package vis
// MyName is visible outside of the package
var MyName = "Chaca"
var yourName = "Future Go Pro"
|
// DRUNKWATER TEMPLATE(add description and prototypes)
// Question Title and Description on leetcode.com
// Function Declaration and Function Prototypes on leetcode.com
//50. Pow(x, n)
//Implement pow(x, n), which calculates x raised to the power n (xn).
//Example 1:
//Input: 2.00000, 10
//Output: 1024.00000
//Example ... |
package payment
// Payment contains payment information such as amount and currency, commisions, stakeholders information, etc.
// swagger:model
type Payment struct {
Type string `json:"type,omitempty"`
ID string `json:"id,omitempty"`
Version int ... |
package q_test
import (
"github.com/elliotchance/gedcom/q"
"github.com/elliotchance/tf"
"testing"
)
var documentChoices = []string{
".AddFamily",
".AddFamilyWithHusbandAndWife",
".AddIndividual",
".AddNode",
".DeleteNode",
".Families",
".GEDCOMString",
".Individuals",
".NodeByPointer",
".Nodes",
".Place... |
package main
import (
"github.com/bit101/blgg/blgg"
"github.com/bit101/blgg/blmath"
"github.com/bit101/blgg/render"
"github.com/bit101/blgg/util"
)
func main() {
target := render.Gif
switch target {
case render.Image:
render.RenderImage(800, 800, "out.png", renderFrame, 0.5)
util.ViewImage("out.png")
br... |
package api
import (
model "github.com/EgorKekor/chat_backend/models"
"github.com/google/uuid"
"github.com/valyala/fasthttp"
"net/http"
"time"
)
func EnterRoom(ctx *fasthttp.RequestCtx) {
ctx.Response.Header.Set("Access-Control-Allow-Origin", "http://localhost:8080")
ctx.Response.Header.Set("Access-Control-All... |
package go_utils
import (
"bufio"
"fmt"
"os"
"strings"
)
func GetInt() int {
var tmp int
fmt.Scan(&tmp)
return tmp
}
func GetFloat() float64 {
var tmp float64
fmt.Scan(&tmp)
return tmp
}
func GetString() string {
var tmp string
fmt.Scan(&tmp)
return tmp
}
func GetLine() string {
reader := bufio.NewRe... |
package main
import (
"fmt"
"sort"
)
func threeSumBrute(nums []int) [][]int {
r := make([][]int, 0)
n := len(nums)
if n > 2 {
sort.Ints(nums)
for a := 0; a < n-2; a++ {
if a > 0 && nums[a] == nums[a-1] {
continue
}
sum := nums[a]
if sum > 0 {
break
}
for b := a + 1; b < n-1; b++ {
... |
// Copyright 2020 The go-bindata Authors. All rights reserved.
// Use of this source code is governed by a CC0 1.0 Universal (CC0 1.0)
// Public Domain Dedication license that can be found in the LICENSE file.
//go:generate go run main.go
//go:build ignore
// +build ignore
package main
import (
"log"
"regexp"
"... |
package blockchain
import (
"bytes"
"encoding/binary"
"crypto/sha256"
)
type Block struct {
Index int64 `json:"index"`
Timestamp int64 `json:"timestamp"`
Transactions []Transaction `json:"transactions"`
Proof int64 `json:"proof"`
PreviousHash []byte `json:"previ... |
/*
Background
The hyperfactorial is a variant of the factorial function. is defined as
H(n)=1^1⋅2^2⋅3^3⋅⋯⋅n^n
For example, H(4)=1^1⋅2^2⋅3^3⋅4^4=27648.
Test cases
n H(n)
0 1
1 1
2 4
3 108
4 27648
5 86400000
6 4031078400000
7 3319766398771200000
8 55696437941726556979200000
Rules
The standard loop... |
package responses
import (
TransactionModels "marketplace-api/application/modules/Transaction/models"
)
type PaginationResponse struct {
Status int `json:"status"`
Message string `json:"message"`
Data []TransactionModels.Transaction ... |
package cve
// CvssV2 Common Vulnerability Scoring System version 2.0
type CvssV2 struct {
AccessComplexity string `json:"accessComplexity,omitempty"`
AccessVector string `json:"accessVector,omitempty"`
Authentication string `json:"authentication,omitempty"`
AvailabilityImpac... |
package geo
// Line ...
type Line struct {
Points []*Point
}
// NewLine ...
func NewLine(pts []*Point) *Line {
return &Line{
Points: pts,
}
}
|
package mapbox
import (
"io/ioutil"
"strings"
"testing"
)
func readAccessToken(t *testing.T) (string, error) {
contents, err := ioutil.ReadFile("MAPBOX_ACCESS_TOKEN")
if err != nil {
t.Fatalf("cannot read file MAPBOX_ACCESS_TOKEN; make sure to add this file and paste your Mapbox Access Token in there.\nError: ... |
package function
import "github.com/serverless/event-gateway/metadata"
// Service represents service for managing functions.
type Service interface {
GetFunction(space string, id ID) (*Function, error)
ListFunctions(space string, filters ...metadata.Filter) (Functions, error)
CreateFunction(fn *Function) (*Functio... |
package model
/**
* Holds one particular blog entry
*/
type Post struct {
Id string
Title string
Content string
}
/**
* Creates new instance of the post structure
*/
func Create(id, title, content string) *Post {
return &Post{id, title, content}
} |
package x
// GENERATED BY XO. DO NOT EDIT.
import (
"errors"
"strings"
//"time"
"strconv"
"github.com/jmoiron/sqlx"
)
// (shortname .TableNameGo "err" "res" "sqlstr" "db" "XOLog") -}}//(schema .Schema .Table.TableName) -}}// .TableNameGo}}// Blocked represents a row from 'sun.blocked'.
// Manualy copy this to ... |
package keeper
import (
"context"
"github.com/InjectiveLabs/injective-oracle-scaffold/injective-chain/modules/oracle/types"
sdk "github.com/cosmos/cosmos-sdk/types"
)
var _ types.QueryServer = BaseKeeper{}
func (k BaseKeeper) Params(c context.Context, _ *types.QueryParamsRequest) (*types.QueryParamsResponse, erro... |
package pojo
import "tesou.io/platform/brush-parent/brush-api/common/base/pojo"
/**
欧赔历史,变化过程表
*/
type EuroTrack struct {
/**
初盘胜平负赔率
*/
Sp3 float64
Sp1 float64
Sp0 float64
/**
即时盘胜平负赔率
*/
Ep3 float64
Ep1 float64
Ep0 float64
//博彩公司id
CompId string `xorm:"unique(CompId_MatchId_OddDate) index"`
//比赛id... |
// Licensed to Elasticsearch B.V. under one or more contributor
// license agreements. See the NOTICE file distributed with
// this work for additional information regarding copyright
// ownership. Elasticsearch B.V. licenses this file to you under
// the Apache License, Version 2.0 (the "License"); you may
// not use ... |
// Copyright 2017 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 metrics
type FakeCollector struct{}
func (fc *FakeCollector) Timing(name string, tags ...string) (end func(moretags ...string)) {
return func(moretags ...string) {}
}
func (fc *FakeCollector) Increment(name string, tags ...string) {}
func (fc *FakeCollector) Gauge(name string, value float64, tags ... |
// Copyright 2017 VMware, 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 api_handlers
import (
"net/http"
"github.com/labstack/echo/v4"
)
type (
billing struct {}
)
func Billing() (a *billing) {
return
}
func (*billing) Customer(ctx echo.Context) error {
return ctx.String(http.StatusOK, "Hello Login page")
}
func (*billing) RegisterEmail(ctx echo.Context) error {
return... |
package service
import (
"fmt"
"github.com/taufanmahaputra/forex/pkg/repository"
"log"
"math"
"time"
)
type Map map[string]interface{}
type RateDataService struct {
rateRepository repository.RateRepositoryItf
rateDataRepository repository.RateDataRepositoryItf
}
func InitRateDataService(rateRepository re... |
package main
import (
"fmt"
"euler"
)
func pandigital(n int) bool {
counts := make([]int,10)
ds := euler.GetDigits(n)
for _, v := range ds {
if v == 0 {
return false
}
counts[v]++
if counts[v] > 1 {
return false
}
}
for k, v := range counts {
if k <= l... |
package main
import (
"fmt"
akamai "github.com/akamai/cli-common-golang"
MQTT "github.com/eclipse/paho.mqtt.golang"
"github.com/fatih/color"
"github.com/urfave/cli"
"log"
)
var commandSubscribe = cli.Command{
Name: "subscribe",
ArgsUsage: "[qos][host][client-id][key-name][topic]",
Description: "Subs... |
// +build ignore
package main
import (
"flag"
"github.com/zlowred/embd"
"github.com/zlowred/embd/controller/pca9955b"
_ "github.com/zlowred/embd/host/all"
"fmt"
)
func main() {
flag.Parse()
if err := embd.InitI2C(); err != nil {
panic(err)
}
defer embd.CloseI2C()
bus := embd.NewI2CBus(1)
pca9955b :=... |
package oss
import (
"github.com/aliyun/aliyun-oss-go-sdk/oss"
"github.com/bennya8/go-union-opensdk/utils"
"math/rand"
"os"
"strconv"
"sync"
)
var (
endpoint = "<endpoint>"
accessKeyID = "<accessKeyId>"
accessKeySecret = "<accessKeySecret>"
domain = "<domain>"
instance *oss.Clien... |
package main
import "github.com/roessland/gopkg/mathutil"
import "fmt"
func ConcatenatedProduct(integer, n int64) int64 {
digits := []int64{}
for i := int64(1); i <= n; i++ {
digits = append(digits, mathutil.ToDigits(integer*i, 10)...)
}
return mathutil.FromDigits(digits, 10)
}
func TestConca... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.