text stringlengths 11 4.05M |
|---|
package xbase
import (
"encoding/hex"
"log"
"os"
"sync"
"github.com/syndtr/goleveldb/leveldb"
)
func MustHexEncode(src []byte) []byte {
sz := hex.EncodedLen(len(src))
dst := make([]byte, sz)
hex.Encode(dst, src)
return dst
}
func MustHexEncodeWithEOF(src []byte) []byte {
dst := MustHexEncode(src)
return ... |
package cmd
import (
"flag"
"fmt"
"os"
"path/filepath"
"github.com/spf13/cobra"
"github.com/spf13/pflag"
"k8s.io/klog"
"github.com/magratheaguide/cybertron/pkg/theme"
)
var (
version string
versionCommit string
inputFile string
stylesheet string
name string
wrapper string
... |
package main
import (
"io"
"strings"
"testing"
"unicode"
)
func NewTestWriter(t *testing.T) io.Writer {
return &TestWriter{t: t}
}
type TestWriter struct {
t *testing.T
}
func (w *TestWriter) Write(p []byte) (n int, err error) {
w.t.Helper()
s := string(p)
n = len(s)
s = strings.TrimRightFunc(string(p), u... |
package qiwi
import (
"bytes"
"compress/zlib"
"context"
"encoding/base64"
"encoding/json"
"fmt"
"io"
"net/http"
"net/http/httptest"
"testing"
)
func Examplezlibzompress() {
// eJzzSM3JyVcozy/KSQEAGKsEPQ== -- compressed and base64 encoded
// if string(res) != string(result) {
// t.Errorf("Wrong result o... |
package main
import (
"fmt"
"mygithub/twogocode/d01工厂模式解决私有结构体引入/student"
)
func main() {
//返回值 stu是指针类型
stu := student.NewStudent("tom", 88.8)
//"*"取指向数据值
fmt.Println(*stu)
//(*stu)可简写为 stu
//fmt.Println("name=",(*stu).Name,"score=",(*stu).Score)
//fmt.Println("name=",stu.Name,"score=",stu.Score)
//当结构体的字... |
package luxafor
import (
"time"
"github.com/karalabe/hid"
"github.com/pkg/errors"
)
// Luxafor is used to access the devices.
type Luxafor struct {
deviceInfo hid.DeviceInfo
}
const (
vendorID uint16 = 0x04d8
deviceID uint16 = 0xf372
)
// Enumerate returns a slice of attached Luxafors
func Enumerate() []Luxa... |
// Copyright 2019 Kuei-chun Chen. All rights reserved.
package analytics
import (
"io/ioutil"
"os"
"strings"
"testing"
)
const DiagnosticDataDirectory = "../diagnostic.data"
const DiagnosticDataFilename = DiagnosticDataDirectory + "/metrics.2017-10-12T20-08-53Z-00000"
func TestReadDiagnosticFiles(t *testing.T) ... |
package tx
import (
"time"
"incognito-chain/common"
"incognito-chain/privacy"
"incognito-chain/privacy/privacy_v1/schnorr"
"incognito-chain/privacy/privacy_v1/zeroknowledge/serialnumbernoprivacy"
"incognito-chain/privacy/privacy_v2"
)
func SignNoPrivacy(privKey *privacy.PrivateKey, hashedMessage []byte) (signa... |
package semt
import (
"encoding/xml"
"github.com/thought-machine/finance-messaging/iso20022"
)
type Document00600102 struct {
XMLName xml.Name `xml:"urn:iso:std:iso:20022:tech:xsd:semt.006.001.02 Document"`
Message *StatementOfInvestmentFundTransactionsV02 `xml:"StmtOfInvstmtFndT... |
package pid
import (
"errors"
"os"
"strconv"
"syscall"
)
var (
ErrProcessExists = errors.New("Process already exists.")
)
type PidFile struct {
path string
Pid int
}
func New(path string) (pf *PidFile, err error) {
pf = &PidFile{path, os.Getpid()}
var f *os.File
f, err = os.OpenFile(path, os.O_CREATE|os.... |
package postgres
import _ "github.com/lib/pq"
|
// Copyright 2022 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 download
import(
"config"
"fmt"
)
type StockRtDownloader struct {
config config.ServiceAPI
}
func (s *StockRtDownloader) GetData(code, exchange string) string {
var excode string
switch exchange {
case "EX$$$$XSHG":
excode = "sh"
case "EX$$$$XSHE":
... |
package kaniko
import (
"io"
"strings"
)
type kanikoLogger struct {
out io.Writer
}
// Implement the io.Writer interface
func (k kanikoLogger) Write(p []byte) (n int, err error) {
str := string(p)
lines := strings.Split(str, "\n")
newLines := make([]string, 0, len(lines))
for _, line := range lines {
trimm... |
package main
import (
"errors"
"fmt"
"strconv"
"time"
)
// ErrInput - If inputs are invalid
var ErrInput = errors.New("INPUT ERROR")
// ListNode - a single node that composes the list
type ListNode struct {
Val int
Next *ListNode
}
// LinkedListNode the linked list of Items
type LinkedListNode struct {
Head... |
package random
import (
crand "crypto/rand"
"encoding/binary"
"log"
)
type Source struct{}
func (s Source) Seed(seed int64) {}
func (s Source) Int63() int64 {
return int64(s.Uint64() & ^uint64(1<<63))
}
func (s Source) Uint64() (v uint64) {
err := binary.Read(crand.Reader, binary.BigEndian, &v)
if err != ni... |
package gcp
import (
"context"
"github.com/pkg/errors"
"google.golang.org/api/compute/v1"
"google.golang.org/api/googleapi"
"github.com/openshift/installer/pkg/types/gcp"
)
func (o *ClusterUninstaller) listHealthChecks(ctx context.Context) ([]cloudResource, error) {
return o.listHealthChecksWithFilter(ctx, "i... |
package main
import (
"fmt"
"github.com/colefan/gsgo/console"
"github.com/colefan/gsgo/gameprotocol/login"
"github.com/colefan/gsgo/netio"
"github.com/colefan/gsgo/netio/iobuffer"
"github.com/colefan/gsgo/netio/packet"
"runtime"
"strconv"
"time"
)
type MyClient struct {
*netio.Client
}
func NewMyClient() ... |
// Copyright 2021 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 net
import "net/http"
import "bytes"
import "io/ioutil"
import "github.com/purstal/go-tieba-modules/operation-analyser/old/log"
//http://www.crifan.com/go_language_http_do_post_pass_post_data/
func Get(srcUrl string, parameters Parameters) (string, error) { //url,parameters
httpClient := http.Client{}
... |
// test-input project doc.go
/*
test-input document
*/
package main
|
package main // import "github.com/janberktold/redis-autopilot"
import (
"fmt"
"os"
"os/signal"
"time"
log "github.com/sirupsen/logrus"
)
func main() {
if len(os.Args) != 2 {
log.Info("Invoke as redis-autopilot [path to config file]")
os.Exit(1)
}
logger := log.StandardLogger()
configurationFilePath :... |
package parser
import (
"fmt"
"go/token"
"ligo/lexer"
"ligo/typ"
)
type Node interface {
Type() NodeType
String() string
Copy() Node
Val() typ.Val
}
type NodeType int
func (t NodeType) Type() NodeType {
return t
}
const (
NodeIdent NodeType = iota
NodeString
NodeNumber
NodeCons
NodeVector
)
type Ide... |
// Merging
//
// There are several functions available that handle different kinds of merging:
//
// - MergeNodes(left, right Node) Node: returns a new node that merges children
// from both nodes.
//
// - MergeNodeSlices(left, right Nodes, mergeFn MergeFunction) Nodes: merges
// two slices based on the mergeFn. This a... |
/*
* @lc app=leetcode.cn id=17 lang=golang
*
* [17] 电话号码的字母组合
*/
// @lc code=start
package main
import "fmt"
import "strings"
func main() {
var s string
var res []string
s = "29"
res = letterCombinations(s)
fmt.Printf("digits is %s, result is %v, len is %d\n", s, res, len(res))
s = "239"
res = letterComb... |
package main
import (
"fmt"
"time"
)
type ServerStruct struct {
channel_subscriber chan Sub
channel_publisher chan Message
}
type Sub struct {
topic string
news chan string
}
type Message struct {
topic string
body string
}
func Server(server ServerStruct) {
subscribedTopics := make(map[string] []chan str... |
package router
import (
"BackendGo/middlewares"
"BackendGo/server"
"github.com/gin-gonic/gin"
"net/http"
)
func ApplyRoutes(s *server.Server) error {
s.Router.GET("/health", func(c *gin.Context) {
c.String(http.StatusOK, "OK")
})
s.Router.POST("/login", loginUser(s))
s.Router.GET("/query", middlewares.JwtAu... |
package main
import (
"fmt"
log "github.com/Sirupsen/logrus"
"net/http"
//"path"
"time"
"bitbucket.org/cicadaDev/utils"
"github.com/dgrijalva/jwt-go"
"github.com/markbates/goth"
"github.com/markbates/goth/providers/gplus"
"github.com/markbates/goth/providers/linkedin"
"github.com/zenazn/goji/web"
)
//////... |
package chme
import (
"io"
"io/ioutil"
"net/http"
"net/http/httptest"
"net/url"
"strings"
"testing"
"github.com/go-chi/chi"
)
var endpoint = "/chme"
func TestChangePostToHiddenMethodOfDefault(t *testing.T) {
r := newTestRouter()
r.Use(ChangePostToHiddenMethod)
r.registerRoute()
ts := httptest.NewServer(... |
package nhs
import (
"encoding/xml"
"fmt"
"github.com/aquinofb/location_service/http_client"
"github.com/aquinofb/location_service/models"
"os"
"strings"
)
type Result struct {
Entry Entry `xml:"entry"`
}
type Entry struct {
Id string `xml:"id"`
Content struct {
Service struct {
Name string `xml:"... |
package core
import (
"../models"
"encoding/json"
"net/http"
)
func Login(requestUser *models.User) (int, []byte) {
authBackend := InitJWTAuthenticationBackend()
if authBackend.Authenticate(requestUser) {
id := "12345" //get id from DB
token, err := authBackend.Generate(id)
if err != nil {
return http.... |
/*
Copyright (c) 2017 Simon Schmidt
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, s... |
package main
import (
"fmt"
"time"
)
/*
In this example we show how to close a channel.
*/
func main() {
var c = make(chan int)
go doSomething(c)
for i := range c {
fmt.Printf("value read from channel is %d\n", i)
time.Sleep(1 * time.Second)
}
fmt.Println("Main go routine end")
}
func doSomething(c chan... |
package ds
/**
*
Given an array of size n, find the majority element. The majority element is the element that appears more than ⌊ n/2 ⌋ times.
You may assume that the array is non-empty and the majority element always exist in the array.
Example 1:
Input: [3,2,3]
Output: 3
Example 2:
Input: [2,2,1,1,1,2,2]
... |
package tccp
const VPC = `
{{define "vpc"}}
{{- $v := .Guest.VPC }}
VPC:
Type: AWS::EC2::VPC
Properties:
CidrBlock: {{ $v.CidrBlock }}
EnableDnsSupport: 'true'
EnableDnsHostnames: 'true'
Tags:
- Key: Name
Value: {{ $v.ClusterID }}
- Key: Installation
Value:... |
package main
import (
"bufio"
"flag"
"fmt"
"log"
"os"
"regexp"
)
// A function to check the equality of string slices
func equalSlice(compare1 []string, compare2 []string) bool {
if len(compare1) != len(compare2) {
return false
} else {
i := 0
for i < len(compare1) {
if compare1[i] != compare2[i] {... |
package models
import (
"github.com/lempiy/echo_api/types"
"github.com/lempiy/echo_api/utils"
)
type user struct{}
var User *user
func (u *user) Create(user *types.User) error {
encryptPass := utils.EncryptPassword(user.Password)
sqlQuery := `INSERT INTO person(username, password, login, age, telephone, created_... |
package main
import (
"fmt"
"github.com/liuzl/ling"
)
var nlp = ling.MustNLP(ling.Norm)
func main() {
text := "北京ทันทุกเหตุการ有限公司"
d := ling.NewDocument(text)
if err := nlp.Annotate(d); err != nil {
fmt.Println(err)
return
}
fmt.Println(text)
for i, token := range d.Tokens {
fmt.Println(i, token, tok... |
package main
import (
"fmt"
"math"
)
func Sqrt(x float64) float64 {
var low float64 = 0
var hight float64 = x
var mid float64 = (hight+low)/2
var precise float64 = 0.01
for math.Abs(mid*mid-x)>precise{
fmt.Println(low,hight,mid,precise)
fmt.Println(math.Abs(mid*mid-x))
if mid*mid > x{
hight = mid
}... |
package custPkg
func Min(arry []float64) float64 {
temp := 0.0
temp = arry[0]
for i := 1; i < len(arry); i++ {
if temp > arry[i] {
temp = arry[i]
}
}
return temp
}
func Max(arry []float64) float64 {
temp := 0.0
temp = arry[0]
for i := 1; i < len(arry); i++ {
if temp < arry[i] {
temp = arry... |
// Copyright 2021 The image-cloner 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 o... |
package main
import "fmt"
func main() {
i := 10
fmt.Printf("%v and %T\n", i, i)
}
|
package main
import (
"bytes"
"encoding/json"
"fmt"
"io"
"io/ioutil"
"log"
"os"
"os/exec"
"strings"
)
const (
rootPackage = "github.com/openshift/origin"
)
// Package is a subset of cmd/go.Package
type Package struct {
ImportPath string `json:",omitempty"` // import path of package in dir
Imports ... |
package web
import (
"encoding/json"
"fmt"
"net/http"
"github.com/siggy/bbox/beatboxer/render"
log "github.com/sirupsen/logrus"
)
type Web struct {
hub *Hub
}
func InitWeb() *Web {
log.Debugf("InitWeb")
hub := newHub()
go hub.run()
http.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) {
ht... |
package main
import (
"bufio"
"fmt"
"log"
"os"
"strconv"
"strings"
)
type coords struct {
row int
col int
}
var arr = [1000][1000]int{}
var grid = arr[:]
func main() {
file, err := os.Open("../input")
if err != nil {
log.Fatalln("Cannot read file", err)
}
defer file.Close()
scanner := bufio.NewScann... |
// log包实现了基于logrus的日志管理器
package log
import (
"fmt"
"github.com/ebar-go/ego/component/trace"
"github.com/ebar-go/ego/utils"
"github.com/ebar-go/ego/utils/date"
"github.com/ebar-go/ego/utils/file"
"github.com/sirupsen/logrus"
"os"
"path/filepath"
)
// Logger 日志接口
type Logger interface {
Info(message string, c... |
// 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 schemas
import (
"time"
)
type UserSchema struct {
ID uint64 `json:"id"`
Username string `json:"username" binding:"required,min=3,max=100"`
Email string `json:"email" binding:"required,email"`
Password string `json:"password" binding:"required,min=6,max=100"`
Phone string ... |
package main
import (
"os"
"strconv"
)
func main() {
localPortString := os.Getenv("CFIGGIS_PORT")
redisHostString := os.Getenv("CFIGGIS_REDIS_HOST")
redisPortString := os.Getenv("CFIGGIS_REDIS_PORT")
localPort := 765
redisPort := 6379
if localPortString != "" {
localPort, _ = strconv.Atoi(localPortString... |
package main
import (
"bufio"
"chat/sandbox/redis/04/db"
"chat/sandbox/redis/04/element"
"chat/sandbox/redis/04/receiver"
"chat/sandbox/redis/04/redis"
"chat/sandbox/redis/04/room"
"chat/sandbox/redis/04/sender"
"context"
"fmt"
"os"
"os/user"
"strconv"
"strings"
"time"
)
func main() {
if len(os.Args) <... |
// Copyright Fuzamei Corp. 2018 All Rights Reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
package para
import (
"testing"
"time"
"github.com/33cn/chain33/common"
"github.com/33cn/chain33/common/crypto"
"github.com/33cn/chain33/common/log"
"git... |
package main
import (
"github.com/alexliesenfeld/health"
"github.com/etherlabsio/healthcheck/v2/checkers"
"log"
"net/http"
)
func main() {
http.Handle("/health", health.NewHandler(
health.NewChecker(
health.WithCheck(health.Check{
Name: "disk",
Check: checkers.DiskSpace("/var/log", 90).Check,
})... |
package main
import (
"github.com/beego/beego/v2/core/logs"
)
func main() {
logs.Info("hello beego")
}
|
package nsdownload
import(
"strings"
"fmt"
"config"
"download"
"time"
"util"
)
type NationStatDownloader struct{
root config.ServiceAPI
child1 config.ServiceAPI
child2 config.ServiceAPI
child3 config.ServiceAPI
period config.ServiceAPI
data config.ServiceAPI
}
func (d ... |
package server
import (
"encoding/json"
"errors"
"net/http"
"github.com/imrenagi/go-payment"
)
type Meta struct {
TotalItems int `json:"total_items"`
TotalPages int `json:"total_pages"`
CurrentPage int `json:"cur_page"`
Cursor string `json:"last_cursor"`
}
// Error is struct used to return e... |
package main
import (
"fmt"
)
func main() {
m := map[string][]string{
`bond_james`: []string{`Shaken, not stirred`, `Martinis`, `Women`},
`moneypenny_miss`: []string{`James Bond`, `Literature`, `Computer Science`},
`no_dr`: []string{`Being evil`, `Ice cream`, `Sunsets`},
}
fmt.Println(m)
m[... |
// Package main -
package main
import (
"fmt"
"log"
"os"
"time"
"github.com/shanehowearth/concurrency_in_go/bridge"
"github.com/shanehowearth/concurrency_in_go/pipeline"
"github.com/shanehowearth/concurrency_in_go/steward"
)
func main() {
log.SetOutput(os.Stdout)
log.SetFlags(log.Ltime | log.LUTC)
doWork ... |
package handler
import (
"context"
"strings"
)
// DeployUsecases defines the trigger handler usecases.
//go:generate mockery -inpkg -testonly -name DeployUsecases
type DeployUsecases interface {
DeployR10KEnvAsync(ctx context.Context, env string, onSuccess func(string), onError func(string, error))
}
func getEnvi... |
package main
import (
"testing"
"github.com/aws/aws-lambda-go/events"
"github.com/stretchr/testify/assert"
)
func TestUnmarshalStreamImage(t *testing.T) {
t.Run("unmarshalStreamImage", func(t *testing.T) {
event := event()
image := event.Records[0].Change.NewImage
var entry entry
unmarshalStreamImage(ima... |
package resto
import (
"context"
"encoding/json"
"errors"
"math/rand"
"net/http"
"net/http/httptest"
"reflect"
"sort"
"testing"
"time"
"github.com/stretchr/testify/assert"
"github.com/saucelabs/saucectl/internal/job"
"github.com/saucelabs/saucectl/internal/vmd"
)
func TestClient_GetJobDetails(t *testin... |
package eventlogger
import (
"fmt"
"io"
"time"
"github.com/dollarshaveclub/acyl/pkg/models"
"github.com/dollarshaveclub/acyl/pkg/persistence"
"github.com/google/uuid"
"github.com/pkg/errors"
)
// Logger is an object that writes log lines to the database in an EventLog as well as to Sink
type Logger struct {
... |
package operatorlister
import (
"fmt"
"sync"
v1 "k8s.io/api/rbac/v1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/labels"
"k8s.io/apimachinery/pkg/types"
rbacv1 "k8s.io/client-go/listers/rbac/v1"
)
type UnionRoleBindingLister struct {
roleBindingListers map[string]rbacv1.RoleBinding... |
package main
import (
"fmt"
"io"
"net/http"
"os"
)
type logWriter struct{}
func main() {
resp, err := http.Get("http://google.com")
if err != nil {
fmt.Println("Error:", err)
os.Exit(1)
}
lw := logWriter{}
// Same thing as below but with only one line
// First argument is the output channel where to... |
package it
import (
"bytes"
"net/url"
"os"
"testing"
"time"
"github.com/boltdb/bolt"
"github.com/fxnn/deadbox/config"
"github.com/fxnn/deadbox/crypto"
"github.com/fxnn/deadbox/daemon"
"github.com/fxnn/deadbox/drop"
"github.com/fxnn/deadbox/model"
"github.com/fxnn/deadbox/rest"
"github.com/fxnn/deadbox/wo... |
// Licensed to Elasticsearch B.V. under one or more contributor
// license agreements. See the NOTICE file distributed with
// this work for additional information regarding copyright
// ownership. Elasticsearch B.V. licenses this file to you under
// the Apache License, Version 2.0 (the "License"); you may
// not use ... |
package fixtures
import "github.com/pkg/errors"
func foo(a bool, b int) (err error) {
n, err := bar()
if n == 0 {
return errors.Wrap(err, "aaaa") // MATCH /errors.Wrap nil/
}
if n == 0 && err != nil {
return errors.Wrap(err, "ccc")
}
if err != nil {
return errors.Wrap(err, "xxxx")
}
return nil
}
func b... |
// Copyright © 2021 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 ... |
// Copyright 2019 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 config
import (
"encoding/json"
"github.com/pkg/errors"
"io/ioutil"
)
// 配置文件 获取
type LogConfig struct {
LogPath string `json:"log_path"`
LogLevel string `json:"log_level"`
}
type Config struct {
LogConfig LogConfig `json:"log_config"`
DBConfig DBConfig `json:"db_config"`
RedisConfig RedisConfig `jso... |
package sarama
import (
"testing"
)
func TestActorWorker(t *testing.T){
kafkaTopic := "air_temperature_10"
StartProducer(kafkaTopic, 308593)
StartAverageCalcConsumer(kafkaTopic)
} |
package config
import (
"os"
)
type Configuration struct {
DatabaseURI string
ListenAddress string
Secret string
Debug bool
EnvironmentName string
}
var C = Configuration{}
func getEnv(variable string) string {
prefix := "LINKEDLOCKED_"
return os.Getenv(prefix + variable)
}
func in... |
package stateful
import (
"context"
"fmt"
aliceapi "github.com/yandex-cloud/examples/serverless/alice-shareable-todolist/app/alice/api"
"github.com/yandex-cloud/examples/serverless/alice-shareable-todolist/app/errors"
"github.com/yandex-cloud/examples/serverless/alice-shareable-todolist/app/model"
"github.com/y... |
// Copyright 2018 Kuei-chun Chen. All rights reserved.
package mdb
import (
"context"
"testing"
"github.com/simagix/gox"
"go.mongodb.org/mongo-driver/x/mongo/driver/connstring"
)
func TestGetAllShardURIstWithConn(t *testing.T) {
var err error
UnitTestURL = "mongodb://user:password@localhost/"
client := getMo... |
package accesslog
import (
"net/http"
"strings"
)
func readResponseHeaders(header http.Header) map[string]string {
headers := map[string]string{}
for k, v := range header {
headers[k] = strings.Join(v, " ")
}
return headers
}
|
// Copyright 2019 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... |
// +build !spell
package main
type Spellcheck struct {
check CheckFunc
}
func NewSpellcheck(ts TokenSet, ignoreFile string) (*Spellcheck, error) {
return &Spellcheck{func(w string) bool { return true }}, nil
}
func (sc *Spellcheck) Close() {}
func (sc *Spellcheck) WithPassTokens() CheckFunc {
return func(string... |
package view
import (
"fmt"
tgbotapi "github.com/go-telegram-bot-api/telegram-bot-api"
"log"
"projja_telegram/command/current_project/controller"
"projja_telegram/command/current_project/menu"
"projja_telegram/command/util"
"projja_telegram/model"
"strconv"
)
func ChangeProjectStatuses(botUtil *util.BotUtil, ... |
package test
import (
"testing"
"github.com/stretchr/testify/assert"
)
func TestCalcNumRuns(t *testing.T) {
// Helper for assert
nr := func(a, b int) []interface{} { return []interface{}{a, b} }
// Base case when no flags are passed
assert.Equal(t, nr(1, 1), nr(calcNumRuns(0, 0)))
// Trivially flaky test; ru... |
package info
import "context"
type infoServer struct {
managedNamespace string
}
func (i *infoServer) GetInfo(context.Context, *GetInfoRequest) (*InfoResponse, error) {
return &InfoResponse{ManagedNamespace: i.managedNamespace}, nil
}
func NewInfoServer(managedNamespace string) InfoServiceServer {
return &infoSe... |
package utils
import (
"fmt"
"golang.org/x/net/publicsuffix"
"net/http"
"net/http/cookiejar"
"net/url"
"strings"
"time"
)
const (
UserAgent string = "Mozilla/5.0 (iPhone; CPU iPhone OS 12_3 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) CriOS/75.0.3770.85 Mobile/15E148 Safari/605.1"
Patch string... |
// Copyright (c) 2013, Sean Treadway, SoundCloud Ltd.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
// Source code and contact info at http://github.com/streadway/zk
package zk
import (
"github.com/streadway/zk/proto"
)
// Permission is a bitmask of permissi... |
package trello
import (
"encoding/json"
"fmt"
"io/ioutil"
"net/http"
"net/url"
"reflect"
"strings"
)
const TrelloAPI = "https://api.trello.com/1"
type Client struct {
client *http.Client
key string
token string
}
// Create a Trello API client.
func NewClient(key string, token string) *Client {
return... |
package secl
import (
"encoding/xml"
"github.com/thought-machine/finance-messaging/iso20022"
)
type Document00100103 struct {
XMLName xml.Name `xml:"urn:iso:std:iso:20022:tech:xsd:secl.001.001.03 Document"`
Message *TradeLegNotificationV03 `xml:"TradLegNtfctn"`
}
func (d *Document00100103) AddMe... |
package config
import (
"errors"
"evier/integrations"
"evier/job"
"evier/rsync"
"gopkg.in/yaml.v2"
"io/ioutil"
)
type Config struct {
Integrations []integrations.Config
Jobs []job.Job
Rsync rsync.Options
}
func ParseFile(path string) (c Config, e error) {
content, err := ioutil.ReadFile(path... |
package main
import (
"flag"
"logstream/pkg/proxy"
)
func main() {
laddr := flag.String(
"laddr",
":8500",
"local address on which to listen for incoming connections",
)
raddr := flag.String(
"raddr",
":8000",
"remote address to which to connect",
)
flag.Parse()
p := proxy.NewProxy(*laddr, *raddr... |
// 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... |
package gotils_test
import (
"net/http"
"os"
"testing"
. "github.com/onsi/gomega"
gotils "github.com/korovkin/gotils"
)
type MyObject struct {
ErrorStr string `json:"err_str"`
HttpStatusCode int `json:"err_http_status_code"`
ClientErrCode int `json:"err_client_c... |
package core
import (
"errors"
"fmt"
)
type Word uint16
type OpcodeError struct {
Opcode Word
}
func (err *OpcodeError) Error() string {
return fmt.Sprintf("invalid opcode %#04x", err.Opcode)
}
type State struct {
Registers
Ram Memory
step func(bool) error
}
type asyncState struct {
*State
stepper chan ... |
package gormsql
import (
"github.com/atymkiv/echo_frame_learning/blog/model"
"github.com/jinzhu/gorm"
)
// NewUser returns a new user database instance
func NewUser(db Database) *User {
return &User{db: db}
}
// Interface for post database
type Database interface {
Where(query interface{}, args ...interface{}) *... |
package main
import (
"github.com/BurntSushi/toml"
)
var config configuration
type configuration struct {
Database databaseConfig
Server serverConfig
Captcha captchaConfig
}
type databaseConfig struct {
Username string
Password string
Database string
}
type serverConfig struct {
Address string
}
type c... |
package polls
import (
"fmt"
"github.com/Nv7-Github/Nv7Haven/eod/types"
)
func (b *Polls) handlePollSuccess(p types.Poll) {
b.lock.RLock()
dat, exists := b.dat[p.Guild]
b.lock.RUnlock()
if !exists {
return
}
controversial := dat.VoteCount != 0 && float32(p.Downvotes)/float32(dat.VoteCount) >= 0.3
controv... |
package agent
type Registration struct {
Instance Instance `json:"instance"`
}
type Instance struct {
InstanceId string `json:"instanceId"`
HostName string `json:"hostName"`
App string `json:"app"`
IpAddr string `json:"ipAddr"`
VipAddr string ... |
package mysql
import (
"database/sql"
"fmt"
_ "github.com/go-sql-driver/mysql"
"log"
"time"
)
type Config struct {
Host string `yaml:"host"`
Port uint `yaml:"port"`
User string `yaml:"user"`
Password string `yaml:"password"`
Database string `yaml:"database"`
C... |
package client_test
import (
"context"
"fmt"
"net/http"
"reflect"
"strings"
"testing"
"time"
"github.com/chanioxaris/go-datagovgr/datagovgrtest"
"github.com/jarcoal/httpmock"
)
type testPayload struct {
Author string `json:"author"`
}
func TestClient_MakeRequestGET_Success(t *testing.T) {
ctx := context.... |
package alarm
type AlarmCounter struct {
YellowCount float64
RedCount float64
}
|
package here_test
import (
"github.com/codingsince1985/geo-golang"
"github.com/codingsince1985/geo-golang/here"
"strings"
"testing"
)
const appID = "YOUR_APP_ID"
const appCode = "YOUR_APP_CODE"
var geocoder = here.Geocoder(appID, appCode, 100)
func TestGeocode(t *testing.T) {
location, err := geocoder.Geocode(... |
/*
By starting at the top of the triangle below and moving to adjacent numbers on the row below, the maximum total from top to bottom is 23.
3
7 4
2 4 6
8 5 9 3
That is, 3 + 7 + 4 + 9 = 23.
Find the maximum total from top to bottom in triangle.txt (right click and 'Save Link/Target As...'), a 15K text file containin... |
package types
import (
"encoding/json"
"time"
)
// DelayQueueData struct
type DelayQueueData struct {
Data string `json:"data"` // the queue origin data
DelayTime int `json:"delaytime"` // the delay time, unit is second
TriggerTime time.Time `json:"triggertime"` // the unix timestamp t... |
package main
import (
"fmt"
"net/rpc"
"os"
)
type Args struct {
A, B int
}
type Quotient struct {
Q, R int
}
func readArgs() Args {
var a, b int
fmt.Println("A: ")
fmt.Scanln(&a)
fmt.Println("B: ")
fmt.Scanln(&b)
return Args{a, b}
}
func checkError(str string, err error) {
if err != nil {
fmt.Println(... |
package main
import (
"fmt"
"os"
"github.com/gin-gonic/gin"
"htmlparser/httpclient"
"htmlparser/handlers"
)
func main() {
// test connectity to spark
if ! httpclient.SparkDashboardIsRequestable() {
fmt.Println("FATAL : Cannot request spark dashboard :-(")
fmt.Println("\tAre the SPARK_DASHBOARD_URL, SPARK_... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.