text stringlengths 11 4.05M |
|---|
package routes
type config struct {
Routes []r `yaml:"routes"`
}
type r struct {
Rule string `yaml:"rule"`
Method []string `yaml:"method"`
Action string `yaml:"action"`
}
|
package main
import (
"github.com/modcloth/docker-builder/builder"
"github.com/modcloth/docker-builder/parser"
"github.com/codegangsta/cli"
"github.com/modcloth/queued-command-runner"
)
func build(c *cli.Context) {
builder.SkipPush = c.Bool("skip-push")
builderfile := c.Args().First()
if builderfile == "" {
... |
package structures
import "github.com/goodwine/yaaji/tokenizer"
// Structure is Node in the tree of code, probably not the best name :/
// This interface must be implemented by pointers.
type Structure interface {
Add(Structure) Structure
Parent() Structure
setParent(Structure)
Children() []Structure
String() st... |
package manifests
import (
"path/filepath"
"github.com/pkg/errors"
"github.com/openshift/installer/pkg/asset"
"github.com/openshift/installer/pkg/asset/installconfig"
"github.com/openshift/installer/pkg/asset/manifests/aws"
"github.com/openshift/installer/pkg/asset/manifests/azure"
"github.com/openshift/insta... |
package interf
import (
"net/http"
entity "silverfish/silverfish/entity"
"github.com/PuerkitoBio/goquery"
)
// INovelFetcher export
type INovelFetcher interface {
Match(url *string) bool
FetchDoc(url *string) (*goquery.Document, error)
IsSplit(doc *goquery.Document) bool
Filter(raw *string) *string
GetChap... |
package node
import (
"fmt"
"github.com/ethereum/go-ethereum/common"
"github.com/hyperorchidlab/go-miner-pool/microchain"
"sync"
"time"
)
const (
InitBucketSize = 1 << 24 //16M
RechargePieceSize = 1 << 22 //4M
MaxLostRechargeReq = 2
ConnectionBufSize = 1 << 20
)
var (
ErrNoPacketBalance = fmt.Errorf(... |
package jsonio
type internalNoOp struct {}
func (internalNoOp) Close() error {
return nil
}
func (internalNoOp) ReadJSON(interface{}) error {
return nil
}
func (internalNoOp) WriteJSON(interface{}) error {
return nil
}
|
package main
import (
"bufio"
"fmt"
"net"
"os"
"strings"
)
func main() {
//1.与server端建立连接
con, err := net.Dial("tcp", "127.0.0.1:20000")
if err != nil {
fmt.Printf("connet to server wrong,err:%v\n", err)
return
}
//2.发送数据
reader := bufio.NewReader(os.Stdin)
for {
//发送数据
fmt.Print("请输入消息:")
mes, ... |
package common
import (
"container/list"
log "github.com/cihub/seelog"
"os"
"time"
)
type dealElemRs struct {
dealElem
t *taskManagerRS
}
type taskManagerRS struct {
l *list.List
/* if we add task node such as push back or move back, modify it */
lIter *list.Element
/* sync changes with leftGorutines */
d... |
package query
import (
"regexp"
"bitbucket.org/matchmove/go-tools/secure"
)
// Clean removes aesthetic characters
func Clean(query string) string {
r := regexp.MustCompile(`\s+`)
return r.ReplaceAllString(query, " ")
}
// Stub creates 32-character stub
func Stub(query string) string {
return secure.MD5(Clean(q... |
/**
Write a function to delete a node in a singly-linked list. You will not be given access to the head of the list, instead you will be given access to the node to be deleted directly.
It is guaranteed that the node to be deleted is not a tail node in the list.
**/
/**
* Definition for singly-linked list.
* t... |
package algorithm
import (
"bufio"
"bytes"
"fmt"
"io"
"os"
"testing"
"github.com/hnnyzyf/go-stl/container/queue"
"github.com/hnnyzyf/go-stl/container/value"
. "gopkg.in/check.v1"
)
// Hook up gocheck into the "go test" runner.
func Test(t *testing.T) { TestingT(t) }
type MySuite struct {
ac *Dart
text i... |
package handlers
import (
"fmt"
"net/http"
"github.com/Yangshuting/golang_model/lib"
"github.com/Yangshuting/golang_model/model"
"github.com/labstack/echo"
)
func NewCommands(c echo.Context) error {
cc := c.Get("cc").(*lib.Cusctx)
user := lib.GetUser(c).(*model.KuaiMaoUser)
command := c.QueryParam("command")... |
// Copyright 2017 Google 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... |
package fakes
import (
bmagentclient "github.com/cloudfoundry/bosh-micro-cli/deployer/agentclient"
bmas "github.com/cloudfoundry/bosh-micro-cli/deployer/applyspec"
)
type FakeAgentClient struct {
PingResponses []pingResponse
PingCalledCount int
StopCalled bool
stopErr error
ApplyApplySpec bmas.ApplySpec... |
package models
import (
"fmt"
"github.com/jinzhu/gorm"
"github.com/linkedlocked/webapp/database"
)
type Gateway struct {
gorm.Model
Name string
Lon float64
Lat float64
PrivateIdentifier string `gorm:"type:varchar(100);unique_index"`
}
type Pole struct {
gorm.Model
G... |
package feedback
type TransportRoutes struct {
GetFeedbackOptionsAPI HTTPTransportInterface
SubmitFeedbackAPI HTTPTransportInterface
}
func MakeTransportRoutes(service FeedbackServiceInterface) (TransportRoutes, error) {
defaultHTTPTransport := DefaultHTTPTransport{service}
return TransportRoutes{
GetFeedb... |
// Copyright 2019 Leandro Akira Omiya Takagi. All rights reserved.
// Use of this source code is governed by a MIT-style
// license that can be found in the LICENSE file.
package unio
import (
"github.com/go-bongo/bongo"
"github.com/labstack/echo"
"github.com/labstack/gommon/log"
"net/url"
"reflect"
"s... |
package bitcask
import (
"encoding/binary"
"errors"
"hash/crc32"
"io"
)
const (
recordHeaderSz = 20
)
type record struct {
tstamp int64
key string
value []byte
}
func serialize(r *record) ([]byte, error) {
k := []byte(r.key)
// crc32 + tstamp64 + keysize32 + valuesize32 + key + value
sz := 4*5 + len(... |
// Copyright (c) 2013-2016 The btcsuite developers
// Use of this source code is governed by an ISC
// license that can be found in the LICENSE file.
package keystore
import (
"bytes"
"crypto/rand"
"reflect"
"testing"
"github.com/btcsuite/btcd/btcec/v2"
"github.com/btcsuite/btcd/btcec/v2/ecdsa"
"github.com/bt... |
package dandler
import (
"fmt"
"io"
"log"
"math/rand"
"net/http"
"os"
"path"
"path/filepath"
"time"
"github.com/jakdept/dir"
)
// Split allows the routing of one handler at /, and another at all locations below /.
func Split(root, more http.Handler) http.Handler {
return splitHandler{bare: root, more: mor... |
package repo
import (
"proximity/config"
"proximity/models"
"proximity/pkg/clients/db"
"go.mongodb.org/mongo-driver/bson"
)
const userColNmae = "badwords"
// UserRepoInterface ..
type UserRepoInterface interface {
Insert(u models.User) error
GetOne(userName string) (*models.User, error)
}
// NewUserRepo Crea... |
package routers
import (
"github.com/gingerxman/eel"
"github.com/gingerxman/eel/handler/rest/console"
"github.com/gingerxman/eel/handler/rest/op"
"github.com/gingerxman/ginger-product/rest/area"
"github.com/gingerxman/ginger-product/rest/cart"
"github.com/gingerxman/ginger-product/rest/dev"
"github.com/gingerxm... |
package main
import (
"fmt"
)
func main() {
w := []int{1, 2, 3, 4, 5, 6, 7, 8, 9}
fmt.Println(w)
w1 := ioo(w...)
fmt.Println(w1)
w2 := evensum(ioo, w...)
fmt.Println(w2)
w3 := odd(ioo, w...)
fmt.Println(w3)
}
func ioo(s ...int) int {
total := 0
for _, v := range s {
total += v
}
return total
}
func e... |
package main
import (
"encoding/json"
"fmt"
"io/ioutil"
)
type Mapping struct {
Exchange string
Queue string
RoutingKey string
WorkerQueue string
WorkerClass string
}
type configuration struct {
Mappings []Mapping
Rabbitmq RabbitConfiguration
}
type RabbitConfiguration struct {
Url string
}
fu... |
package wzsd
import (
"log"
"github.com/nats-io/nats.go"
)
type WzStateDaemonEvents struct {
}
func (wz *WzStateDaemonEvents) onConsoleEvent(m *nats.Msg) {
log.Println("received from console", len(m.Data), "bytes")
}
func (wz *WzStateDaemonEvents) onResponseEvent(m *nats.Msg) {
log.Println("received from respo... |
package libkv
import (
"errors"
"testing"
"github.com/golang/mock/gomock"
"github.com/serverless/event-gateway/event"
"github.com/serverless/event-gateway/function"
"github.com/serverless/event-gateway/metadata"
"github.com/serverless/event-gateway/mock"
"github.com/serverless/libkv/store"
"github.com/stretc... |
package mgr
import (
"testing"
"github.com/jchprj/GeoOrderTest/cfg"
)
func BenchmarkGenerateOrderID(b *testing.B) {
var currentID = autoID
var result int64
for i := 0; i < b.N; i++ {
result = generateOrderID()
}
expected := currentID + int64(b.N)
if result != expected {
b.Errorf("unexpected result: got %... |
package logging
import (
"net/http"
)
type responseWriter struct {
http.ResponseWriter
status int
wroteHeader bool
}
func (rw *responseWriter) Status() int {
return rw.status
}
func (rw *responseWriter) WriteHeader(code int) {
if rw.wroteHeader {
return
}
rw.status = code
rw.ResponseWriter.WriteHea... |
package smartcrop
import "log"
// The Logger interface
type Logger interface {
Debugf(format string, args ...interface{})
Printf(format string, args ...interface{})
}
type defaultLogger struct {
Debug bool
}
func (l *defaultLogger) Debugf(format string, args ...interface{}) {
if l.Debug {
log.Printf(format, a... |
package delicious
import (
"errors"
"io"
"io/ioutil"
"log"
"net/http"
"net/url"
"os"
"regexp"
"strings"
"time"
"github.com/oz/miniporte/link"
)
const (
DeliciousPostUrl = "https://api.del.icio.us/v1/posts/add"
HttpTimeout = 5 // Wait at most 5 seconds for Delicious.
ServiceName = "delicious"
... |
package strucct
type PlayerExtro struct {
Id int64 `xorm:"not null pk autoincr BIGINT(20)"`
PlayerId int64 `xorm:"not null default 0 index BIGINT(20)"`
OffensiveRebound int `xorm:"not null default 0 INT(11)"`
DefensiveRebound int `xorm:"not null default 0 INT(11)"`
ShotAttempt int ... |
package router
import (
"github.com/gin-gonic/gin"
"log"
)
func GetJson(c *gin.Context) {
log.Println("")
c.JSON(200, gin.H{"code": 200, "message": "pongv2.0 ping"})
}
func GetNormal(c *gin.Context) {
log.Println("")
c.Status(200)
}
func GetNormalString(c *gin.Context) {
log.Println("")
c.String(200, "%v", ... |
package cli
import (
"context"
"fmt"
"github.com/bonedaddy/go-defi/bclient"
"github.com/bonedaddy/go-defi/config"
"github.com/urfave/cli/v2"
)
func transactionsCommand() *cli.Command {
return &cli.Command{
Name: "transactions",
Aliases: []string{"txs"},
Usage: "command for workign with transactions"... |
package gosnowth
import (
"bytes"
"context"
"encoding/json"
"encoding/xml"
"net/http"
"net/http/httptest"
"net/url"
"strings"
"testing"
"github.com/google/uuid"
)
const topologyTestData = `[
{
"id": "1f846f26-0cfd-4df5-b4f1-e0930604e577",
"address": "10.8.20.1",
"port": 8112,
"apiport": 8112,
"w... |
package main
import (
"context"
"fmt"
"io"
"log"
"net"
"sync"
"google.golang.org/grpc/codes"
"google.golang.org/grpc/status"
pb "github.com/todai88/thesis/Thesis-GRPC/proto"
"google.golang.org/grpc"
"google.golang.org/grpc/reflection"
)
type User struct {
name, ip string
id int
}
type MessageCha... |
package day20
func BubbleSort(arr []int) ([]int, int) {
sorted, totalSwaps := arr, 0
for j := 0; j < len(sorted); j++ {
swaps := 0
for i := 0; i < len(sorted)-1; i++ {
if sorted[i] > sorted[i+1] {
sorted[i], sorted[i+1] = sorted[i+1], sorted[i]
swaps++
}
}
if swaps == 0 {
break
}
totalSw... |
/*
# -*- coding: utf-8 -*-
# @Author : joker
# @Time : 2020-07-27 09:20
# @File : lt_143_Reorder_List.go
# @Description :
# @Attention :
*/
package v0
/*
对链表重排序
最简单的方式就是 依次从头部和尾部获取数据拼接
1. 直接遍历存储下标即可
*/
func reorderList(head *ListNode) {
nodes := make([]*ListNode, 0)
for walkerNode := head; nil != walkerNode; ... |
package server
import (
pb "api/talk_cloud"
"context"
"db"
"log"
"pkg/user_friend"
)
// 添加好友 TODO 暂时不等对方确认加不加好友,直接给你加上
func (serv *TalkCloudServiceImpl) AddFriend(ctx context.Context, req *pb.FriendNewReq) (*pb.FriendNewRsp, error) {
log.Printf("Add friend: uid: %d, friend_id:%d", req.Uid, req.Fuid)
resp := &... |
package scan
import (
"fmt"
"log"
"os"
"path/filepath"
"sync"
"time"
"github.com/mitro42/coback/catalog"
"github.com/pkg/errors"
"github.com/spf13/afero"
)
// FileSystemDiff contains the details of catalog checked against a folder in the file system.
// Ok (set of paths): these files have the same size, mod... |
/*
Copyright (C) 2018 Intel Corporation
SPDX-License-Identifier: Apache-2.0
This file contains code from the Go distribution, under:
SPDX-License-Identifier: BSD-3-Clause
More specifically, this file is a copy of net/rpc/json/client.go,
updated to encode messages such that SPDK accepts them (jsonrpc,
params, etc.).
... |
package main
import (
"io/ioutil"
"net/http"
"github.com/tidwall/limiter"
)
func main() {
// Create a limiter for a maximum of 10 concurrent operations
l := limiter.New(10)
http.HandleFunc("/work", func(w http.ResponseWriter, r *http.Request) {
input, err := ioutil.ReadAll(r.Body)
if err != nil {
http... |
package clickhouse
import (
"database/sql"
"errors"
"fmt"
"net/url"
"os"
"path"
"path/filepath"
"strconv"
"strings"
"syscall"
"time"
"github.com/AlexAkulov/clickhouse-backup/config"
"github.com/AlexAkulov/clickhouse-backup/pkg/metadata"
"github.com/apex/log"
_ "github.com/ClickHouse/clickhouse-go"
"g... |
package auth
import (
"encoding/hex"
"github.com/gin-gonic/gin"
"github.com/zhuiyi1997/go-gin-api/app/controller/param_bind"
"github.com/zhuiyi1997/go-gin-api/app/controller/param_verify"
"github.com/zhuiyi1997/go-gin-api/app/model"
"github.com/zhuiyi1997/go-gin-api/app/util/bind"
"github.com/zhuiyi1997/go-gin-... |
package server
import (
"context"
"crypto/sha256"
"log"
"github.com/troydai/blocks/echo/proto"
"google.golang.org/grpc/metadata"
)
type (
impl struct {
proto.UnimplementedEchoServerServer
}
)
func New() (proto.EchoServerServer, error) {
return &impl{}, nil
}
func (s *impl) Echo(ctx context.Context, req *... |
package main
import (
"context"
"errors"
"github.com/aws/aws-lambda-go/lambda"
)
func main() {
lambda.Start(lambdaHandler)
}
// Handles the incoming request from trigger
func lambdaHandler(ctx context.Context, request sumRequest) (resp interface{}, err error) {
total, err := sum(request.ParamOne, request.Param... |
package main
import (
"bufio"
"fmt"
"os"
"unicode"
)
func main() {
var T int
r := bufio.NewReader(os.Stdin)
for fmt.Fscan(r, &T); T > 0; T-- {
var a, b string
fmt.Fscan(r, &a, &b)
output := Solve(a, b)
if output {
fmt.Println("YES")
} else {
fmt.Println("NO")
}
}
}
func Solve(a, b string) b... |
package mapxml
import (
"fmt"
"testing"
)
func TestReadTiledMap(t *testing.T) {
tm := ReadTiledMapFile("testdata/Voyager.tmx")
if len(tm.Properties.Properties) != 6 {
t.Error(`not 6 properties`)
}
if tm.Width != 516 {
t.Error(`wrong width`)
}
if !tm.Infinite {
t.Error(`not infinite`)
}
for _, ts := ... |
// Copyright (C) 2015 Scaleway. All rights reserved.
// Use of this source code is governed by a MIT-style
// license that can be found in the LICENSE.md file.
package commands
import (
"bytes"
"testing"
. "github.com/smartystreets/goconvey/convey"
)
func TestVersion(t *testing.T) {
Convey("Testing Version()", ... |
package main
import (
"fmt"
)
// 213. 打家劫舍 II
// 你是一个专业的小偷,计划偷窃沿街的房屋,每间房内都藏有一定的现金。这个地方所有的房屋都围成一圈,这意味着第一个房屋和最后一个房屋是紧挨着的。同时,相邻的房屋装有相互连通的防盗系统,如果两间相邻的房屋在同一晚上被小偷闯入,系统会自动报警。
// 给定一个代表每个房屋存放金额的非负整数数组,计算你在不触动警报装置的情况下,能够偷窃到的最高金额。
// https://leetcode-cn.com/problems/house-robber-ii/
func main() {
fmt.Println(rob([]int{2, 3, ... |
// Copyright 2020 Google LLC
//
// 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
//
// https://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in wri... |
package main
import (
"fmt"
"os"
)
func main() {
fmt.Println("Comprobando directorios introducidos por parámetro")
//Recibimos un array de parámetros, la primera posición es la ruta del script
if len(os.Args) < 2 {
println("Debes introducir los directorios")
os.Exit(2)
}
directorios := os.Args
// Validamo... |
package main
import "testing"
func TestMyTot(t *testing.T) {
type test struct {
data []int
answer int
}
tests := []test{
test{[]int{44, 44}, 88},
test{[]int{21, 44}, 65},
test{[]int{-2, 4}, 2},
test{[]int{-11, 66, 0}, 55},
}
for _, v := range tests {
x := myTot(v.data...)
if x != v.answer {
... |
// Copyright 2018 The go-interpreter Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
package main
import (
"bytes"
"flag"
"io/ioutil"
"testing"
)
func TestProcess(t *testing.T) {
opts := []string{"-h", "-x", "-s", "-d"}
err :... |
package temporary
//DriverTrackers parse json
type DriverTrackers struct {
Status int
Code int
Message string
Data DataStruct
}
// DataStruct json data
type DataStruct struct {
DriverID int64 `json:"driverId"`
DriverName string
Locations []Location
}
// Location location data
type Location struct {
... |
package main
import (
"github.com/godbus/dbus"
)
func GetVisibleNetworks() ([]string, error) {
conn, err := dbus.SystemBus()
if err != nil {
panic(err)
}
obj := conn.Object("org.freedesktop.NetworkManager", "/org/freedesktop/NetworkManager")
networkDevices := []dbus.ObjectPath{}
if err := obj.Call("org.fre... |
package main
import (
"errors"
"fmt"
"github.com/iNamik/go_flag"
"strings"
"time"
)
type flag_t struct {
MyBool bool `name:"bool" usage:"a bool, as defined by strconv.ParseBool"`
MyInt int `name:"int" usage:"an int"`
MyInt64 int64 `nam... |
package main
import "fmt"
func main() {
fmt.Println(0)
fmt.Println(1)
fmt.Println(3)
fmt.Println(4)
fmt.Println(5)
}
|
package main
import (
"encoding/json"
"fmt"
"log"
"net/http"
"os"
"strings"
"time"
flags "github.com/jessevdk/go-flags"
graceful "gopkg.in/tylerb/graceful.v1"
)
var Options = struct {
Host string `long:"host" short:"h" description:"hostname" default:"localhost" env:"HOST"`
Port int `long:"port" short:"... |
package scraper
import (
"encoding/json"
"regexp"
"strings"
"unicode"
"unicode/utf8"
"github.com/PuerkitoBio/goquery"
"github.com/apex/log"
)
// StringValFromCSSPath tries to get a string from a node
func StringValFromCSSPath(path []string, node *goquery.Selection) (string, bool) {
var val str... |
/*
# -*- coding: utf-8 -*-
# @Author : joker
# @Time : 2021/9/26 9:10 上午
# @File : lt_118_杨辉三角.go
# @Description :
# @Attention :
*/
package offer
func generate(numRows int) [][]int {
if numRows == 0 {
return nil
}
ret := make([][]int, numRows)
for index := range ret {
ret[index] = make([]int, index+1)
ret[i... |
package user
import "rest_server/pkg/database"
type Module struct {
s service
H *Handler
}
func New(db database.DataStore) *Module {
s := Service{db: db}
return &Module{s: &s, H: &Handler{user: &s}}
}
|
package rest
import (
"github.com/jinmukeji/jiujiantang-services/pkg/rest"
proto "github.com/jinmukeji/proto/v3/gen/micro/idl/partner/xima/core/v1"
"github.com/kataras/iris/v12"
)
// ReadPushNotification 阅读通知的body
type ReadPushNotification struct {
PnID int32 `json:"pn_id"`
}
// PushNotifications 通知
type PushNo... |
package main
import (
"fmt"
"os"
"github.com/qlova/script"
"github.com/qlova/script/language"
"github.com/qlova/script/runtime"
)
func main() {
var Conditionals = func(q script.Ctx) {
q.Main(func() {
q.IfL(true, func() {
q.PrintL("This will run")
}).ElseIfL(false, func() {
q.PrintL("This will n... |
package humphrey
import (
"encoding/xml"
"fmt"
"net/url"
)
// Station stubs out the BART Station interface
type Station struct {
Abbreviation string `xml:"abbr"`
Name string `xml:"name"`
Latitude float32 `xml:"gtfs_latitude"`
Longitude float32 `xml:"gtfs_longitude"`
Address string `xml:... |
package cryptography
import (
"crypto/aes"
"crypto/cipher"
"crypto/md5"
"crypto/rand"
"encoding/base64"
"encoding/hex"
"errors"
"io"
"os"
)
//HashString func
func HashString(s string) string {
hasher := md5.New()
hasher.Write([]byte(s))
return hex.EncodeToString(hasher.Sum(nil))
}
//EncryptString func
fu... |
package main
import "github.com/luciancaetano/arch-v/vm"
func main() {
v := vm.New()
v.Run()
}
|
package models
type Partner struct {
Id int `json:"id"`
Name string `json:"name"`
Website string `json:"website"`
LogoUrl string `json:"logoUrl"`
}
type Partners []Partner
|
package kuki
import (
"fmt"
"time"
"net/url"
"github.com/bwmarrin/discordgo"
"github.com/valyala/fasthttp"
"github.com/valyala/fastjson"
)
var client = &fasthttp.Client{}
func chatbot(session *discordgo.Session, msg *discordgo.MessageCreate) {
if msg.Author.Bot {
return
}
respons... |
// 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_tree_builder
* @Version: 1.0.0
* @Date: 2020/4/10 15:47
*/
package behavior_tree
import (
"fmt"
... |
package main
import (
"fmt"
"io/ioutil"
"math"
"os"
"strconv"
"strings"
)
type coord struct {
x, y, z int
}
type particle struct {
p, v, a coord
collided bool
}
func (part particle) fromProps(point []string, velocity []string, acc []string) particle {
p := coord{strToInt(point[0]), strToInt(point[1]), st... |
package phone_dao
type Person struct{
PId int32
Name string
Phone string
Tel string
Mail string
Position string
TeamId int32
TeamName string
DeptId int32
DeptName string
}
/*
select p.p_id,p.p_name,p.p_phone,p.p_tel,
p.p_mail ,p.p_position,p.t_id,t.t_name,
p.d_id,d.d_name
from person p,d... |
package engine
import (
"fmt"
"golang.org/x/exp/shiny/screen"
"image"
"sync"
"time"
)
// Anim is an animated image. An Anim can also be a static image by
// simply having a single frame. An Anim is normally initialized by a
// State.
type Anim struct {
image screen.Texture
cur image.Rectangle
// TODO: Find... |
// Copyright 2020 PingCAP, Inc.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to i... |
package utils
import (
"bytes"
"encoding/gob"
"encoding/json"
"fmt"
"io"
"io/ioutil"
"net/http"
"os"
"strings"
)
func MustEncodeJSON(v interface{}) []byte {
buf := bytes.NewBuffer(nil)
err := json.NewEncoder(buf).Encode(v)
if err != nil {
panic(err)
}
return buf.Bytes()
}
func ParseJSONFile(filename ... |
package client
import (
"bytes"
"container/ring"
"errors"
"fmt"
"io/ioutil"
"modules/app"
"modules/services/conn"
"modules/services/script"
"path/filepath"
"strings"
"sync"
"time"
"github.com/herb-go/herbgo/util/config/tomlconfig"
"github.com/jarlyyn/ansi"
"golang.org/x/text/encoding/japanese"
"golan... |
package collectors
import (
"bufio"
"encoding/json"
"fmt"
"os"
"strconv"
"strings"
"time"
cclog "github.com/ClusterCockpit/cc-metric-collector/pkg/ccLogger"
lp "github.com/ClusterCockpit/cc-metric-collector/pkg/ccMetric"
)
//
// CPUFreqCollector
// a metric collector to measure the current frequency of the... |
package main
import (
"image/gif"
"os"
"log"
)
func handleError (err error, message string) {
if err != nil {
log.Fatal(message)
}
}
func main () {
if len(os.Args) < 2 {
log.Fatal("Infile/Outfile path not provided")
}
// Reading and parsing the input GIF
infile, e... |
package main
import "fmt"
func main() {
var a, b, c int
fmt.Scanf("%d", &a)
fmt.Scanf("%d", &b)
fmt.Scanf("%d", &c)
fmt.Printf("A = %d, B = %d, C = %d\n", a, b, c)
fmt.Printf("A = %10d, B = %10d, C = %10d\n", a, b, c)
fmt.Printf("A = %010d, B = %010d, C = %010d\n", a, b, c)
fmt.Printf("A = %-10d, B = %-10d,... |
package api2localdiff
import (
"github.com/spf13/pflag"
"sigs.k8s.io/kpng/localsink"
)
type Config struct {
NodeName string
}
func (c *Config) BindFlags(flags *pflag.FlagSet) {
flags.StringVar(&c.NodeName, "node-name", "", "Node name override")
}
type Sink = localsink.Sink
type Job struct {
Sink Sink
}
|
package domain
type BasketItem struct {
Product *Product
Quantity int
}
|
package tumblr
// Root is response root
type Root struct {
Meta Meta
Response Response
}
// Meta is meta data struct
type Meta struct {
Status int
Msg string
}
// Response is tumblr response struct
type Response struct {
Blog Blog
Posts []Post
}
// Blog is tumbler blog struct
type Blog struct {
Title... |
package handlers
import (
"GameReviews/servers/gateway/models/users"
"GameReviews/servers/gateway/sessions"
"encoding/json"
"net/http"
"path"
"strconv"
"strings"
"time"
)
//TODO: define HTTP handler functions as described in the
//assignment description. Remember to use your handler context
//struct as the re... |
package store
import (
"hash/crc32"
"os"
"github.com/bwmarrin/snowflake"
)
func NewSnowflake() (*snowflake.Node, error) {
hostname, err := os.Hostname()
if err != nil {
return nil, err
}
checksum := crc32.ChecksumIEEE([]byte(hostname))
nodeID := checksum % 1024
return snowflake.NewNode(int64(nodeID))
}
|
package sudoku
import (
"testing"
)
func TestSubsetCellsWithNPossibilities(t *testing.T) {
grid, err := MutableLoadSDKFromFile(puzzlePath("nakedpair3.sdk"))
if err != nil {
t.Log("Failed to load nakedpair3.sdk")
t.Fail()
}
results := subsetCellsWithNPossibilities(2, grid.Col(DIM-1))
if len(results) != 1 {
... |
package main
import (
"log"
"os"
"github.com/spf13/cobra"
)
var (
kubeconfig string
configContext string
ignoreError bool
version string
)
func main() {
log.SetOutput(os.Stderr)
log.SetFlags(log.Ldate | log.Ltime)
cmd := rootCmd(os.Args[1:])
if err := cmd.Execute(); err != nil {
os.Exit(1)
... |
package main
import (
"errors"
"fmt"
"sync"
"sync/atomic"
"time"
"github.com/disq/werify/cmd/werifyd/checkers"
"github.com/disq/werify/cmd/werifyd/pool"
t "github.com/disq/werify/cmd/werifyd/types"
wrpc "github.com/disq/werify/rpc"
)
const rpcOperationTimeout = 30 * time.Second
// OperationStatusCheck is t... |
package main
import (
"fmt"
"github.com/helioguardabaxo/livro-a-linguagem-de-programacao-go/ch2/tempconv"
)
func main() {
fmt.Println(tempconv.CToF(tempconv.BoilingC))
}
|
package main
import (
"github.com/webability-go/xdominion"
"testing"
)
func TestQueryMY(t *testing.T) {
xdominion.DEBUG = true
// Test 1: assign a simple parameter string with some comments
// Be sure the database exists or have an error
/*
// Install postgres server and client on your server
UNIX> creat... |
//Copyright (c) 2017 Phil
package apollo
import (
"testing"
"github.com/stretchr/testify/suite"
)
type TestConfigSuite struct {
suite.Suite
}
func (ts *TestConfigSuite) TestNewConf() {
var tcs = []struct {
name string
wantErr bool
}{
{
name: "fakename",
wantErr: true,
},
{
name: "./... |
//go:build tools
// +build tools
// Official workaround to track tool dependencies with go modules:
// https://github.com/golang/go/wiki/Modules#how-can-i-track-tool-dependencies-for-a-module
package tools
import (
_ "github.com/daixiang0/gci" // dependency of hack/go-fmt.sh
// used to generate mocks
_ "github.co... |
/*
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 "License"); you may not use this fi... |
package testdata
import (
"github.com/frk/gosql"
"github.com/frk/gosql/internal/testdata/common"
)
type DeleteWithResultSingleAfterScanQuery struct {
_ gosql.Relation `rel:"test_user:u"`
Where struct {
Id int `sql:"u.id"`
}
Result *common.User2
}
|
package day13
import (
"testing"
"github.com/stretchr/testify/require"
)
func TestPart1(t *testing.T) {
busIds, remainders, err := parseBusIDs("7,13,x,x,59,x,31,19")
require.NoError(t, err)
require.Equal(t, []int{7, 13, 59, 31, 19}, busIds)
require.Equal(t, []int{0, 1, 4, 6, 7}, remainders)
id, departure, err... |
package pascal
import (
"testing"
"github.com/google/go-cmp/cmp"
)
func TestGenerate(t *testing.T) {
testCases := map[string]struct {
output [][]int
input int
}{
"Example 1": {
input: 5,
output: [][]int{{1}, {1, 1}, {1, 2, 1}, {1, 3, 3, 1}, {1, 4, 6, 4, 1}},
},
"Example 2": {
input: 1,
o... |
package main
import (
"encoding/csv"
"flag"
"io"
"log"
"math/rand"
"os"
"strings"
)
var (
fileTypeFlag = flag.String("type", "csv", "File type (csv, json).")
fieldsFlag = flag.String("fields", "", "Comma-separated fields to obfuscate.")
)
func main() {
flag.Parse()
switch *fileTypeFlag {
case "csv":
... |
package engine
import (
"fmt"
"net"
"github.com/coreos/go-iptables/iptables"
)
const (
inputChain = "INPUT"
// we use our own chain to keep things seperated. It will be cleared and
// removed on teardown.
contrackrChain = "contrackr"
// This is the default table, it contains the built-in chains INPUT
// (fo... |
package exec
const (
GasQuickStep uint64 = 2
GasFastestStep uint64 = 3
GasFastStep uint64 = 5
GasMidStep uint64 = 8
GasSlowStep uint64 = 10
GasExtStep uint64 = 20
GasReturn uint64 = 0
GasStop uint64 = 0
GasContractByte uint64 = 200
)
func constGasFunc(gas uint64) gasFunc {
ret... |
package rpcd
import (
"io"
"github.com/Cloud-Foundations/Dominator/lib/log"
"github.com/Cloud-Foundations/Dominator/lib/objectserver"
"github.com/Cloud-Foundations/Dominator/lib/srpc"
"github.com/Cloud-Foundations/tricorder/go/tricorder"
"github.com/Cloud-Foundations/tricorder/go/tricorder/units"
)
type Config... |
package util
import (
"errors"
"fmt"
"regexp"
"strconv"
"strings"
)
var ERR_NOT_FOUND = errors.New("not found")
func GetHighestVersionWithFilter(versions []string, filter string) (string, error) {
targetTag := ""
targetVer := int64(0)
patt, err := regexp.Compile(fmt.Sprintf("^%s$", strings.Replace(regexp.Qu... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.