text stringlengths 11 4.05M |
|---|
package git
import (
"crypto/rand"
"crypto/rsa"
"crypto/x509"
"encoding/pem"
"errors"
"fmt"
"os"
"strings"
"sync"
"testing"
"testing/fstest"
git "github.com/go-git/go-git/v5"
"github.com/google/go-cmp/cmp"
)
type mockGitSvc struct {
cloneOpts *git.CloneOptions
fetchOpts *git.FetchOptions
plainOpe... |
package models
import(
"encoding/json"
)
/**
* Type definition for HostTypeEnum enum
*/
type HostTypeEnum int
/**
* Value collection for HostTypeEnum enum
*/
const (
HostType_KLINUX HostTypeEnum = 1 + iota
HostType_KWINDOWS
HostType_KAIX
HostType_KSOLARIS
)
func (r HostT... |
package examples
import (
"bytes"
"io"
"os"
"github.com/go-echarts/go-echarts/v2/charts"
"github.com/go-echarts/go-echarts/v2/opts"
"github.com/go-echarts/go-echarts/v2/render"
tpls "github.com/go-echarts/go-echarts/v2/templates"
)
// copy from go-echarts/templates/header.go
// Now I want to customize my own ... |
package go_test_parallel
import (
"testing"
"time"
)
func Test_slow1(t *testing.T) {
time.Sleep(3 * time.Second)
}
func Test_slow2(t *testing.T) {
time.Sleep(1 * time.Second)
}
func Test_slow3(t *testing.T) {
time.Sleep(2 * time.Second)
}
|
package handler
import (
"excho-job/helper"
"excho-job/resume"
"fmt"
"strconv"
"github.com/gin-gonic/gin"
)
type resumeHandler struct {
service resume.Service
}
func NewResumeHandler(service resume.Service) *resumeHandler {
return &resumeHandler{service}
}
func (h *resumeHandler) GetResemuByJobSeekerIDHandl... |
package set1
func HammingDistance(A []byte, B []byte) int {
xor := FixedXOR(A, B)
bits := 0
for i:=0; i<len(xor); i+=1 {
n := xor[i]
for n > 0 {
bits += 1
n -= (n & -n)
}
}
return bits
}
func KeySizeScore(data []byte, keysize int) float64 {
var sum int
var count int
var i i... |
package main
import (
"fmt"
"log"
"github.com/PuerkitoBio/goquery"
)
func HtmlScrape(rule *Rule, url string) {
// doc, err := goquery.NewDocument("http://www.biquge.com.tw/17_17275/")
doc, err := goquery.NewDocument(url)
if err != nil {
log.Fatal(err)
}
if len(rule.Class)
t := doc.Find("div.volume").Fin... |
package helper
import "github.com/MOZGIII/evans/config"
func TestConfig() *config.Config {
return config.Get()
}
|
package generator
var serverTemplate = `
package main
import (
"fmt"
"github.com/watchman1989/rninet/server"
"{{.Rpath}}/router"
"{{.Rpath}}/proto/{{.Package.Name}}"
)
var (
routerServer = &router.RouterServer{}
)
func main() {
fmt.Printf("START_SERVER\n")
if err := server.Init(); err != nil {
fmt.Printf... |
package supervisor_test
import (
. "github.com/onsi/ginkgo"
. "github.com/onsi/gomega"
// sql drivers
_ "github.com/mattn/go-sqlite3"
. "github.com/starkandwayne/shield/supervisor"
)
var _ = Describe("HTTP Rest API", func() {
Describe("/v1/status API", func() {
It("handles GET requests", func() {
r := GE... |
package reverse
import "testing"
func TestReverse(t *testing.T) {
a := 123
b := 2147483648
a = Reverse(a)
b = Reverse(b)
if a != 321 {
t.Error("reverse error, expected result is 321")
}
if b != 0 {
t.Error("reverse error, expected result is 0")
}
}
|
package main
import "fmt"
var count int
func totalNQueens(n int) int {
putQueen(n,0,0,0,0)
return count
}
func putQueen(n,row,col,pia,na int) {
if row >= n {
count++
return
}
// 查看是否有空位
bits := (^(col | pia | na)) & ((1<<n)-1)
for bits > 0 {
// 取出最近的一个空位
p := bits & -bits
putQueen(n,row+1,(col|p)... |
package main
import (
"fmt"
"sync"
"time"
)
func main() {
wg := &sync.WaitGroup{}
wg.Add(1)
go func() {
defer func() {
wg.Done()
}()
//panic(-1)
Println()
time.Sleep(time.Second * 10)
//wg.Done()
}()
fmt.Println("+++++++++++")
wg.Wait()
fmt.Println("***********")
}
func Println() {
fmt.Prin... |
package Add_Two_Numbers
type ListNode struct {
Val int
Next *ListNode
}
func addTwoNumbers(l1 *ListNode, l2 *ListNode) *ListNode {
var l3, curr *ListNode
var carry = 0
for l1 != nil || l2 != nil {
var value1, value2 int
if l1 != nil {
value1 = l1.Val
l1 = l1.Next
} else {
value1 = 0
}
if l... |
package main
import (
"fmt"
"github.com/aliyun/aliyun-datahub-sdk-go/datahub"
"time"
)
func example_error() {
maxRetry := 3
dh = datahub.New(accessId, accessKey, endpoint)
if _, err := dh.CreateProject(projectName, "project comment"); err != nil {
if _, ok := err.(*datahub.InvalidPara... |
package server
import (
"errors"
"github.com/evcc-io/evcc/util/config"
"github.com/evcc-io/evcc/util/templates"
)
func templateForConfig(class templates.Class, conf map[string]any) (templates.Template, error) {
typ, ok := conf[typeTemplate].(string)
if !ok {
return templates.Template{}, errors.New("config tem... |
package main
import (
"encoding/json"
"fmt"
"io/ioutil"
"log"
"net/http"
"strconv"
"github.com/gorilla/mux"
"github.com/jinzhu/gorm"
_ "github.com/jinzhu/gorm/dialects/mysql"
)
var db *gorm.DB
var err error
type Artical struct {
ID int64 `json:"Id"`
TITLE string `json:"title"`
DESCRIPTIO... |
package zhenai
import (
"bufio"
"fmt"
"github.com/xiaozefeng/go-web-crawler/fetcher"
"github.com/xiaozefeng/go-web-crawler/model/zhenai"
"io/ioutil"
"os"
"testing"
)
func TestSaveProfile(t *testing.T) {
content, err := fetcher.Fetch("https://album.zhenai.com/u/108208979")
if err != nil {
panic(err)
}
fil... |
// Copyright 2016 Lars Wiegman. All rights reserved. Use of this source code is
// governed by a BSD-style license that can be found in the LICENSE file.
package multipass
import (
"testing"
"time"
"github.com/mholt/caddy"
)
func TestParse(t *testing.T) {
tests := []struct {
input string
shouldErr bool
... |
/*
Copyright 2020 Docker Compose CLI 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 a... |
package main
import (
"fmt"
)
/*
原码:正数是其二进制本身;负数是符号位为1,数值部分取X绝对值的二进制。
反码:正数的反码和原码相同;负数是符号位为1,其它位是原码取反。
补码:正数的补码和原码,反码相同;负数是符号位为1,其它位是原码取反,未位加1。
*/
func main() {
//原码 0000 0011
//反码 0000 0011
//补码 0000 0011
var a int8 = 3
//原码 1000 0010
//反码 1111 1101
//补码 1111 1110
var b int8 = -2
//// 左移和右移 操作的是原码, 结果为乘以... |
// +build !linux,!darwin,!windows
package udwSys
func SetCurrentMaxFileNum(limit uint64) (err error) {
return GetErrPlatformNotSupport()
}
|
package main
import (
"bufio"
"flag"
"io"
"log"
"os"
"time"
)
//TODO: Should mark header tags to avoid fetching those files
//TODO: Could also make Tag -> Array of attributes
var crawlTags = map[string]string{
"link": "href",
"script": "src",
"a": "href",
}
const defaultDuration = 60 * time.Second
co... |
// Copyright 2017 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 presigner
import (
"context"
"time"
"github.com/Cloud-Foundations/golib/pkg/awsutil/presignauth"
"github.com/Cloud-Foundations/golib/pkg/log/nulllogger"
"github.com/aws/aws-sdk-go-v2/aws/arn"
"github.com/aws/aws-sdk-go-v2/aws/signer/v4"
"github.com/aws/aws-sdk-go-v2/config"
"github.com/aws/aws-sdk-go... |
// Copyright (C) 2021 Storj Labs, Inc.
// See LICENSE for copying information.
package useragent_test
import (
"testing"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
"storj.io/common/useragent"
)
func TestEncodeEntries(t *testing.T) {
// invalid product
_, err := useragent.Encod... |
package installer
import (
"fmt"
"io/fs"
"io/ioutil"
"net/http"
"os"
"path"
"github.com/bernardolm/iot/supervisor-go/config"
"github.com/gosimple/slug"
log "github.com/sirupsen/logrus"
)
const (
permission fs.FileMode = 0744
)
func Install(p config.Program) (string, error) {
pPath := "./bin"
if _, err ... |
package openrtb
// SeatBid type encapsulates a set of bids submitted on behalf of a buyer, or a bidder seat, via
// the containing bid response object.
// See OpenRTB 2.3.1 Sec 4.2.2.
//go:generate easyjson $GOFILE
//easyjson:json
type SeatBid struct {
Bids []*Bid `json:"bid,omitempty"`
Seat string `json:"seat,omi... |
package cmd
import (
"fmt"
"strings"
"time"
log "github.com/sirupsen/logrus"
"github.com/spf13/cobra"
"github.com/fanaticscripter/EggContractor/db"
"github.com/fanaticscripter/EggContractor/util"
)
const _peekedThreshold = 7 * 24 * time.Hour
var _peekedCommand = &cobra.Command{
Use: "peeked [<contract-id... |
// Copyright 2014 mqant Author. 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... |
// Routing based on the gorilla/mux router
package gorilla
import (
"crypto/sha1"
"fmt"
"html/template"
"io"
"log"
"net/http"
"os"
"path/filepath"
//"strconv"
"strings"
//"sort"
"time"
"github.com/gorilla/mux"
)
import (
"github.com/upper/db/v4"
"github.com/upper/db/v4/adapter/cockroachdb"
)
var Serve ... |
package server
import (
"github.com/yacen/gong/context"
"net/http"
)
type Server struct {
server *http.Server
middlewares []Middleware
}
type MFun func(ctx *context.Context, next MFun)
func (s *Server) Use(f MiddlewareFunc) *Server {
s.middlewares = append(s.middlewares, &FunctionMiddleware{Fn: f})
retur... |
package main
import (
"context"
"encoding/json"
"flag"
"fmt"
"io/ioutil"
"kto/rpcclient"
"kto/rpcclient/message"
"kto/transaction"
"kto/types"
"kto/until"
"log"
"os"
"runtime"
"sync"
"time"
"github.com/BurntSushi/toml"
"google.golang.org/grpc"
)
const (
coinbaseAddr = "Kto9sFhbjDdjEHvcdH6n9dtQws1m4... |
package bjkl8
import (
"snatch_ssc/ioc"
"snatch_ssc/models/snatch/base"
"snatch_ssc/models/snatch/inter"
"strings"
"snatch_ssc/sys"
"github.com/astaxie/beego"
"github.com/duansky/goquery"
)
// 北京福彩网
type BwlcSnatch struct {
base.DataProcesserAbs
}
func init() {
ioc.RegisterObj("snatch.ssc.bjkl8.bwlc", &Bw... |
// call from project root with
// go run scripts/push_new_patch/main.go
// goreleaser expects a $GITHUB_TOKEN env variable to be defined
// in order to push the release got github
package main
import (
"fmt"
"io/ioutil"
"log"
"os"
"os/exec"
"strconv"
"strings"
)
func main() {
version, err := ioutil.ReadFil... |
package label
//selector in
// equality-based
// set-based
type Labels interface {
Has(label string) (exists bool)
Get(label string) (value string)
}
type Selector interface {
Matches(Labels) bool
Empty() bool
String() string
Add(r ...Requirement) Selector
Requirements() (requirements Requirements, selectable... |
package login
import (
"database/sql"
"fmt"
"o2clock/api-proto/onboarding/login"
"o2clock/constants/errormsg"
db "o2clock/db/postgres"
"o2clock/table/accesstoken"
"o2clock/table/allusers"
"google.golang.org/grpc/codes"
"google.golang.org/grpc/status"
)
const (
SQL_STATEMENT_FIND_USER_USING_USERNAME = `
SE... |
package discovergy
const API = "https://api.discovergy.com/public/v1"
type Meter struct {
MeterID string `json:"meterId"`
SerialNumber string `json:"serialNumber"`
FullSerialNumber string `json:"fullSerialNumber"`
}
type Reading struct {
Time int64
Values struct {
EnergyOut i... |
// 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.
// Type for a device identity result. Every device should have a subscriber getidentity.
package identity
import (
"fmt"
"github.com/dirkjabl/bricker"
"gi... |
package main
import (
"fmt"
"sync"
)
// MessageChannel is a global relay for all messages.
type MessageChannel struct {
sync.Mutex
members map[string]chan string
}
// MakeMessageChannel makes a MessageChannel.
func MakeMessageChannel() (m MessageChannel) {
m.members = make(map[string]chan string)
return
}
// ... |
package ossfile
import (
"github.com/jinzhu/gorm"
"log"
_ "github.com/jinzhu/gorm/dialects/mysql"
)
type Migration struct {
Dsn string
}
func (m Migration) InstallDb() {
db, err := gorm.Open("mysql", m.Dsn)
if err != nil {
log.Fatal(err)
}
defer db.Close()
db.Set("gorm:table_options", "ENGINE=InnoDB").Cr... |
package server
import (
"net/http"
"strings"
"github.com/Sirupsen/logrus"
"github.com/paddycarey/ims/pkg/images"
"github.com/paddycarey/ims/pkg/storage"
)
type Server struct {
Cache *InMemoryCache
Storage storage.FileSystem
// disable optimizations
NoOpts bool
}
func (s *Server) ServeHTTP(rw http.Respon... |
package oauth2bearer
import (
"context"
"fmt"
"log"
"net/http"
"time"
"golang.org/x/oauth2"
"golang.org/x/oauth2/clientcredentials"
)
type controlMessage struct {
action int
channel chan controlMessage
token *oauth2.Token
}
const (
getToken int = 0
refresh = 1
registerChannel ... |
package handlers
import (
"net/http"
"github.com/jalexanderII/literate-octo-pancake/backend/data"
)
// swagger:route GET /products products listProducts
// Return a list of products from the database
// responses:
// 200: productsResponse
// ListAll handles GET requests and returns all current products
func (p *P... |
package discovery
import (
"testing"
"time"
"github.com/stretchr/testify/assert"
)
func TestClientNodes(t *testing.T) {
server := NewServer("testing", 1234, "v1.0")
go server.Serve()
defer server.Stop()
nodes, err := Nodes(1 * time.Second)
assert.NoError(t, err)
assert.Len(t, nodes, 1)
assert.Equal(t, int... |
package command
import (
"fmt"
"math/rand"
"regexp"
)
var swearings = []string{
"a maronn",
"san giuseppe",
"san pietro",
"o patatern 'n croc",
"tutti i santi",
"gesu",
"gesu bambin 'n croc",
"gesu crist",
}
type SwearCommand struct {
pattern *regexp.Regexp
}
func Swear() SwearCommand {
return SwearCom... |
package headerutil
import (
"net"
"net/http"
"strings"
)
// GetNextXForwardedFor returns the X-Forwarded-For header value and append
// the remote address (client IP or proxy IP)
func GetNextXForwardedFor(r *http.Request) string {
var IPs string
priorIPs, hasXff := r.Header["X-Forwarded-For"]
if hasXff {
IP... |
package main
import (
"context"
"fmt"
"os"
"os/signal"
"sync"
"syscall"
"testing"
"time"
)
var w sync.WaitGroup
//处理进程信号
var signalChan = make(chan os.Signal)
var ctx, cancel = context.WithCancel(context.Background())
func processSignal() {
//处理退出信号,优雅停机
signal.Notify(signalChan, syscall.SIGKILL, syscall... |
package factory
import (
"bufio"
"encoding/json"
"fmt"
"github.com/mitchellh/cli"
"github.com/thoas/go-funk"
"os"
"seeder/constants"
"seeder/models"
"seeder/tools"
"seeder/utils"
"strings"
)
func Plan() (cli.Command, error) {
plan := &planCommandCLI{}
return plan, nil
}
type planCommandCLI struct {
Arg... |
package sub
var version = "v0.1"
func Version() string {
return version
}
|
/*
@Time : 2019/9/16 16:06
@Author : zxr
@File : recommend
@Software: GoLand
*/
package poetry
import "poetryAdmin/worker/core/grasp/poetry"
//诗词首页推荐信息抓取
type Recommend struct {
}
func NewRecommend() *Recommend {
return &Recommend{}
}
func (r *Recommend) Run() {
poetry.NewRecommend().StartGrasp()
}
|
package main
import "fmt"
func main() {
//fmt.Println("Hello World!")
var age int = 20
// 格式化字符串
var name string = "liuruichao"
fmt.Printf("name: %s, age: %d.\n", name, age)
}
|
package ingress
import (
"fmt"
"net"
"net/url"
"regexp"
"strconv"
"strings"
"github.com/pkg/errors"
"github.com/rs/zerolog"
"github.com/urfave/cli/v2"
"golang.org/x/net/idna"
"github.com/cloudflare/cloudflared/config"
"github.com/cloudflare/cloudflared/ingress/middleware"
"github.com/cloudflare/cloudfla... |
package iot
import (
"log"
"gobot.io/x/gobot"
"gobot.io/x/gobot/drivers/gpio"
"gobot.io/x/gobot/platforms/firmata"
"gobot.io/x/gobot/platforms/mqtt"
)
var (
led1 *gpio.LedDriver
led2 *gpio.LedDriver
mqttAdaptor *mqtt.Adaptor
)
func work() {
mqttAdaptor.On("leds", func(msg mqtt.Message) {
if... |
package cmd
import (
"fmt"
"github.com/fugue/fugue-client/client/scans"
"github.com/fugue/fugue-client/format"
"github.com/spf13/cobra"
)
type listScansOptions struct {
Offset int64
MaxItems int64
OrderBy string
OrderDirection string
Status []string
RangeFrom int64
RangeT... |
// 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, ... |
// 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, ... |
package lru
func (c *Cache) GetCalltracking(phones []RealPhone) (phonesInCache map[RealPhone]VirtualPhone, phonesNotFoundInCache []RealPhone) {
phonesInCache = make(map[RealPhone]VirtualPhone, len(phones))
phonesNotFoundInCache = make([]RealPhone, 0, len(phones))
if !config.calltracking.enabled {
phonesNotFoundI... |
package lc
import "math"
// Time: O(n)
// Benchmark 4ms 3.1mb | 100%
func findNumbers(nums []int) int {
var c, digits int
for _, n := range nums {
digits = int(math.Log10(float64(n))) + 1
if digits%2 == 0 {
c++
}
}
return c
}
|
package main
import (
"flag"
"fmt"
corev1 "k8s.io/api/core/v1"
"k8s.io/client-go/informers"
"k8s.io/client-go/kubernetes"
cliFlag "k8s.io/component-base/cli/flag"
"k8s.io/klog"
"multidim-pod-autoscaler/pkg/admission/config"
"multidim-pod-autoscaler/pkg/admission/logic"
podPatch "multidim-pod-autoscaler/pkg/a... |
/*
* Flow CLI
*
* Copyright 2019-2021 Dapper Labs, 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 appl... |
package forum
import (
"github.com/kil0meters/acolyte/pkg/authorization"
"github.com/kil0meters/acolyte/pkg/database"
"log"
"time"
)
type Comment struct {
ID string `db:"comment_id" valid:"printableascii,required"`
Account *authorization.Account `db:"-" valid:"-"`
... |
package config
import (
"github.com/kosotd/go-microservice-skeleton/config"
"gotest.tools/assert"
"testing"
)
type testConfig struct {
config config.Config
}
func (c *testConfig) GetBaseConfig() *config.Config {
return &c.config
}
func TestConfigEnv(t *testing.T) {
config.InitConfig(&testConfig{}, func(helper... |
package openrtb_ext
import (
"errors"
"github.com/buger/jsonparser"
)
// ExtSite defines the contract for bidrequest.site.ext
type ExtSite struct {
// AMP should be 1 if the request comes from an AMP page, and 0 if not.
AMP int8 `json:"amp"`
}
func (es *ExtSite) UnmarshalJSON(b []byte) error {
if len(b) == 0 {... |
package testutil
import (
"github.com/codeskyblue/go-sh"
"github.com/stretchr/testify/require"
"testing"
)
func MustRun(t *testing.T, name string, a ...interface{}) {
require.Nil(t, sh.Command(name, a...).Run())
}
|
package reader
import (
"adventure_book/model"
"encoding/json"
"os"
)
func ReadJsonStory(filename string) (storyRes model.Story, err error) {
file, err := os.Open(filename)
if err != nil {
return nil, err
}
d := json.NewDecoder(file)
if err := d.Decode(&storyRes); err != nil {
return nil, err
}
return... |
package models
type Following struct {
Username string
}
|
package request
import (
"github.com/z-ray/alipay/api/response"
)
// AlipayMobilePublicMessageCustomSendRequest
// API: alipay.mobile.public.message.caustom.send request
type AlipayMobilePublicMessageCustomSendRequest struct {
BizContent string
}
func (r *AlipayMobilePublicMessageCustomSendRequest) GetApiMethod() ... |
package todo
import (
"github.com/codegangsta/cli"
)
func Commands() []cli.Command {
return []cli.Command{
{
Name: "add",
Usage: "Add a new todo item.",
Action: AddAction,
},
{
Name: "list",
Usage: "List all active todo items.",
Action: ListAction,
},
{
Name: "show",
Usage:... |
package torrent
const (
// Base API Endpoint
ENDPOINT_API = "%s/api/v2"
// Authentication Endpoints
// https://github.com/qbittorrent/qBittorrent/wiki/Web-API-Documentation#authentication
ENDPOINT_AUTHENTICATION = ENDPOINT_API + "/auth/"
// [GET]... |
// 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 firmware
import (
"bufio"
"context"
"io"
"os"
"strings"
"time"
"chromiumos/tast/common/testexec"
"chromiumos/tast/local/bundles/cros/firmware/fwupd"
"chrom... |
package main
import "fmt"
import "sync"
import "time"
var wg sync.WaitGroup
func main() {
wg.Add(2)
go foo()
go bar()
wg.Wait()
}
func foo() {
for i := 0; i < 45; i++ {
fmt.Println("Foo: ", i)
time.Sleep(time.Duration(3 * time.Millisecond))
}
wg.Done()
}
func bar() {
for i := 0; i < 45; i++ {
fmt.Prin... |
package filter
import (
"strconv"
"github.com/layer5io/meshkit/errors"
)
const (
ErrInvalidAuthTokenCode = "1000"
ErrInvalidAPICallCode = "1001"
ErrReadAPIResponseCode = "1002"
ErrUnmarshalCode = "1003"
)
func ErrInvalidAuthToken() error {
return errors.New(ErrInvalidAuthTokenCode, errors.Alert, []... |
package csv
import (
"context"
"log"
"testing"
"github.com/go-tamate/tamate"
"github.com/go-tamate/tamate/driver"
"github.com/stretchr/testify/assert"
)
func Test_GetSchema(t *testing.T) {
var (
rootDir = "./"
fileName = "getSchema"
testData = `
(id),name,age
`
)
path := joinPath(rootDir, fileNa... |
// Unless explicitly stated otherwise all files in this repository are licensed
// under the Apache License Version 2.0.
// This product includes software developed at Datadog (https://www.datadoghq.com/).
// Copyright 2016-present Datadog, Inc.
package clusteragent
import (
"fmt"
"strconv"
securityv1 "github.com... |
package httpexpect
import (
"testing"
"github.com/gorilla/websocket"
)
func TestWebsocketFailed(t *testing.T) {
chain := makeChain(newMockReporter(t))
chain.fail("fail")
ws := &Websocket{
chain: chain,
}
ws.chain.assertFailed(t)
ws.Raw()
ws.WithReadTimeout(0)
ws.WithoutReadTimeout()
ws.WithWriteTime... |
package goserver
// UserRepo is a general interface definition for getting persistent user data
type UserRepo interface {
CreateUser(user *User) error
UpdateUserPasswd(user *User) error
GetUserByID(user *User) error
GetUserByUsername(user *User) error
}
|
package main
import "fmt"
func main(){
var names [5]string
friends:=[5] string {"Luis","Eduardo","Martin","Luis Fernando","Carlos"}
names = friends
for i, named := range names {
fmt.Println(named, &names[i]) // the & is for get the direction
}
fmt.Println(names)
} |
// Markdown Table Generator
package md
import (
"strings"
)
type Cell struct {
Value string
}
func NewPlainTextCell(data string) Cell {
return Cell{
Value: data,
}
}
func (c *Cell) String() string {
value := c.Value
value = strings.Replace(value, "\n", "<br/>", -1)
value = strings.Replace(value, "\\n", "<b... |
package routes
import (
"fmt"
"github.com/kataras/iris/v12"
)
type testdata struct {
Name string `json:"name" xml:"Name"`
Age int `json:"age" xml:"Age"`
City string `json:"city" xml:"city"`
}
func registerContentNegotiationRoute(app *iris.Application) {
// Render a resource with "gzip" encoding algorithm ... |
package go3uparse
import (
"encoding/json"
"fmt"
"io/ioutil"
"path/filepath"
)
func ChannelMerge(channels ...map[string]int) map[int]*Normal {
normals := GetListAvailableChannels()
for _, channel := range channels {
for name, id := range channel {
// if not exist this channel (id) in normalize channels
... |
package main
import (
"fmt"
"github.com/bbalet/stopwords"
"github.com/wilcosheh/tfidf"
"github.com/wilcosheh/tfidf/similarity"
"regexp"
"strings"
)
type StopWords struct {
Words []string
}
var t1 = "@BeautifulAtAll when's is season 6 out? Jimmy looks great, this role is definitely for him. Seriously, could an... |
package models
type Email struct {
To string `json:"to"`
From string `json:"from"`
ReplyTo string `json:"replyTo"`
ReplyToEmail string `json:"replyToEmail"`
Subject string `json:"subject"`
Template string `json:"tem... |
package aggregates
import (
"github.com/fission/fission-workflows/pkg/api/events"
"github.com/fission/fission-workflows/pkg/fes"
"github.com/fission/fission-workflows/pkg/types"
"github.com/golang/protobuf/proto"
)
const (
TypeTaskInvocation = "task"
)
type TaskInvocation struct {
*fes.BaseEntity
*types.TaskI... |
// Package main implements the pomerium-cli.
package main
import (
"crypto/tls"
"fmt"
"os"
"github.com/spf13/cobra"
"github.com/pomerium/pomerium/pkg/cryptutil"
)
var rootCmd = &cobra.Command{
Use: "pomerium-cli",
}
func main() {
err := rootCmd.Execute()
if err != nil {
fatalf("%s", err.Error())
}
}
fu... |
// Copyright (C) 2019 Storj Labs, Inc.
// See LICENSE for copying information.
package identity
import (
"bytes"
"context"
"crypto"
"crypto/x509"
"crypto/x509/pkix"
"fmt"
"io"
"os"
"sync"
"sync/atomic"
"github.com/zeebo/errs"
"storj.io/common/peertls"
"storj.io/common/peertls/extensions"
"storj.io/com... |
package routers
import (
"intra-hub/controllers"
"github.com/astaxie/beego"
)
func init() {
beego.Router("/", &controllers.HomeController{}, "get:HomeView")
beego.Router("/me", &controllers.UserController{}, "get:MeView")
beego.Router("/logout", &controllers.UserController{}, "get:Logout")
beego.Router("/login... |
package gobcnbicing
import "testing"
func TestGetStations(t *testing.T) {
_, err := GetStations()
if err != nil {
t.Error(err)
}
}
|
../../../../../local/bundles/cros/ui/conference/room_type.go |
package pointer
// Of takes the pointer of a value.
func Of[T any](v T) *T { return &v }
// Deref will return the referenced value,
// or if the pointer has no value,
// then it returns with the zero value.
func Deref[T any](v *T) T {
if v == nil {
return *new(T)
}
return *v
}
|
package cmd
import (
"context"
"errors"
"fmt"
"net/url"
"os"
"path/filepath"
"strings"
"github.com/Azure/azure-storage-azcopy/common"
)
type copyUploadEnumerator common.CopyJobPartOrderRequest
// this function accepts the list of files/directories to transfer and processes them
func (e *copyUploadEnumerato... |
package main
import (
"bufio"
"fmt"
"io"
"log"
"os"
"strings"
)
func checkSum(data io.Reader) {
scanner := bufio.NewScanner(data)
twice := 0
thrice := 0
for scanner.Scan() {
x := scanner.Text()
var count int
twie := 0
trie := 0
for _, char := range x {
count = strings.Count(x, string(char))
... |
package main
import "fmt"
func main() {
s := make([]int, 10) //criando um slice de inteiros com 10 posições
s[9] = 12
fmt.Println(s)
s = make([]int, 10, 20) //criando um slice de inteiros com 10 elementos e 20 posições
// len é a qtd de elementos e cap é o tamanho real do slice
fmt.Println(s, len(s), cap(s))
... |
package model
import (
pb "github.com/eriklupander/tradfri-go/grpc_server/golang"
"time"
)
func ToDeviceResponse(device Device) BlindResponse {
if device.BlindControl != nil && len(device.BlindControl) > 0 {
dr := BlindResponse{
DeviceMetadata: DeviceMetadata{
Name: device.Name,
Id: device.D... |
package revocation
import (
"io/ioutil"
"net/http"
"github.com/dbogatov/dac-lib/dac"
"github.com/dbogatov/fabric-amcl/amcl"
"github.com/dbogatov/fabric-amcl/amcl/FP256BN"
)
var skRevoke dac.SK
var ys []interface{}
var epoch *FP256BN.BIG
// RunServer ...
func RunServer() {
logger.Notice("Server starting. Ctl+C... |
/*
* @Author: Sy.
* @Create: 2019-11-01 20:54:15
* @LastTime: 2019-11-16 18:36:07
* @LastEdit: Sy.
* @FilePath: \server\models\admin.go
* @Description: 管理员
*/
package models
import (
"github.com/astaxie/beego/orm"
)
type Admin struct {
Id int
LoginName string
RealName string
Password string
... |
package core
import (
"fmt"
)
//Extended int64eger
type Int64 struct {
int64
Valid bool
Context *Context
}
func (this Int64) String() string {
if this.Valid {
return fmt.Sprint(this.int64)
} else {
return ""
}
}
func (this *Int64) Parse(i int64) {
this.int64 = i
this.Valid = true
}
func (this *Int64)... |
package spudo
import (
"errors"
"flag"
"math/rand"
"os"
"os/signal"
"strings"
"sync"
"syscall"
"time"
"github.com/BurntSushi/toml"
"github.com/bwmarrin/discordgo"
"github.com/robfig/cron/v3"
)
// Config contains all options for the config file
type Config struct {
Token string
CommandPr... |
// 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, ... |
///
/// Websocket connection to send and receive data
/// through a web interface
///
package main
import (
"io"
"log"
"net/http"
"time"
"github.com/gorilla/websocket"
)
const (
// Time allowed to write a message.
writeWait = 10 * time.Second
// Time allowed to read the next message
readWaitTime = 60 * ti... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.