text stringlengths 11 4.05M |
|---|
package vsphere
import (
"github.com/openshift/installer/pkg/types"
typesvsphere "github.com/openshift/installer/pkg/types/vsphere"
)
// Metadata converts an install configuration to vSphere metadata.
func Metadata(config *types.InstallConfig) *typesvsphere.Metadata {
terraformPlatform := "vsphere"
// Since curr... |
package controller
import (
"errors"
"golib/comm"
"golib/listen"
"path/filepath"
"github.com/astaxie/beego/logs"
)
//TaskExecute 任务执行全局变量
var TaskExecute *TaskExec
//StartTaskExec 直接启动任务执行器,不是通过TCP监听执行
func StartTaskExec() (err error) {
// initTaskData()
//如果任务状态是pause,则需要开始执行
if TaskExecute.Status == comm.... |
package installer
import (
"github.com/wx13/genesis"
)
// Switch runs a Doer depending on a value.
type Switch struct {
Dos []genesis.Doer
Donts []genesis.Doer
Name string
}
func NewSwitch(name string) *Switch {
return &Switch{
Name: name,
}
}
func (sw Switch) Files() []string {
files := []string{}
for... |
package common
import (
"testing"
"github.com/stretchr/testify/assert"
)
func TestAmountToLotSize(t *testing.T) {
assert := assert.New(t)
type args struct {
lot float64
precision int
amount float64
}
tests := []struct {
name string
args args
want float64
}{
{
name: "test with lot of ... |
/**
* @program: Go
*
* @description:
*
* @author: Mr.chen
*
* @create: 2020-03-09 09:52
**/
package datamodels
//简单的消息体
type Message struct {
ProductID int64
UserID int64
}
//创建结构体
func NewMessage(userId int64,productId int64) *Message {
return &Message{UserID:userId,ProductID:productId}
}
|
package task
import (
"TskSch/command"
"TskSch/execute"
"TskSch/msgQ"
"TskSch/logger"
"fmt"
"github.com/garyburd/redigo/redis"
"gopkg.in/mgo.v2"
"os"
"sync"
"code.google.com/p/goconf/conf"
"time"
)
var ConcLimit int
var y time.Time
var managerPath string
var host string
var name string
func Execute(file *o... |
package entity
// LoadBalancer is a load balancer entity.
type LoadBalancer struct {
ID string
Name string
Region string
DigitaloceanAccessToken string
State string
FloatingIP string
FlotingIPID int
Leader ... |
/*
* Copyright 2018, CS Systemes d'Information, http://www.c-s.fr
*
* 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 requir... |
package main
func main() {
}
func isSameTree_dfs(p *TreeNode, q *TreeNode) bool {
if p == nil && q == nil {
return true
}
if p == nil || q == nil {
return false
}
if p.Val != q.Val {
return false
}
return isSameTree_dfs(p.Left, q.Left) && isSameTree_dfs(p.Right, q.Right)
}
func isSameTree_bfs(p *TreeNo... |
package util
import (
"encoding/base64"
"fmt"
"regexp"
"strings"
"sync"
"github.com/goshuirc/irc-go/ircmsg"
"github.com/goshuirc/irc-go/ircutils"
)
// IRC SASL numerics
//nolint:golint // These refer to external things and should be as they are
const (
RPL_LOGGEDIN = "900"
RPL_LOGGEDOUT = "901"
RPL_NI... |
package http
// ResponseEntity 响应数据体
type ResponseEntity struct {
// 错误码
ErrorCode int `json:"errcode"`
// 响应消息
Message string `json:"errmsg"`
// 响应数据
Data interface{} `json:"data"`
}
// PaginationEntity 分页数据体
type PaginationEntity struct {
// 是否有下一页
HasMore bool `json:"more"`
// 下一页开始数据
Start int32 `json:"... |
package auth
import (
"context"
"net/http"
userModel "github.com/LFSCamargo/twitter-go/database/models/user"
"github.com/LFSCamargo/twitter-go/graph/services/user"
)
var userCtxKey = &contextKey{"user"}
type contextKey struct {
name string
}
// Middleware - Is the authentication middleare to get the user from... |
package command_line
/**
subcommands - each have their own set of flags - like go build and go get
The flag package lets us easily define simple subcommands that have
their own flags
*/
import (
"flag"
"fmt"
"os"
)
func main() {
// declare a subcommand using the NewFlagSet function and proceed to define new fla... |
package taskengine
import (
"context"
)
// Max number of instances for each worker
const maxInstances = 100
//-----------------------------------------------------------------------------
// Types to be customized if needed. For example:
// type TaskID int
// type WorkerID int
// WorkerID type definition.
... |
/*
5 Friends (let's call them a, b, c, d and e) are playing a game and need to keep track of the scores. Each time someone scores a point, the letter of his name is typed in lowercase. If someone loses a point, the letter of his name is typed in uppercase. Give the resulting score from highest to lowest.
Input Descri... |
package models
type BoompowWorkGenerateRequestVariables struct {
Hash string `json:"hash" mapstructure:"hash"`
DifficultyMultiplier int `json:"difficultyMultiplier" mapstructure:"difficultyMultiplier"`
BlockAward bool `json:"blockAward" mapstructure:"blockAward"`
}
type BoompowWorkGe... |
package practice
import (
"fmt"
"testing"
)
func Test_nextStats(t *testing.T) {
type args struct {
s string
d []int
}
tests := []struct {
name string
args args
want string
}{
{
name: "test 1",
args: args{
s: "0000",
d: []int{0, 0, 0, 1},
},
want: "0001",
},
{
name: "test 2... |
package config
type JwtConfig struct {
Secret []byte
}
func NewJwtConfig() *JwtConfig {
return &JwtConfig{
Secret: []byte(getIni("jwt_secret", "JWT_SECRET", "awesome")),
}
}
|
package main
import (
"fmt"
"static_proxy_server/lib/test"
)
func init() {
fmt.Printf("我是1\n")
}
func Greet(name string) {
fmt.Println("Hello, " + name)
}
func GreetNames(names []string, suffix string) {
for _, n := range names {
Greet(n + suffix)
}
}
func main() {
test.Puts()
name := []string{
"Weston... |
package ds
import (
"babyboy/common"
"sync"
)
type HashSet struct {
data map[common.Hash]struct{}
lock sync.RWMutex
}
func NewHashSet() *HashSet {
return &HashSet{data: make(map[common.Hash]struct{})}
}
func (hs *HashSet) Insert(val common.Hash) {
hs.lock.Lock()
defer hs.lock.Unlock()
hs.data[val] = struct... |
package main
import "github.com/rahulsidpatil/golang-basic-exercises/webserver/app"
func main() {
app.InitServer(app.GetStore())
}
|
package schemas
import "time"
// type Admin struct{
// Id int `xorm:"int(11) pk autoincr comment('主键ID')"`
// Username string `xorm:"varchar(255) notnull default('') comment('用户名') index"`
// Password string `xorm:"char(32) notnull default('') comment('密码')"`
// Status int `xorm:"tinyint(2) default(1) comment('状态... |
package controllers
import (
"github.com/astaxie/beego"
m "scholarship/middlewares"
"io/ioutil"
"fmt"
"scholarship/models"
"encoding/hex"
middleware "scholarship/middlewares"
)
// Operations about object
type StudentController struct {
beego.Controller
}
// @Title Create
// @Description create student
// @Pa... |
package responses
import "time"
type GithubRelease struct {
ID uint
CreatedAt time.Time
UpdatedAt time.Time
Name string
Description string
RepoName string
TagName string
UserName string
PreRelease bool
Message string
}
|
package main
import (
"fmt"
)
var one = 1
func main() {
var two = 2
fmt.Println(one)
fmt.Println(two)
fmt.Println(Three) //error in code
}
|
package mmysql
// Mysql总管理器
type DBManager struct {
GroupMap map[string]*DBGroup
}
func NewMysql(config *DBConf) (dbMgr *DBManager, err error) {
dbMgr = &DBManager{
GroupMap: make(map[string]*DBGroup),
}
MyfDB = dbMgr // 单例
if config == nil || config.GroupConfList == nil {
return
}
// 按Name索引每一个DBGroup
... |
package main
import (
"github.com/hajimehoshi/oto"
"github.com/nsf/termbox-go"
"github.com/tosone/minimp3"
"fmt"
"io/ioutil"
"os"
"strings"
"log"
)
func initialize() {
if err := termbox.Init(); err != nil {
panic(err)
}
}
func Sonud(filename string) {
if len(filename) == 0 {
return
}
file, err := i... |
package middleware
import (
"github.com/majid-cj/go-docker-mongo/infrastructure/auth"
"github.com/majid-cj/go-docker-mongo/util"
"github.com/kataras/iris/v12"
)
// AuthMemberMiddleware ...
func AuthMemberMiddleware(c iris.Context) {
membertype, err := auth.ExtractMemberType(c.Request())
if err != nil {
util.R... |
package test
import (
"fmt"
"testing"
"time"
)
func TestAdd(t *testing.T) {
now := time.Now()
fmt.Println("now:", now)
fmt.Println("昨天:", now.Add(time.Hour*-24))
}
|
package strings
import (
"fmt"
"testing"
)
func TestMatchAndCaptures(t *testing.T) {
var tests = []struct {
pattern string
subject string
matches bool
invalid bool
}{
{
pattern: "|.*|",
subject: "one |two| three |four| five",
// [|two| three |four|]
},
{
pattern: "|.+|",
subject: "one... |
package codewizards
type Player struct {
Id int64
Me bool
Name string
StrategyCrashed bool
Score int
Faction Faction
}
type SkillType int
const (
Skill_RangeBonusPassive1 SkillType = iota
Skill_RangeBonusAura1
Skill_RangeBonusPassive2
Skill_RangeBonusA... |
package coding
/*
1. Basic Climbing Stair
You are climbing a stair case. It takes n steps to reach to the top.
Each time you can either climb 1 or 2 steps. In how many distinct ways can you climb to the top?
Note: Given n will be a positive integer.
Example 1:
Input: 2
Output: 2
Explanation: There are two ways to c... |
package models
import (
"reflect"
"testing"
"time"
)
func TestUser_MarshalJSON(t *testing.T) {
type fields struct {
UUID string
Email string
Password string
Name string
CreatedAt time.Time
DeletedAt *time.Time
UpdatedAt time.Time
}
tests := []struct {
name string
fields fiel... |
package main
import (
"fmt"
_io "io"
"os"
"strings"
"syscall"
"time"
"github.com/funkygao/golib/io"
"github.com/funkygao/golib/pipestream"
"github.com/funkygao/golib/signal"
"github.com/funkygao/tcpdumper/report"
)
func main() {
startedAt = time.Now()
tcpdumpFlag := []string{
"-i",
options.ifdev,
... |
/*
Go language provides inbuilt support for bits to implement
bit counting and manipulation functions for the predeclared
unsigned integer types with the help of bits package.
This package provides ReverseBytes() function which is used to
find the reversed order of the value of a. To access ReverseBytes(... |
//~0 1 2
//~3 0 0
//~1
//~0
//~+3.140000e+000 +2.710000e+000
//Struct testing, with arrays and slices >:) i like writing test programs too much does that make me mean
//NOT BENCHMARK
package main
type a struct {
a int
int int
b int
}
type struct_o_struct struct{
field2 struct {
... |
package database
import (
"sync"
"github.com/Cristofori/kmud/types"
"github.com/Cristofori/kmud/utils"
)
type Locker struct {
mutex sync.RWMutex
}
type Container struct {
Locker `bson:",omitempty"`
Inventory utils.Set
Cash int
}
func (self *Locker) ReadLock() {
self.mutex.RLock()
}
func (self *Loc... |
package kafka
import (
"encoding/json"
"fmt"
"strconv"
"time"
"github.com/batchcorp/plumber-schemas/build/go/protos/opts"
"github.com/logrusorgru/aurora"
"github.com/pkg/errors"
"github.com/batchcorp/plumber-schemas/build/go/protos/records"
"github.com/batchcorp/plumber/printer"
"github.com/batchcorp/plum... |
package modmath
// Note: this file is only for performing the euclidean algorithm
// and extended euclidean algorithm
// Finds the Greatest Common Divisor using the euclidean algorithm. (Optimized to not use recursion)
func Gcd(a, b int) int {
next := a - a/b*b
for next != 0 {
oldB := b
b = next
next =... |
package main
import "fmt"
func sum2(a int, b int) int {
return a+b
}
func sum3(a, b, c int) {
fmt.Println(a + b + c)
}
func main(){
fmt.Println(sum2(1,2))
sum3(1,2,3)
}
|
package kvs_test
import (
"errors"
. "github.com/bryanl/dolb/kvs"
"github.com/bryanl/dolb/mocks"
"github.com/coreos/etcd/client"
"golang.org/x/net/context"
. "github.com/onsi/ginkgo"
. "github.com/onsi/gomega"
)
var _ = Describe("Etcd", func() {
var (
kaMock = &mocks.KeysAPI{}
ctx = context.Backgr... |
package mw
import (
"github.com/FrankSantoso/go-hydra-login-consent/internal/log"
"github.com/go-chi/chi/middleware"
"net/http"
"runtime/debug"
"time"
)
func ReqLoggerMw(l *log.Log) func(next http.Handler) http.Handler {
return func(next http.Handler) http.Handler {
fn := func(w http.ResponseWriter, r *http.R... |
package fishweb
import (
"fmt"
"math"
"math/rand"
"time"
// "time"
"github.com/siggy/bbox/bbox/color"
"github.com/siggy/bbox/bbox/leds"
"github.com/siggy/bbox/beatboxer/render/web"
"github.com/siggy/rpi_ws281x/golang/ws2811"
log "github.com/sirupsen/logrus"
)
const (
// 2x side fins
STRAND_COUNT1 = 5
ST... |
package main
import "fmt"
func main() {
var myArray [5]int
for i := range myArray {
myArray[i] = i + 100
}
for i, v := range myArray {
fmt.Println(i, v)
}
fmt.Printf("%T\n", myArray)
}
|
package repository
import (
"go-binar/user/domain"
uuid "github.com/satori/go.uuid"
)
type UserRepository interface {
Save(user domain.User) error
Login(username string, password string) (*domain.User, error)
FindByEmail(email string) (*domain.User, error)
}
type AuthRepository interface {
FindByUserID(userID... |
// Copyright 2015 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 Problem0031
import "sort"
func nextPermutation(nums []int) {
length := len(nums)
if length <= 1 {
return
}
var i int
for i = length - 1; i >= 1; i-- {
if nums[i] > nums[i-1] {
break
}
}
if i > 0 {
sort.Ints(nums[i:])
for j := i - 1; j < length; j++ {
if nums[j] > nums[i-1] {
nums... |
package server
import (
"fmt"
"log"
"net"
)
// NewServer initializes the chat server
func NewServer(port string) *Server {
return &Server{
Port: port,
}
}
// Server contains port definition
type Server struct {
Port string
}
type ChatServer interface {
RunChatServer() error
}
type clients []net.Conn
var ... |
package main
import (
"math"
"math/rand"
"time"
//"fmt"
)
type axon struct {
From *Neuron
Terminals []*axonTerminal
}
func (a *axon) Genesis(neuron *Neuron) {
a.From = neuron
}
func (a *axon) GrowTerminals() {
rand.Seed(time.Now().UnixNano())
if a.From.Type == neurontype.Sen... |
// Written in 2014 by Petar Maymounkov.
//
// It helps future understanding of past knowledge to save
// this notice, so peers of other times and backgrounds can
// see history clearly.
package circuit_test
import (
"fmt"
"testing"
cir "github.com/hoijui/escher/pkg/circuit"
)
func TestSame(t *testing.T) {
if !c... |
package numIslands
func numIslands(grid [][]byte) int {
row := len(grid)
if row == 0 {
return 0
}
col := len(grid[0])
if col == 0 {
return 0
}
uf := newUnionFind(grid, row, col)
uf.union(grid, row, col)
return uf.count
}
type UnionFind struct {
count int
arr []int
}
func newUnionFind(grid [][]byte, ... |
package main
import "fmt"
type carro struct {
nome string
velocidadeAtual int
}
// adicioneio o método
func (c carro) getVelocidade() int {
return c.velocidadeAtual
}
type ferrari struct {
carro // campos anonimos
turboLigado bool
}
// adicionei o método
func (f ferrari) getNome() string {
r... |
package c50_cbc_mac_hashing
import (
"bytes"
"crypto/aes"
"github.com/vodafon/cryptopals/set1/c1_hex_to_base64"
"github.com/vodafon/cryptopals/set1/c2_fixed_xor"
"github.com/vodafon/cryptopals/set2/c09_pkcs7_padding"
"github.com/vodafon/cryptopals/set7/c49_cbc_mac_forgery"
)
type HashCBC struct {
cbc c49_cbc_... |
/*
* Copyright 2019 Dgraph Labs, Inc. and Contributors
*
* 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 appli... |
package html_test
import (
"bytes"
"github.com/antchfx/htmlquery"
"github.com/elliotchance/gedcom/html/core"
"github.com/elliotchance/tf"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
"strings"
"testing"
)
func testComponent(t *testing.T, name string) func(args ...interface{}) *tf... |
package api
import "github.com/globalsign/mgo/bson"
type Feed struct {
Id bson.ObjectId `json:"id" bson:"_id"`
Txt string `json:"txt"`
}
func NewFeed() *Feed {
return new(Feed)
} |
package main
import (
"context"
"errors"
"log"
"os"
"github.com/magodo/shippy-service/consignment/internal"
pb "github.com/magodo/shippy-service/consignment/proto/consignment"
userPb "github.com/magodo/shippy-service/user/proto/user"
vesselPb "github.com/magodo/shippy-service/vessel/proto/vessel"
"github.co... |
package shell
import (
"fmt"
"sort"
"github.com/hoop33/perm/config"
)
type command interface {
name() string
description() string
usage() string
run(env *env, args []string) error
}
var allCommands = make(map[string]command)
var sorted []string
var maxCommandLength int
func sortedCommandNames() []string {
... |
package unio
import (
"encoding/json"
"errors"
"github.com/labstack/gommon/log"
"gopkg.in/mgo.v2/bson"
"reflect"
"strconv"
"time"
)
// Validate if value is string, if is, try to convert to float/32. If error, returns -999
func (u *Util) StringToFloat(value interface{}) (number float32, err... |
package main
import (
"log"
"os"
)
func main() {
err := os.RemoveAll("D:\\新建文本文档.txt")
if err != nil {
log.Fatalln(err)
}
}
/*
一.文件类型
1.设备文件
1.屏幕: 标准输出
2.键盘: 标准输入
2.磁盘文件
1.文本文件
2.二进制文件
二.为什么需要文件
1.持久化存储数据
*/
//该Read了...................
|
// DO NOT EDIT. This file was generated by "github.com/frk/gosql".
package testdata
import (
"github.com/frk/gosql"
)
func (q *InsertDefaultAllReturningSliceQuery) Exec(c gosql.Conn) error {
var queryString = `INSERT INTO "test_user_with_defaults" AS u (
"email"
, "full_name"
, "is_active"
, "created_at"
... |
package microsvc
import (
"context"
"github.com/go-kit/kit/endpoint"
"github.com/hathbanger/microsvc-base/pkg/microsvc/models"
)
// MakeHealthEndpoint - returns an endpoint for the health function
func MakeHealthEndpoint(s Service) endpoint.Endpoint {
return func(ctx context.Context, request interface{}) (interf... |
package main
import "fmt"
func main() {
const coba = "bisa"
const (
data1 = "dont change"
data2 = "cant change"
// data1 = "uncomment me to test"
)
fmt.Println(data1)
}
|
package main
import (
"encoding/json"
"flag"
"fmt"
"io/ioutil"
"os"
"path/filepath"
"regexp"
"strconv"
"strings"
"tetra/lib/lang"
)
var (
prune bool
verbose bool
localeList string
obsolete string
keywords string
filetypes string
rxtemplate = `\(\s*((?s:\x60[^\x60]*\x60)|"(?:(?:\\"|.)*?)... |
package facade
type Bidder interface {
bid(request *Request) float32
}
type BidderImpl struct {
detargeter *Detargeter
predictor *Predictor
bidOptimizer *BidOptimizer
}
func (bidder *BidderImpl) bid(request *Request) float32 {
bidder.detargeter.detarget(request)
pVal := bidder.predictor.predict(request)
... |
package main
import "fmt"
func main() {
ids := []int{33, 76, 54, 23, 11, 2}
// Loops though ids
for i, id := range ids { //index, value
fmt.Printf("%d - ID: %d\n", i, id)
}
sum := 0
for _, id := range ids { //if not use index, put _ on first parameter
sum += id
}
fmt.Println(sum)
//range for MAP
ema... |
package main
import (
"bufio"
"log"
"os"
"strings"
)
type Group struct {
AnsweredQuestions map[string]int
NumPeople int
}
func NewGroup() *Group {
return &Group{AnsweredQuestions: make(map[string]int)}
}
func (group *Group) RecordAnswers(answers string) {
group.NumPeople += 1
for _, char := range ... |
package actn
import (
"er"
"fmt"
"fwb"
"sgs"
)
type actnSkip int
func actnSkipParser(command sgs.Command) fwb.Action {
cid := command.Who
return (*actnSkip)(&cid)
}
func (me *actnSkip) String() string {
return fmt.Sprintf("Action %v from Player 0x%x", ActionNames[ACTN_SKIP], *me)
}
func (me *actnSkip) ID() ... |
package services
import (
"database/sql"
"github.com/allentom/youcomic-api/database"
"github.com/allentom/youcomic-api/model"
"github.com/jinzhu/gorm"
)
type TagQueryBuilder struct {
IdQueryFilter
OrderQueryFilter
NameQueryFilter
NameSearchQueryFilter
DefaultPageFilter
TagTypeQueryFilter
TagSubscriptionQue... |
package main
const (
COMMAND = "difup"
VERSION = "0.1.0"
)
|
// Copyright 2020 IOTA Stiftung
// SPDX-License-Identifier: Apache-2.0
package test
import (
"github.com/iotaledger/wasp/packages/coretypes"
)
const ScName = "testcore"
const ScDescription = "Core test for ISCP wasmlib Rust/Wasm library"
const ScHname = coretypes.Hname(0x370d33ad)
const ParamAddress = "address"
co... |
package pxc
import (
"context"
"fmt"
"github.com/operator-framework/operator-sdk/pkg/sdk"
"github.com/sirupsen/logrus"
"k8s.io/apimachinery/pkg/api/errors"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
api "github.com/Percona-Lab/percona-xtradb-cluster-operator/pkg/apis/pxc/v1alpha1"
"github.com/Percona-Lab/... |
// 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... |
package fivethirtyeightclient
import (
"encoding/xml"
"fmt"
"io/ioutil"
"net/http"
)
type Client struct {
Url string
Categories map[string]Category
}
type Category struct {
Uri string
Pretty string
}
func NewClient() *Client {
var categories = map[string]Category{
"all": Category{Uri: "all... |
package models
import (
"github.com/astaxie/beego/orm"
)
type Cards struct {
Id string `orm:"column(id);size(64);pk" json:"cards_id"`
Cardtype string `orm:"size(16)" json:"cardtype"`
Remark string
}
func init() {
orm.RegisterModel(new(Cards))
}
func GetCardsInfo(card_id string)(Cards ,error) {
o := orm.New... |
/*
* Auction Bid Tracker
*
* This is an example server for auction bid tracker.
*
* API version: 1.0.0
* Contact: antony.h@riseup.net
* Generated by: OpenAPI Generator (https://openapi-generator.tech)
*/
package openapi
import (
"encoding/json"
"net/http"
"strconv"
"strings"
"github.com/antonyho/go-auct... |
// Example SVG parser using a combination of xml.Unmarshal and the
// xml.Unmarshaler interface to handle an unknown combination of group
// elements where order is important.
package main
import (
"encoding/xml"
"fmt"
"strconv"
)
type Path struct {
Id string `xml:"id,attr"`
D string `xml:"d, attr"`
}
type Re... |
// Copyright (c) 2020 Blockwatch Data Inc.
// Author: alex@blockwatch.cc
package index
import (
"context"
"fmt"
"github.com/jinzhu/gorm"
"github.com/zyjblockchain/sandy_log/log"
"sort"
"tezos_index/chain"
"tezos_index/puller/models"
"tezos_index/rpc"
)
const RightsIndexKey = "rights"
type RightsIndex struct... |
package lilraft
import (
"bytes"
"encoding/gob"
"encoding/json"
"fmt"
"log"
"math/rand"
"net/http"
"os"
"sync"
"time"
"github.com/golang/protobuf/proto"
)
func init() {
gob.Register(&HTTPNode{})
}
// Logger
var logger = log.New(os.Stdout, "[lilraft]", log.Lmicroseconds)
// Error
var (
errDepose = fm... |
package sitemap
import (
"testing"
"time"
)
func TestIndex(t *testing.T) {
lm := time.Date(2020, 1, 1, 1, 1, 1, 0, time.UTC)
sm := NewSiteMapIndex()
sm.AddSitemap("/sm1", lm)
sm.AddSitemap("/sm2", lm)
s, err := sm.String()
if err != nil {
t.Error(err)
}
if s != `<?xml version="1.0" encoding="UTF-8"?>`+... |
package futures
import (
"testing"
"github.com/stretchr/testify/suite"
)
type basePositionMarginHistoryTestSuite struct {
baseTestSuite
}
func TestPositionMarginHistoryTestService(t *testing.T) {
suite.Run(t, new(positionMarginHistoryServiceTestSuite))
}
type positionMarginHistoryServiceTestSuite struct {
bas... |
package main
import (
"fmt"
"github.com/influxdata/influxdb/client/v2"
"github.com/namsral/flag"
)
// DataLayerInterface abstracts the db connection
type DataLayerInterface interface {
CreatePoint(pt *client.Point) error
QueryDB(cmd string) (res []client.Result, err error)
}
var (
DBName *string
)
// InfluxD... |
package game
import (
"math"
"time"
)
// Represents a player in the game
type Player struct {
Name string
AccessCode string
Created time.Time
IntelligenceXp float64
StrengthXp float64
DexterityXp float64
Life float64
authenticated bool
}
func NewPlayer(name, accessCod... |
package exasol
const driverVersion = "v1.0.0"
|
package router
import (
"gin-vue-admin/api/v1"
"gin-vue-admin/middleware"
"github.com/gin-gonic/gin"
)
func InitTitUserBaseinfoRouter(Router *gin.RouterGroup) {
TitUserBaseinfoRouter := Router.Group("userBaseinfo").Use(middleware.JWTAuth()).Use(middleware.CasbinHandler())
{
TitUserBaseinfoRouter.POST("createTi... |
// Copyright 2016-2017 The psh Authors. All rights reserved.
package psh
import "testing"
func TestResetFgBg(t *testing.T) {
expected := `\[\e[0m\]`
output := ResetFgBg()
if string(output) != expected {
t.Fatalf("Expected %s but got %s", expected, string(output))
}
}
func TestResetForegound(t *testing.T) {
e... |
package gortex
import "fmt"
// DeltaRNN cell https://arxiv.org/pdf/1703.08864.pdf
type DeltaRNN struct {
Wr *Matrix
Ur *Matrix
Wx *Matrix
Wh *Matrix
Wo *Matrix
Br *Matrix
Bias *Matrix
A *Matrix
B *Matrix
C *Matrix
}
// MakeDeltaRNN create new cell
func MakeDeltaRNN(x_size, h_size, out_... |
package restserver
import (
"github.com/astaxie/beego"
)
//ATMPAgent 的基本信息
type ATMPAgent struct {
beego.Controller
}
//GetStatus 获取Agent状态
func (c *ATMPAgent) GetStatus() {
c.Data["json"] = struct {
Status string
}{Status: "Active"}
c.ServeJSON()
}
|
package main
import "fmt"
type Data struct {
}
func (d Data) String() string{
return "data"
}
func main() {
d:=Data{}
fmt.Println(d)
}
|
package model
import (
"time"
"visitor/client/gorm_client"
"visitor/pkg/common"
"visitor/pkg/ierr"
)
type User struct {
Id int `json:"id" gorm:"id;primary_key;AUTO_INCREMENT"` // 自增id
OpenId string `json:"open_id" gorm:"open_id;type:varchar(32);index:idx_open_id"` // 用户微信openId
Token ... |
package main
import (
"encoding/json"
"fmt"
"net/http"
)
type cityData struct {
ID int
Name string
CountryCode string
District string
Population int
}
// cityPresenter
type cityPresenter struct{}
func newCityPresenter() cityPresenter {
return cityPresenter{}
}
func (presenter *cityPres... |
package request
import (
"fmt"
"net/url"
)
type (
// Paginator interface
Paginator interface {
GetLimit() uint
GetCurrentPage() uint
}
// PaginationArgs struct
PaginationArgs struct {
Limit int `json:"limit"`
Page int `json:"page"`
}
)
// GetLimit ...
func (s *PaginationArgs) GetLimit() int {
if s... |
package store
import (
"os"
"path/filepath"
"testing"
"github.com/stretchr/testify/assert"
"github.com/openshift/installer/pkg/asset"
)
func TestFetchByName(t *testing.T) {
tests := []struct {
name string
files map[string][]byte
input string
expectFile *asset.File
}{
{
name: ... |
package command
import (
"fmt"
)
// Unknown is a "gen" cli command
type Unknown struct {
*command
}
// NewUnknown creates an instance of Generate
func NewUnknown(pool Pooler, name string) *Unknown {
return &Unknown{newCommand(pool, name)}
}
// Run implements Commander
func (c *Unknown) Run(args []string) (int, e... |
package main
import (
"log"
)
const MainImportPath = "github.com/omise/omise-go"
func main() {
jobs, e := ExtractJobs()
noError(e)
log.Println(len(jobs), "job(s):")
for _, job := range jobs {
_, outname := job.Filenames()
log.Printf("* %s\n\033[90m%#v\033[0m", outname, job)
noError(Execute(job))
}
lo... |
/* nigthhawk.rabbitmq.message
* author: 0xredskull
*
* Contains message structures passed using RabbitMQ
* among nighthawk worker and other components
*/
package rabbitmq
type JobMessage struct {
CaseName string
CaseDate string
ComputerName string
CaseAnalyst string
TriageFile string
}
|
package 链表
import "sort"
/**
* Definition for singly-linked list.
* type ListNode struct {
* Val int
* Next *ListNode
* }
*/
// ----------------------方法1: 时空复杂度 O(n^2),O(1) -----------------
// 概述: 暴力查找。
func numComponents(head *ListNode, G []int) int {
cur := head
countOfComponents := 0
curLength :=... |
package twitter
import (
"go.coder.com/hat"
"go.coder.com/hat/asshat"
"net/http"
"testing"
)
func TestTwitter(tt *testing.T) {
t := hat.New(tt, "https://twitter.com")
t.Get(
hat.Path("/realDonaldTrump"),
).Send(t).Assert(t,
asshat.StatusEqual(http.StatusOK),
asshat.BodyMatches(`President`),
)
}
|
package main
import (
"bytes"
"image"
"image/draw"
"image/png"
"log"
"net/http"
"strconv"
"github.com/davecgh/go-spew/spew"
)
func main() {
var src bytes.Buffer
_, err := src.Write(baked)
if err != nil {
log.Fatal(err)
}
in, err := png.Decode(&src)
if err != nil {
log.Fatal(err)
}
e := &endpoin... |
package common
import (
"crypto/rand"
"math/big"
"time"
"gorm.io/gorm"
)
var (
randRunes = []rune("abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789")
)
// Upload object
type Upload struct {
ID string `json:"id"`
TTL int `json:"ttl"`
ExtendTTL bool `json:"extend_ttl"`
Downlo... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.