text stringlengths 11 4.05M |
|---|
// This file was generated for SObject ActionLinkTemplate, API Version v43.0 at 2018-07-30 03:47:58.55727601 -0400 EDT m=+44.901567272
package sobjects
import (
"fmt"
"strings"
)
type ActionLinkTemplate struct {
BaseSObject
ActionLinkGroupTemplateId string `force:",omitempty"`
ActionUrl string `... |
package main
import (
"fmt"
"os"
"strconv"
"github.com/hackebrot/gofizzbuzz/gofizzbuzz"
)
func main() {
for _, s := range os.Args[1:] {
i, err := strconv.Atoi(s)
if err == nil {
w := gofizzbuzz.GoFizzBuzz(i)
fmt.Println(w)
}
}
}
|
package data
type Category struct {
Id int
Status int
Order int
Name string
Color string
Pics string
}
|
package main
func main() {
}
func firstUniqChar(s string) byte {
mm := make(map[rune]int)
for _, v := range s {
mm[v]++
}
for _, v := range s {
if mm[v] == 1 {
return byte(v)
}
}
return ' '
}
|
// Package main - задание четвертого урока для курса go-core.
package main
import (
"fmt"
"go.core/lesson4/pkg/crawler"
"go.core/lesson4/pkg/crawler/spider"
"go.core/lesson4/pkg/document"
"go.core/lesson4/pkg/index"
"sort"
"strings"
)
func main() {
urls := []string{"https://golangs.org", "https://altech.onlin... |
// Copyright 2020 MongoDB 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 main
import (
"fmt"
"log"
"time"
"github.com/shanghuiyang/rpi-devices/dev"
"github.com/stianeikeland/go-rpio"
)
const (
pinTrig = 21
pinEcho = 26
)
func main() {
if err := rpio.Open(); err != nil {
log.Fatalf("failed to open rpio, error: %v", err)
return
}
defer rpio.Close()
hcsr04 := dev.Ne... |
package agent
import (
"context"
"net"
"net/url"
"github.com/go-openapi/strfmt"
"github.com/pkg/errors"
"github.com/sirupsen/logrus"
"github.com/openshift/assisted-service/api/v1beta1"
"github.com/openshift/assisted-service/client"
"github.com/openshift/assisted-service/client/events"
"github.com/openshift... |
package binance
import (
"testing"
"github.com/stretchr/testify/suite"
)
type userUniversalTransferTestSuite struct {
baseTestSuite
}
func TestUserUniversalTransferService(t *testing.T) {
suite.Run(t, new(userUniversalTransferTestSuite))
}
func (s *userUniversalTransferTestSuite) TestUserUniversalTransfer() {
... |
package main
import (
"fmt"
"io/ioutil"
"net/http"
"os"
"strings"
"time"
"github.com/gocolly/colly"
)
const economistBaseURL = "https://www.economist.com"
type section struct {
title string
articleLinks []string
}
func main() {
// step 1 : get latest weekly URL
urlSuffix, date := getLatestWeeklyE... |
// 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 law or agreed to in writing... |
/*
# -*- coding: utf-8 -*-
# @Author : joker
# @Time : 2021/8/22 1:01 下午
# @File : bench.go
# @Description :
# @Attention :
*/
package main
import (
"fmt"
"reflect"
"sync"
"testing"
)
var funcs = []struct {
name string
f func(...<-chan int) <-chan int
}{
{"goroutines", goroutine},
{"goroutineMerge", mergeN... |
package main
import (
"encoding/json"
"fmt"
"github.com/samuel/go-zookeeper/zk"
"testing"
"time"
client2 "zookeeper/client"
)
var client *client2.SdClient
// 自己客户端的服务地址,
// 只注册自己能提供的服务,
// 如果注册其它IP提供的服务(这里可以做个限制,自动获取本机IP),那么其它IP服务是否可用自己不清楚
const Self_Node = "127.0.0.1"
func callback1(event zk.Event) {
//fmt.... |
package depot
import "sync"
// StockValue value from a stock
type StockValue struct {
Stock Stock
Close float32
Price float32
}
// StockValueList list of stock values
type StockValueList struct {
svl chan StockValue
cap int
ready int
sumYesterday float32
sumToday float32
//mutua... |
package tasks
import (
"bytes"
"io"
"os"
"os/exec"
)
// ExecCommandTask executes a specified console command
type ExecCommandTask struct {
RunnableTask
}
func (task ExecCommandTask) GetDescription() (description string) {
return task.Description
}
func (t ExecCommandTask) Execute() (result Result) {
command ... |
// Package docs GENERATED BY THE COMMAND ABOVE; DO NOT EDIT
// This file was generated by swaggo/swag
package docs
import (
"bytes"
"encoding/json"
"strings"
"text/template"
"github.com/swaggo/swag"
)
var doc = `{
"schemes": {{ marshal .Schemes }},
"swagger": "2.0",
"info": {
"description": ... |
package jdatabase
import (
"database/sql"
"encoding/json"
"fmt"
"github.com/ijidan/jgo/jgo/jconfig"
"github.com/ijidan/jgo/jgo/jlogger"
"github.com/ijidan/jgo/jgo/jutils"
"reflect"
"strconv"
"strings"
)
//活动记录
type ActiveRecord struct {
isManualClose bool
isDebug bool
connect *sql.DB
model ... |
package checks
import (
"fmt"
"os/exec"
"plugins"
)
type ExternalCheck struct {
command string
name string
checkStatus plugins.Status
}
func (ec *ExternalCheck) Init(config plugins.PluginConfig) (string, error) {
// make sure that the command exists?
ec.name = config.Name
ec.command = config.Comm... |
package main
import (
"bufio"
"encoding/binary"
"encoding/hex"
"encoding/json"
"errors"
"fmt"
"io"
"math"
"net"
"os"
"regexp"
"runtime"
"strconv"
"strings"
"time"
"github.com/fatih/color"
"github.com/gordonklaus/portaudio"
rpio "github.com/stianeikeland/go-rpio"
"github.com/tarm/serial"
"golang.or... |
package main
import "fmt"
type concert interface {
getPrice() int
}
type ticket struct {
}
func (t *ticket) getPrice() int {
return 10000
}
type vipZone struct {
concert concert
}
func (o *vipZone) getPrice() int {
ticketPrice := o.concert.getPrice()
return ticketPrice + 6000
}
type armyBomb struct {
conce... |
package types
import (
"math"
"testing"
sdk "github.com/irisnet/irishub/types"
"github.com/stretchr/testify/require"
)
func TestValidateParams(t *testing.T) {
tests := []struct {
testCase string
Params
expectPass bool
}{
{"Minimum value",
Params{
AssetTaxRate: sdk.ZeroDec(),
MintToke... |
package ibm
import (
"fmt"
"testing"
)
const (
ibmTranslatorBaseURL = "https://gateway.watsonplatform.net/"
ibmTranslatorAPIKey = "0X0NrhL0wUYsDmWKAAIegoUhOcUp3cazYNz6-Rv-81uJ"
)
func Test_Translate(t *testing.T) {
tr, err := NewIBMTranslatorClient(ibmTranslatorBaseURL, ibmTranslatorAPIKey, 5)
if err != nil {... |
package models
// init 初始化
func init() {
// orm.RegisterModel(new(User), new(Profile))
}
|
package db
import (
"godis/src/datastruct/dict"
List "godis/src/datastruct/list"
"godis/src/datastruct/lock"
"sync"
"time"
)
type DataEntity struct {
Data interface{}
}
const (
dataDictSize = 1 << 16
ttlDictSize = 1 << 10
lockerSize = 128
aofQueueSize = 1 << 16
)
type DB struct {
Data dict.Dict
TTLM... |
package process
type CNC struct{
Station
}
func (x CNC) StateNum() string {
return "No.1"
}
func (x CNC) Machine() string {
return "Milling machine"
} |
/*
Package pageContext "Every package should have a package comment, a block comment preceding
the package clause.
For multi-file packages, the package comment only needs to be present in one file, and any
one will do. The package comment should introduce the package and provide information
relevant to the package as a... |
package str2int
import "testing"
func TestSolve(t *testing.T) {
result, err := Atoi("01")
if err != nil {
t.Log(err)
}
t.Log(result)
}
|
/*
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 main
import (
"bufio"
"fmt"
"os"
"strconv"
"strings"
)
func main() {
scan := scanner()
cnt := scan()
for i := 0; i < cnt; i++ {
n := scan()
// 5a + 3b = n
a := 0
found := false
for a <= n/5 && !found {
b := 0
for b <= n/3 {
sum := a*5 + b*3
if sum < n {
b++
} else if ... |
package v1
type Dictionary map[string]string
func (dict Dictionary) Search(key string) string {
return dict[key]
}
|
package main
import (
"fmt"
"github.com/oho-sugu/graphdb"
)
func main() {
db, _ := graphdb.Open("celegans.db")
start := db.GetNode(NEURON, no2ID("0"))
edges := db.GetNodesEdge(start)
for _, edge := range edges {
fmt.Println(graphdb.Byte2string(edge.To))
}
}
|
package pg
import (
"database/sql"
"fmt"
. "grm-searcher/types"
. "grm-service/dbcentral/pg"
"strings"
)
type DataDB struct {
DataCentralDB
}
func (db DataDB) GetTableData(r SearchInfo) (*TableData, error) {
var tableData TableData
var tableName, sqlStr string
tableName = fmt.Sprintf(`"ftr-%s"`, r.DataId)... |
package db
import (
"fmt"
"time"
"github.com/kotakanbe/goval-dictionary/db/rdb"
"github.com/kotakanbe/goval-dictionary/models"
)
// DB is interface for a database driver
type DB interface {
Name() string
NewOvalDB(string) error
CloseDB() error
GetByPackName(string, string) ([]models.Definition, error)
GetBy... |
package executor
import "github.com/alehatsman/mooncake/internal/logger"
type ExecutionContext struct {
Variables map[string]interface{}
CurrentDir string
CurrentFile string
Level int
Logger *logger.Logger
SudoPass string
}
func (ec *ExecutionContext) Copy() ExecutionContext {
newVariables :=... |
package main
import (
"sync/atomic"
"fmt"
"runtime"
"sync"
)
func test(c chan int) {
c <- 'A'
}
func testDeadLock(c chan int) {
for {
fmt.Println(<-c)
}
}
var (
count int32
wg sync.WaitGroup
)
func main() {
// c := make(chan int)
// go test(c)
// go testDeadLock(c)
/... |
package main
import (
"flag"
"fmt"
)
type Config struct {
Auth string `toml:"auth"`
Bind string `toml:"bind"`
Ca string `toml:"ca,omitempty"`
Cert string `toml:"cert"`
Key string `toml:"key"`
}
func newConfig() *Config {
return &Config{
Auth: "localhost:8080",
Bind: ":8082",
Ca: "../tls_setup/cert... |
package local
import (
"fmt"
"runtime"
"testing"
)
func TestFindingTests(t *testing.T) {
p, err := NewProject("testdata/cases")
if err != nil {
t.Fatal(err)
}
if err := p.Init(); err != nil {
t.Fatal(err)
}
var expected []Result
switch runtime.GOOS {
case "darwin":
expected = []Result{
{Name: "te... |
package structs
type Service struct {
Name string `json:"name"`
Stack string `json:"-"`
Status string `json:"status"`
StatusReason string `json:"status-reason"`
Type string `json:"type"`
Apps Apps `json:"apps"`
Exports map[string]string `json:"exports"`
Outputs ... |
package blevebench
import (
"github.com/blevesearch/bleve"
"github.com/blevesearch/bleve/mapping"
)
// BuildArticleMapping returns a mapping for indexing wikipedia articles
// in a manner similar to that done by lucene nightly benchmarks
func BuildArticleMapping() mapping.IndexMapping {
// a generic reusable mapp... |
// Copyright 2020 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 golang
type FreqRecord struct {
accFreq int
freq int
val int
}
func sampleStats(count []int) []float64 {
record := make([]FreqRecord, 0)
sum, minimum, maximum, mode, maxFreq, accFreq :=
0, 256, -1, 0, 0, 0
for i := 0; i < 256; i++ {
if count[i] == 0 {
continue
}
sum += i * count[i]
... |
package form
import (
"bytes"
"github.com/astaxie/beego/logs"
"text/template"
)
type RadioInput struct {
Name string
Options []SelectOption
}
func (r *RadioInput) String() string {
html := `{{with and ($name := .Name) ($options := .Options)}}{{range $option := $options}}<input type="radio" name="{{$name}}" ... |
/*
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 primitives
const VERTEX_SIZE = 10
type Vertex struct {
position Vec4
color Vec4
uv Vec2
} |
package ejbcarest
import "time"
// PKCS10EnrolRequest represents data to send to enrol certificate using PKCS#10.
type PKCS10EnrolRequest struct {
CSR string `json:"certificate_request"`
CertificateProfileName string `json:"certificate_profile_name"`
EndEntityProfileName string `json:"end_enti... |
/*
Every number of the form 2i (where i is a non-negative integer) has a single 1 in its binary representation.
Given such a number, output the 1-based position of the 1.
Examples:
DECIMAL BINARY POSITION
--------------------------
1 0001 1
2 0010 2
4 0100 3
8 ... |
package parser
import (
"errors"
"strings"
)
type reader struct {
position int
readAheadPosition int
readAheadCalled bool
tokens []string
parensCount int
bracketsCount int
bracesCount int
}
func newReader(tokens []string) *reader {
reader := reader{tokens: tokens}
ret... |
package main
import (
"bufio"
"encoding/json"
"fmt"
"io"
"log"
"os"
"os/exec"
"syscall"
"unicode"
"github.com/vincent-petithory/structfield"
)
// Header defines the struct of the header in the i3bar protocol.
type Header struct {
Version int `json:"version"`
StopSignal int `json:"stop_signal,omite... |
package client
import (
"gopkg.in/resty.v0"
"github.com/slawek87/GOstorageClient/conf"
"errors"
"io"
"bytes"
"mime/multipart"
"os"
"strings"
)
type GOrequest struct{}
// method returns resty instance with already set BasicAuth token.
func (goRequest *GOrequest) resty() *resty.Request {
request := resty.R()
... |
package conf
import (
"log"
"strings"
"github.com/Maxgis/ToyBrick/util"
"github.com/go-ini/ini"
)
type Config struct {
Port int
IsOpenReferrer bool
ReferrerWhiteList []string
IsOpenDomainWhitelist bool
DomainWhitelist []string
IsOpenAdmin bool
AdminPort ... |
package mt
import (
"bytes"
"encoding/json"
"errors"
"fmt"
"strconv"
)
func (tc ToolCaps) String() string {
b, err := tc.MarshalJSON()
if err != nil {
panic(err)
}
return string(b)
}
func (tc ToolCaps) MarshalJSON() ([]byte, error) {
if !tc.NonNil {
return []byte("null"), nil
}
var dgs bytes.Buffer... |
package main
import "math"
//dp from bottom to top
func minimumTotal(triangle [][]int) int {
for i := len(triangle)-2;i>=0;i--{
for j :=0;j< len(triangle[i]);j++{
triangle[i][j] += int(math.Min(float64(triangle[i+1][j]),float64(triangle[i+1][j+1])))
}
}
return triangle[0][0]
}
|
package middlewares
import "github.com/gin-gonic/gin"
func BasicAuth() gin.HandlerFunc {
return gin.BasicAuth(gin.Accounts{
"fabio": "torino",
})
}
|
package creds
import (
"time"
"github.com/aws/aws-sdk-go/aws"
"github.com/aws/aws-sdk-go/aws/credentials"
"github.com/aws/aws-sdk-go/aws/credentials/ec2rolecreds"
"github.com/aws/aws-sdk-go/aws/session"
"github.com/aws/aws-sdk-go/service/sts"
)
type AwsCredentialGetter interface {
GetCreds() (credentials.Valu... |
package parser
import (
"testing"
"github.com/stretchr/testify/assert"
)
func TestAddDefaultClientCertificateRule(t *testing.T) {
var p Policy
p.AddDefaultClientCertificateRule()
assert.Equal(t, Policy{
Rules: []Rule{{
Action: ActionDeny,
Or: []Criterion{
{Name: "invalid_client_certificate"},
},
... |
package task
import (
"fmt"
"sync/atomic"
"time"
)
// ID is a unique Task identifier
type ID uint64
// State represents current state of the Task
type State int
// FailedBehavior defines behavior in case that Task execution fails
type FailedBehavior int
// Task state
const (
TaskStateNew State = iota
TaskStat... |
package article
import (
"github.com/hardstylez72/bblog/internal/storage/article"
)
func NewGetArticlesByPeriodResponse(in []article.Article) []Article {
out := make([]Article, 0, len(in))
for _, i := range in {
el := Article{
Id: i.Id,
Preface: i.Preface,
Title: i.Title,
UserId: i.Us... |
package main
import "fmt"
import "strings"
func main() {
str := " aaa \n\t"
fmt.Println(strings.TrimSpace(str))
} |
// Copyright (C) 2019 rameshvk. All rights reserved.
// Use of this source code is governed by a MIT-style license
// that can be found in the LICENSE file.
package match_test
import (
"go/parser"
"go/token"
"path"
"runtime"
"testing"
"github.com/tvastar/gogo/pkg/match"
)
func TestMatcherOnItself(t *testing.T... |
package hash
import (
"github.com/plandem/xlsx/internal/ml"
"strings"
)
//StringItem return string with values of ml.StringItem
func StringItem(si *ml.StringItem) Key {
if si == nil {
si = &ml.StringItem{}
}
result := []string{
string(si.Text),
string(Reserved(si.PhoneticPr)),
}
if si.RPh != nil {
fo... |
package obs
import (
"errors"
"strings"
"time"
)
// MonitorConfig stores the configuration for the monitor.
type MonitorConfig struct {
Enabled bool `json:"enabled" yaml:"enabled"`
PrometheusEndpoint string `json:"prometheus-endpoint" yaml:"prometheus-endpoint... |
package handlers
type InvalidArgument struct {
Message string
}
func (e InvalidArgument) Error() string {
return e.Message
}
type RequiredValueError struct {
Message string
}
func (e RequiredValueError) Error() string {
return e.Message
}
type UnexpectedError struct {
Message string
error
}
type Unauthorize... |
package demo10_UDP通信
import (
"sync"
"time"
)
var wg sync.WaitGroup
func UDPConn() {
wg.Add(2)
go udpServer()
time.Sleep(time.Second * 3)
go udpClient()
wg.Wait()
}
|
package main
import (
"encoding/csv"
"fmt"
"github.com/ziutek/mymysql/mysql"
"log"
"net"
"os"
"strconv"
"strings"
"time"
)
type mockConnection struct {
}
type mockResult struct {
reader *csv.Reader
isSolvesTable bool
limit int
counter int
}
func (self *mockConnection) Start(sql str... |
// +build windows
package redux
import (
"errors"
"os"
)
func statUidGid(finfo os.FileInfo) (uint32, uint32, error) {
return 0, 0, errors.New("finfo.Sys() is unsupported")
}
|
package c22_crack_mt19937_seed
import (
"math/rand"
"time"
"github.com/vodafon/cryptopals/set3/c21_mt19937"
)
func Number(seed uint32) uint32 {
mt := c21_mt19937.NewMT19937(seed)
waitRandom()
return mt.ExtractNumber()
}
func Exploit(num uint32) uint32 {
seed := uint32(time.Now().Unix())
for seed >= 0 {
if... |
package atlas
import "testing"
var (
file_25x100 = &File{FileName: "25x100", Width: 25, Height: 100}
file_50x50 = &File{FileName: "50x50", Width: 50, Height: 50}
file_50x300 = &File{FileName: "50x300", Width: 50, Height: 300}
file_100x100 = &File{FileName: "100x100", Width: 100, Height: 100}
file_200x200 = &... |
package sandbox
// @class Cube
// This is Cube, it operates on int32 and can compute areas
type Cube struct {
// Internal width value
width int32
// Internal height value
height int32
// Internal depth value
depth int32
}
// Constructor which creates a cube by taking three values in
// @param width The width ... |
package spec
import (
"os"
"testing"
"github.com/kaitai-io/kaitai_struct_go_runtime/kaitai"
"github.com/stretchr/testify/assert"
. "test_formats"
)
func TestProcessRotate(t *testing.T) {
f, err := os.Open("../../src/process_rotate.bin")
if err != nil {
t.Fatal(err)
}
s := kaitai.NewStream(f)
var r Proc... |
package logging
import (
"adminbot/framework"
"adminbot/config"
"github.com/bwmarrin/discordgo"
"fmt"
"encoding/json"
"io/ioutil"
"time"
"sync"
)
var Mu sync.Mutex
var Log map[string]int64
func StartLogging(ticker *time.Ticker){
for {
select {
case <- ticker.C:
... |
package main
import (
"flag"
"github.com/teploff/otus/hw_6/carbon"
"log"
)
var (
srsFilePath = flag.String("src", "full/source/file/path", "full path to src file")
destFilePath = flag.String("dest", "full/dest/file/path", "full path to dest file")
offset = flag.Int64("offset", 0, "offset count bytes from... |
package publisher
import (
"context"
"fmt"
"time"
"github.com/Shopify/sarama"
"github.com/golangid/candi/candihelper"
"github.com/golangid/candi/candishared"
"github.com/golangid/candi/logger"
"github.com/golangid/candi/tracer"
)
// KafkaPublisher kafka
type KafkaPublisher struct {
producer sarama.SyncProdu... |
package cli
import _ "github.com/joho/godotenv/autoload"
import (
"github.com/urfave/cli"
)
type CLIApp = cli.App
func CreateCLI(
config *Config,
) *CLIApp {
App := cli.NewApp()
App.Name = config.Name()
App.Usage = config.Description()
App.HelpName = config.HelpPrefix()
return App
}
func ProvideCLI(config ... |
package camt
import (
"encoding/xml"
"github.com/thought-machine/finance-messaging/iso20022"
)
type Document04100103 struct {
XMLName xml.Name `xml:"urn:iso:std:iso:20022:tech:xsd:camt.041.001.03 Document"`
Message *FundConfirmedCashForecastReportV03 `xml:"FndConfdCshFcstRptV03"`
}
fu... |
package piscine
func NRune(s string, n int) rune {
result := []rune(s) // кастинг - преобразование типов. перевод строки в массив рун
for index, value := range result { // перевод массив рун в символы (разбиваем на отдельные элементы )
if index == n-1 {
return value
}
}
return 0
}
|
package queue
import "time"
// A job to be run by a Queue.
type Job struct {
// Give jobs a key to ensure no more than one are queued at once.
Key string
// Wait this long before running the job. Combine with Key to debounce jobs.
Delay time.Duration
// Repeat job this long after it completes.
Repeat time.Dur... |
package gee
type RouterGroup struct {
prefix string
middlewares []HandlerFunc
parent *RouterGroup
engine *Engine
}
func (g *RouterGroup) Group(prefix string) *RouterGroup {
e := g.engine
newGroup := &RouterGroup{
prefix: g.prefix + prefix,
parent: g,
engine: e,
}
e.groups = append(e.group... |
package physics
import (
"github.com/bcokert/engo-test/logging"
"github.com/bcokert/engo-test/metrics"
)
// The ParticleRegistry stores all particles in some structure, and retrieves them for collision related logic
// This is where optimizations like quadtrees and other subdivisions would be done to rule out
// pa... |
package cert
import (
"fmt"
"github.com/cosmos/cosmos-sdk/client"
sdktest "github.com/cosmos/cosmos-sdk/testutil"
"github.com/ovrclk/akcmd/cmd/akash/x/cert/create"
clitestutil "github.com/ovrclk/akcmd/testutil/cli"
)
// TxCreateServerExec is used for testing create server certificate tx
func TxCreateServerExec(... |
package honeycombio
import (
"context"
"os"
"testing"
"github.com/joho/godotenv"
"github.com/stretchr/testify/assert"
)
func init() {
// load environment values from a .env, if available
_ = godotenv.Load()
}
func newTestClient(t *testing.T) *Client {
apiKey, ok := os.LookupEnv("HONEYCOMBIO_APIKEY")
if !ok... |
package schedule
import (
"booking-calendar/utils"
"time"
)
type DaySchedule struct {
startTime time.Time
endTime time.Time
}
func (daySchedule DaySchedule) Start() time.Time {
return daySchedule.startTime
}
func (daySchedule DaySchedule) End() time.Time {
return daySchedule.endTime
}
func (daySchedule Day... |
package main
import (
"fmt"
)
func main() {
fmt.Println(addDigits(27))
}
func addDigits(num int) int {
return (num-1)%9 + 1
}
|
package main
import (
"fmt"
"reflect"
"unsafe"
)
func main() {
var data []string // data is bunch of listed string
for record := 0; record < 1050; record ++{
data = append(data, fmt.Sprintf("Rec:%d", record)) // output: data => [ "Rec:0", "Rec:1", ...]
if record < 10 || record == 256 || record == 512 || ... |
package db
import (
"database/sql"
"log"
"user-bank-manage/config"
_ "github.com/go-sql-driver/mysql"
)
var db *sql.DB
var err error
func Init() {
conf := config.GetConfig()
// connectionString := "root:Padaringan_k383k@tcp(127.0.0.1:3306)/localpedia"
connectionString := conf.DB_USERNAME + ":" + conf.DB_PA... |
package main
import (
"fmt"
"strings"
)
func basename(s string) string {
slash := strings.LastIndex(s, "/") // -1 if "/" not found
s = s[slash+1:]
if dot := strings.LastIndex(s, "."); dot >= 0 {
s = s[:dot]
}
return s
}
func main() {
s := "abc"
b := []byte(s)
s2 := string(b)
fmt.Printf(s2)
}
|
package comment
type Mock struct {
Interface
}
func NewMock() *Mock {
return &Mock{}
}
func (s *Mock) Add(id string, comment *Model) error {
comment.Id = "b2ff6329-9023-4776-a0ed-ff5fa98a888d"
return nil
}
func (s *Mock) Delete(id string) error {
return nil
}
|
package dynamic_programming
import (
"fmt"
"testing"
)
func Test_minDistance(t *testing.T) {
// res := minDistance("horse", "ros")
res := minDistance2("", "")
fmt.Println(res)
}
|
package router
import (
"net/http"
"project/utils/config"
admin "project/app/admin/router"
"project/common/middleware"
"project/utils"
//_ "project/docs"
"github.com/gin-contrib/pprof"
"github.com/gin-gonic/gin"
ginSwagger "github.com/swaggo/gin-swagger"
"github.com/swaggo/gin-swagger/swaggerFiles"
)
// ... |
/*
Given an unsigned integer that represents a timestamp since 1970/01/01 00:00:00 (which is Unix epoch time), output one of these:
An array that stores year, month, date, hour, minute, second.
A string in format YYYYMMDDHHmmss.
Or whatever similar, as long as it complies with standard i/o rules.
Rules
... |
package domain
import (
"testing"
"github.com/gofrs/uuid"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/mock"
)
type ReservoirServiceMock struct {
mock.Mock
}
func (m *ReservoirServiceMock) FindFarmByID(uid uuid.UUID) (ReservoirFarmServiceResult, error) {
args := m.Called(uid)
return args... |
package easypost
import (
"context"
"encoding/json"
"io"
"io/ioutil"
"net/http"
"net/url"
"strings"
)
// A BetaPaymentRefund that has the refund details for the refund request.
type BetaPaymentRefund struct {
RefundedAmount int `json:"refunded_amount,omitempty"`
RefundedPaymentLogs []string `js... |
package main
import (
"errors"
"testing"
"github.com/aws/aws-sdk-go/aws/awserr"
"github.com/aws/aws-sdk-go/service/cognitoidentityprovider"
"github.com/aws/aws-sdk-go/service/cognitoidentityprovider/cognitoidentityprovideriface"
)
type mockDelete struct {
cognitoidentityprovideriface.CognitoIdentityProviderAPI... |
package main
import (
"time"
)
const ENDLESS = 99999 * time.Hour
type TransitionFSM struct {
next NextStateFunc
doTransition bool
}
func (fsm *TransitionFSM) Setup(doTransition bool, next NextStateFunc) {
fsm.doTransition = doTransition
fsm.next = next
}
type NextRoomFSM struct {
}
type GameOverAllFS... |
package cluster
// Copyright (c) Microsoft Corporation.
// Licensed under the Apache License 2.0.
import (
"context"
"net/http"
"github.com/Azure/go-autorest/autorest/azure"
"github.com/sirupsen/logrus"
"k8s.io/client-go/kubernetes"
"github.com/Azure/ARO-RP/pkg/api"
"github.com/Azure/ARO-RP/pkg/env"
"github... |
package acl
import (
"io"
)
func unpackTSV(r io.Reader) (map[string][]byte, string, error) {
files := map[string][]byte{}
uname := ""
if bytes, err := io.ReadAll(r); err != nil {
return nil, "", err
} else {
files["ACL"] = bytes
}
files["signature"] = []byte{}
return files, uname, nil
}
|
/*
Output the following result (which is a result of calculating 6 * 9 in bases from 2 to 36). Make sure letters are uppercase, and the multiplication itself is outputed on every line.
6 * 9 = 110110
6 * 9 = 2000
6 * 9 = 312
6 * 9 = 204
6 * 9 = 130
6 * 9 = 105
6 * 9 = 66
6 * 9 = 60
6 * 9 = 54
6 * 9 = 4A
6 * 9 = 46
6 ... |
package mygl
import (
"io"
"os"
"path"
"reflect"
"testing"
"time"
)
const (
testFileDir = "test_files"
)
func assertFile(t *testing.T, filename string, expected []*Entry) {
f, err := os.Open(path.Join(testFileDir, filename))
if err != nil {
t.Fatalf("unable to open test file %s for reading, %v", filename,... |
package setting
import (
"database/sql"
"github.com/SUCHMOKUO/falcon-ws/util"
"log"
"path/filepath"
)
var (
db *sql.DB
)
func init() {
prepareDB()
initTable()
}
func prepareDB() {
dbPath := filepath.Join(util.GetCurrentPath(), "setting.db")
var err error
db, err = sql.Open("sqlite3", dbPath)
if err != ni... |
package main
import "fmt"
func main(){
// arrays
var fruitArray [2] string
// assign values
fruitArray[0] = "apples"
fruitArray[1] = "oranges"
fmt.Println(fruitArray)
fmt.Println(fruitArray[0])
fmt.Println(fruitArray[1])
// declare and assign
fruitArrayTwo := [2]string{"watermelon", "grapes"}
fmt.P... |
package common
import (
"testing"
"github.com/stretchr/testify/assert"
)
func TestKhoriumStepBuildEnvironmentVariables(t *testing.T) {
assert := assert.New(t)
ks := &KhoriumStep{
Name: "test",
Description: "test",
Inputs: map[string]*KhoriumStepInput{
"input1": {
Description: "input1",
D... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.