text stringlengths 11 4.05M |
|---|
package cmd
import (
"log"
config "mysql-metadata/configuration"
"mysql-metadata/internal/cmd"
"mysql-metadata/internal/repositories"
"mysql-metadata/internal/storage"
"os"
)
func MysqlMetaData() {
path, err := os.Getwd()
path = path + "/configuration/properties"
config.Configuration, err = config.InitConfig... |
package main
import (
"fmt"
"net/http"
"go.mongodb.org/mongo-driver/bson"
"go.mongodb.org/mongo-driver/mongo"
"go.mongodb.org/mongo-driver/mongo/options"
"github.com/rigglo/gql"
"github.com/rigglo/gql/pkg/handler"
"github.com/rigglo/gqlws"
)
func main() {
exec := gql.DefaultExecutor(Schema)
h := handler.... |
package routing
import "github.com/gorilla/mux"
func createSubRouter(urlText string) *mux.Router {
return r.PathPrefix("/" + urlText).Subrouter()
}
|
package goodreadQuoteScraper
import (
"net/http"
"errors"
"fmt"
"github.com/PuerkitoBio/goquery"
"log"
"strconv"
"github.com/gin-gonic/gin/json"
"io/ioutil"
"regexp"
)
type Quote struct {
Author string `json:"author"`
AuthorAvatar string `json:"author_avatar"`
Content string `json:"content"`
Tags []strin... |
/*Copyright [2019] housepower
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, software
dist... |
package testdata
import (
"github.com/frk/gosql/internal/testdata/common"
)
type UpdatePKeyCompositeSingleQuery struct {
Data *common.ConflictData `rel:"test_composite_pkey:p"`
}
|
package dialect
type Mssql struct {
CommonDialect
}
func (Mssql) GetName() string {
return "mssql"
}
|
package iot
const (
// WsnToken is the token of wsn iot cloud
WsnToken = "your_wsn_token"
// WsnNumericalAPI is the api of wsn iot cloud for pushing numerical datapoints
WsnNumericalAPI = "http://www.wsncloud.com/api/data/v1/numerical/insert"
// WsnGenericAPI is the api of wsn iot cloud for pushing generic datapo... |
package main
import (
"bingjian-go/com/ning/iris-demo/01-hello/util"
"fmt"
)
func main() {
fmt.Println(util.Rand())
} |
package pgsql
import (
"database/sql"
"database/sql/driver"
)
// UUIDArrayFromByteArray16Slice returns a driver.Valuer that produces a PostgreSQL uuid[] from the given Go [][16]byte.
func UUIDArrayFromByteArray16Slice(val [][16]byte) driver.Valuer {
return uuidArrayFromByteArray16Slice{val: val}
}
// UUIDArrayToB... |
package config
import (
"bytes"
"encoding/json"
"errors"
"gopkg.in/yaml.v2"
"os"
"path"
"reflect"
"strconv"
"strings"
"text/template"
)
//- ConfigBytes Functions ------------------------------------------------------
type ConfigBytes []byte
// Reads the specified config file. Note that bedrock.Application ... |
// DRUNKWATER TEMPLATE(add description and prototypes)
// Question Title and Description on leetcode.com
// Function Declaration and Function Prototypes on leetcode.com
//808. Soup Servings
//There are two types of soup: type A and type B. Initially we have N ml of each type of soup. There are four kinds of operations:... |
package main
import (
"context"
"fmt"
"time"
)
func Yield(ctx context.Context) <-chan string {
ch := make(chan string)
go func() {
for {
tCh := time.After(3 * time.Second)
select {
case <-ctx.Done():
return
case <-tCh:
ch <- fmt.Sprintf("%+v", time.Now())
}
}
}()
return ch
}
func m... |
// Copyright © 2020 Attestant Limited.
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed ... |
package proto
import (
"context"
"crypto/ecdsa"
"crypto/elliptic"
"crypto/rand"
"errors"
"fmt"
"log"
"github.com/DragonF0rm/decent_5_remote_key/netemu"
)
var ErrChallengeFailed = errors.New("challenge failed")
type Peer struct {
name string
pubKey *ecdsa.PublicKey
prvKey *ecdsa.PrivateKey
// Assume that... |
package main
import (
"fmt"
"log"
"strconv"
"strings"
"text/scanner"
)
var input string = "input.txt"
func add(nums ...int) (sum int) {
//fmt.Println(" add", nums)
for _, n := range nums {
sum += n
}
return sum
}
func mul(nums ...int) (product int) {
//fmt.Println(" mul", nums)
product = 1
for _, n ... |
package main
import (
"errors"
"fmt"
"strconv"
"strings"
)
type interpreter struct {
sentence string
}
func (i *interpreter) tokens() []string {
return strings.Split(i.sentence, " ")
}
func (i *interpreter) exec() int {
sum := 0
tokens := i.tokens()
for k, item := range tokens {
if item == "*" {
fmt.P... |
package redisDB
const (
TaskResult_Success = 0
TaskResult_EmptyAuth = 1
TaskResult_FailAuth = 2
)
|
package types
type Schema string
|
package constant
const (
//group admin
OrdinaryMember = 0
GroupOwner = 1
Administrator = 2
//group application
Application = 0
AgreeApplication = 1
//feiend related
BlackListFlag = 1
ApplicationFriendFlag = 0
FriendFlag = 1
RefuseFriendFlag = -1
//Websocket Protocol
W... |
package main
import (
"bytes"
"fmt"
"io"
"strings"
"testing"
"github.com/blang/semver"
"github.com/orion-labs/go-scmversion/cmd"
)
// OpenerFunc is a function that operats as an `Opener`
type OpenerFunc func(path string) (io.WriteCloser, error)
func (f OpenerFunc) Open(path string) (io.WriteCloser, error) {
... |
package realm_test
import (
"testing"
"github.com/10gen/realm-cli/internal/cloud/realm"
"github.com/10gen/realm-cli/internal/local"
u "github.com/10gen/realm-cli/internal/utils/test"
"github.com/10gen/realm-cli/internal/utils/test/assert"
)
func TestFunctions(t *testing.T) {
u.SkipUnlessRealmServerRunning(t)
... |
package utils
import (
"errors"
"fmt"
"time"
"github.com/dgrijalva/jwt-go"
"github.com/gin-gonic/gin"
)
type CustomClaims struct {
ID uint `json:"userId"`
jwt.StandardClaims
}
const TokenExpireDuration = time.Hour * 2
var CustomSecret = []byte("dapan")
func GenToken(userId uint) (string, error) {
fmt.Print... |
package bean
import (
"errors"
"log"
"github.com/astaxie/beego/orm"
)
var (
ErrPaymentAlreadyAchieved = errors.New("payment already achieved")
)
// 安卓支付
type AndroidPayment struct {
OrderID string `orm:"column(order_id);pk"` // SDK订单号
UUID string `orm:"column(uuid)"` // SDK唯一用户编号
ZoneID int... |
package main
import (
"fmt"
"strconv"
"strings"
)
//X'x go first 0
func main() {
game := []string{"102",
"457",
"386"}
//buildStr := ""
gameCombine := ""
for _, x := range game {
gameCombine += string(x)
}
gameBoard := "........."
for strings.Contains(gameBoard, ".") {
for i := 0; i < len(game... |
package repo
import (
"strings"
"github.com/bitnami-labs/charts-syncer/api"
"github.com/bitnami-labs/charts-syncer/pkg/utils"
"github.com/juju/errors"
helmRepo "helm.sh/helm/v3/pkg/repo"
"k8s.io/klog"
)
// HarborClient implements ChartRepoAPI for a Harbor implementation.
type HarborClient struct {
repo *api.R... |
package problem0598
import "testing"
func TestSolve(t *testing.T) {
t.Log(maxCount(3, 3, [][]int{[]int{2, 2}, []int{3, 3}}))
}
|
package api
import (
"fmt"
"octlink/mirage/src/modules/user"
"octlink/mirage/src/modules/usergroup"
"octlink/mirage/src/utils"
"octlink/mirage/src/utils/merrors"
"octlink/mirage/src/utils/octlog"
"octlink/mirage/src/utils/uuid"
)
func APIAddUser(paras *ApiParas) *ApiResponse {
resp := new(ApiResponse)
newUs... |
package structs
type LNode struct {
data int
next *LNode
}
type SliceStack struct {
slice []int
sliceSize int
}
type LinklistStack struct {
head *LNode
end *LNode
} |
package pain
import (
"encoding/xml"
"github.com/thought-machine/finance-messaging/iso20022"
)
type Document01200104 struct {
XMLName xml.Name `xml:"urn:iso:std:iso:20022:tech:xsd:pain.012.001.04 Document"`
Message *MandateAcceptanceReportV04 `xml:"MndtAccptncRpt"`
}
func (d *Document01200104... |
package conn
import(
"net"
"fmt"
"bytes"
"encoding/binary"
"handler"
)
const(
MAX_RECV_QUEUE_SIZE = 1024
MAX_SEND_QUEUE_SIZE = 1024
MAX_RECV_BUFF_SIZE = 65536
MSG_HEADER_LEN = 4
OP_CODE_LEN = 4
CACHE_SIZE = 1024
)
type RecvQueue chan []byte
type SendQueue chan []byte
type Connection struct{
tcp_s... |
package frame
func (config *Config) VisibleHeight() int {
height := config.Height()
forwardDrawAreaHeight := terminalHeight - (config.startRow - 1)
if height > forwardDrawAreaHeight {
return forwardDrawAreaHeight
}
return height
}
func (config *Config) Height() int {
height := config.Lines
if config.HasHead... |
package resp
import (
"fmt"
"io"
"net"
"reflect"
"runtime/debug"
"github.com/dvirsky/go-pylog/logging"
"gitlab.doit9.com/backend/instrument"
"github.com/EverythingMe/meduza/driver"
"github.com/EverythingMe/meduza/errors"
"github.com/EverythingMe/meduza/protocol"
"github.com/EverythingMe/meduza/query"
"git... |
package services
import (
"fmt"
r "github.com/davelaursen/idealogue-go/Godeps/_workspace/src/github.com/dancannon/gorethink"
)
// UserSvc represents a service that provides read/write access to user data.
type UserSvc interface {
GetAll() (Users, *Error)
GetByID(id string) (*User, *Error)
GetByEmail(email strin... |
package manager_test
import (
"testing"
"github.com/wst-libs/wst-sdk/sdk/manager"
)
const (
url = "http://39.105.49.69:48083/api/v1/storage/file"
)
// func TestAdd(t *testing.T) {
// manager.Add(url)
// }
func TestPut(t *testing.T) {
manager.Put(url)
}
|
package secretconf
import (
"io"
"os"
"path/filepath"
"github.com/cosmos/go-bip39"
conf "github.com/tendermint/starport/starport/chainconf"
"gopkg.in/yaml.v2"
)
const (
SecretFile = "secret.yml"
SelfRelayerAccountName = "relayer"
)
var (
selfRelayerAccountDefaultCoins = []string{"800token"}
)
... |
package keys
import (
"github.com/cosmos/cosmos-sdk/crypto/keyring"
"github.com/gookit/gcli/v3"
"github.com/gookit/gcli/v3/interact"
"github.com/ovrclk/akcmd/client"
"github.com/ovrclk/akcmd/flags"
)
const (
flagYes = "yes"
flagForce = "force"
)
var deleteOpts = struct {
Yes bool
Force bool
}{}
// Dele... |
package models
import (
"time"
)
type ItemTag struct {
ItemID uint64 `json:"item_id" gorm:"column:item_id;primary_key" sql:"not null;type:bigint(20);index:idx_tag_item_id_tag_id"`
TagID uint64 `json:"tag_id" gorm:"column:tag_id;primary_key" sql:"not null;type:bigint(20);index:idx_tag_item_id_t... |
package main
import (
"log"
"math/rand"
"time"
)
func main() {
rand.Seed(time.Now().UnixNano())
log.Printf("random num generated: %v", rand.Uint64())
}
|
package ingest
import (
"strings"
sq "github.com/Masterminds/squirrel"
"github.com/stellar/go/services/horizon/internal/db2/core"
"github.com/stellar/go/services/horizon/internal/db2/history"
"github.com/stellar/go/support/db"
"github.com/stellar/go/xdr"
)
func (assetsModified AssetsModified) handlePaymentOp(p... |
package queryrange
import (
"context"
"github.com/prometheus/client_golang/prometheus"
"github.com/weaveworks/common/instrument"
)
// InstrumentMiddleware can be inserted into the middleware chain to expose timing information.
func InstrumentMiddleware(name string, queryRangeDuration *prometheus.HistogramVec) Mid... |
package management
import "encoding/json"
type DBConnectionsChangePassword struct {
// The client_id of your client. We strongly recommend including a Client ID so that the email template knows from which client the request was triggered.
ClientID *string `json:"client_id,omitempty"`
// The user's email address.... |
package client
import (
"context"
"sync"
"github.com/drand/drand/chain"
"github.com/drand/drand/client"
dclient "github.com/drand/drand/client"
"github.com/drand/drand/cmd/relay-gossip/lp2p"
"github.com/drand/drand/protobuf/drand"
"github.com/gogo/protobuf/proto"
logging "github.com/ipfs/go-log/v2"
pubsub "... |
package controllers
import (
"time"
"github.com/chrilnth/apikeymanager/models"
"github.com/gofiber/fiber"
"go.mongodb.org/mongo-driver/bson"
"go.mongodb.org/mongo-driver/mongo"
)
type LogController struct {
Collection mongo.Collection
}
func NewLogController(collection *mongo.Collection) *LogController {
ret... |
package raftor
// Stopper stops whatever you need to be stopped. It is meant to be used inside a select statement.
type Stopper interface {
Stop() <-chan struct{}
}
|
package dushengchen
/**
Submission:
https://leetcode.com/submissions/detail/372752824/
Runtime: 4 ms, faster than 77.21% of Go online submissions for Permutations II.
Memory Usage: 3.5 MB, less than 77.78% of Go online submissions for Permutations II.
*/
func permuteUnique(nums []int) [][]int {
nums = SortInt(nums... |
package main
// go run .\main.go .\model.go .\mwscalls.go .\xmlhelpers.go .\parsers.go
import (
"MyGoPackages/Amazon/Mws"
"encoding/json"
"fmt"
)
var (
// SellerID or merchant id from user
SellerID = ""
// AuthToken from user
AuthToken = ""
// Region from user
Region = "US"
// AccessKey is from main accoun... |
package main
import (
"net/http"
"io/ioutil"
"fmt"
"encoding/json"
"log"
)
func fListCompany(w http.ResponseWriter, r *http.Request) {
slFile, err := ioutil.ReadDir("./csv")
w.Header().Set("Content-Type", "application/json")
if err != nil {
fmt.Fprintf(w, `{"error": "%s"}`, err)
log.Println(err)
retu... |
package main
import "fmt"
func main() {
s := []int{2, 3, 5, 7, 11, 13}
fmt.Println("s ==", s)
fmt.Println("s[1:4] ==", s[1:4])
fmt.Println("s[:3] ==", s[:3])
fmt.Println("s[4:] ==", s[4:])
// s == [2 3 5 7 11 13]
// s[1:4] == [3 5 7]
// s[:3] == [2 3 5]
// s[4:] == [11 13]
}
/... |
package main
import (
"log"
"sort"
"strconv"
"strings"
)
type Manager struct {
FullName string
Position string
Age int32
YearsInCompany int32
}
func main() {
// log.Println(DuplicateEncode("Supralapsarian"))
// log.Println(findSubstring("aqkgwyolaososilnvnquimtcawuwtqrigjnxfjtcwvuoxg... |
package main
import (
"encoding/hex"
"flag"
"fmt"
"log"
"reflect"
"dfnpf/examples/iniths"
)
func main() {
flag.Parse()
if len(flag.Args()) < 4 || len(flag.Args()) > 11 {
log.Fatalln("Please provide Noise Protocol name, initiator's static and ephemeral keys,",
"\n responder's static and ephemeral keys... |
// Package outputstream represents the messages which the ircserver package
// generates in response to what is being sent to RobustIRC.
//
// Data is stored in a temporary LevelDB database so that not all data is kept
// in main memory at all times. The working set we are talking about is ≈100M,
// but using LevelDB (... |
package main
import "fmt"
//func funcname(parameters) returntype {funcdesc}
func add(list []int) int{
sum:=0
for _,val:=range list {
sum+=val
}
return sum
}
//functions in Go can return multiple values
func nextnums(num int) (int, int) {
return num+1, num+2
}
//for functions where you don't know number of pa... |
package main
import (
"flag"
"github.com/sergei-svistunov/hlcup-checker/phase"
"log"
)
var (
argServer = flag.String("server", "http://localhost:8080", "Server address")
argDataDir = flag.String("data-dir", "./", "Directory with ammo and answers")
argPhase = flag.Int("phase", 1, "Number of phase")
arg... |
package task
import (
log "code.google.com/p/log4go"
"github.com/d-d-j/ddj_master/common"
"github.com/d-d-j/ddj_master/dto"
"github.com/d-d-j/ddj_master/node"
"github.com/d-d-j/ddj_master/reduce"
"time"
)
type job func(dto.RestRequest) bool
func (w *TaskWorker) getJob(taskType int32) job {
switch taskType {
... |
package main
import (
"fmt"
)
func main() {
cliPrams := ParseFlags()
if err := InitLogger(cliPrams.Debug, cliPrams.Verbose); err != nil {
panic(fmt.Errorf("cannot init logger, exited with error: %v", err))
}
Logger.Debug("server params: %v", cliPrams)
bot, err := NewBot()
if err != nil {
panic(fmt.Error... |
package main
import "fmt"
func main() {
chann := make(chan int, 10)
for i := 0; i < 10; i++{
chann <- i
}
close(chann)
for {
v, ok := <- chann
//检测管道是否关闭
if ok == false {
fmt.Println("chan is close")
break
}
fmt.Println(v)
}
}
|
package main
import (
"bufio"
"fmt"
"io"
"io/ioutil"
"os"
"os/exec"
"regexp"
"runtime/debug"
"sort"
"strconv"
"strings"
"text/tabwriter"
"time"
"github.com/bndr/gopencils"
"github.com/docopt/docopt-go"
"github.com/op/go-logging"
)
var (
reStashURL = regexp.MustCompile(
`(https?://.*/)` +
`((use... |
package demo
import (
"github.com/go-xe2/xthrift/lib/go/xthrift"
)
type HelloServiceProcessor struct {
*xthrift.TBaseProcessor
handler HelloService
}
func NewHelloServiceProcessor(handler HelloService) *HelloServiceProcessor {
inst := &HelloServiceProcessor{
handler: handler,
}
inst.TBaseProcessor = xthrift... |
package main
import "fmt"
func main(){
fmt.Println("22");
var arr = [...]int{1,2,4,12,44}
fmt.Println(arr[3])
arr2 :=[9]int{3,3,3,4,5,6}
fmt.Println(arr2[3])
var slice = arr2[1:2]
fmt.Println(slice)
var mm = map[int]string{1:"a",2:"b"}
fmt.Println(mm[1])
e,ok := mm[4]
fmt.Println(e)
fmt.... |
package db
import (
"github.com/jinzhu/gorm"
)
// Open opens database and returns DB object.
func Open() (db *gorm.DB, err error) {
db, err = gorm.Open("sqlite3", "database/test.sqlite3")
if err != nil {
return
}
return
}
|
package main
import (
"bufio"
"flag"
"os"
"path/filepath"
"regexp"
"sync"
"time"
log "github.com/sirupsen/logrus"
)
const (
WhoisRequestPerSecond = 128
WhoisRequestPeriod = time.Second / time.Duration(WhoisRequestPerSecond)
)
func main() {
var file_path = flag.String("filepath", "/var/log/nginx/access... |
/*
Copyright 2017 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 config
import (
"log"
"net"
"github.com/spf13/viper"
)
// Config holds the global server-wide config.
type Config struct {
HostIP string `mapstructure:"host_ip"`
BinPath string `mapstructure:"bin_path"`
DevMode bool
DevModeOptions DevModeOptions
Discord Discord
Database Database
Laun... |
// This file was generated for SObject EntityDefinition, API Version v43.0 at 2018-07-30 03:47:50.05474474 -0400 EDT m=+36.398716954
package sobjects
import (
"fmt"
"strings"
)
type EntityDefinition struct {
BaseSObject
DataStewardId string `force:",omitempty"`
DefaultCompactLayoutId string... |
package internal
import (
"encoding/json"
"io"
"io/ioutil"
"log"
"marauders-map-client-desktop/tools"
"net/http"
"os"
"path"
)
// ==========================================================
// Observer for sending to server files
// ==========================================================
type FileCmdObserve... |
package config
import (
"github.com/corpix/relay/transport"
)
type Channel struct {
Name string `json:"name" yaml:"name"`
Transport string `json:"transport" yaml:"transport"`
}
type Relaying struct {
Channels []string `json:"channels" yaml:"channels"`
Mode string `json:"mode" yaml:"mode"`
}
type Co... |
package domain
import (
"errors"
"time"
)
type Note struct {
Id int `json:"id" db:"id"`
Title string `json:"title" db:"title" binding:"required"`
Body string `json:"body" db:"body" binding:"required"`
DateCreated time.Time `json:"date_created" db:"date_created"`
UserId in... |
package core
import "context"
type KV struct {
K string
V interface{}
}
type stateAdapter interface {
IsConnected() bool
Connect(ctx context.Context) error
Disconnect()
Has(ctx context.Context, key string) bool
Get(ctx context.Context, key string, dest interface{}) error
Set(ctx context.Context, key string, ... |
package controllers
import (
"github.com/gin-gonic/gin"
"github.com/hernancabral/Library/api/models"
"net/http"
)
func (server *Server) GetAuthors(c *gin.Context) {
// clear previous error if any
errList = map[string]string{}
authors, err := models.FindAllAuthors(server.DB)
if err != nil {
errList["no_auth... |
package utils
import (
"errors"
"io"
"io/ioutil"
"log"
"net/http"
"github.com/go-rod/rod"
"github.com/go-rod/rod/lib/launcher"
)
func MakeRequestHeadless(url string) (string, error) {
l := launcher.MustNewManaged("")
l.NoSandbox(true)
browser := rod.New().Client(l.Client()).MustConnect()
defer browser.... |
// Copyright 2023 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 ... |
package database
import (
"fmt"
"github.com/jmoiron/sqlx"
"github.com/pkg/errors"
"github.com/spf13/viper"
)
func ConnectMySQL() (err error) {
var dsnObj DSN
if err := viper.UnmarshalKey("DB", &dsnObj); err != nil {
return errors.WithStack(err)
}
dsn := fmt.Sprintf("%s:%s@tcp(%s:%d)/%s?charset=utf8&parseTim... |
package twosum
func twoSum(nums []int, target int) []int {
hashmap := make(map[int]int)
for index, value := range nums {
anotherNum := target - value
if _, ok := hashmap[anotherNum]; ok {
return []int{hashmap[anotherNum], index}
}
hashmap[value] = index
}
return nil
}
func twoSumWithLoop(nums []int, ta... |
package main
import "fmt"
func countingSort(slice []int) []int {
if len(slice) == 0 {
return slice
}
var min,max = slice[0], slice[0]
for i:=0; i<len(slice); i++ {
if slice[i] > max {
max = slice[i]
} else if slice[i] < min {
min = slice[i]
}
}
countingSlice := make([]int, max-min+1)
for i:=0; i<... |
package reap
import (
"context"
"fmt"
"log"
"sort"
"strings"
"time"
"gopkg.in/DataDog/dd-trace-go.v1/ddtrace/tracer"
"github.com/dollarshaveclub/acyl/pkg/ghclient"
"github.com/dollarshaveclub/acyl/pkg/locker"
"github.com/dollarshaveclub/acyl/pkg/models"
"github.com/dollarshaveclub/acyl/pkg/persistence"
"... |
// +build windows
/*
Copyright 2018 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 agr... |
package ers_test
import (
"regexp"
"testing"
ers "github.com/mix3/email-regex-safe-go"
"github.com/stretchr/testify/assert"
)
func New(opts ...ers.Option) *regexp.Regexp {
v, err := ers.New(opts...)
if err != nil {
panic(err)
}
return v
}
func TestEmailRegexSafe(t *testing.T) {
fixture := `_boop@beep.com... |
package parser_test
import (
"io/ioutil"
"testing"
"github.com/bddbnet/gospy/parser/h.bilibili.com"
)
// step 1 获取列表
func TestIndexList(t *testing.T) {
const resultSize = 24
expectedItem := []string{
"Page: 1", "Page: 2", "Page: 3",
}
expectedUrl := []string{
"https://api.vc.bilibili.com/link_draw/v2/P... |
package main
import (
"bytes"
"encoding/json"
"fmt"
"io"
"os/exec"
"github.com/osbuild/osbuild-composer/internal/distro"
osbuild "github.com/osbuild/osbuild-composer/internal/osbuild1"
)
// Run an instance of osbuild, returning a parsed osbuild.Result.
//
// Note that osbuild returns non-zero when the pipelin... |
package main
import (
"database/sql"
"flag"
"fmt"
"log"
"net/http"
"net/url"
"strconv"
"github.com/go-chi/chi"
"github.com/go-chi/chi/middleware"
"github.com/go-chi/cors"
"github.com/jinzhu/configor"
"github.com/unrolled/render"
_ "github.com/go-sql-driver/mysql"
"github.com/jmoiron/sqlx"
)
var format... |
package cmd
import (
"errors"
"fmt"
"git-stack/branchstack"
"os"
"github.com/spf13/cobra"
)
var (
rootCmd = &cobra.Command{
Use: "git-stack",
Short: "Keep track of WIP git branches in a stack.",
}
pushCmd = &cobra.Command{
Use: "push",
Short: "Push a branch name onto the stack.",
PreRun: load... |
package main
type Config struct {
bind string
data string
db string
gcInterval int // Seconds, default 300s
gcLimit int // Number of entries to scan each gc, default 100
}
|
package routers
import (
"github.com/barrydev/api-3h-shop/src/common/response"
"github.com/barrydev/api-3h-shop/src/controllers"
"github.com/gin-gonic/gin"
)
func BindCurrent(router *gin.RouterGroup) {
router.GET("/order", func(c *gin.Context) {
handle := response.Handle{Context: c}
handle.Try(controllers.G... |
package main
import "fmt"
func main() {
var arr [4][6]int
arr[2][2] = 1
for i := 0; i < 4; i++ {
for j := 0; j < 6; j++ {
fmt.Print(arr[i][j], " ")
}
fmt.Println()
}
for _, value := range arr {
for id, val := range value {
fmt.Println(id, val)
}
}
}
|
/*
Copyright 2020 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 main
import (
"../common"
"cloud.google.com/go/pubsub"
"context"
"fmt"
"google.golang.org/api/option"
"io/ioutil"
"log"
"os"
"strconv"
"time"
)
func main() {
ctx := context.Background()
c, err := NewOrderChannel(ctx, "hexapod", "servo")
if err != nil {
log.Fatalf("Failed to create channel: %v",... |
package api
import (
"gf-init/app/service"
"gf-init/library/response"
"github.com/gogf/gf/net/ghttp"
)
var User = userApi{}
type userApi struct{}
// Index is a demonstration route handler for output "Hello World!".
func (*userApi) Index(r *ghttp.Request) {
if err := service.User.GetAllUsers(); err != nil {
r... |
package schema
import (
"strings"
)
func StringContains(s, subs string) bool {
return strings.Contains(s, subs)
}
func StringContainsIgnoreCase(s, subs string) bool {
s = strings.ToLower(s)
subs = strings.ToLower(subs)
return strings.Contains(s, subs)
}
|
package log
import "context"
// constant
const key = "log_fields"
func ToContext(ctx context.Context) context.Context {
return l.ToContext(ctx)
//
//fields := logger.GetFields()
//
//ctxFields := fieldsFromContext(ctx)
//
//if ctxFields == nil {
// ctxFields = map[string]interface{}{}
//}
//
//for k, v :=... |
// Copyright 2015 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
package width_test
import (
"fmt"
"gx/ipfs/QmVcxhXDbXjNoAdmYBWbY1eU67kQ8eZUHjG4mAYZUtZZu3/go-text/width"
)
func ExampleTransformer_fold() {
s := "abヲ₩○¥A"... |
package udp
import (
"github.com/golang/glog"
"net"
"sync"
)
type clientConn struct {
*net.UDPConn
}
func Dial(network, address string) (conn net.Conn, err error) {
raddr, err := net.ResolveUDPAddr(network, address)
if err != nil {
return
}
c, err := net.DialUDP(network, nil, raddr)
conn = &clientConn{c}
... |
func findDisappearedNumbers(nums []int) []int {
res:=[]int{}
for i:=0;i<len(nums);i++{
v:=nums[i]
if nums[v-1]!=v{
nums[i]=nums[v-1]
nums[v-1] = v
i--
}
}
for i,v:=range nums{
if i+1!=v{
res = append(res,i+1)
}
}
... |
// Copyright 2021 PingCAP, Inc.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to i... |
// Copyright 2013 The Agostle Authors. All rights reserved.
// Use of this source code is governed by an Apache 2.0
// license that can be found in the LICENSE file.
package main
import (
"bufio"
"bytes"
"fmt"
"io"
"log"
"strconv"
"strings"
//"encoding/json"
"net/http"
"sync"
"time"
"github.com/mreiferso... |
package main
import "fmt"
func getHello(name string) string {
if name == "" {
return "Hallo, salam kenal!"
} else {
return "Hallo " + name
}
}
func main() {
fmt.Println(getHello(""))
result := getHello("Eko")
fmt.Println(result)
}
|
package webwx
import (
"fmt"
"reflect"
"regexp"
"testing"
)
func TestUtilGenDeviceId(t *testing.T) {
if s := genDeviceId(); len(s) != 16 {
t.Error("Invalid deviceId:", s, len(s))
}
}
func TestUtilGetUserAgent(t *testing.T) {
t.Log(getUserAgent())
}
func TestRegexp(t *testing.T) {
s := `<error><ret>0</ret>... |
package main
import (
"bytes"
"flag"
"io/ioutil"
"net"
"net/http"
"sort"
"strings"
"sync"
"sync/atomic"
"time"
"github.com/Sirupsen/logrus"
)
type ipSlice []net.IP
func (slice ipSlice) Len() int {
return len(slice)
}
func (slice ipSlice) Less(a, b int) bool {
return ipCompare(slice[a], slice[b]) == -1... |
package models
import (
"github.com/astaxie/beego/orm"
_ "github.com/go-sql-driver/mysql"
"strconv"
"strings"
"time"
)
func AddTopic(title, category, summery, content string, labels []string) error {
label := ""
if len(labels) > 0 {
label = "$" + strings.Join(labels, "#$") + "#"
}
o := orm.NewOrm()
topic ... |
//converter converts bitmaps into an encoded video.
package converter
import (
"os"
"fmt"
"math"
"image"
"image/color"
"image/png"
"log"
"os/exec"
)
type Circle struct {
X, Y, R float64
}
func (c *Circle) Brightness(x, y float64) uint8 {
var dx, dy float64 = c.X - x, c.Y - y
d := math.Sqrt(dx*dx+... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.