text stringlengths 11 4.05M |
|---|
package main
import (
"github.com/go-chi/chi"
rest "github.com/ktnyt/go-rest"
)
func register(pattern string, router chi.Router, iface rest.Interface) {
router.Route("/"+pattern, func(router chi.Router) {
router.Get("/", iface.Browse)
router.Delete("/", iface.Delete)
router.Post("/", iface.Create)
router.R... |
/*
create a type SQUARE
create a type CIRCLE
attach a method to each that calculates AREA and returns it
circle area= π r 2
square area = L * W
create a type SHAPE that defines an interface as anything that has the AREA method
create a func INFO which takes type shape and then prints the area
create a value of type s... |
package glog
import (
"time"
log "github.com/mosteknoloji/glog"
"golang.org/x/net/context"
"google.golang.org/grpc"
)
var _ grpc.UnaryServerInterceptor = UnaryLogHandler
func UnaryLogHandler(ctx context.Context, req interface{}, info *grpc.UnaryServerInfo, handler grpc.UnaryHandler) (resp interface{}, err error... |
package orderbook
import "sort"
type Orderbook struct {
Ask []*Order
Bid []*Order
}
func New() *Orderbook {
orbook := Orderbook{}
return &orbook
}
func (orderbook *Orderbook) Match(order *Order) ([]*Trade, *Order) {
tr := []*Trade{}
var or *Order
or = nil
switch order.Kind.String() {
case "MARKET":
ord... |
package netutil_test
import (
"fmt"
"net"
"github.com/AdguardTeam/golibs/netutil"
)
func ExampleIPv4Zero() {
fmt.Println(netutil.IPv4Zero())
// Output:
//
// 0.0.0.0
}
func ExampleIPv6Zero() {
fmt.Println(netutil.IPv6Zero())
// Output:
//
// ::
}
func ExampleParseIP() {
ip, err := netutil.ParseIP("1.... |
// 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 template
import (
"fmt"
"regexp"
"strings"
)
type CodeBlock struct {
Old string
New string
}
type CodeSegment struct {
Old string
New string
Block string
}
func FilterImports(src []byte) (dist []byte) {
content := string(src)
lines := strings.Split(content, "\n")
makeLines := make([]string, ... |
/*
Quentin Tarantino is a famous Hollywood filmmaker and actor. His films have a unique characteristic of connecting with youth by using popular culture references.
They are usually divided into various sub-parts denoted by chapters. His plot of stories is never linear, he always make sure that the chapters should nev... |
package types
import (
"encoding/binary"
"time"
"github.com/Secured-Finance/dione/types"
"github.com/libp2p/go-libp2p-core/crypto"
"github.com/ethereum/go-ethereum/common"
"github.com/wealdtech/go-merkletree"
"github.com/wealdtech/go-merkletree/keccak256"
"github.com/libp2p/go-libp2p-core/peer"
)
type Bl... |
package vm
import (
"runtime"
"sync"
"sync/atomic"
"time"
"bounds"
"defs"
"fdops"
"mem"
"res"
"ustr"
"util"
)
type Vm_t struct {
// lock for vmregion, pmpages, pmap, and p_pmap
sync.Mutex
Vmregion Vmregion_t
// pmap pages
Pmap *mem.Pmap_t
P_pmap mem.Pa_t
pgfltaken bool
}
func (as *Vm_t) Lock_... |
package main
//
// import (
// "net/http"
// "bytes"
// "strings"
// "os/exec"
// "log"
// "fmt"
// "io"
// "net"
// "time"
// "crypto/tls"
// "golang.org/x/net/http2"
// )
//
// func main() {
// cmd := exec.Command("docker", "inspect", "-f {{range .NetworkSettings.Networks}}{{.IPAddress}}{{end}}", "backend... |
// Copyright 2019-present Open Networking Foundation.
//
// 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 main
import (
"strconv"
"encoding/json"
"time"
"net"
"bufio"
"fmt"
)
type ErrorData struct {
Ts string `json:"ts"`
Txt string `json:"txt"`
}
const (
tcpLogServerAddr = "127.0.0.1:33334"
procId = "iptv/ffmpeg_rtmp"
logRequestPeriod = 1000
)
func main(){
ts := strconv.FormatInt(time.Now().UnixNa... |
package data
import (
"testing"
"time"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
)
func TestDownloader_candlesCount(t *testing.T) {
tt := []struct {
start time.Time
end time.Time
timeframe string
interval time.Duration
total int
}{
{time.Now(), time.N... |
// Copyright 2022 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 main
import "fmt"
func main(){
s := make([]string, 3)
s[0] = "a"
s[1] = "b"
s[2] = "c"
s = append(s, "3")
s = append(s, "d", "e")
fmt.Println(s)
fmt.Println("Size of slice is", len(s))
l := s[2:5]
fmt.Println(l)
c := make([]string, 2)
copy(c,s)
fmt.Println(c)
}
|
package main
import (
"fmt"
"os"
"github.com/andywow/golang-lessons/lesson2/stringunpack"
)
func main() {
if (len(os.Args)) == 1 {
fmt.Fprintf(os.Stderr, "Error: specify input string\n")
os.Exit(1)
}
result, err := stringunpack.Unpack(os.Args[1])
if err != nil {
fmt.Fprintf(os.Stderr, "Error: %s\n", err... |
package database
import (
"errors"
"strconv"
db "taskweb/database"
)
type TbUser struct {
Id int
Name string
Pwd string
Email string
Createtime int64
Remark string
}
func ExistTbUser(id int) (bool, error) {
rows, err := db.Dtsc.Query("select count(0) Count from tb_user where id=?", id)
if err != nil {
... |
package main
import (
"errors"
"fmt"
)
type LinkedNode struct {
value interface{}
next *LinkedNode
prev *LinkedNode
}
func (l *LinkedNode) IsEmpty() bool {
if l.next == nil && l.prev == nil {
return true
}
if l.next == l && l.prev == l {
return true
}
return false
}
func (l *LinkedNode) AddNode(ne... |
package types
import (
"errors"
"fmt"
"strings"
"gopkg.in/yaml.v2"
sdk "github.com/cosmos/cosmos-sdk/types"
paramtypes "github.com/cosmos/cosmos-sdk/x/params/types"
)
const (
// StandardDenom for coinswap
StandardDenom = sdk.DefaultBondDenom
)
// Parameter store keys
var (
KeyFee = []byte("Fee")... |
// Copyright 2016 Google Inc. All rights reserved.
// Use of this source code is governed by the Apache 2.0
// license that can be found in the LICENSE file.
package main
import (
"io/ioutil"
"log"
"os"
"testing"
"time"
"golang.org/x/net/context"
"github.com/GoogleCloudPlatform/golang-samples/internal/testut... |
package main
import (
"fmt"
"log"
)
func change(m map[string]string) {
m["dicky"] = "novanto"
}
func main() {
mapper := make(map[string]string)
change(mapper)
fmt.Println("map: ", mapper)
fmt.Println("mapper dari dicky: ", mapper["dicky"])
otherMapper := copyMap(mapper)
fmt.Println(otherMapper)
mapper["di... |
package services
import (
"fmt"
"github.com/blockcypher/gobcy"
"github.com/constant-money/constant-event/config"
helpers "github.com/constant-money/constant-web-api/helpers"
)
// BlockcypherService : ...
type BlockcypherService struct {
conf *config.Config
chain gobcy.API
}
// NewBlockcypherService : ...
fun... |
// Copyright (c) 2022 Zededa, Inc.
// SPDX-License-Identifier: Apache-2.0
// A simple demonstration of reconciler + depgraph.
// Files, directories and their dependencies are represented using dependency
// graphs. Reconciler then takes care of the reconciliation between the intended
// and the actual content of a (te... |
package wps
import (
`encoding/json`
)
const (
// 上传文件
FileTypeUpload FileType = "UPLOAD"
// 下载文件
FileTypeDownload FileType = "DOWNLOAD"
// 预览文件
FileTypePreview FileType = "PREVIEW"
)
type (
// FileType 文件类型
FileType string
// FileExistReq 文档是否存在的请求
FileExistReq struct {
// 文件Id
Id string `json:"id"`
... |
package laserframework
import (
"net/http"
"time"
)
type Service struct {
ProductID int `json:"productid"`
ProductName string `json:"productname"`
ServiceID int `json:"serviceid"`
ServiceName string `json:"servicename"`
ServiceType string `json:"servicetype"`
ServiceCount int ... |
package handler
import (
"context"
"fmt"
"github.com/jinmukeji/jiujiantang-services/service/auth"
proto "github.com/jinmukeji/proto/v3/gen/micro/idl/partner/xima/core/v1"
)
// SubmitRemark 用户修改备注
func (j *JinmuHealth) SubmitRemark(ctx context.Context, req *proto.SubmitRemarkRequest, resp *proto.SubmitRemarkResp... |
package onnx
import (
fmt "fmt"
"strings"
)
func (model *ModelProto) fixNames() {
layerTypeOccurrences := map[string]int{}
graph := model.GetGraph()
for _, n := range graph.Node {
if _, ok := layerTypeOccurrences[n.OpType]; !ok {
layerTypeOccurrences[n.OpType] = 0
}
layerTypeOccurrences[n.OpType] = lay... |
package fetcher
import (
"databaseConn"
"models"
"net/http"
"io/ioutil"
log "log"
"encoding/json"
"regexp"
"sync"
)
var threshold int = 5
type Posts struct {
Data struct{
Children []struct{
Kind string
Data models.Post
}
}
}
var wg sync.WaitGroup
func Execute() {
db := databaseConn.DB{}.GetDB()... |
package main
import (
"bufio"
"fmt"
"math/big"
"os"
)
func main() {
var reader = bufio.NewReader(os.Stdin)
var a1, a2, a3, a4 big.Int
fmt.Fscan(reader, &a1)
fmt.Fscan(reader, &a2)
fmt.Fscan(reader, &a3)
fmt.Fscan(reader, &a4)
var ret1 big.Int
if a1.Cmp(&a2) > 0 {
ret1 = a2
} else {
ret1 = a1
}
v... |
package nmxutil
import (
"sync"
)
type SRWaiter struct {
c chan error
token interface{}
}
type SingleResource struct {
acquired bool
waitQueue []SRWaiter
mtx sync.Mutex
}
func NewSingleResource() SingleResource {
return SingleResource{}
}
func (s *SingleResource) Acquire(token interface{}) error ... |
package server
import (
"fmt"
)
func Init(port int) {
r := NewRouter()
r.Run(fmt.Sprintf(":%d", port))
} |
package bst
import "errors"
//Insert add a new node to bst tree
func (t *Tree) Insert(data int) error {
if t.Root == nil {
t.Root = NewNode(data)
return nil
}
return t.Root.insertNode(data)
}
//Insert add node to a bst treer
func (n *Node) insertNode(data int) error {
if n == nil {
return errors.New("Cann... |
// Package config is used for storing and manipulating the plumber config.
// There should be, at most, a single instance of the plumber config that is
// passed around between various components.
//
// If running in cluster mode, config will write the config to NATS. If running
// locally, the config will be saved to ... |
package main
import (
"flag"
"os"
"fmt"
"stfl"
"bufio"
"time"
"exec"
"strconv"
)
type ServerInfo struct {
Server string
Port int
Nick string
}
func init() {
stfl.Init()
}
func main() {
info := ServerInfo{ "", 6666, "" }
flag.IntVar(&info.Port, "port", 6666, "IRC server port")
flag.StringVar(&info.Se... |
package endpoint
import (
"context"
guest "github.com/angryronald/guestlist/internal/guest/application"
// httpResponse "github.com/angryronald/guestlist/lib/net/http"
"github.com/go-kit/kit/endpoint"
)
func CountEmptySeats(application guest.Application) endpoint.Endpoint {
return func(ctx context.Context, req ... |
package cmd
import (
"context"
"os"
stencilv1 "github.com/odpf/stencil/server/odpf/stencil/v1"
"github.com/spf13/cobra"
"google.golang.org/grpc"
)
// DownloadCmd creates a new cobra command for download descriptor
func DownloadCmd() *cobra.Command {
var host, filePath string
var req stencilv1.DownloadDescrip... |
package fifth
import "fmt"
type Word struct {
Name string
IsImmediate bool
IsPrimitive bool
IsCompileOnly bool
PrimBody PrimBody
Body []*Word
pc int // program counter
}
type PrimBody func() error
func (w *Word) String() string {
s := ""
if w.IsPrimitive {
s += fmt.S... |
package main
import (
"bytes"
"encoding/json"
"time"
"context"
"errors"
"io"
"net/http"
)
var (
schemaVersions = map[string]bool{"0.1": true}
modelVersions = map[string]bool{"1.0": true}
)
type requestError struct {
SchemaVersionError string `json:"schema_version_error,omitempty"`
ModelVersionError s... |
package vrf
import (
"testing"
"github.com/ethereum/go-ethereum/common"
"github.com/stretchr/testify/assert"
)
var (
keyD = common.HexToHash("0x0fdcdb4f276c1b7f6e3b17f6c80d6bdd229cee59955b0b6a0c69f67cbf3943fa").Big()
keyHash = common.HexToHash("0x9fe62971ada37edbdab3582f8aec660edf7c59b4659d1b9cf321396b73918b... |
package config
import (
"github.com/spf13/viper"
)
const (
CacheTypeInMemory = "memory"
CacheTypeRedis = "redis"
BlockchainDatabaseInMemory = "memory"
BlockChainDatabaseLMDB = "lmdb"
)
type Config struct {
ListenPort int `mapstructure:"listen_port"`
ListenAddr string... |
package log
import (
"bufio"
"fmt"
"github.com/sirupsen/logrus"
"log/syslog"
"os"
"runtime"
"strings"
"github.com/api7/ingress-controller/conf"
)
var logEntry *logrus.Entry
func GetLogger() *logrus.Entry {
if logEntry == nil {
var log = logrus.New()
setNull(log)
log.SetLevel(logrus.DebugLevel)
if co... |
package main
import (
"encoding/json"
"fmt"
"io/ioutil"
"log"
"net/http"
"os"
"github.com/gorilla/handlers"
"github.com/gorilla/mux"
"github.com/go-pg/pg/v9"
)
// App interface for the full application
type App struct {
Router *mux.Router
DB *pg.DB
}
func checkAuth(r *http.Request) bool {
// This endpo... |
package lambdas_test
import (
"testing"
"github.com/life4/genesis/lambdas"
"github.com/matryer/is"
)
func TestAbs(t *testing.T) {
is := is.New(t)
is.Equal(lambdas.Abs(2), 2)
is.Equal(lambdas.Abs(-2), 2)
is.Equal(lambdas.Abs(0), 0)
is.Equal(lambdas.Abs(-1.2), 1.2)
}
func TestMin(t *testing.T) {
is := is.New... |
package main
import (
"bufio"
"fmt"
"log"
"math"
"os"
"strconv"
"strings"
)
// Head represents the head vertex of an edge, along with its length.
type Head struct {
head, length int
}
// Dijkstra takes a directed graph as input, and returns the shortest
// paths from the source vertex 1 to every other vertex... |
package main
import (
"github.com/gin-gonic/gin"
"net/http"
)
func logout(c *gin.Context) {
c.JSON(http.StatusOK, gin.H{
"logout": "success",
})
}
func login1(c *gin.Context) {
c.JSON(http.StatusOK, gin.H{
"login": "success",
})
}
func main() {
r := gin.Default()
userGroup := r.Group("/user")
{
userGro... |
package readconfig
import (
"gopkg.in/yaml.v2"
"io/ioutil"
"log"
)
// ConfigFileYaml 读取yaml格式的配置文件
type ConfigFileYaml struct {
Enabled bool `yaml:"enabled"` // yaml:yaml格式 Enabled:属性
Path string `yaml:"path"`
}
// ReadConfYaml 读取yaml格式的配置文件
func (conf *ConfigFileYaml) ReadConfYaml(path string) *ConfigFile... |
// Router module
// 菜单资源
package service
import (
"portal/util"
"portal/model"
"portal/database"
)
// Create router
func CreateRouter(r model.Route) (int, interface{}) {
// check router uniqueness
code, _ := database.UniqueRouter(r)
if code == 0 {
return 30001, "名称或地址已占用"
}
// check appid if parent not equa... |
package shared
func newRepeatingString(length int, value string) string {
result := ""
for i := 0; i <= length; i++ {
result = result + value
}
return result
}
|
package map_slice
import (
"reflect"
"testing"
)
func TestCrossover(t *testing.T) {
arr := []struct{
ns, xs, ys, r1, r2 []int
} {
{
[]int{1, 3},
[]int{1,2,3,4,5,6},
[]int{7,8,9,10,11,12},
[]int{1,8,9,4,5,6},
[]int{7,2,3,10,11,12},
},
{
[]int{1},
[]int {1,2,3},
[]int {10,11,12},
... |
package main
import (
"net/http"
"fmt"
)
func d(w http.ResponseWriter,r *http.Request){ //this is the signature of handler interface
//switch r.URL.Path {
fmt.Fprintln(w,"barks")
//case "/cat":fmt.Fprintln(w,"meows")
//}
}
func c(w http.ResponseWriter,r *http.Request){ //this is the signature of han... |
// This file was generated for SObject BusinessHours, API Version v43.0 at 2018-07-30 03:47:19.964149023 -0400 EDT m=+6.306992117
package sobjects
import (
"fmt"
"strings"
)
type BusinessHours struct {
BaseSObject
CreatedById string `force:",omitempty"`
CreatedDate string `force:",omitempty"`
Fri... |
package main
import (
"bufio"
"fmt"
"os"
"strconv"
)
// https://www.hackerrank.com/challenges/quicksort1
func main() {
next := func() func() int {
scan := bufio.NewScanner(os.Stdin)
scan.Split(bufio.ScanWords)
return func() int {
scan.Scan()
i, _ := strconv.Atoi(scan.Text())
return i
}
}()
l... |
// Copyright 2016, Google
//
// 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 writ... |
func Integer: numPrint (Integer: num, Integer: length)
{
num := 1000;
length := 5;
Integer: i, j, first, temp;
Integer : c;
temp := 999;
c := 20 + num * (length + 1); /* arithmatic expression */
println(c);
In >> i;
println(i);
while i > 0 :
{
/* this is a comment */
i:= i - 1;
if i = 1:{
prin... |
package cryptotrader
import (
"fmt"
"strings"
)
// TradeVolumeType represents the way to calculate the trade volume
type TradeVolumeType int
const (
// TVTFixed use a fixed volume (quote asset) for trading
TVTFixed TradeVolumeType = iota
// TVTPercent use a percentage of the available quote asset for trading
... |
package fizz
import (
"encoding/json"
"fmt"
"io/ioutil"
"net/http"
"net/http/httptest"
"net/url"
"os"
"reflect"
"sync"
"testing"
"time"
"github.com/gin-gonic/gin"
"github.com/gofrs/uuid"
"github.com/loopfz/gadgeto/tonic"
"github.com/stretchr/testify/assert"
"gopkg.in/yaml.v2"
"github.com/wI2L/fizz/o... |
package server
import "os"
func (h *handler) FilterItems(items []os.FileInfo) []os.FileInfo {
if h.shows == nil &&
h.showDirs == nil &&
h.showFiles == nil &&
h.hides == nil &&
h.hideDirs == nil &&
h.hideFiles == nil {
return items
}
filtered := make([]os.FileInfo, 0, len(items))
for _, item := range... |
package main
import "fmt"
func main() {
s := "Hello everybody!\n"
fmt.Printf(s)
change_string(s, 's')
}
// // err
// func main() {
// var a int
// var b int32
// b = a + a
// b = b + 5
// }
const (
a = iota
b
c string = "0"
)
func change_string(s string, change rune) {
// s := "hello"
c := []r... |
// Copyright 2018 Amazon.com, Inc. or its affiliates. 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. A copy of the
// License is located at
//
// http://aws.amazon.com/apache2.0/
//
// or in the "license"... |
package main
import (
"fmt"
"reflect"
)
func main() {
var num float64 = 1.2345
fmt.Println("old value of pointer:", num)
// 通过reflect.ValueOf获取num中的reflect.Value,注意,参数必须是指针才能修改其值
pointer := reflect.ValueOf(&num)
newValue := pointer.Elem()
fmt.Println("type of pointer:", newValue.Type... |
package functions
import (
"fmt"
"google.golang.org/grpc/codes"
"google.golang.org/grpc/status"
"k8s.io/apimachinery/pkg/api/errors"
)
func k8sToGRPCError(err error) error {
if errors.IsNotFound(err) {
return status.Error(codes.NotFound, "not found")
}
if errors.IsAlreadyExists(err) {
return status.Error... |
/*
Graded lexicographic order (grlex order for short) is a way of ordering words that:
First orders words by length.
Then orders words of the same size by their dictionary order.
For example, in grlex order:
"tray" < "trapped" since "tray" has length 4 while "trapped" has length 7.
"trap" < "tray" s... |
package req
const NameReq string = "NAME_REQ"
type NameForm struct {
Name string `json:"name"`
}
type IdForm struct {
ID int `json:"game_id"`
}
type TemplateReq struct {
Template string `json:"template"`
}
type ActionReq struct {
Action string `json:"action"`
}
|
package main
import (
"encoding/json"
"github.com/Shopify/sarama"
"github.com/astaxie/beego/logs"
"logAgent/config"
"logAgent/kafka"
"logAgent/logger"
"logAgent/tail"
)
func init() {
config.InitConfig()
logger.InitLogger()
}
type Msg struct {
IP string
Log string
}
func main() {
tailClient := tail.Init... |
package config
import(
"encoding/json"
"io/ioutil"
"util"
)
type StockHistSourceItem struct {
Id string `json: "id"`
Url string `json: "url"`
}
type StockHistSourceConfig struct {
Sources [] StockHistSourceItem `json: "sources"`
}
type StockHistManager struct {
Config StockHistSourceConf... |
package max_common_prefix
import "testing"
func TestSolve(t *testing.T) {
t.Log(longestCommonPrefix([]string{"flower", "flow", "flight"}))
t.Log(longestCommonPrefix([]string{"dog", "racecar", "car"}))
}
|
// Copyright (c) 2020 Blockwatch Data Inc.
// Author: alex@blockwatch.cc
package puller
import (
"context"
"github.com/zyjblockchain/sandy_log/log"
"sort"
"sync"
"tezos_index/chain"
model "tezos_index/puller/models"
util "tezos_index/utils"
"time"
)
const rankDefaultSize = 1 << 16
type AccountRankingEntry s... |
/*
Copyright 2021 The KubeVela 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, softw... |
package api
import (
"encoding/json"
"github.com/cloudfly/ecenter/pkg/account"
"github.com/cloudfly/ecenter/tools"
"github.com/cloudfly/mowa"
"github.com/pkg/errors"
"github.com/valyala/fasthttp"
)
func init() {
registerRoute("GET", "/v1/users", GetUsers, 0)
registerRoute("POST", "/v1/users", AddUser, 0)
r... |
// 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 parsing
import (
"github.com/s2gatev/sqlmorph/ast"
)
const (
RightWithoutJoinError = "Expected JOIN following RIGHT."
RightJoinWithoutTargetError = "RIGHT JOIN statement must be followed by a target class."
RightJoinWithoutOnError = "RIGHT JOIN statement must have an ON clause."
RightJoin... |
package initRouter
import (
"github.com/gin-gonic/gin"
"proxy_download/handler"
)
func SetupRouter() *gin.Engine {
router := gin.Default()
// 添加 Get 请求路由
router.GET("/", handler.IndexHandler)
mysql := router.Group("/mysql")
{
mysql.GET("/detail/:id", handler.MysqlDetail)
mysql.GET("/list", handler.MysqlLi... |
package api
import (
"encoding/json"
"io/ioutil"
"log"
"net/http"
"strconv"
"time"
"kumparan/constants"
"kumparan/repository"
"kumparan/service"
)
type Handler interface {
CreateNews(w http.ResponseWriter, r *http.Request)
GetNews(w http.ResponseWriter, r *http.Request)
}
type handler struct {
producer ... |
// Copyright 2020 The Reed Developers
// Distributed under the MIT software license, see the accompanying
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
package validation
import (
bm "github.com/reed/blockchain/blockmanager"
"github.com/reed/consensus/pow"
"github.com/reed/errors"
"github... |
package fractalnoise
import (
"github.com/lmbarros/sbxs_go_noise"
)
// Params contains additional parameters passed to the fractal noise generator
// constructors.
//
// If any of these values is zero, a sensible default value is used instead:
// Layers (4), Frequency (1.0), Lacunarity (2.0), Amplitude (1.0), Gain (... |
package scan
import (
"os"
"path/filepath"
"sync"
"time"
"github.com/mitro42/coback/catalog"
fsh "github.com/mitro42/coback/fshelper"
"github.com/spf13/afero"
)
type mockDoubleProgressBar struct {
count int64
size int64
countTotal int64
sizeTotal int64
incrByCount int
setTotalC... |
package main
import (
"errors"
"strconv"
"strings"
)
func ParseSettings(settingsFile string) error {
if rxpBotToken.FindStringSubmatch(settingsFile) != nil && rxpBotToken.FindStringSubmatch(settingsFile)[1] != "" {
botToken = strings.Trim(rxpBotToken.FindStringSubmatch(settingsFile)[1], " ")
} else {
return ... |
package alertmanager
import (
"bytes"
"encoding/json"
"io"
"net/http"
"net/http/httptest"
"testing"
"github.com/go-kit/kit/log"
"github.com/pkg/errors"
"github.com/prometheus/alertmanager/notify/webhook"
"github.com/prometheus/client_golang/prometheus"
"github.com/stretchr/testify/assert"
)
const validWeb... |
package grpc
import (
"context"
"google.golang.org/grpc/codes"
grpc_health "google.golang.org/grpc/health/grpc_health_v1"
"google.golang.org/grpc/status"
"github.com/pomerium/pomerium/internal/log"
)
type healthCheckSrv struct {
}
// NewHealthCheckServer returns a basic health checker
func NewHealthCheckServe... |
package ytrwrap
import (
"fmt"
"net/http"
"net/url"
"testing"
"github.com/stretchr/testify/assert"
)
func TestTr_DetectRU(t *testing.T) {
tr := createRealTestClientFromEnv()
lc, err := tr.Detect("мама мыла раму", nil)
assert.Nil(t, err, "err")
assert.Equal(t, RU, lc, "lc")
}
func TestTr_DetectEN(t *testin... |
package domain_test
import (
. "github.com/onsi/ginkgo"
. "github.com/onsi/gomega"
. "oneday-infrastructure/internal/pkg/authenticate/domain"
"oneday-infrastructure/mocks"
"oneday-infrastructure/tools"
"testing"
)
var tt *testing.T
var mockRepo *mocks.LoginUserRepo
func TestLogin(t *testing.T) {
tt = t
mock... |
// 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 lv2_rotate_matrix
import (
"fmt"
"log"
)
func PrintMatrix(nums [][]int, rowLen, colLen int) {
log.Println("==========")
for i := 0; i < rowLen; i++ {
for j := 0; j < colLen; j++ {
fmt.Printf("%5d ", nums[i][j])
}
fmt.Println()
}
log.Println("==========")
}
|
package rest
import (
"fmt"
"github.com/gin-gonic/contrib/ginrus"
"github.com/natefinch/lumberjack"
log "github.com/sirupsen/logrus"
"io"
"os"
"time"
)
const (
loggerFile = "/tmp/logger.log"
)
func setupLogger(s *server) {
if !fileExists(loggerFile) {
createFile()
}
// setup logger
lumberjackLogRotat... |
package medianheap_test
import (
"fmt"
"github.com/pietv/medianheap"
)
func ExampleIntMedianHeap() {
h := medianheap.New()
h.Add(-1)
h.Add(0)
h.Add(1)
fmt.Println(h.Median())
// Output: 0
}
|
package api
import (
"github.com/ch3lo/overlord/configuration"
"github.com/gorilla/mux"
"github.com/thoas/stats"
)
var routesMap = map[string]map[string]serviceHandler{
"GET": {
"/": getServices,
"/{service_id}": getServiceByServiceId,
"/{service_id}/{cluster}": getServiceByC... |
package timingwheel
import (
"context"
"log"
"sync"
"testing"
"time"
)
func waitCtxTimeout(ctx context.Context, timeout time.Duration) {
before := time.Now()
<-ctx.Done()
log.Printf("%v -> %v", timeout, time.Since(before))
}
func TestWithTimeout(t *testing.T) {
timeouts := []time.Duration{
10 * time.Milli... |
/*
Copyright (C) 2018 Synopsys, Inc.
Licensed to the Apache Software Foundation (ASF) under one
or more contributor license agreements. See the NOTICE file
distributed with this work for additional information
regarding copyright ownership. The ASF licenses this file
to you under the Apache License, Version 2.0 (the
"... |
// Copyright (C) 2018 Storj Labs, Inc.
// See LICENSE for copying information.
package main
import (
"flag"
"fmt"
"net"
"go.uber.org/zap"
"google.golang.org/grpc"
"storj.io/storj/pkg/netstate"
proto "storj.io/storj/protos/netstate"
"storj.io/storj/storage/boltdb"
)
var (
port int
dbPath string
prod ... |
package network
import (
"bytes"
"eos-network/config"
"time"
"unsafe"
)
type BlockRequest struct {
Id Sha256Type
LocalRetry bool
}
type BlockOrigin struct {
Id Sha256Type
Origin *Connection
}
type TransactionOrigin struct {
Id Sha256Type
Origin *Connection
}
type DispatchMgr struct {
jus... |
package main
import (
"crypto/tls"
"flag"
"fmt"
"net/http"
"net/url"
"os"
"strconv"
remoteworkflowapi "code.it4i.cz/lexis/wp4/alien4cloud-interface/client"
kclib "code.it4i.cz/lexis/wp4/keycloak-lib"
remoteapprovalapi "github.com/lexis-project/lexis-backend-services-interface-approval-system.git/client"
re... |
package apps
import (
"fmt"
"github.com/fd/forklift/util/syncset"
)
type (
domain_t struct {
Id string `json:"id,omitempty"`
Hostname string `json:"hostname"`
}
domain_set struct {
ctx *App
requested []string
current []string
domains map[string]*domain_t
}
)
func (app *App) sync_domain... |
package jira
type TestClient struct {
Config
jTasks map[string]*Task
returnError error
}
func (t *TestClient) Connect() error {
return nil
}
func (t *TestClient) GetUserTasks() (map[string]*Task, error) {
return t.jTasks, t.returnError
}
|
package main
import (
"encoding/json"
"flag"
"fmt"
"log"
"net/http"
"strings"
"time"
"github.com/prometheus/client_golang/prometheus"
"github.com/prometheus/client_golang/prometheus/promauto"
"github.com/prometheus/client_golang/prometheus/promhttp"
)
var (
awairAddress = flag.String("awair-address", "",... |
package main
import (
"fmt"
"math/rand"
"net/http"
"os"
"time"
)
func main() {
fmt.Println("starting the server")
client := &http.Client{}
rand.Seed(time.Now().UTC().UnixNano())
port := os.Getenv("PORT")
if port == "" {
port = "8080"
}
host := os.Getenv("HOST")
if port == "" {
port = "localhost"
... |
// Copyright 2021 Clivern. All rights reserved.
// Use of this source code is governed by the MIT
// license that can be found in the LICENSE file.
package definition
import (
"fmt"
"strings"
"testing"
"github.com/franela/goblin"
)
// TestUnitVault test cases
func TestUnitVault(t *testing.T) {
g := goblin.Gobl... |
package tests
import (
"log"
"math/rand"
"testing"
"time"
"github.com/almerlucke/kallos"
"github.com/almerlucke/kallos/generators"
)
func TestRandomWalk(t *testing.T) {
seed := time.Now().UTC().UnixNano()
rand.Seed(seed)
matrix := &generators.RandomWalk2DMatrix{
Values: []kallos.Values{
kallos.ToValu... |
package venti
import "testing"
func TestPackRoot(t *testing.T) {
r := Root{
Name: "foo",
Type: "bar",
Score: ZeroScore(),
BlockSize: 256,
Prev: ZeroScore(),
}
buf := make([]byte, RootSize)
if err := r.Pack(buf); err != nil {
t.Fatal(err)
}
rr, err := UnpackRoot(buf)
if err != n... |
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT license.
package common
import (
"fmt"
"sort"
"strings"
"github.com/blang/semver"
"github.com/pkg/errors"
)
// AllKubernetesSupportedVersions is a hash table of all supported Kubernetes version strings
// The bool value indi... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.