text stringlengths 11 4.05M |
|---|
package list
type node struct {
val interface{}
prev *node
next *node
}
type LinkedList struct {
first *node
last *node
size int
}
func (l *LinkedList) Add(val interface{}) {
if l == nil {
panic("list is nil")
}
n := &node{
val: val,
}
if l.last == nil {
l.first = n
l.last = n
} else {
n.pre... |
package web
import (
"github.com/gin-gonic/gin"
"github.com/iancoleman/strcase"
"path"
"reflect"
)
var Engine = gin.New()
func Serve() error {
return Engine.Run(":8080")
}
var handlerTyp = reflect.TypeOf((*gin.HandlerFunc)(nil)).Elem()
func Use(action interface{}) {
actionVal := reflect.ValueOf(action)
if a... |
package main
import (
"encoding/base64"
"fmt"
)
func main() {
message := "Away fro keyboard. https://golang.org/"
// 编码信息
encodeMessage := base64.StdEncoding.EncodeToString([]byte(message))
// 输出编码完成的信息
fmt.Println(encodeMessage)
// 解码信息
data, err := base64.StdEncoding.DecodeString(encodeMessage)
// 出错处理
i... |
package main
import (
"context"
"github.com/PacktPublishing/Go-Programming-Cookbook-Second-Edition/chapter7/oauthcli"
)
func main() {
ctx := context.Background()
conf := oauthcli.Setup()
tok, err := oauthcli.GetToken(ctx, conf)
if err != nil {
panic(err)
}
client := conf.Client(ctx, tok)
if err := oauth... |
package runner
// This file contains the implementation of a resource tracker for a local host on
// which CUDA, storage, and main motherboard resources can be found and tracked on
// behalf of an application
import (
"fmt"
"strings"
"github.com/go-stack/stack"
"github.com/karlmutch/errors"
)
type CpuAllocated ... |
package keepalive
import "testing"
func TestDoIt(t *testing.T) {
size := int64(25000)
s := make([]int64, size)
var want int64
for i := int64(0); i < size; i++ {
s[i] = i
want += i
}
got := DoIt(s)
if want != got {
t.Errorf("Wanted %d, got %d", want, got)
}
}
func TestDoItKeepAlive(t *testing.T) {
s... |
/*
* 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 v1alpha1 contains API Schema definitions for the patrick v1alpha1 API group
// +k8s:deepcopy-gen=package,register
// +groupName=cert.patrickeasters.com
package v1alpha1
|
package bench
import (
"bytes"
"testing"
"github.com/polydawn/refmt"
"github.com/polydawn/refmt/cbor"
"github.com/polydawn/refmt/json"
)
var fixture_arrayFlatInt = []int{1, 2, 3, 4, 5, 6, 7, 8, 9, 0}
var fixture_arrayFlatInt_json = []byte(`[1,2,3,4,5,6,7,8,9,0]`)
var fixture_arrayFlatInt_cbor = []byte{0x80 + 10... |
package controllers
import (
"github.com/SungKing/blogsystem/models/dao"
"encoding/json"
)
var userDao = new(dao.UserDao)
type MainController struct {
BaseController
}
func (c *MainController) Get() {
pageIndex,_:=c.GetInt32("pageIndex",1)
if pageIndex<1 {
pageIndex=1
}
blogs:=blogService.Query(pageIndex... |
package database
import (
"github.com/jinzhu/gorm"
_ "github.com/jinzhu/gorm/dialects/sqlite" // import
)
// DB database
var DB *gorm.DB
// Open connection and migrates
func Open() *gorm.DB {
var err error
DB, err = gorm.Open("sqlite3", "test.db")
if err != nil {
panic("error connecting to Database")
}
retu... |
package lock
import (
"sort"
"sync"
)
const prime32 = uint32(16777619)
func fnv32(key string) uint32 {
hash := uint32(2166136261)
for i := 0; i < len(key); i++ {
hash *= prime32
hash ^= uint32(key[i])
}
return hash
}
type Locks struct {
table []*sync.RWMutex
}
func New(tableSize int) *Locks {
table := ... |
package main
import (
"github.com/RobinVerachtert/GoEnigma/enigma"
. "github.com/smartystreets/goconvey/convey"
"testing"
)
func TestMain(t *testing.T) {
Convey("[Main] full test with config.json", t, func() {
enigma_config, err := enigma.ReadConfig("jsonConfigFiles/config.json")
noError := true
if err != ... |
/**
* @Author: 人从众[ckhero]
* @Date: 2020/9/7 3:42 下午
* @Desc: a
*/
package test
import (
"fmt"
"main/algorithm/sort"
"testing"
)
func TestQuickSort(t *testing.T) {
arr := []int{3,9,1}
fmt.Println(sort.QuickSort(arr))
arr2 := []int{3,9,1,11,12,15}
sort.QuickSort2(arr2, 0, len(arr2) - 1)
fmt.Println(arr2)
} |
package docker
type Node struct {
ID string `json:"id,omitempty" gorethink:"id,omitempty"`
Name string `json:"name,omitempty" gorethink:"name,omitempty"`
Addr string `json:"addr,omitempty" gorethink:"addr,omitempty"`
Containers string `json:"containers,omitempty"`
Reser... |
package common
import (
"bytes"
"encoding/json"
"fmt"
"github.com/rebelit/rpIoT/config"
"gopkg.in/alexcesaro/statsd.v2"
"log"
"net/http"
"os"
"os/exec"
"strconv"
"strings"
)
const (
UPDATE_LOG_DIR = "/var/log/apt/history.log"
)
func SendMetric(uri string, responseCode int, method string ){
measurement :... |
/*
Copyright (c) 2023 Red Hat, 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 writing, software... |
package Problem0480
import (
"fmt"
"testing"
"github.com/stretchr/testify/assert"
)
// tcs is testcase slice
var tcs = []struct {
nums []int
k int
ans []float64
}{
{
[]int{1, 2},
1,
[]float64{1, 2},
},
{
[]int{1, 2},
2,
[]float64{1.5},
},
{
[]int{1, 3, -1, -3, 5, 3, 6, 7},
3,
[]fl... |
package main
import (
"fmt"
)
func main() {
number := 5
result, err := fatorial(number)
if err != nil {
fmt.Println(err)
}
result_rec, err := fatorial_rec(number)
if err != nil {
fmt.Println(err)
}
fmt.Printf("Fatorial of %d is %d\n", number, result)
fmt.Printf("Fatorial rec of %d is %d\n", number, res... |
package main
import (
"database/sql"
"fmt"
"time"
_ "github.com/go-sql-driver/mysql"
)
func checkErr(err error) {
if err != nil {
fmt.Println(err)
panic(err)
}
}
func initDB() {
db, err := sql.Open("mysql", "root:micbay911@tcp(127.0.0.1:3306)/escollect?charset=utf8mb4")
checkErr(err)
db.SetConnMaxLife... |
package handlers
import (
"fmt"
articlePkg "github.com/david-sorm/montesquieu/article"
"github.com/david-sorm/montesquieu/globals"
templates "github.com/david-sorm/montesquieu/template"
"net/http"
"strconv"
"strings"
)
type ArticleView struct {
BlogName string
Article articlePkg.Article
RootURL string
}
... |
package main
import (
"fmt"
"log"
"runtime"
)
func versionsSubmajorGen(major, submajor, minor int) []string {
var versions []string
for i := 0; i <= minor; i++ {
v := fmt.Sprintf("%d.%d.%d", major, submajor, i)
versions = append(versions, v)
}
return versions
}
func versionsGen() []string {
var versions... |
package labels
import (
"fmt"
"sync"
"time"
"github.com/rcrowley/go-metrics"
p2metrics "github.com/square/p2/pkg/metrics"
)
type labelLister interface {
ListLabels(labelType Type) ([]Labeled, error)
}
type Batcher struct {
createBatcherMux sync.Mutex
lister labelLister
holdTime time.Durat... |
package controllers
import (
"github.com/astaxie/beego"
"my-blog/models"
)
type CateController struct {
beego.Controller
}
func (this *CateController) Get() {
op := this.Input().Get("op")
name := this.Input().Get("name")
switch op {
case "add":
err := models.AddCategory(name)
if err != nil {
beego.Erro... |
package handlers
import (
"Site1/helpers"
"Site1/models"
"fmt"
"net/http"
)
func IndexHandler(write http.ResponseWriter, request *http.Request) {
user := helpers.GetUserCookie(request)
userData := models.User{}
if len(user) > 0 {
userData = models.ShowUser(user)
fmt.Println("This Works")
}
fmt.Println(... |
package helpers
import "time"
type UserActivity struct {
Time time.Time
SecondsFrom int64
}
func IsWorkingDay(hourStartUTC, workingDayHours, hourNowUTC int) bool {
// В случае, если завершение рабочего дня по UTC перехало на утро (например на Камчатке по utc рабочий день начинается в 22)
// Нужно пересчит... |
package mongodb
import (
"context"
"time"
"github.com/brigadecore/brigade/v2/apiserver/internal/api"
"github.com/brigadecore/brigade/v2/apiserver/internal/lib/mongodb"
"github.com/brigadecore/brigade/v2/apiserver/internal/meta"
"github.com/pkg/errors"
"go.mongodb.org/mongo-driver/bson"
"go.mongodb.org/mongo-d... |
package utils_mock
import (
time "time"
)
type TimeTravelingMock struct {
CurrentTime time.Time
}
func NewTimeTravelingMock(startTime time.Time) *TimeTravelingMock {
return &TimeTravelingMock{CurrentTime: startTime}
}
func (t *TimeTravelingMock) Now() time.Time {
return t.CurrentTime
}
func (t *TimeTravelingMo... |
//nolint
package gov
import (
"fmt"
sdk "github.com/irisnet/irishub/types"
)
const (
DefaultCodespace sdk.CodespaceType = "gov"
CodeUnknownProposal sdk.CodeType = 1
CodeInactiveProposal sdk.CodeType = 2
CodeAlreadyActiveProposal sdk.CodeType = 3
CodeAlreadyFinishedProposal sdk.CodeType = 4
... |
package main
// Импортируем необходимые зависимости. Мы будем использовать
// пакет из стандартной библиотеки и пакет от gorilla
import (
"net/http"
"github.com/gorilla/mux"
"github.com/gorilla/handlers"
"os"
"api/faq"
"api/product"
"api/AddFeedbackHandler"
"api/status"
)
func main() {
// Инициализируем gori... |
// package main - read json, cleanup json swagger file, convert to yaml
package main
import (
"bufio"
"encoding/json"
"fmt"
"io/ioutil"
"os"
yaml "gopkg.in/yaml.v2"
)
func main() {
f, err := os.OpenFile("./availability_v3.json", os.O_RDWR|os.O_CREATE, 0666)
if err != nil {
fmt.Println(err)
return
}
def... |
// base/channel/ok.
package main
import "fmt"
func main() {
ch := make(chan int, 10)
for i := 0; i < cap(ch); i++ {
ch <- i
}
close(ch)
for {
i, ok := <-ch
if !ok {
break
}
fmt.Println(i, ok)
}
}
|
/**
* @Author: Alen
* @Date: 2019-03-10 00:22
* @Description: TODO
*/
package logger
import "testing"
func TestLogger(t *testing.T) {
logFile = LogInstance()
logFile.SetLogOutFile("", "logger.log")
logFile.SetLogLevel(InfoLevel)
DEBUG("我是调试日志", 1, "abc")
INFO("我是输出日志", 1, "abc")
logFile.SetLogLevel(ErrorLevel... |
package main
import "fmt"
func TypeJudge(items... interface{}) {
for index, x := range items {
switch x.(type) {
case bool:
fmt.Printf("第%v个参数是bool类型,值是%v \n", index, x)
case float32, float64:
fmt.Printf("第%v个参数是float类型,值是%v \n", index, x)
case int, int32, int64:
fmt.Printf("第%v个参数是int类型,值是%v ... |
package lsproduct
import (
"errors"
"strconv"
)
func LargestSeriesProduct(digits string, span int) (int, error) {
if span > len(digits) {
return 0 ,errors.New("span must be smaller than string length")
}
if span < 0 {
return 0,errors.New("span must not be negative")
}
if len(digits) == 0 || span == 0{
re... |
package worker
import (
"FoG/src/github.com/cl/crontab/common"
"fmt"
"time"
)
//任务调度
type Scheduler struct {
// jobMgr 将任务事件通过通道进行推送
jobEventChan chan *common.JobEvent
// 将任务信息放入table表
jobPlanTable map[string]*common.JobSchedulePlan
// 记录执行任务信息
jobExecutionTable map[string]*common.JobExecuteInfo
//8 创建获取响应结... |
package sqlx
import (
"bytes"
)
var IsPrimary = true
var NotNull = true
type SQLTableColumn struct {
Name string
Type string
IsPrimary bool
NotNULL bool
}
type SQLTableDefinition struct {
TableName string
Columns []SQLTableColumn
}
func (definition *SQLTableDefinition) CreateStatement() string... |
package entity
import "github.com/jinzhu/gorm"
//用户表
type Users struct {
gorm.Model
Username string
Pwd string
NickName string
}
//用户关系表
type UserCompanyRel struct {
UserId int `gorm:"primary key"`
CompanyId int `gorm:"primary key"`
}
|
package string
import (
"fmt"
"strings"
)
type String []rune
//New
func New(s interface{}) String {
switch s.(type) {
case *string:
return New([]byte(*s.(*string)))
case string:
return New([]byte(s.(string)))
case []byte:
return String([]rune(string(s.([]byte))))
case []rune:
return String(s.([]rune))... |
// 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 cmd
import (
"fmt"
"os"
"path/filepath"
"github.com/swanwish/go-common/logs"
"github.com/swanwish/go-common/utils"
"github.com/swanwish/godeps/bash"
"github.com/swanwish/godeps/models/godeps"
"github.com/urfave/cli"
)
var (
Sync = cli.Command{
Name: "sync",
Usage: "Sync packages fro... |
package sqlbuilder
import (
. "github.com/smartystreets/goconvey/convey"
"testing"
)
type exprParam struct {
name string
expr SQLProvider
expected string
vars []interface{}
}
func TestExpressions(t *testing.T) {
params := []exprParam{
{"Equal", Equal{"foo", "bar"}, "foo = $1", []interface{}{"bar... |
package model
import (
"time"
"gopkg.in/mgo.v2/bson"
)
// Session represents an initialized session
type Session struct {
ID bson.ObjectId `bson:"_id"`
Address string `bson:"address"`
DeviceType string `bson:"device_type"`
CreatedAt time.Time `bson:"created_at"`
UpdatedAt time.T... |
package logic
import (
"context"
"tpay_backend/adminapi/internal/common"
"tpay_backend/adminapi/internal/svc"
"tpay_backend/adminapi/internal/types"
"tpay_backend/utils"
"github.com/tal-tech/go-zero/core/logx"
)
type UploadImageLogic struct {
logx.Logger
ctx context.Context
svcCtx *svc.ServiceContext
}
... |
package util
import (
"bytes"
"strings"
)
func BytesCombine(pBytes ...[]byte) []byte {
return bytes.Join(pBytes, []byte(""))
}
func StringToBytes32_4(input string) (*[4][32]byte, error) {
if input == "" {
return nil, ErrParamShouldNotNil
}
bytes := []byte(input)
if len(bytes) > 128 {
return nil, ErrParamS... |
package main
import (
"fmt"
"ms/sun/shared/dbs"
"ms/sun/shared/helper"
"ms/sun/shared/x"
"sync/atomic"
)
func main() {
x.LogTableSqlReq.PostCdb = false
i := int64(0)
fn := func() {
var arr []x.PostCdb
for ; i < 100000000; i++ {
for j := 0; j < 100; j++ {
atomic.AddInt64(&i, 1)
n := int(i)
... |
package main
import (
"fmt"
"webqq/config"
"github.com/spf13/viper"
)
func main(){
//读取配置文件
var conf = config.Config{
"config/conf.yaml",
}
if err := conf.InitConfig(); err != nil{
fmt.Println("读取配置文件出错: ", err)
return
}
} |
// Package rlog
// A simple Golang logger with lots of features and no external dependencies
//
//
// Rlog is a simple logging package, rich in features. It is configurable 'from
// the outside' via environment variables and/or config file and has no
// dependencies other than the standard Golang library.
//
// It is c... |
package controllers
import (
"fmt"
"golang.org/x/crypto/bcrypt"
"github.com/dancewing/revel"
"github.com/dancewing/yysrevel/app/models"
)
type Account struct {
//*revel.Controller change to GorpController
GorpController
}
func (c Account) List() revel.Result {
//users, err := c.Txn.Select(models.User{}, `se... |
package util
import (
"context"
"regexp"
"google.golang.org/grpc/metadata"
)
var (
// For trace header, see https://cloud.google.com/trace/docs/troubleshooting#force-trace
traceHeaderRegExp = regexp.MustCompile(`^\s*([0-9a-fA-F]+)(?:/(\d+))?(?:;o=[01])?\s*$`)
)
func GetTraceIDFromHeader(header string) string {... |
package models
import (
"time"
)
type User struct {
ID int
Name string
CreatedAt time.Time
UpdatedAt time.Time
UsersItems []UsersItem
}
|
package main
import (
"database/sql"
"fmt"
_ "github.com/zensqlmonitor/go-mssqldb"
)
type Result struct {
Number uint32
AnalyzeType string
}
func main() {
var server = "127.0.0.1"
var port = 1433
var database = "sandbox"
var user = "username"
var password = "password"
con... |
package main
//给定一个整数数组,其中第 i 个元素代表了第 i 天的股票价格 。
//
//设计一个算法计算出最大利润。在满足以下约束条件下,你可以尽可能地完成更多的交易(多次买卖一支股票):
//
//你不能同时参与多笔交易(你必须在再次购买前出售掉之前的股票)。
//卖出股票后,你无法在第二天买入股票 (即冷冻期为 1 天)。
//示例:
//
//输入: [1,2,3,0,2]
//输出: 3
//解释: 对应的交易状态为: [买入, 卖出, 冷冻期, 买入, 卖出]
func main() {
}
func maxProfit(prices []int) int {
if len(prices) ... |
package opt
import (
"bufio"
"fmt"
"os"
"testing"
)
type T1 struct {
String func() string
}
func (T1) Error() string {
return "T1.Error"
}
type T2 struct {
Error func() string
}
func (T2) String() string {
return "T2.String"
}
var t1 = T1{String: func() string { return "T1.String" }}
var t2 = T2{Error: fu... |
// 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 dht
type Msg struct {
Type string
Src [2]string
// Relay string
Dst [2]string
Node [2]string //(address, ID)
Key string
Bytes []byte
FingerID int
}
func lookupMsg(src, dst [2]string, msgType, key string, id int) *Msg {
msg:=new(Msg)
msg.Type = msgType
msg.S... |
//Package lists contains custom doubly linked lists that allow for fast insertion and deletion of elements
package lists
//Type MsgList is a list of messages a client recieves from the server
type MsgList struct {
Head, Tail *Node //head and tail nodes, necessary for the list
Size int //size of the list
}
/... |
// 安装:go get github.com/Knetic/govaluate
// 作用:用于计算任意表达式的值
// 参考链接:https://mp.weixin.qq.com/s/X6yMzAoylNbuXj4CfudQLw
package govaluateuse
import (
"errors"
"fmt"
"github.com/Knetic/govaluate"
"testing"
)
func TestGovaluate_Simple(t *testing.T){
expr,_:=govaluate.NewEvaluableExpression("a + b")
params:=make(map... |
package medasync
import (
"git.scc.kit.edu/sdm/lsdf-checksum/meda"
)
// truncateInsertsQuery is the SQL query performing an TRUNCATE TABLE
// statement on the inserts table. The query is meant to be run using exec and
// has no output.
//
// The query requires no parameters.
const truncateInsertsQuery = meda.Generic... |
package glogger
import (
"net/http"
"strings"
"time"
"github.com/google/uuid"
"github.com/gorilla/mux"
"github.com/sirupsen/logrus"
)
const (
correlationIDKey = "X-Request-Id"
contentTypeKey = "Content-Type"
userAgentKey = "user-agent"
forwardedHostKey = "X-Forwarded-Host"
forwardedForKey = "X-Forw... |
package consensus
import "go.uber.org/fx"
var Module = fx.Options(
fx.Provide(
NewConsensusManager,
NewConsensusHandler,
NewDisputeManager,
),
)
|
package cache
import "github.com/BorisBorshevsky/GolangDemos/catapult"
const fallbackKeyPrefix = "$fb$"
type falbackCacheMaker struct {
Provider
key string
}
func AddFallbackCache(provider Provider) *falbackCacheMaker {
return &falbackCacheMaker{
Provider: provider,
}
}
func (c *falbackCacheMaker) WithKey(ca... |
package routers
import (
"ions_zhiliao/controllers"
"github.com/astaxie/beego"
"ions_zhiliao/controllers/auth"
"ions_zhiliao/controllers/caiwu"
"ions_zhiliao/controllers/cars"
"ions_zhiliao/controllers/echarts"
"ions_zhiliao/controllers/login"
"ions_zhiliao/controllers/news"
"ions_zhiliao/controllers/user"
)
... |
/*
This challenge is really simple (and a precursor to a more difficult one!).
Given an array of resource accesses (simply denoted by nonnegative integers) and a parameter n, return the number of cache misses it would have assuming our cache has capacity n and uses a first-in-first-out (FIFO) ejection scheme when it ... |
package main
import (
"bufio"
"bytes"
"encoding/csv"
"encoding/json"
"fmt"
"io"
"net/http"
"net/http/httputil"
"os"
"os/signal"
"syscall"
)
type jobResult struct {
resp *http.Response
err error
}
func job(jobs chan []string, results chan<- jobResult) {
for urls := range jobs {
buffer := new(bytes.Bu... |
// Copyright (c) 2020 Xiaozhe Yao & AICAMP.CO.,LTD
//
// This software is released under the MIT License.
// https://opensource.org/licenses/MIT
package entities
import (
"reflect"
"testing"
"time"
)
func TestLog_TableName(t *testing.T) {
type fields struct {
ID string
Title string
Filepath str... |
package app
import (
"errors"
"html/template"
"io"
"net"
"net/http"
"strconv"
"time"
log "github.com/sirupsen/logrus"
"google.golang.org/grpc"
"main/server"
"main/utils"
database "g.ghn.vn/scte-common/godal"
"main/apis/employeepb"
_ "github.com/jinzhu/gorm/dialects/postgres"
"github.com/labstack/e... |
package main
import (
"github.com/go-redis/redis"
"github.com/satori/go.uuid"
"log"
"math"
"strings"
)
// 标志字符串
const VALID_CHARACTS string = "`abcdefghijklmnopqrstuvwxyz{"
// 由ascii码顺序我们可以向集合添加标记符号来快速查找指定前缀所在的范围
func Find_Prefix_range(predix string) (start string, end string) {
// 找到最后一个字符在valid字符串中的位置
posn ... |
package main
import (
"database/sql"
"flag"
"fmt"
"html/template"
"log"
"os"
"os/exec"
"path/filepath"
"strconv"
"strings"
"unicode"
_ "github.com/lib/pq"
)
func main() {
currdir, err := os.Getwd()
if err != nil {
printAndExit(err)
}
var (
databaseFlag = flag.String("database", "", "(required) D... |
package command
import (
"encoding/json"
"errors"
"fmt"
"github.com/jclem/graphsh/types"
)
type parsedSchema struct {
Data struct {
Type struct {
Fields []struct {
Name string
Description string
}
} `json:"__type"`
}
}
func getSchema(s types.Session, typename string) (parsedSchema, er... |
package utils
import "time"
type Time interface {
Now() time.Time
}
type TimeImpl struct{}
func NewTime() Time {
return &TimeImpl{}
}
func (t *TimeImpl) Now() time.Time {
return time.Now()
}
|
// Copyright 2019 The OpenSDS 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 agre... |
// 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 common
import (
"fmt"
"io"
"math/rand"
"net/http"
"strings"
"time"
)
const (
NeteaseMusicOrigin = "https://music.163.com"
NeteaseMusicReferer = "https://music.163.com"
NeteaseMusicCookie = "appver=4.1.3; MUSIC_U=dc5b075d43a3815098b96ce361510c5045495a205ea9ff85e5ea6c502a777644538edaa51b1a56a3e83f5c6... |
package main
import (
"bytes"
"encoding/json"
"errors"
"io"
"io/ioutil"
"net/http"
"os"
"os/exec"
"strings"
"time"
"github.com/azure-nginx/azure-nginx/common"
)
type NginxAgent struct {
}
var (
backupPath = os.Getenv("HOME") + "/nginxagent"
confPath = "/etc/nginx/nginx.conf"
contro... |
package main
import (
"context"
"fmt"
"io"
"io/ioutil"
"math"
"net/http"
"os"
"sort"
"github.com/u-root/webboot/pkg/menu"
)
// WriteCounter counts the number of bytes written to it. It implements an io.Writer
type WriteCounter struct {
received float64
expected float64
progress menu.Progress
}
func NewW... |
package centos
import (
"github.com/caos/orbos/mntr"
)
func getEnsureTarget(monitor mntr.Monitor, zoneName string) ([]string, error) {
var changeTarget []string
target, err := runFirewallCommand(monitor, "--zone", zoneName, "--permanent", "--get-target")
if err != nil {
return changeTarget, err
}
if target !... |
package saucecloud
import (
"github.com/saucelabs/saucectl/internal/playwright"
"github.com/stretchr/testify/assert"
"testing"
)
func TestPlaywright_GetSuiteNames(t *testing.T) {
runner := &PlaywrightRunner{
Project: playwright.Project{
Suites: []playwright.Suite{
{Name: "suite1"},
{Name: "suite2"},
... |
package routes
import (
"github.com/gin-gonic/gin"
"github.com/stetsd/blo-go/ctrls"
"github.com/stetsd/blo-go/middlewares"
)
func Init(router *gin.Engine) {
router.Use(middlewares.SetUserStatus())
router.GET("/", ctrls.ShowIndexPage)
router.GET("/forbidden", ctrls.Forbidden)
userRoutes := router.Group("/us... |
package model
import (
"bufio"
"encoding/csv"
"io"
"os"
"quoter/src/api/config/loggers"
"quoter/src/api/model/domain"
"quoter/src/api/model/repository"
)
func PopulateDb(filePath string) {
f, err := os.Open(filePath)
if err != nil {
loggers.Warning.Println("Could not populate the database", err)
return
... |
package main
// The following implements the main Go
// package starting up the paxos server
import (
"net/http"
"os"
log "github.com/sirupsen/logrus"
"./handlers"
)
const (
// PORT defines the port value
// for the Paxos Server service
PORT = "8080"
)
func init() {
log.SetOutput(os.Stdout)
log.SetLevel(... |
package v1
import (
"database/sql"
"github.com/moyrne/tebot/internal/models"
)
type QMessage struct {
ID int `json:"id"`
Time int `json:"time"` // 时间戳
SelfID int `json:"self_id"` // 用户ID
PostType string `json:"post_type"` // 上报类型 meta_event, m... |
/*
Given a string, return a version without the first and last char, so "Hello" yields "ell". The string length will be at least 2.
*/
package main
import (
"fmt"
)
func without_end(s string) string {
if len(s) < 2 { return s }
return s[1:len(s)-1]
}
func main(){
var status int = 0
if without_end("Hello") == "e... |
// 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 main
import (
"log"
"net"
)
var ips map[string]string
func getIPs() map[string]string {
ifaces, err := net.Interfaces()
if err != nil {
log.Fatal(err)
}
ips = make(map[string]string, len(ifaces))
for _, i := range ifaces {
addrs, err := i.Addrs()
if err != nil {
log.Printf("localAddresses: %... |
// Copyright 2016 CoreOS, 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 main
import (
"bytes"
"log"
)
// radix tree, combine with timeline
// +-----------+
// | root, / | here is radix tree
// +-----------+
// / \
// +--------+ +----------+
// | ... | | user |... |
// Package bind is for modular binding of mix to audio interface
package bind
import (
"io"
"time"
"github.com/go-mix/mix/bind/hardware/null"
"github.com/go-mix/mix/bind/opt"
"github.com/go-mix/mix/bind/sample"
"github.com/go-mix/mix/bind/sox"
"github.com/go-mix/mix/bind/spec"
"github.com/go-mix/mix/bind/wav"... |
package models
//分类
type GoodsCategory struct {
Name string `json:"name"`
ID uint `json:"id"`
} |
package main
type Service interface {
Start()
Log(string)
}
type Logger struct {
}
func (g *Logger) Log(l string) {
}
type GameService struct {
Logger
}
func (g *GameService) Start() {
}
|
package rest
import (
"github.com/golang/protobuf/ptypes"
"github.com/jinmukeji/jiujiantang-services/pkg/rest"
"github.com/jinmukeji/jiujiantang-services/service/wechat"
proto "github.com/jinmukeji/proto/v3/gen/micro/idl/partner/xima/core/v1"
"github.com/kataras/iris/v12"
)
// GetWxmpTempQrCodeUrl 得到临时微信二维码
func... |
package module
import (
"buddin.us/eolian/dsp"
"github.com/mitchellh/mapstructure"
)
func init() {
Register("LPGate", func(c Config) (Patcher, error) {
var config struct{}
if err := mapstructure.Decode(c, &config); err != nil {
return nil, err
}
return newLPG()
})
}
type lpg struct {
IO
in, ctrl, mo... |
package game
import (
"fmt"
"testing"
)
var checkStateTests = []struct {
description string
object Ticktacktoe
expected int
}{
{"Empty playing field", Ticktacktoe{[9]int{0, 0, 0, 0, 0, 0, 0, 0, 0}, 0}, 0},
{"Draw", Ticktacktoe{[9]int{1, 2, 1, 2, 2, 1, 1, 1, 2}, 9}, 3},
{"Victory player one", Ticktackt... |
/*
Testing helper functions.
It should not be seen in the imports outside of testing.
*/
package testutil
|
package types
import (
// Stdlib
"bytes"
"encoding/hex"
"fmt"
"testing"
// RPC
"github.com/weibocom/steem-rpc/encoding/transaction"
"github.com/weibocom/steem-rpc/types"
base58 "github.com/itchyny/base58-go"
)
func TestVoteOperation_MarshalTransaction(t *testing.T) {
op := &types.VoteOperation{
Voter: ... |
package walletrpcclient
import (
"math"
"time"
"github.com/decred/dcrd/chaincfg/chainhash"
"github.com/decred/dcrd/dcrutil"
"github.com/decred/dcrwallet/netparams"
pb "github.com/decred/dcrwallet/rpc/walletrpc"
)
type TransactionDirection int8
const (
// TransactionDirectionSent for transactions sent to exte... |
package userstory
import (
"container/list"
)
type UserStory struct {
topic string
executorDataList *list.List
}
func New(topic string) UserStory {
return UserStory{topic: topic, executorDataList: list.New()}
}
func (us UserStory) Tell(name string, testCaseFun func(busybox BusyBox)) UserStory {
us.e... |
package main
import (
"myzone/router"
"github.com/spf13/viper"
"flag"
"strings"
"myzone/db"
"encoding/gob"
"myzone/model"
"os"
"os/signal"
"syscall"
"fmt"
)
var (
fConfig = flag.String("config", "config.yaml", "configuration file to load")
)
func main() {
//设置配置
viper.AddConfigPath("config")
*fConfig ... |
package controller
import (
"fmt"
"reflect"
"sixedu/util"
"strconv"
"strings"
"errors"
)
var (
authController *AuthController
next string
view string
)
func init() {
authController = &AuthController{}
fmt.Println(util.GetConfig())
}
func Run() {
next = "index::Welcome"
f... |
package types
import (
"fmt"
"strconv"
"strings"
)
type SymbolInfo struct {
Symbol Symbol
MinPrice string
MinLotQuantity string
priceDecimalPlaces int
priceInc int
}
func NewSymbolInfo(symbol Symbol, minPriceDecimalPlaces string, minLotQuantity string) (si SymbolInfo) {
si = SymbolI... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.