text stringlengths 11 4.05M |
|---|
package main
import (
"net/http"
"fmt"
"context"
"time"
)
func main() {
http.HandleFunc("/",index)
http.Handle("/favicon.ico",http.NotFoundHandler())
http.ListenAndServe(":8080",nil)
}
func index(w http.ResponseWriter,r *http.Request){
ctx:=r.Context()
ctx=context.WithValue(ctx,"uid",1234)
ctx=context.W... |
package processor
import (
"encoding/json"
"github.com/citrus-tart/certificate-aggregator/certificate"
"github.com/citrus-tart/certificate-aggregator/events"
)
type Repository interface {
GetById(string) certificate.Certificate
Save(certificate.Certificate) certificate.Certificate
}
type processor struct {
re... |
package ui
import (
"testing"
"time"
)
func TestInitMultiProgressInSilentMode(t *testing.T) {
var pw = InitMultiProgress(10, 5)
if !pw.silent {
t.Error("ProgressWrapper should be in silent mode")
}
}
func TestInitMultiProgressInSilentModeWithoutMultiProgress(t *testing.T) {
var pw = InitMultiProgress(10, 5)... |
package libtsm
import (
"fmt"
"reflect"
"runtime"
"unsafe"
)
// #cgo pkg-config: libtsm
// #include <stdlib.h>
// #include <libtsm.h>
// #include "callback_wrapper.h"
import "C"
type VteWriteCallback func(data string)
type vteRef struct {
ptr *C.struct_tsm_vte
writeCallback VteWriteCallback
}
type ... |
package main
import "fmt"
func f1() int {
x, y := 10, 5
if x > 0 {
return y
}
return 0
}
func main() {
// simple if control
fmt.Printf("x = %v \n", f1())
}
|
// Copyright © 2020 Attestant Limited.
// 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 core
import (
"fmt"
"log"
)
type Blockchain struct {
Blocks []*Block
}
func NewBlockchain() *Blockchain {
genesisBlock := GenerateGenesisBlock()
blockchain := Blockchain{}
blockchain.ApendBlock(&genesisBlock)
return &blockchain
}
func (bc *Blockchain) SendData(data string) {
preBlock := bc.Blocks[len... |
package common
//--------------通用的错误定义小于1000---------------------
const (
Success int = 0 // 成功
MissingParam int = 101 // 缺少必须参数
InvalidParam int = 102 // 无效的参数
VerifyParamFailed int = 103 // 参数验证失败
SystemUnknowErr int = 201 // 未知错误
SystemInternalErr int = 202 // 系统内部出错
SystemBusy int = 203... |
package format
import (
"github.com/g-harel/gothrough/internal/types"
)
func formatField(field *types.Field) *Snippet {
snippet := NewSnippet()
if field.Name != "" {
snippet.fieldName(field.Name)
snippet.space()
}
snippet.fieldType(field.Type)
return snippet
}
func formatFieldList(fields []types.Field) *... |
package db
import (
"bytes"
"crypto/sha256"
"fmt"
"os"
"path/filepath"
"strconv"
"strings"
"time"
"github.com/boltdb/bolt"
"github.com/subutai-io/agent/log"
"github.com/subutai-io/gorjun/config"
)
var (
bucket = []byte("MyBucket")
search = []byte("SearchIndex")
users = []byte("Users")
tokens = []byte... |
package main
import (
"GoRepositories/Mongo"
"errors"
"fmt"
"log"
"time"
"gopkg.in/mgo.v2"
"gopkg.in/mgo.v2/bson"
// "errors"
// "fmt"
// "log"
// "strconv"
// "strings"
// "time"
// "GoRepositories/Mongo"
// "gopkg.in/mgo.v2"
// "gopkg.in/mgo.v2/bson"
)
func main() {
// connectionString := ... |
package main
import (
"edjubert/CodeGenerator/functions"
"edjubert/CodeGenerator/parse"
)
func main() {
n, name, prefix, ext := parse.Flags()
functions.WriteCSV(*name, *n, *prefix, *ext)
}
|
package webserver
import (
"net/http"
)
type handlerContainer interface {
PreviewHandler(w http.ResponseWriter, r *http.Request)
}
func newHandlerContainer(store Pagestorer) handlerContainer {
return newService(store)
}
func getRoutes(s handlerContainer) Routes {
var routes = Routes{
{
Name: "BlogI... |
package 路径和问题
// ---------------------- 记忆化搜索 ----------------------
const INF = 100000000000
var maxSumStartWithNode map[*TreeNode]int
func maxPathSum(root *TreeNode) int {
maxSumStartWithNode = make(map[*TreeNode]int)
return getMaxPathSum(root)
}
func getMaxPathSum(root *TreeNode) int {
if root == nil {
retu... |
package gov
import sdk "github.com/irisnet/irishub/types"
var _ Proposal = (*SoftwareUpgradeProposal)(nil)
type SoftwareUpgradeProposal struct {
BasicProposal
ProtocolDefinition sdk.ProtocolDefinition `json:"protocol_definition"`
}
func (sp SoftwareUpgradeProposal) GetProtocolDefinition() sdk.ProtocolDefinition {... |
//go:generate jwg -output model_json.go -transcripttag swagger .
//go:generate qbg -output model_query.go -usedatastorewrapper .
package favcliptools
import (
"context"
"encoding/json"
"fmt"
"testing"
"go.mercari.io/datastore"
"go.mercari.io/datastore/boom"
"go.mercari.io/datastore/testsuite"
)
var _ datasto... |
package main
import "fmt"
func main() {
var atai1 intType = 3
var atai2 intType = 1
fmt.Println(add(atai1, atai2))
}
type intType int
func add(args ...interface{}) intType {
var ans intType
for _, v := range args {
ans += v.(intType)
}
return ans
}
|
package service
import (
"bytes"
"context"
"strings"
"testing"
"time"
"github.com/go-pkgz/repeater"
"github.com/go-pkgz/repeater/strategy"
"github.com/robfig/cron/v3"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/mock"
"github.com/stretchr/testify/require"
"github.com/umputun/cronn/app... |
package fake_uploader
import (
"errors"
"net/url"
)
type FakeUploader struct {
UploadedFileLocations []string
UploadUrls []*url.URL
UploadSize int64
alwaysFail bool
}
func New() *FakeUploader {
return &FakeUploader{}
}
func (uploader *FakeUploader) Upload(fileLocation string,... |
package main
import (
"fmt"
"git.roosoft.com/bitcoin/hd-wallets/lib"
seed "git.roosoft.com/bitcoin/hd-wallets/1-seed"
masterkey "git.roosoft.com/bitcoin/hd-wallets/2-masterPrivateKey"
childkeys "git.roosoft.com/bitcoin/hd-wallets/3-childKeys"
xpub "git.roosoft.com/bitcoin/hd-wallets/4-xpub"
)
func doSeed() {
... |
package cw
import (
"fmt"
)
func AdjacentElementsProduct() {
data := []int{-23, 4, -3, 8, -12}
fmt.Println(adjacentElementsProduct(data))
}
/**
Given an array of integers,
find the pair of adjacent elements
that has the largest product and return that product.
*/
func adjacentElementsProduct(inputArray []int) i... |
package main
import "fmt"
type user struct {
name string
address string
}
func updateValues(u user) user {
u.name = "diwakar"
u.address = "jaipur"
return u
}
func main() {
u := user{name: "ravi", address: "abc"}
u = updateValues(u)
fmt.Println(u)
}
|
package analyze
import (
"context"
"github.com/jmoiron/sqlx"
"github.com/moyrne/tebot/internal/database"
"github.com/moyrne/tebot/internal/models"
"github.com/moyrne/weather"
"github.com/pkg/errors"
"strings"
)
var replacer = strings.NewReplacer("绑定位置", "", " ", "", "\t", "")
func BindArea(ctx context.Context... |
package core
import (
"er"
"math/rand"
)
func prfInit(me *gameImp) *er.Err {
me.lg.Dbg("Enter Round Finish phase")
if me.gd.Round >= me.gd.MinRounds {
if rand.Intn(6)+1-me.gd.MinRounds > 3-me.gd.Round {
return me.gotoPhase(_P_GAME_SETTLEMENT)
}
}
return me.gotoPhase(_P_ROUNDS_START)
}
|
/**
*@Author: haoxiongxiao
*@Date: 2019/1/27
*@Description: CREATE GO FILE api_services
*/
package hotel_api_services
type CreateOrderApiService struct{}
type CreateOrderReqParams struct {
CustomerName string `json:"customerName"`
RatePlanId string `json:"ratePlanId"`
HotelId string `json:"hotelId"`
... |
package templates
import (
"testing"
)
const (
templatesPath = "."
templateName = "test_template"
)
func Test_GetTemplateMeta(t *testing.T) {
var expectedTemplateSubject = "TestTemplateSubject"
// Get template Metadata
var templateMeta = getTemplateMeta(templatesPath + "/meta/" + templateName + ".json")
if ... |
package main
var (
board [8][8]byte
done bool
)
func printBoard() {
for i:=0; i<8; i++ {
for j:=0; j<8; j++ {
print(" ", board[i][j])
}
println()
}
}
func move(x, y int, n byte) {
if !done && 0<=x && x<8 && 0<=y && y<8 && board[x][y] == 0 {
board[x][y] = n
if n == 64 {
printBoard... |
/*
** description("").
** copyright('open-im,www.open-im.io').
** author("fg,Gordon@tuoyun.net").
** time(2021/9/15 10:28).
*/
package manage
import (
pbUser "Open_IM/pkg/proto/user"
"Open_IM/pkg/common/config"
"Open_IM/pkg/common/log"
"Open_IM/pkg/grpc-etcdv3/getcdv3"
"context"
"github.com/gin-gonic/gin"
"net... |
package cmd
import (
"errors"
"fmt"
"github.com/bbrowning/ocf/pkg/app"
"github.com/spf13/cobra"
)
const (
unbindCmdLong = `
Unbind a service from an application.
This command emulates Cloud Foundry's 'cf unbind-service' command but
targeting OpenShift instead. Not all the Cloud Foundry options are
supported; ... |
package main
func partition(head *ListNode, x int) *ListNode {
before := &ListNode{
Val: 0,
Next: nil,
}
bn := before
after := &ListNode{
Val: 0,
Next: nil,
}
an := after
for head != nil {
temp := head
head = head.Next
if temp.Val >= x {
an.Next = temp
an = an.Next
} else {
bn.Next = ... |
// 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 cli
import "github.com/scaleway/scaleway-cli/pkg/commands"
var cmdInspect = &Command{
Exec: runInspect,
UsageLine: "inspect [OPTIONS] IDEN... |
/**
* @program: Go
*
* @description:
*
* @author: Mr.chen
*
* @create: 2020-03-06 15:42
**/
package middleware
import "github.com/kataras/iris"
func AuthConProduct(ctx iris.Context) {
uid := ctx.GetCookie("uid")
if uid == "" {
ctx.Application().Logger().Debug("必须先登录!")
ctx.Redirect("/user/login")
return
}
... |
package types
// characterSearchResponse - a partial search response from stapi
type SearchResponse struct {
Characters []Character `json:"characters"`
Species []Species `json:"species"`
}
// FetchResponse - a partial fetch response from stapi
type FetchResponse struct {
Character FullCharacter `json:"charact... |
package ll3
// use doubly linked list
type MyLinkedList struct {
len int
head *Node
tail *Node
}
type Node struct {
data int
next *Node
prev *Node
}
// node can not be head in linked list
// because we can not change head of
// linked in this func
func (p *Node) insertPrev(val int) *Node {
np := &Node{
dat... |
package Router
type Article struct{
Article_id int
Article_name string
Article_content string
}
type ArticleResponse struct {
Id int
Name string
}
type Comment struct{
Comment_content string
Comment_publisher string
Article_id int
}
|
package productstock
import (
"time"
)
//ProductStock is the definition of product stock table in database
type ProductStock struct {
ID uint `gorm:"primary_key" json:"id" valid:"-"`
Stock int `gorm:"not null" json:"stock" valid:"numeric,required"`
AverageBuyPrice float64 `g... |
package main
import (
"bufio"
"fmt"
"math"
"os"
"regexp"
"sort"
"strconv"
"strings"
)
const (
ImmuneSystem = iota
Infection = iota
)
type UnitGroup struct {
team int
count int
hp int
damage int
attackType string
initiative int
weak string
immune string
}
func (u... |
package vm
import (
"fmt"
"math/rand"
"os"
)
//VM implemets chip8 vm
type VM struct {
Memory [4096]uint8
Gfx [32][64]uint8
Stack [16]uint16
V [16]uint8
I, PC, SP uint16
DelayTimer uint8
SoundTimer uint8
OpCode uint16
DrawFlag bool
Keys [16]bool
}
//Fonts bytes
var F... |
package models
type (
GlobalStats struct {
Hostname string `json:"hostname"`
Time string `json:"time"`
Channels int64 `json:"channels"`
WildcardChannels int64 `json:"wildcard_channels"`
PublishedMessages int64 `json:"published_messages"`
StoredMessages int64 `json:"s... |
package main
import "fmt"
/*
当出现多个if-else时可考虑用其代替
!思考:if和switch的区别?
if 可以嵌套 可以判断区间 执行效率比较低
switch 执行效率高 不能嵌套和区间判断
特性:
1.switch 选择项可以是一个整型变量
2.swich中的值不能是浮点型数据 浮点型数据是一个约等于的数据
*/
func main() {
// 判断今天是星期几
var a int
INPUT:
fmt.Println("请输入1~7数字")
fmt.Scan(&a)
switch a {
case 1:
fmt.Printl... |
package tsmt
import (
"encoding/xml"
"github.com/thought-machine/finance-messaging/iso20022"
)
type Document03100103 struct {
XMLName xml.Name `xml:"urn:iso:std:iso:20022:tech:xsd:tsmt.031.001.03 Document"`
Message *StatusExtensionRequestAcceptanceV03 `xml:"StsXtnsnReqAccptnc"`
}
fun... |
// This file was generated for SObject ContentWorkspacePermission, API Version v43.0 at 2018-07-30 03:47:45.900435663 -0400 EDT m=+32.244251991
package sobjects
import (
"fmt"
"strings"
)
type ContentWorkspacePermission struct {
BaseSObject
CreatedById string `force:",omitempty"`
CreatedDat... |
// Copyright (C) 2015 Nicolas Lamirault <nicolas.lamirault@gmail.com>
// 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 ... |
package log
import (
"fmt"
"os"
"path"
api "github.com/tkhoa2711/proglog/api/v1"
"google.golang.org/protobuf/proto"
)
// The segment wraps the index and store types to coordinate operations across
// the two.
//
// The base offset tells us where the segment starts. The next offset allows us
// to know where to ... |
//author xinbing
//time 2018/9/5 13:52
//正则表达式验证集合
package utilities
import (
"regexp"
)
// 校验国内手机号码
var phoneReg = regexp.MustCompile("^((13[0-9])|(14[5,7])|(15[0-3,5-9])|(17[0-3,5-8])|(18[0-9])|166|198|199)\\d{8}$")
func ValidPhone(phone string) bool{
if len(phone) == 0 {
return false
}
return phoneReg.MatchS... |
package main
import "project-backend/API"
func main () {
API.Run()
}
|
package file
import (
"io"
"os"
"path"
"sync"
)
func newSingle(filename string) *single {
return &single{
filename: filename,
}
}
var _ io.WriteCloser = (*single)(nil)
type single struct {
sync.Once // to open file
filename string
f *os.File
}
func (s *single) Write(p []byte) (n int, err error)... |
package internal
import (
"errors"
"os"
"testing"
)
func TestAuxvVDSOMemoryAddress(t *testing.T) {
av, err := os.Open("../testdata/auxv.bin")
if err != nil {
t.Fatal(err)
}
t.Cleanup(func() { av.Close() })
addr, err := vdsoMemoryAddress(av)
if err != nil {
t.Fatal(err)
}
expected := uint64(0x7ffd377e... |
package http
import (
"net/http"
"os"
"github.com/jinzhu/gorm"
"github.com/smilga/analyzer/api"
"github.com/smilga/analyzer/api/comm"
"github.com/smilga/analyzer/api/datastore/cache"
"github.com/smilga/analyzer/api/datastore/mysql"
"github.com/smilga/analyzer/api/ws"
)
type Handler struct {
Auth a... |
// Copyright 2022 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 couchdb_test
import (
"testing"
"github.com/Liu710/couchdb"
)
var docID string
func TestNewCouchDB(t *testing.T) {
_, cErr := couchdb.NewCouchDB(couchdb.CouchDBConfig{
Host: "http://localhost:5984",
Username: "test_user",
Password: "test_password",
Database: "test_db",
})
if cE... |
/*
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, so... |
package maps
import "testing"
func TestSearch(t *testing.T) {
t.Run("Known word", func(t *testing.T) {
const testKey string = "test"
const testValue string = "this is just a test"
dictionary := Dictionary{testKey: testValue}
got, _ := dictionary.Search(testKey)
want := testValue
assertStrings(want, go... |
package main
import (
"controller"
"github.com/zenazn/goji"
)
const (
albumRoutePrefix = "/v1/albums"
)
func main() {
albumController := new(controller.AlbumController)
// POST /v1/albums
goji.Post(albumRoutePrefix, albumController.Store)
// GET /v1/albums
goji.Get(albumRoutePrefix, albumCo... |
package ui
import (
"context"
"fmt"
"log"
"os"
"fyne.io/fyne/v2"
"fyne.io/fyne/v2/dialog"
"fyne.io/fyne/v2/widget"
"github.com/kouame-florent/axone-cx/api/grpc/gen"
"github.com/kouame-florent/axone-cx/internal/axone"
"github.com/kouame-florent/axone-cx/internal/svc"
)
type AuthView struct {
view
loginEnt... |
package api
import (
"fmt"
"github.com/gin-gonic/gin"
"github.com/mojocn/base64Captcha"
"go.uber.org/zap"
"image/color"
"net/http"
"shop-web/user-api/utils"
)
var store = utils.RedisStore{}
func GetCaptcha(ctx *gin.Context) {
rgba := color.RGBA{
R: 3,
G: 102,
B: 214,
A: 254,
}
fonts := []string{"wq... |
package main
import "fmt"
type N int
func (n N) value() {
n++
fmt.Println("v: %p %v \n ", &n, n)
}
func (n *N) pointer() {
(*n)++
fmt.Println("v: %p %v \n ", n, *n)
}
func main() {
var a N = 25
p := &a
p2 := &p
(*p2).value()
(*p2).pointer()
}
|
/**
* @file
* @copyright defined in aergo/LICENSE.txt
*/
package system
import (
"math/big"
"testing"
"github.com/aergoio/aergo/types"
"github.com/mr-tron/base58/base58"
"github.com/stretchr/testify/assert"
)
func TestBasicExecute(t *testing.T) {
scs, sender, receiver := initTest(t)
defer deinitTest()
... |
package guidService
import (
"github.com/button-tech/BNBTextWallet/data"
"github.com/button-tech/BNBTextWallet/services/redisService"
"github.com/google/uuid"
"time"
)
const guidLifetime = 100 * time.Minute
func Generate(data data.DiscordGuidStamp) (string, error) {
guid := generateGuid()
return guid, redisSer... |
package api
import (
"fmt"
)
func main() {
fmt.Println('api')
} |
package carbonserver
import (
"encoding/json"
"fmt"
"go.uber.org/zap/zapcore"
"net/http"
_ "net/http/pprof"
"strconv"
"strings"
"sync/atomic"
"time"
"go.uber.org/zap"
tindex "github.com/lomik/go-carbon/tags/index"
// protov2 "github.com/go-graphite/protocol/carbonapi_v2_pb"
// protov3 "github.com/go-gra... |
package env
import (
"flag"
"fmt"
"os"
"time"
)
var (
appname string
nodeid string
)
func init() {
flag.StringVar(&appname, "appname", "", "AppName of application. e.g. -appname=nekoq")
flag.StringVar(&nodeid, "node", "", "Unique Node Id of application. e.g. -node=nekoq001")
flag.Parse()
ensure, found := ... |
package usecase
import (
"github.com/Arkadiyche/bd_techpark/internal/pkg/models"
"github.com/Arkadiyche/bd_techpark/internal/pkg/user"
)
type UserUseCase struct {
UserRepository user.Repository
}
func NewUserUseCase(userRepository user.Repository) *UserUseCase {
return &UserUseCase{
UserRepository: userReposit... |
package controllers
import (
"github.com/devplayg/ipas-mcs/objs"
"github.com/devplayg/ipas-mcs/models"
"strconv"
log "github.com/sirupsen/logrus"
"strings"
)
type IpaslistController struct {
baseController
}
func (c *IpaslistController) GetIpasInOrg() {
filter := c.getFilter()
logs, total, err := models.GetI... |
// Copyright © 2019 IBM Corporation and others.
//
// 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 la... |
package main
import (
"github.com/stretchr/testify/assert"
"testing"
)
func Test_test(t *testing.T) {
res := maxSumAfterPartitioning([]int{1, 15, 7, 9, 2, 5, 10}, 3)
assert.Equal(t, 84, res)
}
|
package router
import (
"collectbackend/controllers"
middlewares "collectbackend/middlewares"
"github.com/gin-gonic/gin"
)
// InitRouter 路由初始化
func InitRouter() {
router := gin.Default()
// 要在路由组之前全局使用「跨域中间件」, 否则OPTIONS会返回404
router.Use(middlewares.Cors())
// 使用 session(cookie-based)
// router.Use(sessions.S... |
package client
import (
"bytes"
"encoding/json"
"fmt"
"io/ioutil"
"net/http"
"os"
"strconv"
"strings"
"time"
"github.com/sirupsen/logrus"
tuf "github.com/theupdateframework/notary/tuf/data"
)
type Api struct {
serverUrl string
apiToken string
}
type NetInfo struct {
Hostname string `json:"hostname"`
... |
package account
import (
"github.com/go-openapi/runtime/middleware"
"github.com/go-openapi/swag"
"mingchuan.me/api"
"mingchuan.me/api/models"
apiAccount "mingchuan.me/api/restapi/operations/account"
"mingchuan.me/app/errors"
)
// Routes - create a struct with instance inside it
// this is to help do mock testin... |
package actions
import (
"encoding/json"
"errors"
"fmt"
"io/ioutil"
"log"
"net/http"
"net/url"
"regexp"
"sort"
"strconv"
"strings"
"sync"
"time"
"github.com/lestrrat/go-libxml2"
"github.com/lestrrat/go-libxml2/types"
"github.com/mahendrakalkura/torrents/go/settings"
"github.com/mvdan/xurls"
"github.... |
package main
import (
"encoding/json"
"flag"
"fmt"
"io/ioutil"
"os"
"path/filepath"
"strings"
"text/template"
"github.com/0LuigiCode0/go-gen/tmp"
"github.com/0LuigiCode0/logger"
)
//config модель конфигураций
type config struct {
ModuleName string `json:"module_name"`
GoVersion floa... |
package handlers
import (
"encoding/json"
"time"
rest "github.com/danteay/ginrest"
"github.com/danteay/lanago/api/models"
"github.com/danteay/lanago/api/config"
"github.com/gin-gonic/gin"
)
// addBasketItemRequest is the request data of the endpoint
type addBasketItemRequest struct {
Code string `json:"code,r... |
package processAvaatechSpe
import (
spereader "readAvaatechSpe"
)
type Spectrum struct {
SPE *spereader.SPE `json:"SPE"`
MaxChannel int `json:"-"`
Signal []float64 `json:"-"`
Peaks []*Peak `json:"-"`
Lines map[string]*Peak `json:"Lines"`
Gain float64 ... |
package game
import (
"github.com/tanema/amore/gfx"
"github.com/tanema/amore/keyboard"
)
const (
playerAcc = 200
playerMaxSpeed = 400
playerRotationSpeed = 6
playerFireRate = 0.40
playerJetSize = 25
playerJetWidth = 0.15
)
type Player struct {
*Sprite
lastFire float32
... |
package integration_test
import (
"os"
"path/filepath"
"github.com/cloudfoundry/libbuildpack/cutlass"
. "github.com/onsi/ginkgo"
. "github.com/onsi/gomega"
)
var _ = Describe("deploy a basic auth app", func() {
var app *cutlass.App
AfterEach(func() {
if app != nil {
app.Destroy()
}
app = nil
})
I... |
package main
import "fmt"
func main() {
// Returning a string
s1 := foo()
fmt.Println("foo:", s1)
// Returning a func
x := bar()
fmt.Printf("bar type: %T\n", x)
fmt.Println("bar:", x())
}
func foo() string {
return "Hello world"
}
// func() int is the type that will be returned
// in the return statement,... |
package main
import (
"fmt"
"os"
)
func main() {
Alice := "Alice"
Borys := "Borys"
n := readInt32()
a := readInt32()
b := readInt32()
if n <= 2 {
fmt.Println(Borys)
os.Exit(0)
}
if absInt32(a, b)%2 == 0 {
fmt.Println(Alice)
} else {
fmt.Println(Borys)
}
}
func readInt32() int32 {
var a int32
... |
package tls
import (
"bytes"
"fmt"
"net"
"testing"
)
func TestHTTPS(t *testing.T) {
c, err := net.Dial("tcp", "www.cloudflare.com:443")
if err != nil {
t.Fatal("connect failed", err)
}
tlsConn := &TLS13Conn{Conn: c}
tlsConn.Handshake()
tlsConn.Write([]byte("GET / HTTP/1.1\r\nHost: www.cloudflare.com\r\n\r... |
package mysqldb
import (
"context"
"os"
"path/filepath"
"strconv"
"testing"
"time"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/suite"
)
// UserTestSuite 是 User 的 testSuite
type UserTestSuite struct {
suite.Suite
db *DbClient
}
// SetupSuite 准备设置 Test Suite 执行
func (suite *UserTestSui... |
package transdsl
type Fragment interface {
Exec(transInfo *TransInfo) error
Rollback(transInfo *TransInfo)
}
func forEachFragments(fragments []Fragment, transInfo *TransInfo) (int, error) {
for i, fragment := range fragments {
err := fragment.Exec(transInfo)
if err != nil {
if isEqual(err, ErrSucc) {
re... |
package main
/*
delta is a command-line diff utility.
Usage:
`delta <file1> <file2> <merged>`
file1 is set to the name of the temporary file containing the contents of the diff pre-image.
file2 is set to the name of the temporary file containing the contents of the diff post-image.
merged is the name of th... |
package app
import (
"bytes"
"compress/gzip"
"context"
"errors"
"io"
"io/ioutil"
"net/http"
"net/url"
"sync"
"time"
"github.com/Sirupsen/logrus"
"github.com/honeycombio/honeycomb-opentracing-proxy/sinks"
"github.com/honeycombio/honeycomb-opentracing-proxy/types"
v1 "github.com/honeycombio/honeycomb-open... |
package src
import (
"github.com/llir/llvm/ir"
"io/ioutil"
"os/exec"
)
const (
// emit an exe
AHEAD_COMPILE uint8 = 0x0
// JIT compile using LLVM execution engine (used for compile time execution)
JIT_COMPILE uint8 = 0x1
SUCCESS_COMP uint8 = 0x0
SUCCESS_JIT uint8 = 0x1
FAIL_COMP uint8 = 0x2
TAV_OUT =... |
package models
import "time"
type SysQuartzLog struct {
ID int `gorm:"primary_key" json:"id"` //ID
BeanName string `json:"bean_name"` //bean对象名称
CronExpression string `json:"cron_expression"` //cron表达式
ExceptionDetail string `json:"exception_detail"` //异常... |
package main
import (
_ "fresh/Fresh-order/FreshOrder/routers"
"github.com/astaxie/beego"
_"fresh/Fresh-order/FreshOrder/models"
)
func main() {
beego.Run()
}
|
package tokensource
import "os"
var debug bool
func init() {
debug = os.Getenv("DEBUG") != ""
}
|
package cmd
import (
"github.com/devspace-cloud/devspace/cmd/flags"
"github.com/devspace-cloud/devspace/pkg/devspace/config/generated"
"github.com/devspace-cloud/devspace/pkg/devspace/services/targetselector"
"github.com/devspace-cloud/devspace/pkg/util/factory"
"github.com/pkg/errors"
"github.com/spf13/cobra"
... |
// Copyright 2021 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... |
/*
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, so... |
package antminer
import (
"bytes"
"context"
"sync"
"github.com/ka2n/masminer/machine"
"github.com/ka2n/masminer/machine/asic/base"
mnet "github.com/ka2n/masminer/net"
"golang.org/x/crypto/ssh"
"golang.org/x/sync/errgroup"
)
// GetSystemInfo returns SystemInfo
func (c *Client) GetSystemInfo() (info SystemInfo... |
/*
* @lc app=leetcode.cn id=1078 lang=golang
*
* [1078] Bigram 分词
*/
package main
import (
"strings"
)
// @lc code=start
func findOcurrences(text string, first string, second string) []string {
ret := []string{}
words := strings.Split(text, " ")
for i := 0; i < len(words)-2; i++ {
if words[i] == first && wo... |
package distribution
import (
"container/ring"
"io"
"sync"
)
func NewRoundRobin() Distribution {
return &RoundRobin{
connections: ring.New(1),
}
}
type RoundRobin struct {
connections *ring.Ring
mu sync.Mutex
}
func (r *RoundRobin) Attach(c io.Writer) error {
r.mu.Lock()
defer r.mu.Unlock()
nr ... |
package crud
import (
"encoding/json"
"fmt"
"net/http"
"reflect"
"strings"
"github.com/go-msvc/errors"
"github.com/go-msvc/log"
"github.com/go-msvc/store"
)
//New ...
func New() Server {
return Server{
stores: make([]store.IStore, 0),
opers: make(map[string]operInfo),
}
}
//Server ...
type Server str... |
package google
import (
"context"
"net/http"
"time"
"github.com/otamoe/oauth-client"
)
type (
Client struct {
oauth.OAuth2
}
)
var Endpoint = oauth.Endpoint{
Name: "google",
AuthorizeURL: "https://accounts.google.com/o/oauth2/auth",
AccessTokenURL: "https://accounts.google.com/o/oauth2/tok... |
package DAO
import (
_ "github.com/go-sql-driver/mysql"
"github.com/jinzhu/gorm"
_ "github.com/jinzhu/gorm/dialects/mysql"
"Work_5/object"
)
func DataBaseInit() (*gorm.DB, object.ErrMessage) {
DB , err := gorm.Open("mysql","root:@(127.0.0.1:3306)/go?charset=utf8mb4&parseTime=True&loc=Local")
return DB , obje... |
package client
import (
"context"
"crypto/tls"
"crypto/x509"
"io"
"io/ioutil"
"time"
"github.com/tsaikd/KDGoLib/errutil"
"github.com/tsaikd/go-grpc-echo/logger"
pb "github.com/tsaikd/go-grpc-echo/pb"
"google.golang.org/grpc"
"google.golang.org/grpc/credentials"
"google.golang.org/grpc/metadata"
)
// Ping... |
/*
Tencent is pleased to support the open source community by making Basic Service Configuration Platform available.
Copyright (C) 2019 THL A29 Limited, a Tencent company. All rights reserved.
Licensed under the MIT License (the "License"); you may not use this file except
in compliance with the License. You may obtain... |
package yousign
import (
"bytes"
"io"
"net/http"
"testing"
"github.com/bxcodec/faker/v3"
"github.com/stretchr/testify/assert"
)
var (
client = NewClientStaging("STAGING-KEY")
)
func fatal(t *testing.T, err error, resp *http.Response) {
var b bytes.Buffer
io.Copy(&b, resp.Body)
t.Fatalf("error %v : %s", er... |
package controller
import (
"model"
"net"
proto "github.com/golang/protobuf/proto"
)
/****************************************** req handler ****************************************/
func PingReq(conn *net.Conn, data []byte, n int, reqBasic ReqBasic) error {
return model.Ping(conn, reqBasic.UserID)
}
func SetU... |
package main
import (
"fmt"
"runtime"
"sync"
)
func main() {
runtime.GOMAXPROCS(1)
var wg sync.WaitGroup
wg.Add(1)
go func(){
defer wg.Done()
fmt.Println("ok")
}()
wg.Wait()
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.