text stringlengths 11 4.05M |
|---|
package instancestoresql
import (
"fmt"
"strings"
"time"
"github.com/direktiv/direktiv/pkg/refactor/instancestore"
)
func wheres(clauses ...string) string {
if len(clauses) == 0 {
return ""
}
if len(clauses) == 1 {
return ` WHERE ` + clauses[0]
}
return ` WHERE (` + strings.Join(clauses, ") AND (") + `... |
package main
import (
"encoding/binary"
"flag"
"fmt"
"net"
"os"
"time"
"github.com/golang/glog"
dhcp "github.com/krolaw/dhcp4"
dhcpConn "github.com/krolaw/dhcp4/conn"
"github.com/spf13/cobra"
"golang.org/x/sys/unix"
)
const (
infiniteLease = 999 * 24 * time.Hour
)
func main() {
flag.Parse()
if err :=... |
// Copyright 2013-2014 go-diameter 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 diamtype
import (
"encoding/binary"
"fmt"
)
// Integer32 Diameter Type
type Integer32 int32
func DecodeInteger32(b []byte) (DataType, er... |
package trace
// Trace key
const (
KratosTraceID = "trace-id"
KratosTraceDebug = "trace-debug"
)
|
package main
import "fmt"
func min3(a, b, c int) int {
if a < b {
if a < c {
return a
}
return c
}
if b < c {
return b
}
return c
}
func nthUglyNumber(n int) int {
nums := make([]int, n)
x, y, z := 0, 0, 0
nums[0] = 1
next := 1
for next < len(nums) {
a := 2 * nums[x]
b := 3 * nums[y]
c... |
package stack
import "testing"
func TestPopWorkAfterPush(t *testing.T) {
s := new(Stack)
s.Push(11)
pop_res := s.Pop()
if pop_res != 11 {
t.Log("Pop must return 11")
t.Fail()
}
}
func TestPushPop(t *testing.T) {
s := new(Stack)
s.pushTimes(5)
if s.data != [10]int{0, 1, 2, 3, 4} {
t.Log("s.data must be... |
// +build !excludecodegen
/*
Copyright IBM Corporation 2020
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 flv
import (
"fmt"
//flvutils "github.com/sigmaxue/streamdump/src/utils"
)
type ScriptData struct {
}
func (s *ScriptData)Decode(buffer []byte) (count int, err error){
return len(buffer), nil
}
func (s *ScriptData)ToString() string{
out := fmt.Sprintf("")
return out
}
|
package actions
import (
"net/http"
"github.com/nerdynz/datastore"
flow "github.com/nerdynz/flow"
"github.com/nerdynz/schwifty/backend/server/models"
)
// Login Route
func Login(w http.ResponseWriter, req *http.Request, ctx *flow.Context, store *datastore.Datastore) {
helper := models.PersonHelper()
person, er... |
package generator_test
import (
"fmt"
"io/ioutil"
"os"
"path"
"testing"
"time"
"github.com/syncromatics/kafmesh/internal/generator"
"github.com/syncromatics/kafmesh/internal/models"
)
func Test_Generator(t *testing.T) {
tmpDir, err := ioutil.TempDir("", "Test_Generator")
if err != nil {
t.Fatal(err)
}
... |
package resell
import "github.com/selectel/go-selvpcclient/selvpcclient"
const (
// ServiceType contains the name of the Selectel VPC service for which this
// package is intended.
ServiceType = "resell"
// Endpoint contains the base url for all versions of the Resell client.
Endpoint = selvpcclient.DefaultEndp... |
package csnotes
import (
"fmt"
)
// 打印从 1 到最大的 n 位数
func print(n int) {
if n <= 0 {
return
}
// fmt.Println(byte(100))
// fmt.Println(string(100))
number := make([]int, n)
print1ToMaxOfNDigits(number, 0)
}
func print1ToMaxOfNDigits(number []int, digit int) {
if digit == len(number) {
printNumber(number)... |
package product
import (
"github.com/gingerxman/eel"
b_product "github.com/gingerxman/ginger-product/business/product"
)
type SkuStockConsumption struct {
eel.RestResource
}
func (this *SkuStockConsumption) Resource() string {
return "product.sku_stock_consumption"
}
func (this *SkuStockConsumption) GetParamete... |
package mc_msgpack
import (
"io"
gocodec "gx/ipfs/QmVTAmbCaPqdfbmpWDCJMQNFxbyJoG2USFsumXmTWY5LFp/go-codec/codec"
mc "gx/ipfs/QmYMiyZRYDmhMr2phMc4FGrYbsyzvR751BgeobnWroiq2z/go-multicodec"
)
const HeaderPath = "/msgpack"
var Header = mc.Header([]byte(HeaderPath))
type codec struct {
mc bool
handle *gocodec.... |
package upload
import (
"fmt"
"io"
"io/ioutil"
"launchpad.net/goamz/aws"
"launchpad.net/goamz/s3"
"mime"
"path/filepath"
"log"
)
const (
BUCKET_NAME = "dotaprofiles"
)
var PicsBucket *s3.Bucket
func AWSInit(access_key string, secret_key string) {
var auth aws.Auth
var err error
if access_key != "" && se... |
package rbac
import (
"errors"
"reflect"
)
// all roles
const (
admin string = "admin"
manager string = "manager"
moderator string = "moderator"
customer string = "customer"
guest string = "guest"
)
var (
//Roles переменная со всеми доступными ролями
Roles roles = roles{admin, manager, moderator, customer, ... |
/*
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
distributed under the License... |
package tsrv
import (
"encoding/xml"
"github.com/thought-machine/finance-messaging/iso20022"
)
type Document00400101 struct {
XMLName xml.Name `xml:"urn:iso:std:iso:20022:tech:xsd:tsrv.004.001.01 Document"`
Message *UndertakingAmendmentRequestV01 `xml:"UdrtkgAmdmntReq"`
}
func (d *Documen... |
package dogmatiqapp
import (
"github.com/dogmatiq/dogma"
"github.com/koden-km/dogma-app-setup/customer"
)
// App is an implementation of dogma.Application for the practice app.
type App struct {
customerAggregate customer.Aggregate
}
// Configure configures the Dogma engine for this application.
func (a *App) Con... |
package rest
import (
"time"
jwt "github.com/dgrijalva/jwt-go"
"github.com/jinmukeji/jiujiantang-services/pkg/rest"
proto "github.com/jinmukeji/proto/v3/gen/micro/idl/partner/xima/core/v1"
"github.com/kataras/iris/v12"
)
// ClientAuthReq 客户端授权的 Request
type ClientAuthReq struct {
ClientID string `json:"cl... |
package serv
import (
"encoding/json"
"fmt"
"log"
"net/http"
"io/ioutil"
simplejson "github.com/bitly/go-simplejson"
"github.com/chenyoufu/esql/g"
"github.com/chenyoufu/esql/sp"
"github.com/toolkits/file"
)
func renderJSON(w http.ResponseWriter, v interface{}, pretty bool) {
var bs []byte
var err error
... |
/*
Copyright 2021 The KubeVela 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, so... |
package main
import "fmt"
func main() {
/*
obj := Constructor()
obj.AddWord("bad")
obj.AddWord("dad")
obj.AddWord("mad")
fmt.Printf("search pad: %t\n", obj.Search("pad"))
fmt.Printf("search bad: %t\n", obj.Search("bad"))
fmt.Printf("search .ad: %t\n", obj.Search(".ad"))
fmt.Printf("search b..: %t\n", obj.Sea... |
// Package interfaces ...
//nolint:misspell // I know, BUT, I cant fix it
package interfaces
import (
"io"
"sync"
"time"
"awesome-dragon.science/go/goGoGameBot/internal/config/tomlconf"
)
// GameManager handles games
type GameManager interface {
ReloadGames(configs []tomlconf.Game) // Reload the games on this M... |
package core
import (
"fmt"
"io/ioutil"
"math/rand"
gnet "net"
"os"
"path"
"sync"
"testing"
"time"
"google.golang.org/grpc"
"github.com/BurntSushi/toml"
"github.com/benbjohnson/clock"
"github.com/drand/drand/beacon"
"github.com/drand/drand/key"
"github.com/drand/drand/log"
"github.com/drand/drand/net... |
package neatly
import (
"fmt"
"github.com/viant/toolbox/data"
"strings"
)
type referenceValues map[string]*referenceValue
func (v *referenceValues) CheckUnused() error {
var unused = make([]string, 0)
for k, value := range *v {
if !value.Used {
unused = append(unused, k)
}
}
if len(unused) == 0 {
ret... |
package conf
// CommonConfig is set of common configurations
type CommonConfig struct { // nolint
APIEndpoint *string
APIKey *string
AppVersion string
ExtendedOutput *bool
IsDebugMode bool
}
// StartConfig is set of configurations for starting the process
type StartConfig struct {
Common ... |
package server
import (
"net/http"
"reflect"
"testing"
"github.com/julienschmidt/httprouter"
"github.com/syariatifaris/shopeetax/app/resource/uires"
"github.com/syariatifaris/shopeetax/app/usecase"
)
func TestInitShopeeHTTPServer(t *testing.T) {
type args struct {
ui *uires.UIResource
port int
}
tests... |
package layer
import "io"
type Packer interface {
Encode(query *Query) ([]byte, error)
Decode([]byte) (*Query, error)
DecodeReader(reader io.Reader) (*Query, error)
}
type packer struct {
queryEncoder
queryDecoder
}
func NewPacker() Packer {
return new(packer)
}
|
package main
import (
"reflect"
"testing"
)
const (
simple = "..3.2.6..9..3.5..1..18.64....81.29..7.......8..67.82....26.95..8..2.3..9..5.1.3.."
harder = "4.....8.5.3..........7......2.....6.....8.4......1.......6.3.7.5..2.....1.4......"
diagonal1 = "2.............62....1....7...6..8...3...9...7...6..4...4... |
package 字符串
import "fmt"
func addStrings(num1 string, num2 string) string {
readIndexOfNum1 := len(num1) - 1
readIndexOfNum2 := len(num2) - 1
result := ""
carry := 0
for readIndexOfNum1 >= 0 || readIndexOfNum2 >= 0 || carry != 0 {
sum := carry
if readIndexOfNum1 >= 0 {
sum += int(num1[readIndexOfNum1] - '... |
package main
import (
"fmt"
"io/ioutil"
"os"
"github.com/nitohu/err"
)
func getCmdLineArgs(args []string) (map[string]string, err.Error) {
if len(args) <= 1 {
return nil, err.Error{}
}
res := make(map[string]string)
for i := 1; i < len(args); i += 2 {
var kw, val string
kw = args[i]
if i+1 < len(ar... |
package nomad
import "fmt"
func (n nomadInvocation) Uninstall() error {
fmt.Println("install")
return nil
}
|
package main
import "fmt"
func main() {
var a int
a = 1
one(a)
fmt.Println("a:", a)
fmt.Println("&a:", &a)
var b *int
b = &a
fmt.Println("*b:", *b)
two(b)
fmt.Println("b:",b)
fmt.Println("*b", *b)
fmt.Println("a:",a)
}
func one(x int) {
x = 2
}
func two(x *int) {
*x = 2
} |
package channels
import (
"testing"
)
func TestEasyUse(t *testing.T) {
UseChanel()
}
func TestChannelBlock(t *testing.T) {
BlockChanel()
}
func TestUseChannelPanic(t*testing.T){
UseChannelPanic()
}
func TestUseChannelArray(t*testing.T){
UseChannelArray()
} |
package read
import (
"os"
"fmt"
"encoding/binary"
"log"
)
//(defprotocol ReadChannel
//(position!! [this offset])
//(read-byte!! [this])
//(read-int!! [this])
//(read-wire-format!! [this length])
//(size!! [this])
//(close-read!! [this]))
type ReadChannel interface {
Position(offset int64)
ReadByte()
ReadBy... |
package main
import(
"net/http"
"net/http/httptest"
"testing"
"github.com/julienschmidt/httprouter"
"strings"
)
// Test the index page
// Route should redirect to the login page
func TestIndex(t *testing.T) {
router := httprouter.New()
router.GET("/", index)
writer := httptest.NewRecorde... |
package inventoryd
import (
"bufio"
"encoding/base64"
"encoding/json"
"errors"
"fmt"
"io/ioutil"
"os"
"path/filepath"
"strconv"
"strings"
"time"
)
//go:generate go-bindata -pkg inventoryd ./models/
// CreateDefaultConfig : デフォルトの設定ファイルを生成する
func CreateDefaultConfig(configPath string) error {
rootPath := ... |
package main
import (
"fmt"
"strings"
)
func main() {
//test
pat := "ABCAC"
raw := "ABCABBAC."
yes := pattern(pat, raw)
fmt.Printf("\"%s\" is in \"%s\": %v\n", pat, raw, yes)
}
func pattern(pat, raw string) bool {
rawArray := strings.Split(raw, "")
patArray := strings.Split(pat, "")
if !(len(patArray) < le... |
package vm
import (
bmstemcell "github.com/cloudfoundry/bosh-micro-cli/stemcell"
)
type Infrastructure interface {
CreateVM(bmstemcell.CID, map[string]interface{}, map[string]interface{}, map[string]interface{}) (CID, error)
}
|
// DRUNKWATER TEMPLATE(add description and prototypes)
// Question Title and Description on leetcode.com
// Function Declaration and Function Prototypes on leetcode.com
//69. Sqrt(x)
//Implement int sqrt(int x).
//Compute and return the square root of x, where x is guaranteed to be a non-negative integer.
//Since the r... |
package handlers
import (
"github.com/gin-gonic/gin"
"github.com/jinzhu/gorm"
"golang-rest/models"
"golang-rest/utils"
"net/http"
)
func GetAccessToken(c *gin.Context) {
db := c.MustGet("db").(*gorm.DB)
// create login user struct to restrict data.
var login models.Login
err := c.BindJSON(&login)
if err !=... |
// 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 timed_task
type TimeTask struct {
delMgoChatChan chan bool
}
var timeTask TimeTask
func GetInstance() *TimeTask {
if timeTask.delMgoChatChan == nil {
timeTask.delMgoChatChan = make(chan bool)
go func() {
timeTask.delMgoChatChan <- true
}()
}
return &timeTask
}
func (t *TimeTask) Run() {
for {
... |
package cmd
import tgbotapi "github.com/go-telegram-bot-api/telegram-bot-api"
type Command interface {
Execute (update tgbotapi.Update, scope *tgbotapi.BotAPI) error
GetName() string
GetHelp() string
}
type Commander struct {
Name string
Help string
Scope string
Cmd func(update tgbotapi.Update, scope *tgbota... |
const (
FILE = "./MX.txt"
FILE_DELIMITER = '\t'
TOTAL_ROWS = 5
)
func main() {
file, err := os.Open(FILE)
printError(err)
defer file.Close()
reader := csv.NewReader(file)
reader.Comma = FILE_DELIMITER
rows, err := reader.ReadAll()
printError(err)
fmt.Printf... |
package beginner
import "fmt"
/**
* created: 2019/5/8 9:25
* By Will Fan
*/
func main() {
data := []int {1,2,3}
i := 0
// wrong
//++i
//fmt.Println(data[i++])
// right
i++
fmt.Println(data[i])
}
|
package email
import (
"gopkg.in/gomail.v2"
"crypto/tls"
"log"
)
// Send PlainText.
func SendText(host string, port int, username, password string, to []string, from, cc, subject, body string) error {
addresses := make([]string, len(to))
m := gomail.NewMessage()
m.SetHeader("From", from)
for... |
package runtime
import (
"reflect"
"github.com/qlova/script"
)
//RunMethod implements script.Language.RunMethod.
func (runtime *Runtime) RunMethod(structure script.Value, name string, args []script.Value) {
var NumberOfArguments = len(args)
var Args = make(map[int]func() interface{}, NumberOfArguments)
for i, ... |
package main
import (
"context"
"github.com/spf13/cobra"
cmder "github.com/yaegashi/cobra-cmder"
)
type AppSPJobSchemaReset struct {
*AppSPJobSchema
}
func (app *AppSPJobSchema) AppSPJobSchemaResetComder() cmder.Cmder {
return &AppSPJobSchemaReset{AppSPJobSchema: app}
}
func (app *AppSPJobSchemaReset) Cmd() *... |
package dynamo
import (
"fmt"
"github.com/aws/aws-sdk-go/aws"
"github.com/aws/aws-sdk-go/aws/session"
"github.com/aws/aws-sdk-go/service/dynamodb"
"github.com/google/uuid"
"log"
"os"
"strconv"
"testing"
)
var (
qupDynamo QupDynamo
tableName = "Persons"
)
type PersonTest struct {
Id string `dynamo:... |
package utils
import (
"fmt"
"testing"
"time"
)
func Test_parseDateStr(t *testing.T) {
type args struct {
str string
}
year := time.Now().Year()
time1, _ := time.Parse("2006/1/2 MST", fmt.Sprintf("%d/12/31 JST", year))
time2, _ := time.Parse("2006/1/2 MST", fmt.Sprintf("%d/1/1 JST", year+1))
tests := []st... |
package main
import (
"fmt"
"github.com/coreos/go-etcd/etcd"
"github.com/miekg/dns"
)
type NodeConversionError struct {
Message string
Node *etcd.Node
AttemptedType uint16
}
func (e *NodeConversionError) Error() string {
return fmt.Sprintf(
"Unable to convert etc Node into a RR of type %d ('%... |
package bbir
import (
"context"
"errors"
"math"
"strconv"
"strings"
"time"
"github.com/vvatanabe/go-backlog/backlog/v2"
)
type CommandBuilder interface {
Build(int, *Line) (*Command, error)
}
func NewCommandBuilder(issue IssueRepository, project ProjectRepository, msgs Messages) CommandBuilder {
return &co... |
package LinkedList
import (
"fmt"
"github.com/Amertz08/EECS560-go/Lab01/Node"
)
type LinkedList struct {
head *Node.Node
}
func NewLinkedList() LinkedList {
return LinkedList{}
}
func (l *LinkedList) Insert(val int) {
fmt.Printf("Inserting value %v\n", val)
if l.isEmpty() {
newNode := Node.NewNode(val)
l.... |
package worldengine
|
package main
import (
"bufio"
"encoding/gob"
"fmt"
"net"
"os"
)
//dialing the server
func runClient(userName string, status chan int, msg chan string) {
c, err := net.Dial("tcp", ":9999")
if err != nil {
fmt.Println(err)
return
}
var message, received string
//welcome message
message = userName + " ... |
package forkexec
import (
"syscall"
)
// prepareExec prepares execve parameters
func prepareExec(Args, Env []string) (*byte, []*byte, []*byte, error) {
// make exec args0
argv0, err := syscall.BytePtrFromString(Args[0])
if err != nil {
return nil, nil, nil, err
}
// make exec args
argv, err := syscall.SliceP... |
package portals
import (
"log"
"fmt"
"os"
"strings"
"github.com/galaco/bsp/lumps/datatypes/portal"
"github.com/galaco/bsp/lumps/datatypes/visibility"
"github.com/galaco/bsp/lumps"
"github.com/go-gl/mathgl/mgl32"
)
const PORTALFILE = "PRT1"
const MAX_POINTS_ON_WINDING = 64
const MAX_POINTS_ON_FIXED_WINDING = 1... |
package health
import (
"time"
"github.com/coupa/foundation-go/config"
"github.com/gin-gonic/gin"
)
const (
OK = "OK"
WARN = "WARN"
CRIT = "CRIT"
TypeInternal = "internal"
TypeService = "service"
TypeThirdParty = "third-party"
)
var (
startTime time.Time
//CriticalLevels starts with 1 since 0 wi... |
package room
import (
"github.com/name5566/leaf/module"
"myLeaf/base"
"myLeaf/room/logic"
)
var (
skeleton = base.NewSkeleton()
ChanRPC = skeleton.ChanRPCServer
)
type Module struct {
*module.Skeleton
}
func (m *Module) OnInit() {
m.Skeleton = skeleton
m.initChanRPC()
}
func (m *Module) initChanRPC() {
m... |
package util
import (
"fmt"
k8scontrollerclient "sigs.k8s.io/controller-runtime/pkg/client"
"sync"
)
type ResourceQueue struct {
queue []k8scontrollerclient.Object
lookupTable map[k8scontrollerclient.Object]bool
lock *sync.Mutex
}
func NewResourceQueue() *ResourceQueue {
return &ResourceQueue{
... |
package config
import (
"crypto/md5"
"errors"
"fmt"
"net/url"
"strings"
"github.com/ryanmoran/viron"
)
var UAAPublicKey string
type Environment struct {
CCHost string `env:"CC_HOST" env-required:"true"`
CORSOrigin string `env:"CORS_ORIGIN" en... |
package api
import (
"context"
"os"
"github.com/go-playground/validator"
"github.com/gofiber/fiber"
"github.com/gofiber/session"
"github.com/rs/zerolog"
"github.com/hi019/fiber-boilerplate/ent"
us "github.com/hi019/fiber-boilerplate/pkg/api/user"
uw "github.com/hi019/fiber-boilerplate/pkg/api/user/web"
_ ... |
package collector
import (
"context"
"github.com/jenningsloy318/panos_exporter/panos"
"github.com/prometheus/client_golang/prometheus"
"github.com/prometheus/common/log"
)
var (
InterfaceSubsystem = "interface"
InterfaceLabelNames = []string{"name", "domain", "category"}
)
type InterfaceCollector struct {
c... |
package comm
// 将斐波那契数列项存入通道
func Fibonacci(c chan int) {
x, y := 0, 1
for i := 0; i < cap(c); i++ {
c <- x
x, y = y, x+y
}
close(c)
}
|
package terminator
import (
"reflect"
"testing"
"github.com/jouir/pgterminate/base"
)
func TestFilterUsers(t *testing.T) {
sessions := []*base.Session{
{User: "test"},
{User: "test_1"},
{User: "test_2"},
{User: "postgres"},
}
tests := []struct {
name string
config *base.Config
want []*base.... |
package main
import (
"flag"
"io/ioutil"
"log"
"os"
"path"
"path/filepath"
"strings"
"golang.org/x/text/encoding/charmap"
"parser1c/internal/parser1c"
"parser1c/internal/storage"
)
func main() {
var (
format = flag.String("format", "xlsx", "Формат вывода (по умолчанию xlsx)")
formats = map[string]s... |
// A very basic load balancer implementation.
// It provides round-robin load balancing and sends hearbeats messages
// to backend endpoints in order to detect unreacheable hosts
package main
import (
"context"
"flag"
"fmt"
"sync"
"sync/atomic"
"log"
"strings"
"time"
"net"
"net... |
/*
Tests basic Puts.
First tx puts 4 different key/values and commits.
Second tx puts 4 different values on same key.
Usage:
go run 2_PutTests.go
*/
package main
import "../kvservice"
import (
"fmt"
)
func main() {
var nodes []string
nodes = []string{"52.233.45.243:2222", "52.175.29.87:2222", "40.69.195.111:222... |
package http
type TreeNode struct {
Id string `json:"id"`
Label string `json:"label"`
Creator string `json:"creator"`
Type string `json:"type"`
Children []TreeNode `json:"children"`
}
|
package genInitialData
import (
"database/sql"
"fmt"
"github.com/jackc/pgtype"
_ "github.com/jackc/pgx/v4/stdlib"
)
// Placeholder hack to populate database with fake teams and games
func GenerateInitialData(db *sql.DB) {
var teams []string
db.Exec("TRUNCATE TABLE game")
db.Exec("DELETE ... |
package service
import (
"context"
"fmt"
"io"
"io/ioutil"
netHttp "net/http"
"strconv"
"sync"
"time"
"github.com/go-ocf/cloud/cloud2cloud-connector/events"
oapiStore "github.com/go-ocf/cloud/cloud2cloud-connector/store"
"github.com/go-ocf/cloud/cloud2cloud-gateway/store"
"github.com/go-ocf/cqrs/eventstor... |
// Copyright (c) 2021 Alexey Khan
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, d... |
// Copyright 2019 PingCAP, Inc.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to i... |
package config
import (
"bytes"
"context"
"crypto/tls"
"crypto/x509"
"encoding/base64"
"errors"
"fmt"
"net/http"
"net/url"
"os"
"path/filepath"
"reflect"
"strings"
"time"
envoy_http_connection_manager "github.com/envoyproxy/go-control-plane/envoy/extensions/filters/network/http_connection_manager/v3"
... |
package metadata
import (
"context"
"github.com/appootb/substratum/proto/go/common"
"google.golang.org/grpc"
)
type metadataKey struct{}
// UnaryServerInterceptor returns a new unary server interceptor for parsing request metadata.
func UnaryServerInterceptor() grpc.UnaryServerInterceptor {
return func(ctx cont... |
package main
import (
"github.com/therecipe/qt/core"
"github.com/therecipe/qt/gui"
"github.com/therecipe/qt/quick"
)
func init() {
SomeComponentInternal_QmlRegisterType2("CustomComponentsInternal", 1, 0, "SomeComponent")
}
type SomeComponentInternal struct {
quick.QQuickPaintedItem
_ func() `co... |
package engine_test
import (
"reflect"
"runtime"
"testing"
"github.com/GoPex/caretaker/controllers"
"github.com/GoPex/caretaker/engine"
"github.com/GoPex/caretaker/tests"
)
// Struct to do a table driven test for routes
type expectedRoute struct {
method string
path string
handler interface{}
}
// Var ... |
package repository
import "github.com/alexgtn/esi2021-lab5/pkg/domain"
type StudentFooRepository struct {
data []*domain.Student
}
func NewStudentFooRepostory() *StudentFooRepository {
return &StudentFooRepository{
data: []*domain.Student{},
}
}
func (r *StudentFooRepository) AddStudent(s *domain.Student) (*do... |
package cryptoki
import (
"crypto"
"crypto/ecdsa"
"crypto/elliptic"
"encoding/asn1"
"errors"
"github.com/miekg/pkcs11"
)
// Named curves (RFC 5480 2.1.1.1)
var curveOIDs = map[elliptic.Curve]asn1.ObjectIdentifier{
elliptic.P224(): asn1.ObjectIdentifier{1, 3, 132, 0, 33},
elliptic.P256(): asn1.ObjectIdentifie... |
package main
import (
"fmt"
"time"
)
func main() {
fmt.Printf("%c", '\a')
time.Sleep(3 * time.Second)
fmt.Printf("%s", "\a")
time.Sleep(3 * time.Second)
fmt.Print("\a")
time.Sleep(3 * time.Second)
fmt.Print('\a')
//IDE直接运行, 不响铃, 必须在控制台运行才响铃
}
|
package pred
import floc "gopkg.in/workanator/go-floc.v1"
func alwaysTrue(state floc.State) bool {
return true
}
func alwaysFalse(state floc.State) bool {
return false
}
|
package cfb
import (
"crypto/cipher"
"encoding/hex"
)
// Decrypt is used for decrypt an encrypted term
func (b BuildModel) Decrypt(str string) string {
// // TODO: should fix auto read from stream
// encrypted, _ := hex.DecodeString(str)
// bReader := bytes.NewReader(encrypted)
// stream := cipher.NewOFB(b.blo... |
package demo
import (
"github.com/apache/thrift/lib/go/thrift"
"github.com/go-xe2/x/type/t"
"github.com/go-xe2/xthrift/pdl"
)
type HelloServiceSayHelloArgs struct {
*pdl.TDynamicStructBase
Name *string `thrift:"name,1,optional" json:"name"`
Age int32 `thrift:"age,2,required" json:"age"`
f... |
package exer9
import (
"math"
"math/rand"
"time"
)
// Random Arrays
// We want to generate some random arrays. In array_stats.go, write a function that creates and returns an array with length integers and values from 0 to maxInt-1 with this signature:
// func RandomArray(length int, maxInt int) []int { … }
// Wh... |
package repositories_test
import (
"database/sql"
"os"
"testing"
"github.com/syncromatics/kafmesh/internal/storage/repositories"
"github.com/syncromatics/go-kit/database"
"github.com/syncromatics/go-kit/testing/docker"
_ "github.com/syncromatics/kafmesh/internal/storage/statik"
)
var (
databaseSettings *da... |
/*
* API v2.0 Links Framework
*/
package clcv2
import (
"fmt"
"strings"
"github.com/pkg/errors"
uuid "github.com/satori/go.uuid"
)
// Link adds hyperlink information to resources.
type Link struct {
// The link type (depends on context)
Rel string `json:"rel"`
// Address of the resource.
Href string `json... |
package models
import (
"golang.org/x/crypto/bcrypt"
)
type Person struct {
FirstName string `json:"firstname"`
LastName string `json:"lastname"`
Username string `json:"username"`
Hash string `json:"hash,omitempty"`
Emails []string `json:"emails"`
Addresses Addresses `json:"addresses"`
}... |
// 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 la... |
package utils
import (
"bytes"
"encoding/binary"
"errors"
"os"
"github.com/sirupsen/logrus"
)
// FileExists tests if a file exists and is not a Directory
func FileExists(filename string) bool {
info, err := os.Stat(filename)
if os.IsNotExist(err) {
return false
}
return !info.IsDir()
}
// DirExists test... |
/*
Copyright (C) 2018 Synopsys, Inc.
Licensed to the Apache Software Foundation (ASF) under one
or more contributor license agreements. See the NOTICE file
distributed with this work for additional information
regarding copyright ownershia. The ASF licenses this file
to you under the Apache License, Version 2.0 (the
"... |
package main
import (
"fmt"
"sync"
"time"
)
// 这是因为同一逻辑处理器中三个任务被创建后 理论上会按顺序 被放在同一个任务队列,但实际上最后那个任务会被放在专一的next(下一个要被执行的任务的意思)的位置,
// 所以优先级最高,最可能先被执行,所以表现为在同一个goroutine中创建的多个任务中最后创建那个任务最可能先被执行。
func schedulesSort() {
done := make(chan bool)
values := []string{"a", "b", "c"}
for _, v := range values {
fmt.Printl... |
package main
import "fmt"
func main() {
s1 := make([]int, 50)
fmt.Println(len(s1)) // 50
s2 := make(chan int, 50)
fmt.Println(len(s2)) // 0
s2 <- 0
fmt.Println(len(s2)) // 1
}
|
package main
import "fmt"
// 44. 通配符匹配
// 给定一个字符串 (s) 和一个字符模式 (p) ,实现一个支持 '?' 和 '*' 的通配符匹配。
// '?' 可以匹配任何单个字符。
// '*' 可以匹配任意字符串(包括空字符串)。
// 两个字符串完全匹配才算匹配成功。
// 说明:
// s 可能为空,且只包含从 a-z 的小写字母。
// p 可能为空,且只包含从 a-z 的小写字母,以及字符 ? 和 *。
// https://leetcode-cn.com/problems/wildcard-matching/
func main() {
fmt.Println... |
package cli
import (
"encoding/json"
"fmt"
"log"
"os"
"os/exec"
"time"
"github.com/spf13/afero"
"github.com/spf13/cobra"
ac "github.com/ocramh/fingerprinter/pkg/acoustid"
fp "github.com/ocramh/fingerprinter/pkg/fingerprint"
)
var (
apikey string
)
func init() {
rootCmd.AddCommand(acoustidCmd)
acoustid... |
package main
import (
"github.com/shurcooL/vfsgen"
"log"
"net/http"
)
func main() {
var err error
err = vfsgen.Generate(http.Dir("plugins/micro/component"), vfsgen.Options{
PackageName: "bundle",
VariableName: "Components",
BuildTags: "build",
Filename: "plugins/micro/bundle/component_build.go",... |
// Copyright (C) 2015 Nippon Telegraph and Telephone Corporation.
//
// 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... |
package main
import "fmt"
func main() {
fmt.Println("This is func expression")
f := func(x int) {
fmt.Println("Sundan was born in", x)
}
f(1987)
f2 := func(y string) {
fmt.Println("Sundan was bon in", y)
}
f2("Bangladesh")
f3 := func(z []string) {
fmt.Println("Sundan was", z)
}
f3([]string{"Awesome", ... |
package postgres_backend
import (
"github.com/straumur/straumur"
"testing"
)
type QueryBuilder func(e *straumur.Event) (string, []interface{}, error)
func queryTest(t *testing.T, expected string, e *straumur.Event, qb QueryBuilder) {
expectedArgs := []interface{}{
e.Key,
"{}",
"{}",
e.Created,
e.Update... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.