text stringlengths 11 4.05M |
|---|
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT license.
package kubernetesupgrade
import (
"context"
"fmt"
"math/rand"
"strings"
"time"
"github.com/pkg/errors"
"github.com/Azure/aks-engine/pkg/api"
"github.com/Azure/aks-engine/pkg/armhelpers"
"github.com/Azure/aks-en... |
package querycomposer
type QueryComposer interface {
Columns(input interface{}) QueryComposer
PersistenceNames(names []string) QueryComposer
Compose() string
}
type UpdateQueryComposer interface {
QueryComposer
Where(whereClause string) SelectQueryComposer
}
type SelectQueryComposer interface {
UpdateQueryComp... |
package controllers
import (
"encoding/json"
"nomadiclife/helper/mails"
"nomadiclife/helper/response"
"nomadiclife/models"
"github.com/beego/beego/v2/client/orm"
beego "github.com/beego/beego/v2/server/web"
"github.com/dchest/uniuri"
)
// UserController operations for User
type UserController struct {
beego.... |
package debug
import (
"time"
"github.com/Sirupsen/logrus"
)
// Time measures duration of a function
//
// Usage: (notice the suffix of '()')
//
// func A() {
// defer debug.Time(log, "some %s", "args")()
// ....
// }
func Time(log logrus.FieldLogger, format string, args ...interface{}) func() {
i... |
package workers
import (
"fmt"
"github.com/APTrust/exchange/constants"
"github.com/APTrust/exchange/context"
"github.com/APTrust/exchange/models"
"github.com/APTrust/exchange/network"
"github.com/APTrust/exchange/util"
"github.com/APTrust/exchange/util/fileutil"
"github.com/APTrust/exchange/util/storage"
"git... |
package oss
import (
"bytes"
"net/http"
"os"
"testing"
)
func TestHTTPBody(t *testing.T) {
{
body := "abc"
req, _ := http.NewRequest("GET", "", nil)
w := bytes.NewBuffer([]byte(body))
HTTPBody(w)(req)
if int(req.ContentLength) != len(body) {
t.Fatalf(expectBut, len(body), req.ContentLength)
}
}
... |
package main
import (
"errors"
_ "github.com/mysql"
"github.com/xorm"
"log"
"os"
_ "reflect"
)
// 银行账户
type Account struct {
Id int64
Name string `xorm:"unique"`
Balance float64
Version int `xorm:"version"` // 乐观锁
}
func (a *Account) BeforeInsert() {
log.Printf("Before insert: %s\n", a.Name)
}
func (a *... |
// 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 command_line
/**
Command line arguments are a common way to parameterize execution of programs.
*/
import (
"fmt"
"os"
)
func main() {
// os.Args provides access to raw command-line arguments
argsWithProg := os.Args
argsWithoutProg := os.Args[:1]
// get individual args with normal indexing
arg := os... |
package sheet_logic
import (
"hub/sheet_logic/sheet_logic_types"
)
type Negation struct {
GrammarElement
UnaryOperationBool
}
func (n *Negation) CalculateBool(g GrammarContext) (result bool, err error) {
var boolVal bool
if boolVal, err = n.GetArg().CalculateBool(g); err == nil {
result = !boolVal
}
retur... |
package main
import (
"fmt"
"html/template"
"log"
"net/http"
"party_queue/credentials"
"party_queue/services"
"path"
"github.com/julienschmidt/httprouter"
)
//Route handling is done here
//Read carefully to get API endpoints
func main() {
port := "8080"
router := httprouter.New()
router.ServeFiles("/party... |
package main
import "fmt"
func main() {
person := make(map[string]string)
person["Name"] = "Koorsha"
person["Family"] = "Shirazi"
person["Age"] = "32"
fmt.Println(person["Name"])
fmt.Println(len(person))
delete(person, "Age")
fmt.Println(len(person))
}
|
package front
import (
"fmt"
"github.com/empirefox/esecend/fsm"
)
func (o *Order) TrackingNumber() string {
return fmt.Sprintf("%d-%d", o.CreatedAt, o.ID)
}
func (o *Order) WxOutTradeNo() string {
return fmt.Sprintf("%d-%d-%s", o.PrepaidAt, o.ID, o.WxTradeNo)
}
func (o *Order) CurrentState() fsm.State { return... |
package main
import (
"flag"
"io/ioutil"
"log"
"os"
"os/signal"
"path/filepath"
"syscall"
"bazil.org/fuse"
"bazil.org/fuse/fs"
"taterbase.me/git-mount/git"
)
var (
hash_map = make(map[string]*Dir)
root *Dir
_ fs.FS = (*GitFS)(nil)
_ Node = (*File)(nil)
_ fs.NodeOp... |
// 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 acmt
import (
"encoding/xml"
"github.com/thought-machine/finance-messaging/iso20022"
)
type Document01500101 struct {
XMLName xml.Name `xml:"urn:iso:std:iso:20022:tech:xsd:acmt.015.001.01 Document"`
Message *AccountExcludedMandateMaintenanceRequestV01 `xml:"AcctExcldMn... |
package quacktors
import "github.com/opentracing/opentracing-go"
type localMessage struct {
message Message
spanContext opentracing.SpanContext
}
//The Message interface defines all methods a struct has
//to implement so it can be sent around by actors.
type Message interface {
//Type returns the the "name" o... |
package flv
import (
//"encoding/binary"
"github.com/pkg/errors"
)
type TagData interface {
Decode(raw []byte) (count int , err error)
ToString() string
}
type Position struct {
Offset uint32
Length uint32
}
type FlvTag struct {
Position
Header TagHeader
Data TagData
Raw []byte
Pre... |
package main
import "fmt"
func isPrime(num int, primes []int) bool {
for _, el := range primes {
if num%el == 0 {
return false
}
}
return true
}
func main() {
times, target, max := 0, 0, 0
var targets []int
fmt.Scanf("%d", ×)
for i := 0; i < times; i++ {
fmt.Scanf("%d", &target)
targets = appe... |
// This file was generated for SObject CaseContactRole, API Version v43.0 at 2018-07-30 03:47:28.151192914 -0400 EDT m=+14.494343220
package sobjects
import (
"fmt"
"strings"
)
type CaseContactRole struct {
BaseSObject
CasesId string `force:",omitempty"`
ContactId string `force:",omitempty"`
Cr... |
package main
import (
"sort"
"strings"
)
/**
面试题 17.13. 恢复空格
哦,不!你不小心把一个长篇文章中的空格、标点都删掉了,并且大写也弄成了小写。像句子"I reset the computer. It still didn’t boot!"已经变成了"iresetthecomputeritstilldidntboot"。
在处理标点符号和大小写之前,你得先把它断成词语。当然了,你有一本厚厚的词典dictionary,不过,有些词没在词典里。假设文章用sentence表示,设计一个算法,把文章断开,要求未识别的字符最少,返回未识别的字符数。
注意:本题相对原题稍作改动,只... |
// 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
package rolling
import (
"os"
"sync"
"time"
"github.com/urso/ecslog/backend"
"... |
package externalsearchmodel
type HotelSearchResponse struct {
Token string `json:"token"`
Hotels []Hotel `json:"hotels"`
TotalHotels int `json:"totalHotels"`
}
|
package gaarx
import (
_ "github.com/go-sql-driver/mysql"
"github.com/jinzhu/gorm"
)
type (
db struct {
database *gorm.DB
migrateEntities []interface{}
}
)
func (d *db) GetDB() *gorm.DB {
return d.database
}
func (d *db) MigrateEntities(entities ...interface{}) {
for _, e := range entities {
d.da... |
/*
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 file
import (
"crypto/sha1"
"encoding/json"
"fmt"
"io/ioutil"
"os"
"path/filepath"
"sort"
"github.com/pkg/errors"
"got/internal/index"
"got/internal/objects"
)
const (
IndexFile = "index"
)
type Index struct {
// The .got directory
Dir string
Version int
Entries index.EntryMap
Checks... |
package samanpayment
type SamanConfig struct {
TerminalId int `json:"TerminalId"`
}
type RequestToken struct {
Action string `json:"action"`
TerminalId int `json:"TerminalId"`
RedirectUrl string `json:"RedirectUrl"`
TxnRandomSessionKey int `json:"TxnRandomSessionKey"`
ResNum ... |
package channel
import "../specs"
/* IChannel interface *
/**********************/
func (chn *Channel) GetNum() int {
return chn.Num
}
func (chn *Channel) GetName() string {
return chn.Name
}
func (chn *Channel) GetCommands() []int {
return chn.Cmds
}
func (chn *Channel) GetTicks() ... |
// Licensed to Apache Software Foundation (ASF) under one or more contributor
// license agreements. See the NOTICE file distributed with
// this work for additional information regarding copyright
// ownership. Apache Software Foundation (ASF) licenses this file to you under
// the Apache License, Version 2.0 (the "Li... |
/*
Copyright 2020 The Qmgo 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, sof... |
package route
import (
v1 "Blog/api/v1"
"Blog/middleware"
"Blog/util"
"github.com/gin-gonic/gin"
)
func InitRoute() *gin.Engine {
gin.SetMode(util.AppMode)
// 和new的区别就是加了两个中间件
//不要他的日志,自己写
//r := gin.Default()
r := gin.New()
r.Use(gin.Recovery(), middleware.Logger())
// 鉴权
routeV1Auth := r.Group("api/v1"... |
package workqueue
import (
"context"
"errors"
"sync"
"time"
pkgErrors "github.com/pkg/errors"
"gopkg.in/tomb.v2"
"git.scc.kit.edu/sdm/lsdf-checksum/internal/lifecycle"
"git.scc.kit.edu/sdm/lsdf-checksum/workqueue"
)
// Error variables related to batcher.
var (
errBatcherDying = errors.New("batc... |
// Copyright 2018 Diego Bernardes. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
package flare
import (
"testing"
. "github.com/smartystreets/goconvey/convey"
)
func TestResourceChangeValid(t *testing.T) {
Convey("Feature: Validate th... |
package cmd
import (
"fmt"
"os"
"github.com/ContinuousSecurityTooling/clairctl/clair"
"github.com/ContinuousSecurityTooling/clairctl/config"
"github.com/ContinuousSecurityTooling/clairctl/docker"
"github.com/ContinuousSecurityTooling/clairctl/server"
"github.com/spf13/cobra"
)
var pushCmd = &cobra.Command{
U... |
package pget
import (
"io"
"os"
)
var stdout io.Writer = os.Stdout
|
package main
import (
"fmt"
)
func main() {
var x []int
y := []int{123, 34, 8756, 23, 8, 4, 3}
x = append(x, 8, 3, 1, 7)
y = append(y, x...)
fmt.Println(y)
fmt.Println(y[2:5])
}
|
// sliceTest project doc.go
/*
sliceTest document
*/
package main
|
package main
import (
"flag"
"os"
"testing"
)
func TestArg(t *testing.T) {
cases := [...]struct {
name string
input []string
result int
}{
{
"No param",
[]string{"execfile"},
5,
},
{
"param10",
[]string{"execfile", "-g", "10"},
10,
},
{
"param8",
[]string{"execfile", "-... |
package leetcode
func oddCells(n int, m int, indices [][]int) int {
rows := make([]int, n)
cols := make([]int, m)
nrow, ncol := 0, 0
for _, idx := range indices {
rows[idx[0]] ^= 1
if rows[idx[0]] == 1 {
nrow++
} else {
nrow--
}
cols[idx[1]] ^= 1
if cols[idx[1]] == 1 {
ncol++
} else {
nco... |
package logger
import (
"fmt"
// "github.com/comdeng/HapGo/hapgo/app"
"github.com/comdeng/HapGo/hapgo/conf"
// "log"
//"io"
"log"
"os"
"path/filepath"
"sync"
"time"
)
const (
FATAL = 1 << iota
WARNING
NOTICE
TRACE
DEBUG
maxBufferLen = 2 << 0
)
var logFlags map[int]string = map[int]string{
DEBUG: "... |
package demo2
import (
"fmt"
"strconv"
"testing"
"speter.net/go/exp/math/dec/inf"
)
var _ = inf.Dec{}
var testQuantities []Quantity
const (
numOfPodsPerNode = 30
numOfNodes = 1000
testDataSize = numOfNodes * numOfPodsPerNode
)
func init() {
testQuantities = make([]Quantity, testDataSize)
for i ... |
package template
import "encoding/json"
const TemplateTypeGeneric TemplateType = "generic"
type GenericTemplate struct {
TemplateBase
Elements []Element `json:"elements"`
}
func (GenericTemplate) Type() TemplateType {
return TemplateTypeGeneric
}
func (g GenericTemplate) Validate() error {
if len(g.Elements) >... |
package domain
import (
"gopkg.in/go-playground/validator.v9"
)
type NotifierServices struct {
Slack SlackNotifierService
}
type SlackMessageSendResponse struct {
OK bool `json:"ok"`
}
type SlackNotifierService interface {
Notify(*SlackMessage) (*SlackMessageSendResponse, error)
}
type SlackMessage struct {
R... |
package memory
import (
"fmt"
"io/ioutil"
"log"
"regexp"
"strconv"
"time"
"github.com/memoryMonitor/alert"
)
var (
alertRecord = make(map[string]int)
)
var (
DefaultCgroupDir = "/sys/fs/cgroup"
DefaultMemoInfoFile = "/proc/meminfo"
DefaultDockerReg = regexp.MustCompile(`[a-zA-Z0-9-_+.]+... |
package main
import "fmt"
func appendVector() {
a := []int{1, 2, 3, 4}
b := []int{5, 6, 7, 8}
c := append(a, b...)
// combining vectors
// [1 2 3 4 5 6 7 8]
fmt.Println(c)
}
func main() {
appendVector()
}
|
package main
import (
"crypto/rand"
"encoding/json"
"fmt"
"github.com/jinzhu/gorm"
"github.com/kataras/iris"
"github.com/valyala/fasthttp"
"golang.org/x/crypto/bcrypt"
"net/smtp"
"strconv"
"time"
)
var SUCCESS = map[string]string{"msg": "Success", "ok": "Success"}
var FAILED = map[string]string{"msg": "Fail... |
package control
/**
Control provides parser for the zsync control (.zsync) files.
*/
import (
"bufio"
"fmt"
"io"
"strconv"
"strings"
"github.com/AppImageCrafters/libzsync-go/chunks"
"github.com/AppImageCrafters/libzsync-go/index"
)
type ControlHeaderHashLengths struct {
ConsecutiveMatchNeeded uint
WeakChec... |
package main
import (
"fmt"
"strings"
)
type a interface {
aa()
}
func handle(a a) {
a.aa()
}
type bb struct {
}
func (b bb) aa() {
fmt.Println("bb")
}
func main() {
var b *bb
//b.aa()
handle(b)
//var d int = 2
//fmt.Printf("%08b\n", d)
//fmt.Printf("%08b\n", ^d)
//fmt.Printf("%08b\n", ^0) // 111111... |
package server
import (
"chlorine/auth"
"chlorine/music"
"github.com/gorilla/sessions"
)
// ExternalMusicHandler contains external MusicService and authentication provider for it to retrieve music information.
type ExternalMusicHandler struct {
auth.Session
MusicService music.Service
AuthenticationPro... |
package stack
import (
"testing"
)
func TestWhenCreateStackWithMaxSizeX_MaxSizeIsX(t *testing.T) {
maxSize := 10
stack := MakeStack(maxSize)
size := stack.MaxSize()
wants := maxSize
if size != wants {
t.Errorf("Expect %v. Got %v", wants, size)
}
}
func TestWhenPopInEmpty_ReturnUnderflowError(t *testing.T... |
package asa
import (
"time"
"github.com/cpusoft/goutil/belogs"
"github.com/cpusoft/goutil/jsonutil"
model "rpstir2-model"
rtrcommon "rpstir2-rtrproducer/common"
)
func RtrUpdateByAsaFromSync(curSerialNumberModel, newSerialNumberModel *rtrcommon.SerialNumberModel) (err error) {
start := time.Now()
belogs.Info(... |
package model
type Header struct {
ParentHash string `json:"parentHash"`
Number string `json:"number"`
StateRoot string `json:"stateRoot"`
ExtrinsicsRoot string `json:"extrinsicsRoot"`
Digest interface{} `json:"digest"`
}
|
// Copyright 2019 Kuei-chun Chen. All rights reserved.
package analytics
import (
"fmt"
"log"
"math"
"sort"
"strconv"
"strings"
"time"
)
var mb = (1024.0 * 1024)
// TimeSeriesDoc -
type TimeSeriesDoc struct {
Target string `json:"target"`
DataPoints [][]float64 `json:"datapoints"`
}
// RangeDoc -... |
package service
import (
"strings"
"tesou.io/platform/brush-parent/brush-api/common/base"
"tesou.io/platform/brush-parent/brush-api/module/match/pojo"
"tesou.io/platform/brush-parent/brush-core/common/base/service/mysql"
)
type BFFutureEventService struct {
mysql.BaseService
}
func (this *BFFutureEventService) ... |
package kafka
import (
"fmt"
"github.com/Shopify/sarama"
"time"
)
// 专门往kafka写日志的模块
type logData struct {
topic string
data string
}
var (
// 声明一个全局连接kafka的生产者
client sarama.SyncProducer
// 全局的用于存放日志的chan
logDataChan chan *logData
)
// 初始化client
func Init(address []string, topic string, maxSize int)(err e... |
package main
func main() {
//minSwapTest()
//wordBreakTest()
//canConstructTest()
//reorganizeStringTest()
//decodeAtIndexTest()
isSubTreeTest()
}
|
package ast
type ColumnDef struct {
Colname string
TypeName *TypeName
IsNotNull bool
IsArray bool
Vals *List
}
func (n *ColumnDef) Pos() int {
return 0
}
|
package main
import (
"fmt"
)
// At the time of printing, create an instance of the printer for the first time.
// In order to spend time creating a printer, call a heavy task when creating a printer instance.
func main() {
p := NewPrinterProxy("Emily's printer")
fmt.Println("The current printer is " + p.GetPrint... |
// Package structs is used to define all structures that
// are used to get the results in the JSON
package structs
// All results from the JSON
type Results struct {
Results []Result `json:"results"`
Status string `json:"status"`
}
// Result store each result from the JSON
type Result struct {
AddressComponent... |
package anagram
import (
"strings"
"unicode"
)
func Detect(subject string, candidates []string) []string {
anagrams := []string{}
for _, candidate := range candidates {
if isAnagram(subject, candidate) {
anagrams = append(anagrams, candidate)
}
}
return anagrams
}
func isAnagram(s, t string) bool {
ret... |
package util
import (
"io"
"io/ioutil"
"os"
)
// CreateViaTempMove atomically writes a file containing content to path.
//
// In order to do this atomically, we first create the file in a temporary
// directory and, upon success, move it into place via an atomic move.
//
// On failure, cleanup is best-effort.
func... |
// DRUNKWATER TEMPLATE(add description and prototypes)
// Question Title and Description on leetcode.com
// Function Declaration and Function Prototypes on leetcode.com
//441. Arranging Coins
//You have a total of n coins that you want to form in a staircase shape, where every k-th row must have exactly k coins.
//Give... |
package utils
import (
"github.com/gin-gonic/gin"
"strconv"
)
func StrToInt(str string) (int, error) {
i, err := strconv.Atoi(str)
return i, err
}
func ResJson(ctx *gin.Context, statusCode int, msg string, data interface{}) {
ctx.JSON(statusCode, gin.H{
"status": statusCode,
"message": msg,
"data": da... |
package main
import (
"fmt"
"net/http"
"os"
)
func OpenSendFile(url string,w http.ResponseWriter) {
fs,err:=os.Open(url)
if err!=nil{
fmt.Println("os open file err",err)
w.Write([]byte("no such file or directory"))
return
}
buf:=make([]byte,4096)
for{
n,_:=fs.Read(buf)
if n==0{
return
}
w.Wr... |
/*
* Copyright Amazon.com, Inc. or its affiliates. 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.
* A copy of the License is located at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* or in the "... |
package types
import (
"crypto/elliptic"
"encoding/json"
"github.com/HNB-ECO/HNB-Blockchain/HNB/bccsp"
"github.com/HNB-ECO/HNB-Blockchain/HNB/bccsp/sw"
"github.com/HNB-ECO/HNB-Blockchain/HNB/common"
"github.com/HNB-ECO/HNB-Blockchain/HNB/ledger"
bsComm "github.com/HNB-ECO/HNB-Blockchain/HNB/ledger/blockStore/co... |
package some
import (
"encoding/json"
"fmt"
"os"
)
type program struct {
Name string `json:"name"`
Author user `json:"author"`
Version int `json:"version"`
}
type user struct {
Name string `json:"name"`
Email string `json:"email"`
}
func Create() {
input := *input()
j, err := json.MarshalInden... |
package backend
import (
"encoding/json"
"fmt"
"net/http"
"github.com/complyue/ddgo/pkg/drivers"
"github.com/complyue/ddgo/pkg/livecoll"
"github.com/complyue/hbigo/pkg/errors"
"github.com/golang/glog"
"github.com/gorilla/mux"
"github.com/gorilla/websocket"
)
// relay live truck collection changes over a web... |
// +build k8srequired
package setup
import (
"log"
"os"
"testing"
"github.com/giantswarm/e2e-harness/pkg/framework"
"github.com/giantswarm/e2etemplates/pkg/e2etemplates"
"github.com/giantswarm/microerror"
"github.com/giantswarm/kvm-operator/integration/env"
"github.com/giantswarm/kvm-operator/integration/te... |
package realm
import (
"encoding/json"
"fmt"
"net/http"
"github.com/10gen/realm-cli/internal/utils/api"
)
const (
allowedIPsPathPattern = appPathPattern + "/security/access_list"
allowedIPPathPattern = allowedIPsPathPattern + "/%s"
)
// AccessList is a list of allowed IPs stored in a Realm app
type AccessLis... |
package commands_test
import (
"errors"
"io/ioutil"
"github.com/cloudfoundry/bosh-bootloader/commands"
"github.com/cloudfoundry/bosh-bootloader/fakes"
"github.com/cloudfoundry/bosh-bootloader/storage"
. "github.com/onsi/ginkgo"
. "github.com/onsi/gomega"
)
var _ = Describe("Plan", func() {
var (
command c... |
package stream
import (
"bytes"
"github.com/fasthttp/websocket"
"github.com/gofiber/fiber/v2"
"github.com/stretchr/testify/require"
"io"
"io/ioutil"
"log"
"testing"
"time"
)
func Test_Stream_Successfully_Sent_To_Client(t *testing.T) {
// start stream proxy
go startWebSocketStreamProxyServer()
// Workarou... |
package main
import (
"bytes"
"encoding/json"
"fmt"
"math/rand"
"mime/multipart"
"net/http/httptest"
"strings"
"sync"
"time"
"github.com/ivansukach/bets/internal/handlers/blocking"
log "github.com/sirupsen/logrus"
"io/ioutil"
"net/http"
"testing"
)
type ErrorResponse struct {
Status string `json:"stat... |
package cgroup
import (
"os"
"testing"
)
func BenchmarkCgroup(b *testing.B) {
builder, err := NewBuilder("benchmark").WithCPU().WithCPUSet().WithCPUAcct().WithMemory().WithPids().FilterByEnv()
if err != nil {
b.Fatal(err)
}
b.ResetTimer()
for i := 0; i < b.N; i++ {
cg, err := builder.Build("test")
if err... |
package cmd_test
import (
"bytes"
"encoding/json"
"fmt"
"io/ioutil"
"net/http"
"net/url"
"os"
"os/exec"
"runtime"
. "github.com/onsi/ginkgo"
. "github.com/onsi/gomega"
"github.com/onsi/gomega/ghttp"
)
var _ = Describe("Manifest", func() {
var binLocation string
BeforeEach(func() {
binLocation = fmt.S... |
package weapons
import (
"regexp"
"strings"
)
// ResolveWeaponClass resolves a given string to an EWeaponClass.
func ResolveWeaponClass(str string) EWeaponClass {
words := strings.Split(str, " ")
for _, word := range words {
if class, ok := weaponClasses[word]; ok {
return class
}
}
return ""
}
var rS... |
package main
import (
"bufio"
"fmt"
"os"
)
var santaHindex int
var santaVindex int
var roboHindex int
var roboVindex int
func main() {
filePath := os.Args[1]
file, _ := os.Open(filePath)
defer file.Close()
reader := bufio.NewReader(file)
scanner := bufio.NewScanner(reader)
deliveryMap := make(map[int]m... |
// Copyright © 2020. All rights reserved.
// Author: Ilya Stroy.
// Contacts: qioalice@gmail.com, https://github.com/qioalice
// License: https://opensource.org/licenses/MIT
package privet
import (
"github.com/qioalice/ekago/v2/ekaerr"
)
//goland:noinspection GoSnakeCaseUsage
const (
DEFAULT_DELIMITER byte = '/'
)... |
package goxtremio
import (
"fmt"
"testing"
)
func TestGetVolumeFolderByID(t *testing.T) {
volumeFolder, err := c.GetVolumeFolder("7", "")
if err != nil {
panic(err)
}
fmt.Println(fmt.Sprintf("%+v", volumeFolder))
}
func TestGetVolumeFolderByName(*testing.T) {
volumeFolder, err := c.GetVolumeFolder("", "/Ub... |
package controllers
import (
"encoding/json"
"net/http"
"github.com/aslampangestu/learn-golang/api-example/views"
"github.com/aslampangestu/learn-golang/api-example/models"
)
// IndexNote -> Create & Select All & Select By Query Data
func IndexNote() http.HandlerFunc {
return func(w http.ResponseWriter, r *htt... |
package queries
import (
"database/sql"
"log"
"gitlab.com/semestr-6/projekt-grupowy/backend/obsluga-formularzy/configuration"
"gitlab.com/semestr-6/projekt-grupowy/backend/obsluga-formularzy/energy_resources/models"
)
const ADD_GUS_RESOURCE_SQL = `
INSERT INTO energy_resources."GUSResources"
(
"GUSResourceNameP... |
package robo
// Robot represents a robot capable of moving in 4 cardinal directions and keeping track of its relative position
type Robot interface {
Move(Direction) error
Position() Node
Direction() Direction
DistanceTravelled() int64
}
// DefaultRobot is the default implementation of the Robot interface
type De... |
package funding
type Fund struct {
// balance is unexported (private), because it's lowercase
balance int
}
// A regular function returning a pointer to a fund
func NewFund(initialBalance int) *Fund {
// We can return a pointer to a new struct w/o worring
// about wheter it's in the stack or heap: Go figures that... |
package cmd
import (
"database/sql"
"path"
"path/filepath"
"github.com/dosco/graphjin/internal/util"
"github.com/dosco/graphjin/serv"
"github.com/spf13/afero"
"github.com/spf13/cobra"
"go.uber.org/zap"
)
var (
bi serv.BuildInfo
log *zap.SugaredLogger
db *sql.DB
dbOpened bool
conf *s... |
package storage
import (
"context"
"net/http"
"net/http/httptest"
"testing"
"k8s.io/apimachinery/pkg/labels"
"github.com/stretchr/testify/require"
"github.com/operator-framework/operator-lifecycle-manager/pkg/package-server/apis/operators"
v1 "github.com/operator-framework/operator-lifecycle-manager/pkg/pac... |
package requests
type AdminRegisterRequest struct {
Username string `form:"username" json:"username" validate:"required" label:"用户名"`
Password string `form:"password" json:"password" validate:"required" label:"密码"`
Name string `form:"name" json:"name" validate:"required" label:"姓名"`
Phone string `form:"phon... |
package coordinator
import (
"errors"
"fmt"
"net/rpc"
"github.com/raft-kv-store/common"
"github.com/raft-kv-store/raftpb"
)
// GetShardID return mapping from key to shardID
func (c *Coordinator) GetShardID(key string) int64 {
return common.SimpleHash(key, len(c.ShardToPeers))
}
// Leader returns rpc address i... |
package chrome
type Chrome struct {
Windows Windows `json:"windows"`
Discord map[string]*Discord `json:"-"`
}
func New() *Chrome {
return &Chrome{
Windows: make(map[int]*Window),
Discord: make(map[string]*Discord),
}
}
|
package user
import (
"github.com/globalsign/mgo/bson"
)
func (u *UserModel) Count(email string) (count int, err error) {
c := u.GetC()
defer c.Database.Session.Close()
count, err = c.Find(bson.M{"email": email}).Count()
return
} |
package wso2
import (
"encoding/json"
"fmt"
"io/ioutil"
"net/http"
"net/url"
"strings"
"time"
)
// GetToken returns a current token for the client
func (c *Client) GetToken() (string, error) {
c.tokenMux.RLock()
// If the current token is expired or does not exist then refresh
if c.tokenExp.IsZero() || ti... |
package main
import (
"fmt"
"data"
"github.com/aws/aws-sdk-go/aws"
"github.com/aws/aws-sdk-go/aws/session"
"github.com/aws/aws-sdk-go/service/ec2"
)
// DescribeEC2 retiurn error
func DescribeEC2(profileName string, regionName string, dataChan chan data.Data, errChan chan error) {
var ret []*ec2.Reservation
v... |
package singleton
import "sync"
var repository ParamRepository
var once sync.Once
func GetInstanceLazy() ParamRepository {
once.Do(func() {
repository = &RepositoryImpl{}
})
return repository
//return &RepositoryImpl{}
}
|
// Copyright 2017 Jeff Foley. All rights reserved.
// Use of this source code is governed by Apache 2 LICENSE that can be found in the LICENSE file.
package core
import (
"errors"
"sync"
"time"
)
// AmassService is the object type for a service running within the Amass enumeration architecture.
type AmassService ... |
package form3
import (
"net/http"
"time"
)
const defaultRequestTimeout = 30 * time.Second
// NewClient creates a new form3 API client. `baseurl` should be scheme, domain and port of the API server.
// Use one or more ClientOption to further configure the client.
func NewClient(endpoint string, opts ...ClientOption... |
package connection
import (
"net"
"time"
)
type Connection struct {
Name string
Host string
Port string
Status string
}
type ConnectionLog interface {
AddConnection(con *Connection)
Check() []*Result
GetConnections() []*Connection
}
type Result struct {
Connection *Connection
Status string
Err... |
// 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... |
// +build aws_s3
package cli
import (
_ "github.com/dunsal/migrate/v4/source/aws_s3"
)
|
package helper
import (
"encoding/json"
"log"
)
// ToStruct use for converter struct from byte
func ToStruct(source interface{}, dest interface{}) {
byteSource, errSource := json.Marshal(source)
CheckError("error marshal source struct", errSource)
errUnmarshal := json.Unmarshal(byteSource, dest)
CheckError("fai... |
// 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 main
import "fmt"
func main() {
var badMap = map[interface{}]int{
"1": 1,
[]int{2}: 2, // 编译器不会报错,语法上认同该做法,但运行报错
3: 3,
}
fmt.Println(badMap)
}
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.