text stringlengths 11 4.05M |
|---|
package main
import (
"net/http"
"log"
"fmt"
"html"
)
func handleIndex(w http.ResponseWriter, r *http.Request) {
fmt.Fprint(w, "Welcome to lesson 1: RethinkDB and Go")
}
func main() {
http.Handle("/", handleIndex)
log.Fatal(http.ListenAndServe(":4567", nil))
}
|
package main
// isTaggable returns true if the given resource type is an AWS resource that supports tags.
func isTaggable(t string) bool {
for _, trt := range taggableResourceTypes {
if t == trt {
return true
}
}
return false
}
// taggableResourceTypes is a list of known AWS type tokens that are taggable.
v... |
// Copyright 2014 Dirk Jablonowski. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
// This ist a base virtual connector, this means,
// that this connector do not(!) connect to a real hardware.
package virtual
import (
"github.com/dirkjabl... |
/*Project Euler - Problem 20
n! means n (n 1) ... 3 2 1
For example, 10! = 10 9 ... 3 2 1 = 3628800,
and the sum of the digits in the number 10! is 3 + 6 + 2 + 8 + 8 + 0 + 0 = 27.
Find the sum of the digits in the number 100!
*/
package euler
import (
"fmt"
"math/big"
"strconv"
)
func Euler020()... |
// Copyright 2021 The ChromiumOS Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
package perfboot
import (
"bufio"
"context"
"io/ioutil"
"regexp"
"strconv"
"strings"
"time"
"chromiumos/tast/common/testexec"
"chromiumos/tast/errors"
"chromiumos... |
package toolbox
import (
"fmt"
"github.com/stretchr/testify/assert"
"strings"
"testing"
)
func TestIsASCIIText(t *testing.T) {
var useCases = []struct {
Description string
Candidate string
Expected bool
}{
{
Description: "basic text",
Candidate: `abc`,
Expected: true,
},
{
Des... |
/*
A handful of examples using the standard builtin types.
*/
package types
|
package handlers
import (
"net/http"
"strconv"
"github.com/abhinavdwivedi440/microservices/data"
"github.com/gorilla/mux"
)
func (p *Product) DeleteProduct(w http.ResponseWriter, r *http.Request) {
vars := mux.Vars(r)
id, _ := strconv.Atoi(vars["id"])
p.l.Println("Handle delete product", id)
err := data.De... |
package conf
import "testing"
const (
testConfigName = "/tmp/config.example.json"
)
func TestNew(t *testing.T) {
if _, err := New("/bad_file_path.json"); err == nil {
t.Error("unexpected behavior")
}
cfg, err := New(testConfigName)
if err != nil {
t.Fatal(err)
}
if cfg.Addr() == "" {
t.Error("empty addr... |
//go:build !windows
package platform
import (
"errors"
"os"
"strings"
"time"
"github.com/shirou/gopsutil/v3/host"
terminal "github.com/wayneashleyberry/terminal-dimensions"
"golang.org/x/sys/unix"
)
func (env *Shell) Root() bool {
defer env.Trace(time.Now(), "Root")
return os.Geteuid() == 0
}
func (env *S... |
package deleteduplicates
import (
"reflect"
"testing"
)
func TestDeleteDuplicates(t *testing.T) {
var head *ListNode
var result, expect []int
head = &ListNode{}
head = deleteDuplicates(head)
result = head.Print()
expect = []int{0}
if !reflect.DeepEqual(result, expect) {
t.Errorf("Get %v, Expect %v", resul... |
package s3httpfile
import (
"github.com/aws/aws-sdk-go/service/s3"
"os"
"path/filepath"
"time"
)
type s3PrefixFileInfo struct {
*s3.CommonPrefix
}
func (fi *s3PrefixFileInfo) Name() string {
return filepath.Base(*fi.CommonPrefix.Prefix)
}
func (fi *s3PrefixFileInfo) Size() int64 {
return -1
}
func (fi *s3Pr... |
// Copyright (C) 2016-Present Pivotal Software, Inc. All rights reserved.
// This program and the accompanying materials are made available under the terms of the 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 Licen... |
package identityservice
import (
"net/http"
"strings"
"github.com/gorilla/mux"
"github.com/itsyouonline/identityserver/db"
"github.com/itsyouonline/identityserver/identityservice/company"
"github.com/itsyouonline/identityserver/identityservice/globalconfig"
"github.com/itsyouonline/identityserver/identityserv... |
package main
import "fmt"
func test(x [2]int) {
fmt.Printf("x: %p\n", &x)
x[1] = 1000
}
func main() {
a := [2]int{}
fmt.Printf("a: %p\n", &a)
test(a)
fmt.Println(a)
println(len(a), cap(a))
fmt.Println("多维数组遍历")
var f [2][3]int = [...][3]int{{1, 2, 3}, {7, 8, 9}}
for k1, v1 := range f {
for k2, v2 := ra... |
package models
import (
meta_v1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"github.com/kiali/kiali/kubernetes"
)
type QuotaSpecs []QuotaSpec
type QuotaSpec struct {
meta_v1.TypeMeta
Metadata meta_v1.ObjectMeta `json:"metadata"`
Spec struct {
Rules interface{} `json:"rules"`
} `json:"spec"`
}
func (qss *Quot... |
package fmap
import (
"fmt"
"log"
"strings"
"github.com/lleo/go-functional-collections/key/hash"
)
type fixedTable struct {
nodes [hash.IndexLimit]nodeI
depth uint
usedSlots uint //numEnts uint
hashPath hash.Val
}
func newFixedTable(depth uint, hashVal hash.Val) *fixedTable {
var t = new(fixedTab... |
package main
import (
"context"
"os"
"os/signal"
exporter "producer/metrics"
"strconv"
"time"
cmap "github.com/orcaman/concurrent-map"
log "github.com/sirupsen/logrus"
"github.com/Shopify/sarama"
)
func init() {
log.SetLevel(logLevel())
}
func main() {
topic := "input"
if value, ok := os.LookupEnv("TOP... |
// Package tvdb provides go bindings for the TVDB API at https://api.thetvdb.com/swagger.
package tvdb
import (
"encoding/json"
"errors"
"fmt"
"net/http"
"time"
)
const BaseURL = "https://api.thetvdb.com/"
// client is the TVDB client struct.
type client struct {
client *http.Client
apiKey string
baseURL s... |
package main
import (
"log"
"fmt"
"time"
"os"
"io/ioutil"
"net/url"
"net/http"
"strings"
"strconv"
"github.com/ChimeraCoder/anaconda"
"github.com/sanear/eightBallBot/questionAnalyzer"
"github.com/sanear/eightBallBot/eightBall"
)
func main() {
port := "8080"
if len(os.Args) > 1 {
port = os.Args[1]
}
... |
package references
import (
"JVM-GO/ch07/instructions/base"
"JVM-GO/ch07/rtda"
"JVM-GO/ch07/rtda/heap"
)
// Create new object
type NEW struct{ base.Index16Instruction }
func (self *NEW) Execute(frame *rtda.Frame) {
cp := frame.Method().Class().ConstantPool()
classRef := cp.GetConstant(self.Index).(*heap.ClassRe... |
package marsmedia
import (
"encoding/json"
"fmt"
"net/http"
"strconv"
"github.com/prebid/openrtb/v19/openrtb2"
"github.com/prebid/prebid-server/adapters"
"github.com/prebid/prebid-server/config"
"github.com/prebid/prebid-server/errortypes"
"github.com/prebid/prebid-server/openrtb_ext"
)
type MarsmediaAdapte... |
package kontena
import (
"fmt"
"io/ioutil"
"os"
"strings"
yaml "gopkg.in/yaml.v2"
"github.com/inloop/goclitools"
"github.com/jakubknejzlik/kontena-git-cli/model"
"github.com/jakubknejzlik/kontena-git-cli/utils"
)
// CreateSecretsImport ...
func (c *Client) CreateSecretsImport(stack, path string, currentSecr... |
package main
import (
"flag"
"fmt"
"os"
"time"
"io/ioutil"
"net"
"crypto/tls"
"crypto/x509"
"github.com/bshuster-repo/logrus-logstash-hook"
log "github.com/sirupsen/logrus"
)
func main() {
sleep := flag.Int("sleep", 5, "time to sleep in seconds")
logstash := flag.String("logstash", "", "logstash serv... |
package piscine
func StrRev(s string) string {
ordstr := []rune(s)
revstr := []rune(s)
var r int
for i := range ordstr {
r = i
}
for i := range revstr {
revstr[i] = ordstr[r]
r = r - 1
}
return string(revstr)
}
|
package lang
type mnil struct {
}
var Nil mnil = mnil{}
func IsNil(e Expr) bool {
_, ok := e.(mnil)
return ok
}
func (n mnil) String() string {
return "nil"
}
func (n mnil) Equal(o Expr) bool {
_, ok := o.(mnil)
return ok
}
|
package main
import (
//"unicode/utf8"
"image/color"
//"math"
"math/rand"
//"fmt"
"gonum.org/v1/gonum/stat/distuv"
"gonum.org/v1/plot"
"gonum.org/v1/plot/plotter"
"gonum.org/v1/plot/vg"
)
const (
//male advantage
m = 5.
//For nA and na. We must also choose values for N, B and... |
package bconf_test
import (
"github.com/art4711/bconf"
"testing"
"fmt"
"strings"
)
var testjson = `{"attr": {"name": {"attrind": "4","attronly": "3","body": "5","id": "0","order": "1","status": "6","suborder": "2"},"order": {"0": "id","1": "order","2": "suborder","3": "attronly","4": "attrind","5": "body","6": "s... |
// Copyright 2019 The Cockroach Authors.
//
// Use of this software is governed by the Business Source License
// included in the file licenses/BSL.txt.
//
// As of the Change Date specified in that file, in accordance with
// the Business Source License, use of this software will be governed
// by the Apache License, ... |
package main
import (
"log"
"midCtrl/devices"
"midCtrl/httpServ"
"midCtrl/serv"
"os"
"time"
)
// serviceConn 和主服务器的连接
// var serviceConn net.Conn
// serviceAddr 主服务器地址
// var serviceAddr string
// InitLoger 初始化log配置
func InitLoger(logPath string) error {
if logPath != "" {
file, err := os.OpenFile(logPath,... |
package utils
import (
"bytes"
"context"
"fmt"
"io"
"io/ioutil"
"log"
"time"
"cloud.google.com/go/storage"
)
func UploadFile(path, name string, data []byte) {
// Prevent log from printing out time information
log.SetFlags(0)
var bucket string
bucket = "bills_upload"
// source = "/home/stingray/Download... |
package service
import (
"fmt"
"intelliq/app/common"
utility "intelliq/app/common"
"intelliq/app/dto"
"intelliq/app/enums"
"intelliq/app/model"
"intelliq/app/repo"
"strings"
"time"
)
func isQuestionInfoValid(question *model.Question) bool {
return strings.HasPrefix(question.GroupCode, common.GROUP_CODE_PREF... |
package main
import (
"fmt"
"github.com/xinxuwang/gevloop"
"log"
"net"
"syscall"
)
type session struct {
bytes []byte
pos int
}
func main() {
accept, err := syscall.Socket(syscall.AF_INET, syscall.O_NONBLOCK|syscall.SOCK_STREAM, 0)
if err != nil {
log.Fatal("err:", err)
}
defer syscall.Close(accept)
... |
package main
import "fmt"
type list struct {
sentinel *node
}
type node struct {
data string
prev *node
next *node
}
func newList() *list {
sentinel := new(node)
sentinel.next = sentinel
sentinel.prev = sentinel
return &list{sentinel}
}
// insert adds the element e at index i in the list l
func (l *list) i... |
package main
import (
"fmt"
"mustard/base/container"
)
type E struct {
name string
age int
}
func main() {
trie := container.NewTrie()
trie.Insert([]byte("01234"))
fmt.Println(trie.Root.DumpChild())
fmt.Println(trie.IsPrefix([]byte("01234")))
fmt.Println(trie.IsPrefix("012345"))
fmt.Println... |
package AuthMiddleware
import (
"encoding/json"
"fmt"
"github.com/gin-gonic/gin"
"mytweet/middlewares/aws/dynamodb"
"net/http"
)
func AuthMiddleware() gin.HandlerFunc {
return func(c *gin.Context) {
fmt.Println("-----AuthMiddleware-----")
uuid, error := c.Cookie("uuid")
if error != nil {
fmt.Println("t... |
package packages
func InitGraph() *Graph {
return &Graph{
nodes: []*Node{},
}
}
func InitNode(id int) *Node {
return &Node{
id: id,
edges: make(map[int]int),
}
}
type Graph struct {
nodes []*Node
}
type Node struct {
id int
edges map[int]int
}
//GetId return node's id
func (n *Node) GetId() int ... |
/*
Copyright 2019 The Tekton Authors
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, softw... |
package conn
import (
"fmt"
_ "github.com/go-sql-driver/mysql"
"github.com/go-xorm/xorm"
)
type DBClient struct {
Engine *xorm.Engine
}
func NewDBClient(user, host, port, pwd, dbName string) (db *DBClient, err error) {
db = &DBClient{}
dataSourceName := fmt.Sprintf("%s:%s@%s:%s/%s?charset=utf8", user, pwd, ho... |
package client
import (
"crypto/sha1"
"encoding/hex"
"hash"
"io"
)
// hasherReader calculates the hash of a byte stream
// As an underlying io.Reader is read from, the hash is updated
type hasherReader struct {
hash hash.Hash
reader io.Reader
}
// newHasherReader creates a new hasherReader from a provided io... |
package main
import (
"time"
"github.com/jacmba/desclock/model"
"github.com/jacmba/desclock/view"
)
func main() {
tm := model.NewTime()
v := view.NewView(tm)
go run(v)
v.Init()
}
func run(v *view.View) {
v.Update()
for {
v.Update()
time.Sleep(100 * time.Millisecond)
}
}
|
package observer
import (
"sync"
"sync/atomic"
)
type Batch struct {
mu sync.Mutex
cond sync.Cond
count uint32
}
func (b *Batch) Exec(f func()) {
i := atomic.AddUint32(&b.count, 1)
if i > 8 {
}
if i > 1 {
}
}
|
package middleware
import (
"net/http"
"peribahasa/app/models"
"github.com/gorilla/context"
)
// Xclaim context
var Xclaim = &models.Token{}
// JwtAuthentication middleware
var JwtAuthentication = func(next http.Handler) http.Handler {
return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
noA... |
package main
// 数学总结的方法,就是求n有几个5倍数
func trailingZeroes(n int) int {
var ret = 0
for n >= 5 {
n = n / 5
ret += n
}
return ret
}
func trailingZeroes2(n int) int {
if n < 5 {
return 0
}
var total = int64(1)
for i := 1; i <= n; i++ {
total = total * int64(i)
}
var ret = 0
for total%10 == 0 {
ret += 1
... |
//go:generate fyne bundle -o bundled.go Icon.png
package main
import (
"log"
"fyne.io/fyne/v2"
"fyne.io/fyne/v2/app"
"fyne.io/fyne/v2/dialog"
"fyne.io/fyne/v2/widget"
"github.com/diamondburned/arikawa/v2/session"
)
const prefTokenKey = "auth.token"
func main() {
a := app.NewWithID("xyz.andy.fibro")
a.SetI... |
// SPDX-License-Identifier: ISC
// Copyright (c) 2014-2020 Bitmark Inc.
// Use of this source code is governed by an ISC
// license that can be found in the LICENSE file.
package owner
import (
"golang.org/x/time/rate"
"github.com/bitmark-inc/bitmarkd/account"
"github.com/bitmark-inc/bitmarkd/fault"
"github.com/... |
package cmd
import (
"encoding/json"
"os"
"strings"
chimeralib "github.com/chimera-kube/chimera-admission-library/pkg/chimera"
"github.com/chimera-kube/chimera-admission/internal/pkg/chimera"
"github.com/pkg/errors"
"github.com/urfave/cli/v2"
admissionv1 "k8s.io/api/admission/v1"
admissionregistrationv1 "k8... |
package journal
import (
"context"
"fmt"
"time"
"github.com/rareinator/Svendeprove/Backend/packages/mssql"
. "github.com/rareinator/Svendeprove/Backend/packages/protocol"
)
type JournalServer struct {
UnimplementedJournalServiceServer
DB *mssql.MSSQL
ListenAddress string
}
func (j *JournalServer)... |
package keepassrpc
import "testing"
func TestVersion(t *testing.T) {
protocolVersion = []uint8{1, 2, 3}
if ProtocolVersion() != 66051 {
t.Error("ProtocolVersion() returned invalid version")
}
}
func TestGenKey(t *testing.T) {
a, err := GenKey(32)
if err != nil {
t.Error("GenKey failed:", err)
}
b, err := ... |
package vox
import (
"encoding/json"
"testing"
"github.com/prebid/prebid-server/openrtb_ext"
)
func TestValidParams(t *testing.T) {
validator, err := openrtb_ext.NewBidderParamsValidator("../../static/bidder-params")
if err != nil {
t.Fatalf("Failed to fetch the json schema. %v", err)
}
for _, p := range v... |
package middleware
import (
"net/http"
"log"
)
func Log() Middleware{
return func(h http.HandlerFunc) http.HandlerFunc {
return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request){
log.Println("Before")
defer log.Println("After")
h.ServeHTTP(w,r)
})
}
}
|
package main
import (
_ "github.com/acrossmounation/redpack/apis"
_ "github.com/acrossmounation/redpack/core/accounts"
"github.com/go-spring/spring-boot"
"github.com/go-spring/spring-web"
_ "github.com/go-spring/starter-echo"
_ "github.com/go-spring/starter-gorm/mysql"
"github.com/jinzhu/gorm"
)
func main() {... |
package models
import (
"fmt"
"github.com/BurntSushi/toml"
)
type Config struct {
Data struct{
Organization string
User string
Ticket string
}
}
func (obj *Config) ReadConfig(pathFile string) {
if _, err := toml.DecodeFile(pathFile, obj); err != nil ... |
/*
Copyright 2011-2017 Frederic Langlet
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 smaevcharger
// SMA EV Charger 22 - json Responses
const (
MinAcceptedVersion = "1.2.23"
TimestampFormat = "2006-01-02T15:04:05.000Z"
StatusA = float64(200111) // Not connected
StatusB = float64(200112) // Connected and not charging
StatusC = float64(200113) // Connected and chargin... |
// 在这个例子中,我们将看到如何使用协程与通道实现一个工作池
package main
import (
"fmt"
"time"
)
// 这是 worker 程序,我们会并发的运行多个 worker
// worker 将在 jobs 频道上接收工作,并在 results 上发送相应的结果
// 每个 worker 我们都会 sleep 一秒钟,以模拟一项昂贵的(耗时一秒钟的)任务
func worker(id int, jobs <-chan int, results chan<- int) {
for j := range jobs {
fmt.Println("worker", id, "start job... |
package wallet
import (
"bytes"
"crypto/ecdsa"
"crypto/elliptic"
"crypto/rand"
"crypto/sha256"
"crypto/x509"
"log"
"golang.org/x/crypto/ripemd160"
b58 "github.com/jbenet/go-base58"
)
const version = byte(0x00)
const addressChecksumLen = 4
type Wallet struct {
PrivateKey ecdsa.PrivateKey
PublicKey []byt... |
package protologlogrus
import (
"bytes"
"encoding/json"
"io"
"strings"
"unicode"
"github.com/Sirupsen/logrus"
"github.com/golang/protobuf/proto"
"github.com/sr/operator/protolog"
)
var (
levelToLogrusLevel = map[protolog.Level]logrus.Level{
protolog.LevelDebug: logrus.DebugLevel,
protolog.LevelInfo: lo... |
// Copyright 2020 The Cockroach Authors.
//
// Use of this software is governed by the Business Source License
// included in the file licenses/BSL.txt.
//
// As of the Change Date specified in that file, in accordance with
// the Business Source License, use of this software will be governed
// by the Apache License, ... |
// Copyright 2020 The Moov Authors
// Use of this source code is governed by an Apache License
// license that can be found in the LICENSE file.
package pain_v01
import (
"encoding/xml"
"github.com/moov-io/iso20022/pkg/common"
"github.com/moov-io/iso20022/pkg/utils"
)
type AccountIdentification4Choice struct {
... |
// Copyright 2017 Alem Abreha <alem.abreha@gmail.com>. All rights reserved.
// Use of this source code is governed by a MIT license that can be found in the LICENSE file.
package ccm
import (
"bytes"
"encoding/json"
"gopkg.in/yaml.v2"
"io/ioutil"
"log"
"os"
"text/template"
)
func ERRHandler(err error, message ... |
package models
//Metric model
type Metric struct {
ID uint `gorm:"primary_key" json:"id"`
Temp float64 `gorm:"not null" json:"temp" binding:"required"`
Moisture float64 `json:"moisture" binding:"required"`
}
//List list to delete model
type List struct {
ListID []int `json:"listID" binding:"required"... |
package usecase
import (
"context"
"github.com/pkg/errors"
"github.com/utahta/momoclo-channel/crawler"
"github.com/utahta/momoclo-channel/entity"
"github.com/utahta/momoclo-channel/event"
"github.com/utahta/momoclo-channel/event/eventtask"
"github.com/utahta/momoclo-channel/log"
"github.com/utahta/momoclo-cha... |
package cmd
import (
"errors"
"fmt"
"github.com/NodeFactoryIo/vedran/internal/ui/prompts"
"strconv"
)
func ValidatePayoutFlags(
payoutReward string,
payoutAddress string,
showPrompts bool,
) (float64, error) {
var err error
var rewardAsFloat64 float64
// if total reward is determined as wallet balance
if... |
package crawler
import (
"crypto/tls"
"net/http"
"time"
"golang.org/x/text/encoding/simplifiedchinese"
"golang.org/x/text/transform"
)
// Novel represent a novel
type Novel struct {
Name string
IndexURL string
}
// ICrawler - crawl novels
type ICrawler interface {
LatestChapter(Novel) (string, string)
... |
package leetcode
import (
"strconv"
"strings"
)
func areNumbersAscending(s string) bool {
pre := 0
for _, v := range strings.Split(s, " ") {
if v[0] <= '9' {
cur, _ := strconv.Atoi(v)
if pre >= cur {
return false
}
pre = cur
}
}
return true
}
|
package service
import (
"errors"
"testing"
"time"
"github.com/jinzhu/gorm"
meetupmanager "github.com/lucas-dev-it/62252aee-9d11-4149-a0ea-de587cbcd233"
"github.com/lucas-dev-it/62252aee-9d11-4149-a0ea-de587cbcd233/business/model"
"github.com/lucas-dev-it/62252aee-9d11-4149-a0ea-de587cbcd233/weather"
"github.... |
package extractors
import (
"testing"
"github.com/iawia002/annie/config"
"github.com/iawia002/annie/test"
)
func TestTumblr(t *testing.T) {
config.InfoOnly = true
tests := []struct {
name string
args test.Args
}{
{
name: "image test",
args: test.Args{
URL: "http://fuckyeah-fx.tumblr.com/post/... |
package main
import (
"sync"
)
// hub maintains the set of active clients
type Hub struct {
// Registered clients.
clients map[int]*Client
tokens map[int]string
mutex_client sync.RWMutex
mutex_token sync.RWMutex
}
func InitHub() *Hub {
return &Hub{
clients: make(map[int]*Client),
tokens: make... |
package main
import (
"database/sql"
"encoding/json"
"fmt"
"log"
"../model"
_ "github.com/go-sql-driver/mysql"
)
var db *sql.DB
var err error
func main() {
db, err = sql.Open("mysql", "root:root@tcp(127.0.0.1:3306)/test")
// Check if db is nil
if db == nil {
panic("db is nil")
}
// Check if err conne... |
package sql
import (
"database/sql"
"reflect"
)
type executor interface {
Exec(query string, args ...interface{}) (sql.Result, error)
Query(query string, args ...interface{}) (*sql.Rows, error)
QueryRow(query string, args ...interface{}) *sql.Row
}
func getStructValue(i interface{}) reflect.Value {
v := reflec... |
package main
func Lcm(input []uint64) uint64 {
result := Product(input)
for len(input) > 0 {
candidate := result / input[0]
success := true
for _, v := range input {
if candidate%v != 0 {
success = false
break
}
}
if success {
result = candidate
} else {
input = append(input[:0], ... |
package deeplinks
import (
"net/url"
"strconv"
)
// most of concepts stolen from tdesktop app https://git.io/JtYos
// also, some more info gathered from @deeplink channel at https://t.me/DeepLink
const (
ReservedSchema = "tg"
)
func ReservedHosts() []string {
return []string{
"telegram.me",
"telegram.dog",
... |
package main
import (
"sync"
"context"
"time"
)
// --------------------- WAIT 模式 -------------------------
func main() {
wg := sync.WaitGroup{}
wg.Add(3)
go func() {
defer wg.Done()
//do...
}()
go func() {
defer wg.Done()
//do...
}()
go func() {
defer wg.Done()
//do..... |
package main
import (
"encoding/gob"
"fmt"
"os"
"os/exec"
"path/filepath"
"strings"
"sync"
"github.com/docker/go-plugins-helpers/volume"
)
// TODO: Separate the filesystems into libraries
const (
fsAUFS = iota
fsOverlay
)
type unionMountVolume struct {
Filesystem int
Layers []string
MountPoint stri... |
package main
import (
"fmt"
"github.com/arxanchain/sdk-go-common/crypto/ecc"
"encoding/base64"
)
func main() {
keyfile := "../../certs/ecc/prime256v1/server.key"
certfile := "../../certs/ecc/prime256v1/server.crt"
eccLib,err := ecc.NewECCCryptoLib(keyfile, certfile)
if err!=nil {
fmt.Println(err)
}
fmt.Pr... |
package constants
const (
// LabelEdgeWorker is used to identify if a node is a edge node ("true")
// or a cloud node ("false")
LabelEdgeWorker = "alibabacloud.com/is-edge-worker"
// AnnotationAutonomy is used to identify if a node is automous
AnnotationAutonomy = "node.beta.alibabacloud.com/autonomy"
// YurtC... |
package main
import (
"fmt"
"database/sql"
_ "github.com/godror/godror"
)
func main(){
db, err := sql.Open("godror", "ani/ani5@192.168.12.215:1521/aspwdm")
if err != nil {
fmt.Println(err)
return
}
defer db.Close()
rows,err := db.Query("select count(*) f... |
package command
import (
"fmt"
"github.com/kenlabs/pando/pkg/system"
"github.com/spf13/cobra"
"gopkg.in/yaml.v2"
"os"
"path/filepath"
)
func InitCmd() *cobra.Command {
return &cobra.Command{
Use: "init",
Short: "Initialize server config file.",
RunE: func(cmd *cobra.Command, args []string) error {
i... |
package service
import (
"errors"
"net/http"
"github.com/yerlan-tleubekov/go-redis/internal/models"
"github.com/yerlan-tleubekov/go-redis/pkg/jwt"
)
type Authenticator interface {
SignUp(user *models.User) error
SignIn(userID int)
}
func (service *Service) SignUp(user *models.User) error {
if err := service... |
package core
import (
"log"
"github.com/gorilla/websocket"
)
// The Connection type represents a websocket connection.
type Connection struct {
conn *websocket.Conn
handler Handler
sendCh chan Message
}
func (c *Connection) serve() {
go c.receive()
c.send()
c.conn.Close()
}
func (c *Connection) receive... |
package main
func main() {
continue
}
|
package quiz
import (
"fmt"
"time"
"github.com/fedepaol/quiz/interaction"
)
// Question represents a single quiz question with answer.
type Question struct {
Question string
Answer string
}
// QuestionService implements all the methods related to a single quiz question.
type QuestionService interface {
Ask(... |
package gotezos
import "github.com/pkg/errors"
// CycleService is a struct wrapper for cycle functions
type CycleService struct {
gt *GoTezos
}
// NewCycleService returns a new CycleService
func (gt *GoTezos) newCycleService() *CycleService {
return &CycleService{gt: gt}
}
// GetCurrent gets the current cycle of ... |
// Copyright (C) 2019 Michael J. Fromberger. All Rights Reserved.
package otp_test
import (
"crypto/sha256"
"encoding/base64"
"fmt"
"log"
"github.com/creachadair/otp"
)
func fixedTime(z uint64) func() uint64 { return func() uint64 { return z } }
func Example() {
cfg := otp.Config{
Hash: sha256.New, // de... |
/**
邻接表
单向双向图,有权无权图(交叉4种情况)
储存顶点的数组内从第1位开始
*/
package graph
import (
"fmt"
"github.com/kakiezhang/Algo/geekTime/linkedlist"
)
type Graph struct {
Vtx []*linkedlist.DoublyLinkedList // 存储顶点的数组
Max int
}
type Vertex struct {
data interface{}
weight int
}
func (g *Graph) String() string {
var rs string
for ... |
package utils
import (
"context"
"github.com/azak-azkaran/goproxy"
"net"
"net/http"
"os"
"testing"
"time"
)
func TestGetResponse(t *testing.T) {
Init(os.Stdout, os.Stdout, os.Stderr)
resp, err := GetResponse("", "https://www.google.de")
if err != nil {
t.Error("Error while requesting without proxy, ", er... |
// Package sr implements an Ingest for Standard Release Legacy foods
package sr
import (
"encoding/csv"
"fmt"
"io"
"log"
"os"
"strconv"
"time"
"github.com/littlebunch/gnutdata-bfpd-api/admin/ingest"
"github.com/littlebunch/gnutdata-bfpd-api/admin/ingest/dictionaries"
"github.com/littlebunch/gnutdata-bfpd-ap... |
package handlers
import (
controller "github.com/Brickchain/go-controller.v2"
httphandler "github.com/Brickchain/go-httphandler.v2"
"github.com/julienschmidt/httprouter"
)
// ControllerWrapper is a wrapper that adds some WithBinding request types
type ControllerWrapper struct {
w *httphandler.Wrapper
bsvc con... |
package unimatrix
func NewActivitiesSchedulesOperation(realm string) *Operation {
return NewRealmOperation(realm, "activities_schedules")
}
|
package config
import (
"io/ioutil"
"log"
"os"
"path"
"gopkg.in/yaml.v2"
)
type SingleHost struct {
Host string `yaml:"host"`
User string `yaml:"user"`
Key string `yaml:"privateKey"`
}
type HostList struct {
List []SingleHost `yaml:"list"`
}
func GetConfig() []SingleHost {
config := HostList{}
pwd, _ :... |
package main
import (
"log"
"os"
"os/exec"
"strconv"
"testing"
"github.com/blankon/irgsh-go/internal/config"
"github.com/stretchr/testify/assert"
)
func TestMain(m *testing.M) {
log.SetFlags(log.LstdFlags | log.Lshortfile)
irgshConfig, _ = config.LoadConfig()
dir, _ := os.Getwd()
irgshConfig.Builder.Work... |
package types
import (
"fmt"
"reflect"
)
// PackageMeta represents metadata included with a package.
type PackageMeta struct {
// The version of this manifest, only v1 currently
MetaVersion string `json:"apiVersion,omitempty"`
// The name of the package
Name string `json:"name,omitempty"`
// The version of the... |
package httpx_test
import (
"fmt"
"io"
"net/http"
"net/http/httptest"
"testing"
"time"
"github.com/stretchr/testify/assert"
"github.com/socialpoint-labs/bsk/httpx"
)
func TestAddHeaderDecorator(t *testing.T) {
assert := assert.New(t)
h := httpx.AddHeaderDecorator("key", "value1")(
httpx.AddHeaderDecora... |
package main
import (
"context"
"github.com/aws/aws-sdk-go/aws"
"github.com/aws/aws-sdk-go/service/ecs"
"github.com/coldog/tool-ecs/internal/kv"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/mock"
"testing"
"time"
)
func init() {
// fixed time to "2017-05-05T00:00:00Z"
GetTime = func() t... |
package main
func main() {
type num int
var a num
_ = (5 != a)
}
|
/*
Copyright 2019 The Jetstack cert-manager 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 applicable law or agreed... |
package main
import (
"github.com/backstage/my-go-service/cmd"
)
func main() {
cmd.Execute()
}
|
// Copyright 2014 Dirk Jablonowski. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
package packet
import (
"github.com/dirkjabl/bricker/net/head"
"github.com/dirkjabl/bricker/net/optionaldata"
"github.com/dirkjabl/bricker/net/payload"
"... |
package midec
/*
Based on image/format.go in standard library.
---
Copyright (c) 2009 The Go Authors. All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are
met:
* Redistributions of source code must retain t... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.