text stringlengths 11 4.05M |
|---|
package middlewares
import (
"encoding/json"
"fmt"
"net/http"
"os"
"time"
"github.com/garyburd/redigo/redis"
"github.com/gorilla/mux"
"github.com/octoblu/tattle/logentry"
)
// JobLogger holds the oxy circuit breaker.
type JobLogger struct {
redisChannel chan []byte
router *mux.Router
}
// NewJobLogg... |
package main
import "fmt"
func main() {
switch age := 31; age {
case 28, 29, 30:
fmt.Println("Age is 28-30")
fallthrough
case 31, 32, 33:
fmt.Println("Age is 31-33")
fallthrough
// case 29:
// fmt.Println()
case 34, 35, 40:
fmt.Println("Age is 34-40")
default:
fmt.Println("?")
}
}
|
package openapi
import (
"bufio"
"io"
"strconv"
)
func Parse(input io.Reader) (Job, error) {
scanner := bufio.NewScanner(input)
job := Job{}
for scanner.Scan() {
line := scanner.Text()
switch line {
case "[JobID]":
scanner.Scan()
line = scanner.Text()
id, err := strconv.Atoi(line)
if err != ni... |
// 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 formatting
import (
"fmt"
"sort"
"strings"
"github.com/Alpanakabra/Momenton/EmployeeManagement/data"
)
// Node models a node in the employee tree
// that is a tree where the CEO is the root, its direct managers are its chidren
// and each employee node is a child of its immediate manager node
type Node s... |
package setup
import (
"database/sql"
"log"
)
func CreateTable(dbCon *sql.DB) {
_, err := dbCon.Exec("CREATE TABLE IF NOT EXISTS " +
`users("id" SERIAL PRIMARY KEY,` +
`"firstname" varchar(50), "secondname" varchar(50), "thirdname" varchar(50), "phone" varchar(20))`)
if err != nil {
log.Println("dbCon.Exec(... |
package openFile
import (
"github.com/stretchr/testify/assert"
"testing"
)
func TestFileIsNotExist(t *testing.T) {
path := GetPath() + "/filterRead.go"
assert.False(t, FileIsNotExist(path),"File is exist")
}
func TestOpenFile(t *testing.T) {
path := GetPath() + "/filterRead.go"
buf := OpenFile(path)
txt := `... |
package configuration
import (
"fmt"
"strings"
"github.com/knadh/koanf/providers/confmap"
"github.com/knadh/koanf/v2"
"github.com/authelia/authelia/v4/internal/configuration/schema"
"github.com/authelia/authelia/v4/internal/utils"
)
func koanfGetKeys(ko *koanf.Koanf) (keys []string) {
keys = ko.Keys()
for ... |
// Copyright (C) 2020 Cisco Systems 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 agr... |
// Copyright 2019 The Dice Authors. 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
//
// https://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by app... |
package data
import (
"database/sql"
"log"
"os"
"github.com/google/uuid"
_ "github.com/mattn/go-sqlite3"
"grhamm.com/todo/entity"
)
func InitDatabase() {
var database *sql.DB
if _, err := os.Stat("database.db"); os.IsNotExist(err) {
file, err := os.Create("database.db")
if err != nil {
log.Fatal(er... |
package main
import (
"context"
"fmt"
"grpc-basics/greetpb"
"io"
"log"
"google.golang.org/grpc"
)
func main() {
fmt.Println("Configuring grpc client...")
conn, err := grpc.Dial("localhost:50051", grpc.WithInsecure())
if err != nil {
log.Fatalf("could not connect: %v", err)
}
defer conn.Close()
client... |
package main
import "fmt"
func main() {
sum := 0
for i := 0; i < 10; i++ {
sum += i
}
fmt.Println("1:", sum)
///////////////////////////
sum = 0
for {
sum++
if sum > 10 {
break
}
}
fmt.Println("2:", sum)
///////////////////////////... |
package main
import (
"context"
"database/sql"
"encoding/json"
"errors"
"fmt"
"io/ioutil"
"log"
"net/http"
"net/url"
"strings"
"time"
_ "github.com/go-sql-driver/mysql"
"github.com/graphql-go/handler"
"github.com/jjg-akers/docker-sql-graphql/cmd/schema"
)
func search(w http.ResponseWriter, r *http.Requ... |
// Package filter handles filtering the results of list methods.
package filter
import (
"github.com/google/logger"
"golang.org/x/net/context"
)
// Resource is the resource being filtered on.
type Resource interface{}
// Handler is a function that efficiently handles a specific filter pattern. It parses the specif... |
package main
import (
"database/sql"
"fmt"
"os"
"strings"
aw "github.com/deanishe/awgo"
"github.com/mattn/go-sqlite3"
_ "github.com/mattn/go-sqlite3"
)
//nolint:gochecknoinits
func init() {
sql.Register("sqlite3_custom", &sqlite3.SQLiteDriver{
ConnectHook: func(conn *sqlite3.SQLiteConn) error {
err := 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 gcp
import "testing"
func Test_newQuota(t *testing.T) {
cases := []struct {
name string
}{{
name: "missing usage",
}, {
name: "usage in single zone",
}, {
name: "usage in multiple zones",
}, {
name: "",
}}
for _, test := range cases {
t.Run(test.name, func(t *testing.T) {
})
}
}
|
package slack
import (
"net/http"
"reflect"
"testing"
)
type remindersHandler struct {
gotParams map[string]string
response string
}
func newRemindersHandler() *remindersHandler {
return &remindersHandler{
gotParams: make(map[string]string),
}
}
func (rh *remindersHandler) accumulateFormValue(k string, r ... |
// Copyright The OpenTelemetry Authors
// SPDX-License-Identifier: Apache-2.0
package pmetricjson
import (
"testing"
jsoniter "github.com/json-iterator/go"
"github.com/stretchr/testify/assert"
otlpcollectormetrics "go.opentelemetry.io/collector/pdata/internal/data/protogen/collector/metrics/v1"
otlpmetrics "go... |
package main
import (
"log"
"k8s.io/kubernetes/pkg/api"
k8s "k8s.io/kubernetes/pkg/client/unversioned"
"k8s.io/kubernetes/pkg/labels"
"k8s.io/kubernetes/pkg/watch"
)
type whitelistEntry struct {
EventType string `json:"eventType,omitempty"`
Msg string `json:"msg,omitempty"`
Obj string `json:"obj,... |
package auth
import (
"encoding/xml"
"github.com/thought-machine/finance-messaging/iso20022"
)
type Document00800102 struct {
XMLName xml.Name `xml:"urn:iso:std:iso:20022:tech:xsd:auth.008.001.02 Document"`
Message *RegulatoryTransactionReportV02 `xml:"RgltryTxRpt"`
}
func (d *Document008... |
package main
import (
"fmt"
es "github.com/elastic/go-elasticsearch/v7"
)
func main() {
client, _ := es.NewDefaultClient()
fmt.Println(es.Version)
fmt.Println(client.Info())
}
|
package main
import "fmt"
func ReverseString(b []byte, start, end int) []byte {
for start < end {
t := b[start]
b[start] = b[end]
b[end] = t
start++
end--
}
return b
}
func LeftRotateString(s string, m int) string {
b := []byte(s)
n := len(b)
b = ReverseString(b, 0, m-1)
b = ReverseString(b, m, n-1)... |
package util
import (
"fmt"
"io/ioutil"
"os"
"os/user"
"strconv"
"testing"
. "github.com/anthonybishopric/gotcha"
)
func TestMkdirAll(t *testing.T) {
temp, err := ioutil.TempDir("", "mkdirall")
Assert(t).IsNil(err, "There should not have been an error creating a temp dir")
dirPath := fmt.Sprintf("%s/foo/b... |
package controllers
import (
"context"
"encoding/json"
"fmt"
"log"
"net/http"
"time"
"github.com/aayush1607/instagram_api/config"
"github.com/aayush1607/instagram_api/models"
"go.mongodb.org/mongo-driver/bson"
"go.mongodb.org/mongo-driver/bson/primitive"
"golang.org/x/crypto/bcrypt"
)
fun... |
package chess
var Symbols = map[string]map[string]string{
"white": map[string]string{
"king": "♔",
"queen": "♕",
"rook": "♖",
"bishop": "♗",
"knight": "♘",
"pawn": "♙",
},
"black": map[string]string{
"king": "♚",
"queen": "♛",
"rook": "♜",
"bishop": "♝",
"knight": "♞",
"pawn": ... |
package p9p
import (
"errors"
"net"
)
type Kind byte
const (
KTversion Kind = iota + 100
KRversion
KTauth
KRauth
KTattach
KRattach
KTerror
KRerror
KTflush
KRflush
KTwalk
KRwalk
KTopen
KRopen
KTcreate
KRcreate
KTread
KRread
KTwrite
KRwrite
KTclunk
KRclunk
KTremove
KRremove
KTstat
KRstat
K... |
package main
import (
"encoding/json"
"github.com/gorilla/mux"
"log"
"net/http"
"TLSSign"
)
type Username struct {
User string `json:"username"`
}
type Signature struct {
Sig string `json:"sig"`
}
var pri_key = `-----BEGIN PRIVATE KEY-----
MIGHAgEAMBMGByqGSM49... |
// Copyright 2017 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 main
import (
"io"
"log"
"os"
"os/exec"
"runtime"
"runtime/debug"
"github.com/Nv7-Github/Nv7Haven/eod/logs"
"github.com/go-sql-driver/mysql"
"github.com/gofiber/fiber/v2"
)
var monitors = [][]string{{"measure_temp"}, {"measure_volts"}, {"get_mem", "arm"} /*, {"get_mem", "gpu"}, {"get_throttled"}*/} ... |
package nv7haven
import (
_ "embed"
"github.com/Nv7-Github/Nv7Haven/db"
"github.com/Nv7-Github/firebase"
database "github.com/Nv7-Github/firebase/db"
"github.com/gofiber/fiber/v2"
)
//go:embed serviceAccount.json
var serviceAccount string
// Nv7Haven is the backend for https://nv7haven.tk
type Nv7Haven struct ... |
/**
* @Time : 2020/9/16 11:19 AM
* @Author : solacowa@gmail.com
* @File : service_test
* @Software: GoLand
*/
package transform
import (
"context"
"testing"
)
var (
svc = New()
)
func TestService_Init(t *testing.T) {
ctx := context.Background()
svc.Init(ctx, "world")
}
func TestService_TransformAST2(t ... |
package auth
import (
"crypto/hmac"
"crypto/sha1"
"crypto/subtle"
"encoding/base32"
"encoding/binary"
"fmt"
"hash"
"math"
"strconv"
"strings"
"github.com/uhppoted/uhppoted-lib/kvs"
"github.com/uhppoted/uhppoted-mqtt/log"
)
type HOTP struct {
increment uint64
secrets *kvs.KeyValueStore
counters stru... |
package integers
/*Add ... Function Specification:
INPUTS:
number1 = first number to add
number2 = second number to add
OUTPUTS:
Returns the sum of the two inputted numbers
*/
func Add(number1, number2 int) int {
return number1 + number2
}
/*Subtract ... Function Specification:
INPUTS:
number1 = first number to ... |
// Copyright 2018 Google LLC
//
// 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
//
// https://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in ... |
package main
import (
"flag"
"os"
"testing"
"github.com/tespo/satya/v2/migrations"
"github.com/tespo/satya/v2/seeders"
)
func TestMain(m *testing.M) {
local := flag.String("local", "false", "Determines best way to run tests")
flag.Parse()
os.Setenv("DB_NAME", "tespo_docker")
os.Setenv("DB_USER", "root")
if... |
// 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 models
const (
DATABASENAME = "boxci"
TableNameAccounts = "Accounts"
ErrDatabase = -1
ErrSystem = -2
ErrDupRows = -3
ErrNotFound = -4
)
|
package glogger
import (
"github.com/sirupsen/logrus"
)
// InitOptions is the struct of options to configure logger
type InitOptions struct {
Level string
}
// Init function to init json logger
func Init(option InitOptions) (*logrus.Logger, error) {
logger := logrus.New()
logger.SetFormatter(&JSONFormatter{})
... |
package main
import (
"image/png"
"image/color"
"image"
"runtime"
"os"
"fmt"
"math"
"sync"
)
func rgbV2linear(v float64) float64 {
if v < 0.04045 {
return v/12.92
}
return math.Pow((v+0.055)/1.055, 2.4)
}
func rgb2lineargrayscale(R,G,B uint32) float64 {
R_linea... |
package testutil_test
import (
"errors"
"io/ioutil"
"net/http"
"net/url"
"strings"
"testing"
"github.com/lag13/testutil"
)
// TestCheckErrHasMsg checks that when we check an error for the
// expected message we get the expected diff.
func TestCheckErrHasMsg(t *testing.T) {
tests := []struct {
name stri... |
package security
// import (
// "context"
// "log"
// "github.com/jackc/pgx/v4/pgxpool"
// )
// // SecService ...
// type SecService struct {
// pool *pgxpool.Pool
// }
// // SecondService ...
// func SecondService(pool *pgxpool.Pool) *SecService {
// return &SecService{pool: pool}
// }
// type clientsData st... |
// Copyright 2016-2017 The psh Authors. All rights reserved.
package psh
// SegmentUnknown implements the not-found segment partial of the prompt.
//
// It renders an empty string.
type SegmentUnknown struct {
Data []byte
}
// NewSegmentUnknown creates an instace of SegmentUnknown type.
func NewSegmentUnknown() *Se... |
package main
/*
@Time : 2020-04-04 17:26
@Author : audiRStony
@File : 05_结构体反射.go
@Software: GoLand
*/
import (
"fmt"
"reflect"
)
type student struct {
Name string `json:"name"`
Score int `json:"score"`
}
func main() {
stu1 := student{
Name:"娜扎",
Score:88,
}
t := reflect.T... |
/*
* @lc app=leetcode.cn id=128 lang=golang
*
* [128] 最长连续序列
*/
package main
import "fmt"
// @lc code=start
func longestConsecutive(nums []int) int {
var currentNum, currentSeq, max int
numSet := make(map[int]bool)
for _, v := range nums {
numSet[v] = true
}
for i := range numSet {
if !numSet[i-1] {
c... |
package main
import (
"encoding/json"
"fmt"
"net/http"
"github.com/julienschmidt/httprouter"
)
// Index handles the default route (GET /).
func Index(w http.ResponseWriter, r *http.Request, _ httprouter.Params) {
fmt.Fprint(w, "relayctl reporting for duty!\n")
}
// RelayIndex handles the relays index action (G... |
package main
import (
"io"
)
// Context ...
type Context struct {
WorkingDir string
Stdout io.Writer
Stderr io.Writer
ConfigPath string
OutputPath string
Silent bool
NoColor bool
NoEmoji bool
Query string
}
|
// base/error/make.
package main
import "fmt"
func main() {
n := -1
defer func() {
fmt.Println(recover())
}()
_ = make([]int, 0, n)
}
|
package scan
const (
RuneError = '\uFFFD'
MaxRune = '\U0010FFFF'
RuneSelf = 0x80
surrogateMin = 0xD800
surrogateMax = 0xDFFF
t1 = 0x00 // 0000 0000
tx = 0x80 // 1000 0000
t2 = 0xC0 // 1100 0000
t3 = 0xE0 // 1110 0000
t4 = 0xF0 // 1111 0000
t5 ... |
package article
import (
"log"
"github.com/tidwall/tinylru"
)
// Cache struct
type Cache struct {
fs *Fs
lru *tinylru.LRU
}
// Init func
func (cah *Cache) Init(arg interface{}) {
cah.fs = new(Fs)
cah.fs.Init(arg)
cah.lru = new(tinylru.LRU)
cah.lru.Resize(10)
}
// Get func
func (cah *Cache) Get(name string... |
package metrics
import (
"strings"
"github.com/prometheus/client_golang/prometheus"
"github.com/prometheus/client_golang/prometheus/promauto"
)
func CreateMetrics(reportsDir string) {
promauto.NewGaugeFunc(prometheus.GaugeOpts{
Name: "vuln_count",
Help: "Total count of vulnerabilities, across all servers",
... |
package friend
import (
"Open_IM/pkg/common/config"
"Open_IM/pkg/common/constant"
"Open_IM/pkg/common/db/mysql_model/im_mysql_model"
"Open_IM/pkg/common/log"
pbFriend "Open_IM/pkg/proto/friend"
"Open_IM/pkg/utils"
"context"
)
func (s *friendServer) GetFriendList(ctx context.Context, req *pbFriend.GetFriendList... |
package assert
import (
"reflect"
"testing"
)
func Equal(t *testing.T, want, got interface{}) {
t.Helper()
if isEmptySlices(want, got) {
return
}
if !reflect.DeepEqual(want, got) {
t.Errorf("not equal want=%+v got=%+v", want, got)
}
}
func isEmptySlices(first, second interface{}) bool {
v1 := reflect.Va... |
package main
import (
"bufio"
"fmt"
"os"
)
func main() {
if len(os.Args) != 2 {
fmt.Fprintf(os.Stderr, "Файлын нэр заана уу\n")
os.Exit(1)
}
f, err := os.Open(os.Args[1])
if err != nil {
fmt.Printf("Файлыг нээхэд алдаа гарлаа: %v\n", err)
os.Exit(1)
}
defer f.Close()
n := 10
scanner := bufio.NewS... |
package main
import (
"fmt"
"io"
"os"
"debug/elf"
"bufio"
"strings"
)
func check(e error) {
if e != nil {
panic(e)
}
}
func ioReader(file string) io.ReaderAt {
r, err := os.Open(file)
check(err)
return r
}
type Stack struct {
Fuction uint32
Pc... |
/*
Copyright 2019 The Kubernetes 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, ... |
package cmd
import (
"fmt"
"log"
"os"
"strings"
"github.com/spf13/cobra"
"github.com/spf13/viper"
"github.com/bpineau/cloud-floating-ip/config"
"github.com/bpineau/cloud-floating-ip/pkg/operation"
"github.com/bpineau/cloud-floating-ip/pkg/run"
)
var (
cfgFile string
ip string
hoster string
ins... |
package channelserver
import (
"fmt"
"net"
"sync"
"github.com/Andoryuuta/Erupe/config"
"github.com/Andoryuuta/Erupe/network/binpacket"
"github.com/Andoryuuta/Erupe/network/mhfpacket"
"github.com/Andoryuuta/byteframe"
"github.com/jmoiron/sqlx"
"github.com/matterbridge/discordgo"
"go.uber.org/zap"
)
// Confi... |
/*
* @lc app=leetcode id=12 lang=golang
*
* [12] Integer to Roman
*/
package main
/* Solution 1: using map */
func intToRoman(num int) string {
res := ""
keys := []int{1000, 900, 500, 400, 100, 90, 50, 40, 10, 9, 5, 4, 1}
values := []string{"M", "CM", "D", "CD", "C", "XC", "L", "XL", "X", "IX", "V", "IV", "I"}
... |
package video
import (
"VideoSync/data"
"github.com/astaxie/beego"
"sync"
"encoding/json"
"VideoSync/com"
)
func CreateVideo(obj *[]data.VideoTracker){
//查找频道列表
if(len(*obj)<=0){
return
}
var t []data.VideoTracker
var m =make(map[string]data.VideoFo)
for _,value:=range *obj{
if(value.Id=="00000000000... |
// Copyright 2020 PingCAP, Inc. Licensed under Apache-2.0.
package export
import (
"strings"
"testing"
"github.com/DATA-DOG/go-sqlmock"
"github.com/pingcap/tidb/util/promutil"
"github.com/stretchr/testify/require"
)
type simpleRowReceiver struct {
data []string
}
func newSimpleRowReceiver(length int) *simple... |
package main
func main() {
}
func insertIntoBST(root *TreeNode, val int) *TreeNode {
if root == nil {
return &TreeNode{Val: val}
}
p := root
for p != nil {
if val < p.Val {
if p.Left == nil {
p.Left = &TreeNode{Val: val}
break
}
p = p.Left
} else {
if p.Right == nil {
p.Right = &Tre... |
package util
// this should be moved in to go-whosonfirst-travel and/or a general-purpose
// WOF package (20180814/thisisaaronland)
import (
"fmt"
"github.com/whosonfirst/go-whosonfirst-geojson-v2"
"github.com/whosonfirst/go-whosonfirst-geojson-v2/properties/whosonfirst"
"regexp"
"strings"
)
var re_name *regexp... |
package main
import (
"github.com/astaxie/beego"
"github.com/astaxie/beego/logs"
"github.com/astaxie/beego/orm"
_ "github.com/go-sql-driver/mysql"
_ "ions_zhiliao/models/auth"
_ "ions_zhiliao/models/my_center"
_ "ions_zhiliao/models/caiwu"
_ "ions_zhiliao/models/news"
_ "ions_zhiliao/routers"
"ions_zhiliao/u... |
package cells
import (
"testing"
"github.com/stretchr/testify/assert"
)
func TestThatCellsCanBeReset(t *testing.T) {
cells := NewCells(5, 5)
cells.SetRandomValues()
cell, err := cells.GetCell(2, 2)
assert.NoError(t, err)
isAliveAfterCreation := cell.isAlive
if isAliveAfterCreation {
err = cells.SetCell(2... |
package config
import (
"encoding/json"
"io/ioutil"
"os"
)
//ParseConfig parses the configuration json
func ParseConfig(cfgFile string) *Config {
jsonFile, err := os.Open(cfgFile)
if err != nil {
panic("Could not open config file")
}
defer jsonFile.Close()
jsonBytes, err := ioutil.ReadAll(jsonFile)
if err ... |
package main
import (
"fmt"
"strings"
"os"
"bytes"
"encoding/json"
"github.com/jawher/mow.cli"
)
var (
version string
gitCommit string
buildDate string
)
func main() {
app := cli.App("jg", "a CLI to generate JSON")
app.LongDesc = HELP
app.Version("v version", fmt.Sprintf("%s [sha: %s, time: %s]", ... |
package model
type RenameData struct {
Path string
Recursive bool
Random bool
Remove string
ReplaceWith string
Pattern string
}
|
package chunker
type option func(*Chunker)
type baseOption func(*BaseChunker)
// WithAverageBits allows to control the frequency of chunk discovery:
// the lower averageBits, the higher amount of chunks will be identified.
// The default value is 20 bits, so chunks will be of 1MiB size on average.
func WithBaseAverag... |
package goyum
import (
"testing"
)
func TestSearchRecipes(t *testing.T) {
appid, appkey, err := getTestingCredentials()
if err != nil {
t.Fatal(err)
}
var y *Yummly
y, err = SetCredentials(appid, appkey)
sp := NewSearchParams("meatloaf")
sp.RequirePictures(true).MaxTotalTimeInSeconds(60).AddAllowedIngredie... |
package epic
import (
"log"
"sync"
"github.com/google/go-github/github"
"github.com/karen-irc/popuko/operation"
)
const masterBranchName = "master"
func DetectUnmergeablePR(client *github.Client, ev *github.PushEvent) {
// At this moment, we only care a pull request which are looking master branch.
if *ev.Re... |
package game
import (
"encoding/json"
"fmt"
"qiniupkg.com/x/errors.v7"
"qiniupkg.com/x/log.v7"
"throne/utils"
)
type War struct {
Game *Game `json:"-"`
Area *Area
Attacker *Player
Defender *Player
Winner *Player
AttackerSoldiers []*S... |
package main
import "fmt"
/**
定义一个人结构体
*/
type Person struct {
name string
age int
sex string
}
// 定义一个结构体方法
func (p Person) PrintInfo() {
fmt.Print(" 姓名: ", p.name)
fmt.Print(" 年龄: ", p.age)
fmt.Print(" 性别: ", p.sex)
fmt.Println()
}
func (p *Person) SetInfo(name string, age int, sex string) {
p.name = na... |
package lineartable
import "testing"
func TestArray(t *testing.T) {
a := NewArray(5)
a.Add(0, 0)
t.Log(a)
for i := 1; i < 6; i++ {
a.Add(i, i)
t.Log(a)
}
a.Remove(5)
t.Log(a)
a.Set(3, 44)
a.Set(4, 44)
t.Log(a)
t.Log(a.Get(4))
t.Log(a.Get(1))
t.Log(a.Find(44))
t.Log(a.FindAll(44))
}
|
package certificate
import "crypto/tls"
type Cert struct {
tlsCert tls.Certificate
} |
package command
import (
"context"
"os"
"github.com/logrusorgru/aurora"
isatty "github.com/mattn/go-isatty"
"github.com/moby/buildkit/client"
"github.com/moby/buildkit/util/appcontext"
"github.com/openllb/hlb/diagnostic"
"github.com/openllb/hlb/solver"
cli "github.com/urfave/cli/v2"
)
func Context() context... |
package en
import (
"testing"
)
func TestPolybiusDecodeEN1(t *testing.T) {
e := new(EN)
e.Init()
plainText, _ := e.PolybiusDecode("44 23 15 41 45 24 13 25 12 42 34 52 33 21 34 53 45 32 35 43 34 51 15 42 44 23 15 31 11 55 54 14 34 22")
expectedText := "THEQUI/JCKBROWNFOXUMPSOVERTHELAZYDOG"
if plainText != expec... |
package config
func DefaultConfPath() string {
return "/usr/local/etc/nextdns.conf"
}
|
package util
import (
"github.com/gin-gonic/gin"
"github.com/go-resty/resty/v2"
)
func RequestUtil(url string, data map[string]interface{}, c *gin.Context) *resty.Response {
var headerNames = [8]string{
"X-Request-Id",
"X-B3-TraceId",
"X-B3-SpanId",
"X-B3-ParentSpanId",
"X-B3-Sampled",
"X-B3-Flags",
... |
package main
import (
"flag"
"fmt"
"image"
"image/draw"
"image/png"
"math"
"math/rand"
"os"
"os/exec"
"path/filepath"
"strings"
"sync"
"time"
"github.com/kardianos/osext"
)
//go:generate stringer -type=FormatType
type FormatType int
const (
Both FormatType = iota
PVRTC
ETC1
PVRTC_SPLIT_ALPHA
ETC1... |
package goproxy
import (
"encoding/json"
"fmt"
"io"
"net/http"
"strings"
"time"
"unicode/utf8"
"github.com/rs/zerolog"
"github.com/spaolacci/murmur3"
"github.com/sirkon/goproxy/internal/errors"
"github.com/sirkon/goproxy/semver"
)
// Middleware acts as go proxy with given router.
// transportPrefix is ... |
package main
import (
"bytes"
"fmt"
"io"
"io/ioutil"
"golang.org/x/crypto/openpgp"
"golang.org/x/crypto/openpgp/armor"
openssl "github.com/Luzifer/go-openssl/v3"
)
type decryptMethod func(body []byte, passphrase string) ([]byte, error)
func decryptMethodFromName(name string) (decryptMethod, error) {
switch... |
package main
import (
"fmt"
"net/http"
"time"
"github.com/rokmetro/logging-library/errors"
"github.com/rokmetro/logging-library/logs"
"github.com/rokmetro/logging-library/logutils"
)
type handlerFunc = func(*logs.Log, http.ResponseWriter, *http.Request)
type WebAdapter struct {
logsger *logs.Logger
}
func (... |
package queue
import (
"github.com/go-redis/redis/v8"
)
type RedisQueueTopic struct {
}
func (t *RedisQueueTopic) GetQueue(topic string) Queue {
return
}
type RedisQueue struct {
redisClient *redis.Client
}
// Push message to back
func (q *RedisQueue) Push(message.Message) error {
}
// Pop message
func (q *Re... |
// 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 cmdLogout = &Command{
Exec: runLogout,
UsageLine: "logout [OPTIONS]",
Desc... |
package main
import (
"github.com/hashicorp/terraform/plugin"
"github.com/rfalias/terraform-provider-powershell/pypwsh"
)
func main() {
plugin.Serve(&plugin.ServeOpts{
ProviderFunc: pypwsh.Provider,
})
}
|
package service
import (
"errors"
"github.com/go-kit/kit/log"
"github.com/l-vitaly/golang-test-task/pkg/crawl"
)
// error consts
var (
ErrEmptyURLs = errors.New("empty urls")
)
type jobResult struct {
result crawl.Result
err error
}
// Service service interface
type Service interface {
PostURLs(urls []st... |
package main
import (
"github.com/wajox/gobase/internal/app/cli"
)
func main() {
cli.ExecuteRootCmd()
}
|
/* For license and copyright information please see LEGAL file in repository */
package approuter
// HandleServerServices use to decide and call related internal service
func (s *Server) HandleServerServices(sd *StreamData) error {
return nil
}
|
// Package db provides an abstraction around mgo and MongoDB sessions.
//
// Auto session cloning and closing around when a Query is run by Do.
//
// It is heavily based off this post: http://denis.papathanasiou.org/archive/2012.10.14.post.pdf
//
// Simple goal of making interacting with MongoDB and the mgo package tri... |
package database
import (
"context"
"database/sql"
"fmt"
"strings"
"time"
"boiler/pkg/entity"
"boiler/pkg/store"
)
// AddUser create a new user in the database
func (s *Database) AddUser(ctx context.Context, tx *sql.Tx, user *entity.User) error {
now := time.Now()
id, err := Insert(
ctx, tx,
"INSERT INT... |
// Copyright (c) 2016-2016 Marcus Rohrmoser, http://purl.mro.name/recorder
//
// 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 t... |
// Copyright 2020 Readium Foundation. All rights reserved.
// Use of this source code is governed by a BSD-style license
// that can be found in the LICENSE file exposed on Github (readium) in the project repository.
package licensestatuses
import (
"database/sql"
"testing"
"time"
_ "github.com/mattn/go-sqlite3"... |
package stmanager
import(
//"download"
"stockdb"
"stockdb/stsummary"
"entity/stentity"
"config"
"util"
//"fmt"
)
type CompanyManagerBase struct {
exchmanager *config.ExchangeConfigManager
db *stockdb.StockListDB
compdb *stsummary.CompanyDB
logger *util.StockLog
}
func (m *... |
// gcd 最大公约数 - 欧几里得算法
package main
import "fmt"
func gcd(p int, q int) int {
if q == 0 {
return p
}
r := p%q
return gcd(q, r)
}
func main() {
fmt.Println(gcd(34,328))
} |
package app
import "io"
type App struct {
// Description of the program.
Usage string
// Version of the program
Version string
// List of commands to execute
Commands []Command
// List of flags to parse
Flags []Flag
// Writer writer to write output to
Writer io.Writer
// ErrWriter writes error output
Err... |
package useos
import (
"testing"
)
func TestInterfaceType(t * testing.T){
IsDetemInerinterface()
}
func TestUseFileFunc(t*testing.T){
UseFileFunc()
}
func TestCreateFileFunc(t*testing.T){
CreateFileFunc()
}
func TestFileOsFunc(t*testing.T){
FileOsFunc()
} |
package postgres
import (
"context"
"github.com/jmoiron/sqlx"
)
type contextKey int
// List of context keys for user context.
const (
contextKeyTx contextKey = iota
)
// NewContextTx creates a new context with the *sqlx.Tx value.
func NewContextTx(ctx context.Context, tx *sqlx.Tx) context.Context {
ctx = conte... |
// https://earthquake.usgs.gov/fdsnws/event/1/query?format=geojson&starttime=2014-01-01&endtime=2014-01-02
package main
import (
"bufio"
"encoding/json"
"fmt"
"io/ioutil"
"log"
"net/http"
"os"
"os/exec"
// "strings"
"time"
)
type featureCollection struct {
Features []feature `json:"features"`
}
type feat... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.