text stringlengths 11 4.05M |
|---|
package cloudwatch
import (
"context"
"encoding/json"
"fmt"
"strings"
"time"
"github.com/aws/aws-sdk-go/aws"
"github.com/aws/aws-sdk-go/aws/credentials"
"github.com/aws/aws-sdk-go/aws/session"
"github.com/aws/aws-sdk-go/service/cloudwatchlogs"
"github.com/egnyte/ax/pkg/backend/common"
)
type CloudwatchClie... |
package crypto
import (
"fmt"
"testing"
)
func Test_All(t *testing.T) {
keypair := GenerateKey()
fmt.Println(string(keypair.PrivateKey))
fmt.Println(len(keypair.PrivateKey))
fmt.Println(string(keypair.PublicKey))
fmt.Println(len(keypair.PublicKey))
message := "fwfwwwwwwwfooooooooooooooooooo33333wf"
signatur... |
package strings
import str "strings"
var vowels = [...]string{"a", "e", "i", "o", "u"}
func VowelCount(string string) int {
string = str.ToLower(string)
sum := 0
for _, vowel := range vowels {
sum += str.Count(string, vowel)
}
return sum
}
|
package main
import (
"flag"
"html/template"
"log"
"net/http"
"os"
"path/filepath"
"sync"
"github.com/stretchr/objx"
"github.com/e-left/chat/trace"
"github.com/gorilla/mux"
"github.com/stretchr/gomniauth"
"github.com/stretchr/gomniauth/providers/github"
"github.com/stretchr/gomniauth/providers/google"
)... |
package gtelegram
import (
"log"
"github.com/thomasheller/gslice"
)
type Filter struct {
allowedChatIDs []int
}
func NewFilter(allowedChatIDs []int) *Filter {
return &Filter{allowedChatIDs: allowedChatIDs}
}
func (f Filter) Handle(u Update, handleFunc func(From, Update)) {
var from From
switch v := u.(type)... |
/*
* Copyright © 2018-2022 Software AG, Darmstadt, Germany and/or its licensors
*
* SPDX-License-Identifier: Apache-2.0
*
* 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://... |
package utils
import (
"os"
"os/exec"
"path/filepath"
"strings"
)
func checkFileIsExist(filename string) bool {
var exist = true
if _, err := os.Stat(filename); os.IsNotExist(err) {
exist = false
}
return exist
}
func OpenOrCreateFile(filename string) *os.File {
if checkFileIsExist(filename) {
f, _ := o... |
package amazonmwsapi
import (
"context"
"encoding/xml"
"fmt"
)
// GetReportRequestListRequest calls a list of requested reports and thier status
type GetReportRequestListRequest struct {
amazonRequest
}
// ReportRequestIDList adds list of report IDs to request - not required
func (r *GetReportRequestListRequest)... |
package pipeline
import (
"fmt"
"github.com/mumoshu/gosh"
"github.com/mumoshu/gosh/context"
)
func New() *gosh.Shell {
sh := &gosh.Shell{}
sh.Export("ctx3", func(ctx context.Context) error {
b, lsErr := sh.Pipe(ctx, "echo", "footest")
grepErr := sh.GoRun(b, "grep", "test", gosh.WriteStdout(context.Stdout(... |
package guest
import "errors"
// Errors
var (
ErrNotFound = errors.New("guest not found")
ErrAlreadyExist = errors.New("guest already exists")
ErrInsufficientSpace = errors.New("there is insufficient space")
ErrAlreadyArrived = errors.New("guest already arrived")
)
|
package status
import (
"fmt"
"github.com/spf13/cobra"
"github.com/makkes/gitlab-cli/api"
"github.com/makkes/gitlab-cli/config"
)
func NewCommand(client api.Client, cfg config.Config) *cobra.Command {
return &cobra.Command{
Use: "status",
Short: "Display the current configuration of GitLab CLI",
RunE: ... |
package store
import (
"fmt"
"github.com/go-pg/pg/orm"
"golang.org/x/crypto/bcrypt"
)
type User struct {
ID string `sql:"type:uuid"`
Email string `sql:",notnull"`
Name string `sql:",notnull"`
EncryptedPassword string `sql:",notnull"`
}
func (u User) String() string {
r... |
package main
import (
"fmt"
"log"
"net/http"
"time"
)
func main() {
err := restorePaymentsTimers()
if err != nil {
log.Fatal(err)
}
archiveOldUsers()
r := newRouter()
log.Fatal(http.ListenAndServe(":8081", r))
}
func restorePaymentsTimers() error {
mysql := MySQL{db: initializeDB()}
users, err := mys... |
package main
/*
* @lc app=leetcode.cn id=347 lang=golang
*
* [347] 前 K 个高频元素
*/
// @lc code=start
// 最大堆
type Heap struct {
data []*HeapNode
}
// 按照val进行比较,key作为附属值
type HeapNode struct {
key int
val int
}
func NewHeap(cap int) *Heap {
h := &Heap{}
h.data = make([]*HeapNode, 0, cap)
return h
}
func (h... |
package main
import (
// "fmt"
"github.com/astaxie/beego"
"github.com/astaxie/beego/orm"
"my-blog/controllers"
"my-blog/models"
_ "my-blog/routers"
)
func init() {
models.MyRegister()
}
func main() {
orm.Debug = true
// o := orm.NewOrm()
// var maps []orm.Params
// _, err := o.Raw("SELECT * FROM tests").... |
// Copyright (c) 2020 Xiaozhe Yao & AICAMP.CO.,LTD
//
// This software is released under the MIT License.
// https://opensource.org/licenses/MIT
package daemon
import (
"net/http"
"os"
"github.com/autoai-org/aid/components/cmd/pkg/entities"
"github.com/autoai-org/aid/components/cmd/pkg/utilities"
"github.com/gi... |
package seed
import (
"log"
"git.roosoft.com/bitcoin/hd-wallets/lib"
)
var km *lib.KeyManager
func init() {
var err error
km, err = lib.NewKeyManagerFromMnemonic(lib.Mnemonic, lib.Passphrase)
if err != nil {
log.Fatal(err)
}
}
// GetSeed returns the seed
func GetSeed() []byte {
seed := km.GetSeed()
ret... |
package fasthttpmiddleware
import (
"github.com/prometheus/client_golang/prometheus"
"github.com/prometheus/client_golang/prometheus/promhttp"
"github.com/valyala/fasthttp"
"go.uber.org/zap"
"net/http"
_ "net/http/pprof"
"strconv"
"time"
)
var (
isRegistered = false // fix when to invoke NewPrometheusMiddlew... |
package constant
// topic 消息类型
const (
TOPIC_USER_LOGIN string = "topic.user.login"
TOPIC_USER_CREATED string = "topic.user.created"
// G2L: gate(RPC) -> ums(MQ: TOPIC_L2A_PREFIX) -> chat
TOPIC_L2A_PREFIX string = "topic.L2A:%d" // %d为appid
// L2G: chat(RPC) -> ums(MQ: TOPIC_L2G_PREFIX) -> web/ws
TO... |
package dep
import (
"fmt"
"net"
"sync"
"github.com/Illyrix/tidb-go-fuzz/dep/types"
)
var (
traceTable *types.TraceBits
mu sync.Mutex // this lock is just for singleton
)
const ListenAddress = "127.0.0.1:16801"
// singleton
// todo: a map of TraceBits instead of only one
// NOTE: it only support one ... |
/*
* Copyright 2018, CS Systemes d'Information, http://www.c-s.fr
*
* 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 requir... |
package main
import (
"flag"
"fmt"
"html/template"
"net/http"
)
var addr = flag.String("localhost", ":8000", "hostname of server")
func main() {
flag.Parse()
mux := http.NewServeMux()
mux.HandleFunc("/hello", helloPage)
mux.HandleFunc("/", formPage)
http.ListenAndServe(*addr, mux)
}
func helloPage(w http.R... |
// Copyright 2017 The Grafeas 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
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by ap... |
package keen
import (
"fmt"
"time"
)
const (
addEventTimeout = time.Second
)
type eventTuple struct {
collection string
payload interface{}
}
type BatchClient struct {
*Client
flushInterval time.Duration
flush chan int
events chan *eventTuple
}
func NewBatchClient(client *Client, flushIn... |
package main
import "fmt"
func main() {
fmt.Println(func() string {
return "This is an anonymous func"
}())
}
|
package main
/*
Simple KV in memory. Supports foll commands in lowercase : quit get set del delmany(csv string) _dump (Debug only)
Only 3 important config params
port number
redis server
redis queue name
*/
import (
"bufio"
"fmt"
"net"
"os"
"strconv"
"strings"
"sync"
"time"
)
/* Structure tp hold values a... |
package helpers
import (
"context"
"github.com/GoogleCloudPlatform/berglas/pkg/berglas"
log "github.com/sirupsen/logrus"
"os"
"strings"
)
type EnvVarEnum string
var berglasPrefix = "berglas://"
type IConfigService interface {
GetEnvVar(enum EnvVarEnum) string
}
type BergasOrOsEnvVarConfigService struct {
}
... |
package utils
// EqualIntSlices .. compares two integer slices
// returns true, if same else false
func EqualIntSlices(x, y []int) bool {
if len(x) != len(y) {
return false
}
for i, val := range x {
if y[i] != val {
return false
}
}
return true
}
// EqualIntSlices2D .. compares two integer slices of ... |
package leetcode
import (
"reflect"
"testing"
)
func TestLetterCombinations(t *testing.T) {
tests := []struct {
input string
output []string
}{
{
input: "23",
output: []string{"ad", "ae", "af", "bd", "be", "bf", "cd", "ce", "cf"},
},
{
input: "",
output: []string{},
},
}
for i, tt := ... |
package cloudflare
import (
"context"
"fmt"
"net/http"
"testing"
"time"
"github.com/stretchr/testify/assert"
)
func TestGetMTLSCertificate(t *testing.T) {
setup()
defer teardown()
handler := func(w http.ResponseWriter, r *http.Request) {
w.Header().Set("content-type", "application/json")
fmt.Fprint(w, ... |
// Package mapfunc demonstrate map functions
// kind of functions which operate on every element of a collection
package mapfunc
import (
"fmt"
"math/rand"
)
func intMap(s []int, f func(int) int) []int {
var resS []int
for _, v := range s {
resS = append(resS, f(v))
}
return resS
}
func recoverZeroDivisionPa... |
//each package is itself a small program
//a single unit of change with a single responsibility
package main
import (
"github.com/volodimyr/ood-fizzbuzz/pkg/factory"
"github.com/volodimyr/ood-fizzbuzz/pkg/game"
"os"
)
//import is a source level of coupling
//func
func main() {
f := factory.NewCreator()
var g g... |
/*
Copyright (c) 2017 GigaSpaces Technologies Ltd. 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 applicable ... |
package guest
import (
"context"
"github.com/angryronald/guestlist/internal/guest"
"github.com/angryronald/guestlist/internal/guest/domain"
"github.com/angryronald/guestlist/internal/guest/public"
)
func (s *Service) GetGuestByName(ctx context.Context, name string) (*public.Guest, error) {
guestRepo, err := s.r... |
package main
import (
"context"
"os/exec"
"time"
"github.dev.cybozu.co.jp/hazama/infra/go/src/github.com/cybozu-go/log"
)
func main() {
ctx, cancel := context.WithTimeout(context.Background(), 2*time.Second)
defer cancel()
cmd := exec.CommandContext(ctx, "curl", "localhost:8888")
err := cmd.Run()
if err != ... |
package main
import (
"net/http"
"time"
"github.com/gin-contrib/cors"
"github.com/gin-contrib/sessions"
"github.com/gin-contrib/sessions/cookie"
"github.com/gin-gonic/gin"
)
func main() {
dbConnect("orestis", "Ore$tis1997", "MyCloud")
router := gin.Default()
//Session middleware
store := cookie.NewStore([... |
package main
import (
"fmt"
"net/http"
"net/http/httputil"
)
func main() {
h2()
}
func h1() {
res, err := http.Get("http://www.baidu.com")
if err != nil {
panic(err)
}
defer res.Body.Close()
s, e := httputil.DumpResponse(res, true)
if e != nil {
panic(e)
}
fmt.Printf("%s \n", s)
}
func h2() {
req,... |
package main
import (
"fmt"
"net/http"
"strconv"
"time"
"encoding/csv"
"log"
"os"
"cloud.google.com/go/datastore"
"golang.org/x/crypto/bcrypt"
)
func setupCORS(w *http.ResponseWriter, req *http.Request) {
(*w).Header().Set("Access-Control-Allow-Origin", "*")
(*w).Header().Set("Content-Type", "text/html; ... |
package day18
type Stack struct {
top *Node
size int
}
func (s Stack) NewStack() Stack {
return Stack{}
}
func (s Stack) Len() int {
return s.size
}
func (s *Stack) Push(data rune) {
node := Node{}.NewNode(data)
node.next = s.top
s.top = node
s.size++
}
func (s *Stack) Pop() rune {
if s.top == nil {
re... |
package html
import (
api "github.com/kevinbarbary/go-lms/api"
utils "github.com/kevinbarbary/go-lms/utils"
"strconv"
)
const NOT_STARTED = `<span class="badge rounded-pill bg-secondary">Not Started</span>`
const STARTED = `<span class="badge rounded-pill bg-warning">Started</span>`
const COMPLETED = `<span class=... |
/*
Write a program which prompts the user to first enter a name, and then enter an address.
Your program should create a map and add the name and address to the map using the keys “name” and “address”,
respectively.
Your program should use Marshal() to create a JSON object from the map,
and then your program s... |
// Copyright 2016 Google Inc. 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 applicable... |
/*
Implement CTR, the stream cipher mode
The string:
L77na/nrFsKvynd6HzOoG7GHTLXsTVu9qvY/2syLXzhPweyyMTJULu/6/kXX0KSvoOLSFQ==
... decrypts to something approximating English in CTR mode, which is an AES block cipher mode that turns AES into a stream cipher, with the following parameters:
key=YELLOW SUBMARINE... |
package registry
import (
"context"
"fmt"
"net/http"
cloudevents "github.com/cloudevents/sdk-go/v2"
)
// RegisteredFunction represents a function that has been
// registered with the registry.
type RegisteredFunction struct {
Name string // The name of the functio... |
package models
//Config is the basic configuration structure for the service
type Config struct {
DestinationFolder string `json:"destination_folder"`
SourceFolder string `json:"source_folder"`
SourceType string `json:"source_type"`
SourceName string `json:"source_name"`
TabName strin... |
package user
import (
helper "spapp/src/common/helpers"
usermodels "spapp/src/models/apimodels/user"
"spapp/src/models/domain"
"spapp/src/persistence"
)
func RegisterUserCommand (input usermodels.RegisterUserInput) usermodels.RegisterUserOutput {
// 2
if len(input.Username) == 0 {
var output usermodels.Regis... |
// Copyright 2017 The Fuchsia 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 sign implements the `pm sign` command and signs the metadata of a
// package
package sign
import (
"fuchsia.googlesource.com/pm/pkg"
"golang.... |
package redisutil
import (
"crypto/tls"
"fmt"
"net"
"net/url"
"strconv"
"strings"
"time"
"github.com/go-redis/redis/v8"
"github.com/pomerium/pomerium/internal/sets"
)
var (
standardSchemes = sets.NewHash("redis", "rediss", "unix")
clusterSchemes = sets.NewHash(
"redis+cluster", "redis-cluster",
"red... |
package cmds
import (
"gx/ipfs/Qmde5VP1qUkyQXKCfmEUA7bP64V2HAptbJ7phuPp7jXWwg/go-ipfs-cmdkit"
)
// Flag names
const (
EncShort = "enc"
EncLong = "encoding"
RecShort = "r"
RecLong = "recursive"
ChanOpt = "stream-channels"
TimeoutOpt = "timeout"
OptShortHelp = "h"
OptLongHelp = "help"... |
package targetselector
import ()
/*func TestTargetSelector(t *testing.T) {
namespace := "test"
selectedContainerName := "TestContainer2"
selectedPodName := "TestPod"
kubeClient := &kubectl.Client{
Client: fake.NewSimpleClientset(),
Namespace: namespace,
}
//Create targetSelector
config := latest.Confi... |
GO:0000002 IEA BDEG_00478
GO:0000002 IEA BDEG_04144
GO:0000015 IEA BDEG_02491
GO:0000030 IEA BDEG_04835
GO:0000030 IEA BDEG_05800
GO:0000030 IEA BDEG_07763
GO:0000042 IEA BDEG_00926
GO:0000042 IEA BDEG_04246
GO:0000042 IEA BDEG_05278
GO:0000045 IEA BDEG_05795
GO:0000049 IEA BDEG_00554
GO:0000049 IEA BDEG_02865
GO:00000... |
package pkcs11
import (
"crypto/ecdsa"
"crypto/x509"
"errors"
"fmt"
"github.com/HNB-ECO/HNB-Blockchain/HNB/bccsp"
)
type ecdsaPrivateKey struct {
ski []byte
pub ecdsaPublicKey
}
func (k *ecdsaPrivateKey) Bytes() (raw []byte, err error) {
return nil, errors.New("Not supported.")
}
func (k *ecdsaPrivateKey) ... |
package main
import (
"encoding/json"
"errors"
"fmt"
"io/ioutil"
"k8s.io/api/admission/v1beta1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/runtime"
"k8s.io/apimachinery/pkg/runtime/serializer"
"log"
"net/http"
)
var (
universalDeserializer = serializer.NewCodecFactory(runtime.Ne... |
package main
import "fmt"
var y int
var x newtype
func main() {
fmt.Println(x)
fmt.Printf("%T\n", x)
var x int = 42
fmt.Println(x)
} |
package main
import (
"fmt"
"log"
"net/http"
"os"
"os/signal"
"syscall"
"time"
)
func main() {
mux := &http.ServeMux{} // http.NewServeMux()
fs := http.FileServer(http.Dir("assets/"))
mux.Handle("/static/", http.StripPrefix("/static/", fs))
mux.HandleFunc("/", indexHandler)
mux.HandleFunc("/err", errHan... |
package wire
import (
"bytes"
. "github.com/onsi/ginkgo"
. "github.com/onsi/gomega"
"gx/ipfs/QmU44KWVkSHno7sNDTeUcL4FBgxgoidkFuTUyTXWJPXXFJ/quic-go/internal/protocol"
"gx/ipfs/QmU44KWVkSHno7sNDTeUcL4FBgxgoidkFuTUyTXWJPXXFJ/quic-go/internal/utils"
"gx/ipfs/QmU44KWVkSHno7sNDTeUcL4FBgxgoidkFuTUyTXWJPXXFJ/quic-go/q... |
package db
import (
"database/sql"
"fmt"
"os"
)
var (
host = os.Getenv("HOST")
port = os.Getenv("PORT")
user = os.Getenv("USER")
password = os.Getenv("PASSWORD")
dbname = os.Getenv("DBNAME")
)
func main() {
// connection string
psqlconn := fmt.Sprintf("host=%s port=%s user=%s password=%s dbna... |
package test
import (
"testing"
"fmt"
"github.com/gruntwork-io/terratest/modules/terraform"
"github.com/stretchr/testify/assert"
"github.com/aws/aws-sdk-go/service/ec2"
"github.com/aws/aws-sdk-go/aws/session"
"github.com/aws/aws-sdk-go/aws"
)
func TestTerraform(t *testing.T) {
terraformOptions := &terrafo... |
package gremlin
import (
"encoding/json"
"os"
"testing"
"github.com/eonpatapon/contrail-gremlin/testutils"
"github.com/eonpatapon/gremlin"
uuid "github.com/satori/go.uuid"
"github.com/stretchr/testify/assert"
)
func TestMain(m *testing.M) {
cmd := testutils.StartGremlinServer("gremlin-contrail.yml")
res := ... |
// Package cartesian implements the calculation of cartesian products of
// slices.
package cartesian
// Cartesian contains the current state of the iteration over the cartesian
// products.
type Cartesian struct {
// ss is the slices.
ss [][]interface{}
// ndx is the current index within each slice.
ndx []int
//... |
// Copyright 2019 Authors of Cilium
//
// 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 client_test
import (
"testing"
"time"
)
func TestWrongAmountDates(test *testing.T) {
_, err := satisClient.GetTotalAmount(time.Now(), time.Date(1, time.January, 1, 0, 0, 0, 0, time.UTC))
if err == nil {
test.Fatalf("Expecting error not nil but instead is %v", err)
}
test.Logf("The beautifull error is ... |
package api
import (
m "github.com/grafana/grafana/pkg/models"
"github.com/grafana/grafana/pkg/bus"
"github.com/grafana/grafana/pkg/middleware"
"github.com/grafana/grafana/pkg/log"
//"github.com/grafana/grafana/pkg/api/dtos"
)
func GetMaintenanceAlertsHelper(OrgId int64) Response {
query :=m.GetMalfuna... |
package util
import (
"io/ioutil"
"bytes"
"fmt"
"encoding/json"
"net/http"
"crypto/md5"
"encoding/hex"
"math/big"
"time"
"github.com/sirupsen/logrus"
"math"
)
//DoPost 发送json post 对象
func DoPost(url string, reqobj interface{}, respobj interface{}) error {
fmt.Println("URL:>", url)
buf, err := json.Ma... |
package main
import (
"bufio"
"errors"
"flag"
"log"
"os"
"path/filepath"
"strings"
"time"
"github.com/fsnotify/fsnotify"
"github.com/olebedev/when"
"github.com/olebedev/when/rules/common"
"github.com/olebedev/when/rules/en"
)
var dateParser = when.New(nil)
func nextD... |
package storage
import "context"
// Service provides access to all storage objects.
type Service interface {
MachineTypeService(ctx context.Context) (MachineTypeService, error)
AccessTokenService(ctx context.Context) (AccessTokenService, error)
AccountService(ctx context.Context) (AccountService, error)
}
|
/**
* @program: Go
*
* @description:
*
* @author: Mr.chen
*
* @create: 2020-03-05 09:34
**/
package datamodels
type Product struct {
ID int64 `json:"id" sql:"ID" iris:"ID"`
ProductName string `json:"ProductName" sql:"productName" iris:"ProductName"`
ProductNum int64 `json:"ProductNum" sql:"productNum... |
package inptils
import (
"bytes"
"fmt"
"strings"
"testing"
"github.com/pedromss/kafli/config"
)
func TestProcessValue(t *testing.T) {
val := []byte("boo")
nullStr := []byte("null")
var tests = []struct {
conf config.AppConf
kvp kvp
expectedVal []byte
}{
{conf: config.AppConf{NullValue... |
package main
import "fmt"
import "sort"
func sumArray(a []int) int {
sum := 0
for i := range a {
sum += a[i]
}
return sum
}
func main() {
a := make([]int, 5)
for i := range a {
fmt.Scanf("%d", &a[i])
}
sort.Ints(a)
sum := sumArray(a)
fmt.Printf("%d %d\n", sum-a[4], sum-a[0])
}
|
package model
type Role string
const (
Admin Role = "admin"
USER Role = "user"
PREMIUM_USER Role = "PremiumUser"
)
|
package main
import (
"bufio"
"encoding/csv"
"os"
"strconv"
"github.com/jinzhu/gorm"
)
const sampleQuoteCSVFilePath = "./data/sample_quotes_sp500.csv"
func loadQuoteSample(db *gorm.DB) {
f, _ := os.Open(sampleQuoteCSVFilePath)
r := csv.NewReader(bufio.NewReader(f))
quotes, _ := r.ReadAll()
for _, row := r... |
// Package server contains all functions and methods for the main server that is
// the host to all API endpoints and static files for the chat.
package server
import (
"context"
"net/http"
"os"
"os/signal"
"syscall"
"time"
"github.com/sharpvik/log-go/v2"
"github.com/sharpvik/ava/configs"
)
// Server is a w... |
// Copyright 2022 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 (
log "github.com/sirupsen/logrus"
"sync"
"time"
)
func Bar(wg *sync.WaitGroup) {
defer wg.Done()
log.Info("Bar is starting!")
for i := 0; ; i++ {
log.Debugf("Bar is doing thing %d", i)
if i == 5 {
log.Warn("Bar is 1/2 done!")
}
time.Sleep(1 * time.Second)
if i > 20 {
break
... |
package requests
type CreateCar struct {
Key1 string
}
type UpdateCar struct {
Key1 string
}
func (c *CreateCar) Valid() error {
return validate.Struct(c)
}
func (c *UpdateCar) Valid() error {
return validate.Struct(c)
}
|
package vastflow
import (
"errors"
"github.com/astaxie/beego/orm"
"github.com/jack0liu/logs"
"sync"
"time"
)
const (
defaultHeartInterval = 2
displayTimes = 5
)
var (
heartOnce = sync.Once{}
checkOnce = sync.Once{}
shrinkOnce = sync.Once{}
thisUnit string
intervalSec int
)
func StartHear... |
package game_map
import (
"fmt"
"github.com/faiface/pixel"
"github.com/faiface/pixel/pixelgl"
"github.com/faiface/pixel/text"
"github.com/steelx/go-rpg-cgm/gui"
"github.com/steelx/go-rpg-cgm/state_machine"
"github.com/steelx/go-rpg-cgm/world"
"golang.org/x/image/font/basicfont"
"reflect"
)
type ItemsMenuStat... |
package main
import (
"TechTestNoSql/infraestructure/drivenadapters"
"TechTestNoSql/infraestructure/handlers"
"net/http"
)
func init() {
// Driven Adapter Redis
dbVote := drivenadapters.BirdVoteRedis{}
// Driven Adapter Rest to validate Bird existence on the firs mircoservice
dbValidate := drivenadapters.BirdV... |
package client
import (
"bytes"
"context"
"errors"
"time"
"github.com/drand/drand/chain"
"github.com/drand/drand/log"
)
// New Creates a client with specified configuration.
func New(options ...Option) (Client, error) {
cfg := clientConfig{
cacheSize: 32,
log: log.DefaultLogger,
}
for _, opt := ra... |
package dev
const openCmd string = "xdg-open"
|
package aliyun
import (
"github.com/gogap/config"
"github.com/gogap/context"
"github.com/gogap/flow"
)
func init() {
flow.RegisterHandler("devops.aliyun.dns.domain.record.add", AddDomainRecord)
flow.RegisterHandler("devops.aliyun.dns.domain.record.update", UpdateDomainRecord)
flow.RegisterHandler("devops.aliyun... |
package main
import (
"fmt"
"log"
goaes "github.com/syronz/goAES"
)
func main() {
aes, err := goaes.New().Key("secret key").IV("iv is 16 char!!!").Build()
if err != nil {
log.Fatal(err)
}
encrypted := "257d85d55b"
decrypted := aes.Decrypt(encrypted)
fmt.Printf("Decryption of %q is %q \n", encrypted, dec... |
package infinispan
var id chan uint64
func init() {
MakeID(0)
}
// MakeID explicitly creates the IDs channel, for example if you don't want to start from 0
func MakeID(start uint64) {
id = make(chan uint64)
go func() {
for i := uint64(start); ; i++ {
id <- i
}
}()
}
|
// Copyright 2016 CoreOS, 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 in... |
package cli
import (
"strings"
)
// MapValue implements flag.Value for map options set
// -c name1=value1 -c name2=value2
type MapValue struct {
values map[string]string
}
// NewMapValue creates empty MapValue
func NewMapValue() *MapValue {
return &MapValue{make(map[string]string)}
}
// Values returns all values... |
package aws
import (
"os"
"github.com/aws/aws-sdk-go/service/s3"
)
func (m *Manager) GetCodeURI(funcName string) (string, error) {
return "", nil
}
func (m *Manager) GetImage(funcName string) (string, error) {
return "", nil
}
func (m *Manager) SaveCode(funcName string, file string) (error) {
body, err := os.... |
package repository
import "database/sql"
type (
// Execer is interface of sql.DB.Exec methods.
Execer interface {
Exec(string, ...interface{}) (sql.Result, error)
}
// Queryer is interface of sql.DB.Query and sql.DB.QueryRow methods.
Queryer interface {
Query(string, ...interface{}) (*sql.Rows, error)
Quer... |
package main
import (
"os"
"time"
"github.com/webee/multisocket/examples"
log "github.com/sirupsen/logrus"
"github.com/webee/multisocket/address"
"github.com/webee/multisocket/protocol/stream"
_ "github.com/webee/multisocket/transport/all"
)
func init() {
log.SetLevel(log.DebugLevel)
log.SetFormatter(&log.... |
package rtrserver
import (
"bytes"
"encoding/binary"
"github.com/cpusoft/goutil/belogs"
"github.com/cpusoft/goutil/convert"
"github.com/guregu/null"
)
const (
PDU_PROTOCOL_VERSION_0 = 0
PDU_PROTOCOL_VERSION_1 = 1
PDU_PROTOCOL_VERSION_2 = 2
PDU_TYPE_SERIAL_NOTIFY = 0
PDU_TYPE_SERIAL_QUERY = 1
PDU_TYPE_... |
package vm
import "fmt"
type CallStack struct {
Lines []string
}
func NewCallStack() *CallStack {
return &CallStack{}
}
func (stack *CallStack) Unshift(line string) {
stack.Lines = append([]string{line}, stack.Lines...)
}
func (stack *CallStack) Shift() {
stack.Lines = stack.Lines[1:]
}
func (stack *CallStack... |
package timepack
import (
"database/sql/driver"
"encoding/json"
"strings"
"time"
)
var DefaultLayout = "2006-01-02 15:04:05"
type PackNull struct {
Layout string
time.Time
}
func NewNull(t time.Time) PackNull {
return PackNull{
Layout: DefaultLayout,
Time: t,
}
}
func (p *PackNull) Scan(value interfa... |
package p08
func transpose(A [][]int) [][]int {
if A == nil || len(A) == 0 || len(A[0]) == 0 {
return [][]int{}
}
m := len(A)
n := len(A[0])
newA := make([][]int, n)
for i := 0; i < n; i++ {
newA[i] = make([]int, m)
for j := 0; j < m; j++ {
newA[i][j] = A[j][i]
}
}
return newA
}
|
package tracer
import (
"io"
"log"
"time"
opentracing "github.com/opentracing/opentracing-go"
jaeger "github.com/uber/jaeger-client-go"
config "github.com/uber/jaeger-client-go/config"
)
// New returns a new tracer
func New(serviceName, hostPort string) (opentracing.Tracer, io.Closer) {
cfg := config.Configur... |
package net_test
import (
"errors"
"io"
"testing"
"time"
inet "gx/ipfs/QmZ7cBWUXkyWTMN4qH6NGoyMVs7JugyFChBNP4ZUp5rJHH/go-libp2p-net"
)
var errCloseFailed = errors.New("close failed")
var errWriteFailed = errors.New("write failed")
var errReadFailed = errors.New("read failed")
type stream struct {
inet.Stream
... |
package dcp
import "testing"
func Test_firstMissingPositiveInteger(t *testing.T) {
type args struct {
arr []int
}
tests := []struct {
name string
args args
want int
}{
{"-1", args{arr: []int{1, 1}}, 2},
{"0", args{arr: []int{1, -1, -5, -3, 3, 4, 2, 8}}, 5},
{"1", args{arr: []int{3, 4, -1, 1}}, 2},
... |
package controller
import (
"net/http"
"os"
"os/signal"
"syscall"
"time"
"github.com/go-chi/chi"
"github.com/go-chi/chi/middleware"
"github.com/go-chi/jsonp"
"github.com/hoangbeatsb3/ttcourse/config"
"github.com/hoangbeatsb3/ttcourse/service"
"github.com/rs/cors"
"github.com/sirupsen/logrus"
"golang.org/... |
// DRUNKWATER TEMPLATE(add description and prototypes)
// Question Title and Description on leetcode.com
// Function Declaration and Function Prototypes on leetcode.com
//1. Two Sum
//Given an array of integers, return indices of the two numbers such that they add up to a specific target.
//You may assume that each inp... |
package pipeline
import (
"testing"
"time"
"github.com/sensu/sensu-go/rpc"
"github.com/sensu/sensu-go/testing/mockstore"
"github.com/sensu/sensu-go/types"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/mock"
)
func TestPipelineFilter(t *testing.T) {
p := &Pipeline{}
store := &mockstore.Mo... |
package xhsync
import (
"context"
"testing"
)
func TestEngine_Dispatch(t *testing.T) {
// 事件运行引擎初始化
cancelCtx, cancel := context.WithCancel(context.Background())
if err := NewGroupEngine(cancelCtx, cancel, 8, 1024); err != nil {
panic(err)
}
//parentGoodsPriceEv := ParentGoodsPriceEvent{
// Params: ParentG... |
package classic
// Given a linked list, rotate the list to the right by k places, where k is non-negative.
func rotateRight(head *ListNode, k int) *ListNode {
var len int
var p, pre *ListNode
for p, pre = head, head; p != nil; pre, p, len = p, p.Next, len+1 {
}
if len == 0 {
return head
}
k = len - (k % len)... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.