text stringlengths 11 4.05M |
|---|
package ds
import (
"testing"
)
func TestAdd(t *testing.T) {
list := MyList{data: "1"}
list.Add(MyList{data: "2"})
list.Add(MyList{data: "3"})
if list.Length() != 3 {
t.Errorf("list.Length() == %v, want %v", list.Length(), 3)
}
}
|
package handler
import (
"fmt"
"github.com/hashicorp/hcl/v2/hclwrite"
"go.mercari.io/hcledit/internal/ast"
)
type BlockVal struct {
Labels []string
}
type blockHandler struct {
labels []string
}
func newBlockHandler(labels []string) (Handler, error) {
return &blockHandler{
labels: labels,
}, nil
}
func ... |
package cmd
const VersionLabel = "2.0.29-softlayer-1f8ec43-2017-07-19"
|
package main
import (
"fmt"
"github.com/jackytck/projecteuler/tools"
)
func solve() (int, int) {
var numerators []int
var denominators []int
for i := 11; i < 100; i++ {
for j := 10; j < i; j++ {
// j/i == ab/cd
a, b := tools.Divmod(j, 10)
c, d := tools.Divmod(i, 10)
//trivial
if b == 0 && d == ... |
package pingpong
import (
"coms4113/hw5/pkg/base"
"testing"
)
func TestHashAndEqual(t *testing.T) {
s1 := base.NewState(0, true, true)
server := NewServer(false, true)
s1.AddNode("server", server, nil)
client := NewClient("client", "server", 5, true)
s1.AddNode("client", client, nil)
client.SendCommand(s1,... |
package main
import (
"context"
"crypto/tls"
"crypto/x509"
"fmt"
"os"
"time"
"github.com/yandex-cloud/ydb-go-sdk"
"github.com/yandex-cloud/ydb-go-sdk/auth/iam"
"github.com/yandex-cloud/ydb-go-sdk/table"
)
var (
driver ydb.Driver
tableClient *table.Client
sessPool *table.SessionPool
db s... |
package main
import "fmt"
func vals() (int, string) { // don't forget comma
return 1, "freestyle"
}
func main() {
num, str := vals()
fmt.Println(num)
fmt.Println(str)
_, res := vals()
fmt.Println(res)
}
|
// Copyright 2018 The go-bindata Authors. All rights reserved.
// Use of this source code is governed by a CC0 1.0 Universal (CC0 1.0)
// Public Domain Dedication license that can be found in the LICENSE file.
package bindata
import (
"io"
)
const lowerHex = "0123456789abcdef"
// stringWriter define a writer to wr... |
package hat_test
import (
"net/http"
"net/http/httptest"
"net/url"
"testing"
"github.com/stretchr/testify/require"
"go.coder.com/hat"
"go.coder.com/hat/asshat"
)
func TestURLParams(t *testing.T) {
t.Parallel()
req, err := http.NewRequest("GET", "http://google.com", nil)
require.NoError(t, err)
hat.URLP... |
package main
import (
"fmt"
"golang.org/x/exp/io/i2c"
"time"
)
const (
TEMP_NO_HOLD = byte(0xF3)
HUMIDITY = byte(0xF5)
)
func check(err error) {
if err != nil {
panic(err)
}
}
func waitForRead() {
time.Sleep(500 * time.Millisecond)
}
func getTemp(d i2c.Device) (float64, float64) {
err := d.Write([]b... |
package markers
import "testing"
// TestMarkersEval tests evaluating several instances of our expression language.
func TestMarkersEval(t *testing.T) {
// Aside: the if true {} block is used to make := vs = usage consistent
// Aside: this could be abstracted in several ways, but I prefer to make
// tests as unabst... |
// Package auth provides an API to use GraphJin serv auth handles with your own application. Works with routers like chi and http mux.
// For detailed documentation visit https://graphjin.com
//
// Example usage:
/*
package main
import (
"net/http"
"path/filepath"
"github.com/go-chi/chi"
"github.com/dosco/gr... |
package sudoku
import (
"fmt"
"math/rand"
)
type pointingPairTechnique struct {
*basicSolveTechnique
}
func (self *pointingPairTechnique) humanLikelihood(step *SolveStep) float64 {
return self.difficultyHelper(50.0)
}
func (self *pointingPairTechnique) Description(step *SolveStep) string {
if len(step.TargetNu... |
package main
import (
"fmt"
"unicode/utf8"
)
type (
City string
B0 int8
B1 int16
B2 int32
B3 int64
)
func main() {
city := City("sda")
fmt.Println(city)
fmt.Println(B0(2))
fmt.Println(B1(2))
fmt.Println(B3(2))
fmt.Println(B2(2) / B2(B0(2)))
n := utf8.RuneCountInString("😂😄")
fmt.Println(n)
}
|
package selapi
import (
"encoding/json"
"github.com/ktsstudio/selectel-exporter/pkg/apperrors"
"net/http"
)
type BalanceResponse struct {
Status string `json:"status"`
Data struct {
Currency string `json:"currency"`
IsPostpay bool `json:"is_postpay"`
Discount int `json:"discount"`
Primary stru... |
/*
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 api
import (
"github.com/gophergala2016/source/core/models"
"github.com/gophergala2016/source/internal/facades"
"github.com/gophergala2016/source/internal/modules/parameters"
"github.com/gophergala2016/source/internal/modules/responses"
)
type APIUserController struct {
APIRootController
}
type APIMeCon... |
package commands
import (
"bufio"
"bytes"
"crypto/tls"
"crypto/x509"
"fmt"
syslog "log"
"os"
"path/filepath"
"strings"
"time"
"github.com/aws/aws-sdk-go/aws/credentials"
paho "github.com/eclipse/paho.mqtt.golang"
"github.com/uhppoted/uhppote-core/uhppote"
"github.com/uhppoted/uhppoted-lib/config"
"git... |
package problem0328
import "testing"
func TestSolve(t *testing.T) {
node1 := &ListNode{Val: 1}
node2 := &ListNode{Val: 2}
node3 := &ListNode{Val: 3}
node4 := &ListNode{Val: 4}
node5 := &ListNode{Val: 5}
node1.Next = node2
node2.Next = node3
node3.Next = node4
node4.Next = node5
result := oddEvenList(node1)
... |
package routes
import (
"phonebook_rest_api/controllers"
"github.com/gofiber/fiber/v2"
)
func ContactsRoute(route fiber.Router) {
route.Get("/", controllers.GetAllContacts)
route.Get("/:id", controllers.GetContact)
route.Post("/", controllers.AddContact)
route.Delete("/:id", controllers.DeleteContact)
route.P... |
package main
import _ "github.com/huaweicse/auth/adaptor/gochassis"
import (
"net/http"
_ "net/http/pprof"
_ "code.huawei.com/cse/assets/consumer-gosdk/schemas/rest"
"github.com/go-chassis/go-chassis"
_ "github.com/go-chassis/go-chassis/configcenter"
"github.com/go-chassis/go-chassis/core/lager"
_ "github.com... |
package main
import "fmt"
type Student struct {
id int
name string
score int
}
//结构体数组作为函数参数
//结构体切片作为函数参数
func Sort(arr []Student) {
//外层控制行
for i := 0; i < len(arr)-1; i++ {
//内层控制列
for j := 0; j < len(arr)-1-i; j++ {
//满足条件 进行交换 大于 升序 小于 降序
if arr[j].score < arr[j+1].score {
//交换数据
a... |
package game
import (
"strings"
"awesome-dragon.science/go/goGoGameBot/internal/config/tomlconf"
"awesome-dragon.science/go/goGoGameBot/internal/interfaces"
"awesome-dragon.science/go/goGoGameBot/pkg/format"
"awesome-dragon.science/go/goGoGameBot/pkg/format/transformer"
"awesome-dragon.science/go/goGoGameBot/pk... |
package main
import (
"encoding/json"
"fmt"
"log"
"net/http"
"os"
"time"
)
func getDuration(name string, defval time.Duration) time.Duration {
val := os.Getenv(name)
if val != "" {
result, err := time.ParseDuration(val)
if err != nil {
panic(err)
} else {
return result
}
}
return defval
}
var... |
package main
//go:generate protoc --go_out=../.. --proto_path $PROTO_PATH $PROTO_PATH/Measurement.proto
import (
"flag"
"log"
MQTT "github.com/eclipse/paho.mqtt.golang"
"github.com/golang/protobuf/proto"
"gophers.ac/domain/measurements"
)
var averageTemperatures = map[string]float64{}
func measurementHandler(... |
package commands
import (
"context"
"fmt"
"io"
"os"
"strings"
"text/tabwriter"
"time"
"github.com/docker/buildx/store"
"github.com/docker/buildx/util/platformutil"
"github.com/docker/cli/cli"
"github.com/docker/cli/cli/command"
"github.com/moby/buildkit/util/appcontext"
"github.com/spf13/cobra"
"golang.... |
// +build integration
package main
import (
"database/sql"
"fmt"
"log"
"os"
"testing"
_ "github.com/lib/pq"
"github.com/ory/dockertest"
)
func dbURLFromResource(r *dockertest.Resource) string {
port := r.GetPort("5432/tcp")
return fmt.Sprintf("postgres://%v:%v@%v:%v/%v?sslmode=disable",
"user",
"passwo... |
/*
Copyright 2015 Google Inc. All rights reserved.
Use of this source code is governed by a BSD-style
license that can be found in the LICENSE file or at
https://developers.google.com/open-source/licenses/bsd
*/
package cups
/*
#cgo LDFLAGS: -lcups
#include <cups/cups.h>
#include <stddef.h> // size_t
#include <s... |
package ircserver
import (
"strconv"
"time"
"gopkg.in/sorcix/irc.v2"
)
func init() {
Commands["TOPIC"] = &ircCommand{
Func: (*IRCServer).cmdTopic,
MinParams: 1,
}
}
func (i *IRCServer) cmdTopic(s *Session, reply *Replyctx, msg *irc.Message) {
channel := msg.Params[0]
c, ok := i.channels[ChanToLower(... |
// Copyright (c) 2015, Emir Pasic. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
// Package containers provides core interfaces and functions for data structures.
//
// Container is the base interface for all data structures to implement.
/... |
package phace
// Photo record in the library, references an image on disk.
type Photo struct {
UUID string `db:"uuid"`
MasterUUID string `db:"masterUuid"`
Fingerprint string `db:"fingerprint"`
// Path to the image on disk, relative to the library root.
Path string `db:"imagePath"`
Height int `db:"master... |
package sgf
import (
"fmt"
"os"
"strconv"
"strings"
)
const alpha = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"
// NewTree returns a root node for a game of the given board size, with various
// sensible properties.
func NewTree(size int) *Node {
// Creates a new root node with standard properties.
... |
package main
import (
"fmt"
request "github.com/sniperkit/colly-request/pkg"
http_backoff "github.com/sniperkit/colly-request/plugin/backoff"
)
const wrapperIdentifier = "xcolly-backoff-request"
func main() {
fmt.Println("Running '%s' example...", wrapperIdentifier)
}
|
package main
import "fmt"
func max2(a, b int) int {
if a > b {
return a
}
return b
}
func maxSubArray(nums []int) int {
if len(nums) == 0 {
return 0
}
maxSum := nums[0]
sum := 0
end := 0
for end < len(nums) {
if nums[end]+sum < 0 {
maxSum = max2(maxSum, sum+nums[end])
end++
sum = 0
con... |
package leetcode
/*Given n and m which are the dimensions of a matrix,
which initialized by zeros
and given an array indices where indices[i] = [ri, ci].
For each pair of [ri, ci] you have to increment all cells in row ri and column ci by 1.
Return the number of cells with odd values in the matrix after applying the i... |
package types
import (
"github.com/dispatchlabs/disgo_commons/constants"
"encoding/hex"
"encoding/json"
"github.com/dispatchlabs/disgo_commons/crypto"
)
// WalletAccount
type WalletAccount struct {
Id string
Address [constants.AddressLength]byte
Name string
Balance int64
}
// NewWalletAccount
func Ne... |
package config
type Config struct {
Port string
DatabaseURL string
}
func GetConfig() *Config {
return &Config{
Port: ":5000",
DatabaseURL: "./db/db.sqlite",
}
}
|
package main
import (
"time"
"github.com/PuerkitoBio/goquery"
"fmt"
"regexp"
"strings"
"strconv"
)
type Store struct {
Id string `json: "id"`
Name string `json: "name"`
Url string `json: "url"`
Currency string `json: "currency"`
Description... |
// This file was generated for SObject EmailServicesFunction, API Version v43.0 at 2018-07-30 03:47:49.931568044 -0400 EDT m=+36.275535636
package sobjects
import (
"fmt"
"strings"
)
type EmailServicesFunction struct {
BaseSObject
AddressInactiveAction string `force:",omitempty"`
ApexClassId ... |
package util
func Rand() int {
return 1+1
}
|
package main
import (
"fmt"
shared "github.com/corymurphy/adventofcode/shared"
)
func main() {
input := shared.ReadInput("input")
part1 := part1(input)
part2 := part2(input)
fmt.Printf("\nPart 1 answer: %d\n\n", part1)
fmt.Printf("\nPart 2 answer: %d\n\n", part2)
}
func countOccurrences(char rune, input st... |
// Copyright 2020-2021 Buf Technologies, 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... |
/*
Copyright © 2020 Vlad Krava <vkrava4@gmail.com>
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 深度优先搜索
var isVisit map[int]bool
func canVisitAllRooms(rooms [][]int) bool {
if len(rooms) == 0 {
return true
}
isVisit = make(map[int]bool)
canVisitAllRoomsExec(rooms, 0)
return len(rooms) == len(isVisit)
}
func canVisitAllRoomsExec(rooms [][]int, nowVisit int) {
if isVisit[nowVisit] == true || len(r... |
package process
import (
"encoding/json"
"fmt"
"go_code/project1/94chatroom/common/message"
"go_code/project1/94chatroom/server/model"
"go_code/project1/94chatroom/server/utils"
"net"
)
type UseProcess struct {
Conn net.Conn
//增加一个字段表示该Conn是哪个用户
UserId int
}
//处理登陆请求
func (this *UseProcess) ServerProcessLog... |
package aggregates
import (
"context"
"github.com/tmtx/res-sys/app"
"github.com/tmtx/res-sys/pkg/event"
)
type Base struct {
Id *event.UUID `json:"id"`
Repository event.Repository `json:"-"`
Events []event.Event
AppliedEventCount uint
}
func (ag *Base) GetId() *event.UUI... |
// Copyright 2019 The Dice 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
//
// https://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by app... |
package etcd
import (
"context"
"encoding/json"
"fmt"
"strings"
"sync"
"time"
"github.com/jybbang/go-core-architecture/core"
etcd "go.etcd.io/etcd/client/v3"
"gopkg.in/jeevatkm/go-model.v1"
)
type adapter struct {
client *clientProxy
settings EtcdSettings
}
type clientProxy struct {
etcd *etcd.... |
package utils
import (
"gobackend/chitChat/data"
"net/http"
)
func SignUp(w http.ResponseWriter, r *http.Request) {
generateHTML(w, nil, "login.layout", "public.navbar", "signup")
}
func SignUpAccount(w http.ResponseWriter, r *http.Request) {
if err := r.ParseForm(); err != nil {
w.WriteHeader(http.StatusInter... |
package main
import "fmt"
type own int
var (
x own
y int
)
func main() {
fmt.Println(x)
fmt.Printf("%T\n", x)
x = 42
fmt.Println(x)
y = int(x)
fmt.Println(y)
fmt.Printf("%T\n", y)
}
|
package functions
import "math"
// Stddev is the standard deviation
func (ss SliceType) Stddev() float64 {
if len(ss) == 0 {
return 0.0
}
avg := ss.Average()
var sd float64
for i := range ss {
sd += math.Pow(float64(ss[i])-avg, 2)
}
sd = math.Sqrt(sd / float64(len(ss)))
return sd
}
|
package utils
import (
"fmt"
"github.com/yuneejang/webserver/config"
cli "gopkg.in/urfave/cli.v1"
)
//cmd
var (
//TODO: To setup database, make init cmd
InitCommand = cli.Command{
Action: MigrateFlags(initServer),
Name: "init",
Usage: "Initialize a new Server",
Flags: []cli.Flag{
ConfigFilePath,
... |
package main
import (
"testing"
)
func TestParseLine(t *testing.T) {
tables := map[string]LineEntry{
"10 REM This is a test": LineEntry{
10,
"REM This is a test",
},
"20 INPUT S": LineEntry{
20,
"INPUT S",
},
"30 PRINT S": LineEntry{
30,
"PRINT S",
},
" 10 REM Initial space": LineE... |
package tax
//Tax table database structure
type Tax struct {
ID int64 `json:"id" db:"id"`
Code string `json:"code" db:"code"`
Description string `json:"desc" db:"description"`
Expression string `json:"expression" db:"expression"`
MinPrice float64 `json:"min_price" db:"min_price"`
}
//Com... |
package es
import (
"context"
// "encoding/json"
"fmt"
"github.com/olivere/elastic"
"grm-searcher/types"
// "grm-service/log"
"reflect"
"strconv"
"strings"
)
type ESUtil struct {
Client *elastic.Client
}
const META_TYPE = "type"
const mapping = `
{
"mappings": {
"doc": {
"properties":... |
package fwb
import (
"math"
)
const (
//PD_CLIENT_ID index in PlayerData for player client ID
PD_CLIENT_ID = iota
//PD_PT_HEART index in PlayerData for property Heart
PD_PT_HEART
//PD_PT_GOLD index in PlayerData for property Gold
PD_PT_GOLD
//PD_PT_CEREALS index in PlayerData for property Cereals
PD_PT_CE... |
package main
// IMPORTANT:
// It's guaranteed that the given points are distinct.
import (
"fmt"
)
func iAbs(x int) int { if x >= 0 { return x } else { return -x } }
func solve() {
var x1, x2 int
var y1, y2 int
fmt.Scanf("%d %d %d %d", &x1, &y1, &x2, &y2)
if(y1 == y2) { // horizontal alignment
d := i... |
package webwx
import (
"encoding/json"
"errors"
"io/ioutil"
"net/http"
"net/http/cookiejar"
"regexp"
"runtime"
"strconv"
"strings"
"time"
)
type webwx struct {
uuid string
base_host string //wx.qq.com for default
login_host string
upload_host string
webpush_host string
user_avatar strin... |
package main
import (
"businessense/app"
"businessense/controllers"
"fmt"
"net/http"
"os"
"github.com/gorilla/handlers"
"github.com/gorilla/mux"
)
func main() {
router := mux.NewRouter()
router.Use(app.JwtAuthentication) //attach JWT auth middleware
//Apis to handle user creation and loging
router.Handl... |
package cache
import (
"fmt"
"log"
"time"
_ "github.com/go-sql-driver/mysql"
_ "github.com/lib/pq"
"github.com/pilillo/igovium/utils"
"github.com/prometheus/client_golang/prometheus"
//_ "github.com/mattn/go-oci8"
"xorm.io/xorm"
"xorm.io/xorm/caches"
)
type dbCacheType struct {
engine *xorm.Engine
}
ty... |
package awscommons
import (
"testing"
goaws "github.com/aws/aws-sdk-go-v2/aws"
"github.com/gruntwork-io/terratest/modules/aws"
"github.com/gruntwork-io/terratest/modules/random"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
)
// Test GetSecretsManagerSecret by creating the secret i... |
package main
import "fmt"
//切片 slice 是一个拥有相同类型元素的可变长度的序列,是基于数组类型的一层封装,支持自动扩容
//切片是引用类型,它的内部结构包含 地址、长度、容量
//切片一般用于快速地操作一块数据集合
func main() {
//声明
//var name []T
var s []int //定义一个存放int类型元素的切片
var s1 []string //定义一个存放string类型元素的切片
fmt.Println(s, s1)
fmt.Println(s == nil) //true
fmt.Println(s1 == nil) //tru... |
// DRUNKWATER TEMPLATE(add description and prototypes)
// Question Title and Description on leetcode.com
// Function Declaration and Function Prototypes on leetcode.com
//326. Power of Three
//Given an integer, write a function to determine if it is a power of three.
//Follow up:
//Could you do it without using any loo... |
package main
import (
"fmt"
"sort"
)
// 493. 翻转对
// 给定一个数组 nums ,如果 i < j 且 nums[i] > 2*nums[j] 我们就将 (i, j) 称作一个重要翻转对。
// 你需要返回给定数组中的重要翻转对的数量。
// 注意:
// 给定数组的长度不会超过50000。
// 输入数组中的所有数字都在32位整数的表示范围内。
// https://leetcode-cn.com/problems/reverse-pairs/
func main() {
fmt.Println(reversePairs4([]int{2, 4, 3, 5,... |
package handlers
import (
"bytes"
"net/http"
"net/http/httptest"
"strings"
"testing"
"time"
)
func Test_External_Auth_Wrapper_FailsInvalidAuth(t *testing.T) {
s := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
w.WriteHeader(http.StatusForbidden)
}))
defer s.Close()
n... |
package admin
import (
"context"
"tpay_backend/adminapi/internal/common"
"tpay_backend/model"
"tpay_backend/adminapi/internal/svc"
"tpay_backend/adminapi/internal/types"
"github.com/tal-tech/go-zero/core/logx"
)
type ModifyUpstreamLogic struct {
logx.Logger
ctx context.Context
svcCtx *svc.ServiceContext... |
package main
import (
"fmt"
)
func average(slice []float64) float64{
size := float64(len(slice))
if size == 0 {
return float64(0.0)
}
var sum float64 = 0.0
for _, val := range slice {
sum += val
}
return sum / size
}
func main() {
slice := []float64{1.1, 4.5, 82.3, 4.0, 62.3}
fmt.Printf("... |
package sql
import (
"context"
"github.com/gremlinsapps/avocado_server/api/model"
"github.com/gremlinsapps/avocado_server/dal/model"
"github.com/jinzhu/gorm"
)
type ChatRepository struct {
conn *DBConnection
}
func CreateChatRepo(container DBConnectionContainer) (*ChatRepository, error) {
conn, err := containe... |
package main
import (
"fmt"
"github.com/garyburd/redigo/redis"
"time"
)
/*
1. Refactor: 从main中抽取出函数
2.
*/
var redisAddr = "192.168.3.158:6379"
func main() {
c, err := redis.Dial("tcp", redisAddr)
if err != nil {
fmt.Println("connect to redispt error:", err)
return
}
defer c.Close()
testHash(c)
testHa... |
package main
import (
"os"
"testing"
"github.com/ovrclk/akcmd/testutil"
)
func TestMainProgram(t *testing.T) {
in, out := testutil.ApplyMockIO(nil)
defer in.Cleanup()
defer out.Cleanup()
in.Reset("1\n") // choose option "1" on first app run
os.Args = []string{"akcmd"}
main()
}
|
package client_peer
import (
"fmt"
git_chinawayltd_com_golib_tools_courier "github.com/profzone/eden-framework/pkg/courier"
git_chinawayltd_com_golib_tools_courier_client "github.com/profzone/eden-framework/pkg/courier/client"
git_chinawayltd_com_golib_tools_courier_status_error "github.com/profzone/eden-framework... |
package main
import (
"fmt"
"log"
"net/url"
)
// placeholder values
var (
fakeText = "Some placeholder text"
fakeNum = "12457"
fakePass = "myP@sw0rD1"
fakeMail = "test@test.test"
fakeURL = "http://www.test.net"
injectData = "' OR 1=1; --"
)
// SetFormValues creates the values to be posted to the... |
package slack
import (
"bytes"
"io/ioutil"
"net/http"
"reflect"
"testing"
)
type remindersHandler struct {
gotParams map[string]string
}
func newRemindersHandler() *remindersHandler {
return &remindersHandler{
gotParams: make(map[string]string),
}
}
func (rh *remindersHandler) accumulateFormValue(k string... |
package main
import (
"fmt"
"reflect"
"regexp"
"github.com/manifoldco/promptui"
)
type commitType struct {
Type string
Description string
Example string
}
func promptType(types []string) (commitType, error) {
defaultTypes := map[string]commitType{
"build": {Type: "build", Description: "chang... |
package main
import (
"fmt"
"log"
"github.com/jonmorehouse/gatekeeper/gatekeeper"
"github.com/jonmorehouse/gatekeeper/gatekeeper/utils"
upstream_plugin "github.com/jonmorehouse/gatekeeper/plugin/upstream"
)
// config exposes configuration that can be controlled via the command line for this plugin
type config s... |
package service
import (
"github.com/GoGroup/Movie-and-events/model"
"github.com/GoGroup/Movie-and-events/movie"
)
type MovieService struct {
movieRepo movie.MovieRepository
}
func NewMovieService(mvRepo movie.MovieRepository) movie.MovieService {
return &MovieService{movieRepo: mvRepo}
}
func (m *MovieService)... |
/*
* Delete a shared load balancer.
*/
package main
import (
"flag"
"fmt"
"os"
"path"
"github.com/grrtrr/clcv2/clcv2cli"
"github.com/grrtrr/exit"
)
func main() {
var location = flag.String("l", "", "Data centre location alias to use")
flag.Usage = func() {
fmt.Fprintf(os.Stderr, "usage: %s [options] <L... |
package app
import (
"bytes"
"log"
"testing"
"time"
config "github.com/chutommy/metal-price/api-server/config"
"gopkg.in/go-playground/assert.v1"
)
func TestApp(t *testing.T) {
logger := log.New(bytes.NewBufferString(""), "", log.LstdFlags)
cfg := &config.Config{
Port: 8080,
CurrencyService:... |
package main
import (
"context"
"net"
"testing"
"time"
)
func TestBroadcast(t *testing.T) {
ctx, cancel := context.WithCancel(context.Background())
defer cancel()
src := make(chan ServerList)
broadcast := newBroadcast(ctx, src)
listener := make(chan ServerList)
// adding a listener should not cause troubl... |
package gotravelendpoint
import (
"context"
"github.com/go-kit/kit/endpoint"
"github.com/go-kit/kit/log"
"github.com/radekwlsk/go-travel/gotravel/gotravelservice"
"github.com/radekwlsk/go-travel/gotravel/gotravelservice/trip"
)
type Endpoints struct {
TripPlanEndpoint endpoint.Endpoint
}
func New(s gotravelse... |
package models
import (
"encoding/json"
"fmt"
"github.com/APTrust/exchange/constants"
"strings"
"time"
)
/*
GenericFile contains information about a file that makes up
part (or all) of an IntellectualObject.
IntellectualObject is the object to which the file belongs.
Format is typically a mime-type, such as "a... |
// Package schemes provides standard color schemes from gheat.
//
// These color schemes were converted from the pngs from gheat are made
// available for your convenience.
package schemes
import (
"image"
"image/color"
_ "image/gif" // image format side effect
_ "image/jpeg" // image format side effect
_ "image... |
// Package main downloads and boots an ISO.
package main
import (
"bytes"
"context"
"encoding/json"
"flag"
"fmt"
"html/template"
"io/ioutil"
"log"
"path"
"path/filepath"
"github.com/u-root/u-root/pkg/boot"
"github.com/u-root/webboot/pkg/bootiso"
"github.com/u-root/webboot/pkg/menu"
)
var (
v =... |
package world
import (
"math"
"testing"
"github.com/calbim/ray-tracer/src/util"
"github.com/calbim/ray-tracer/src/ray"
"github.com/calbim/ray-tracer/src/color"
"github.com/calbim/ray-tracer/src/light"
"github.com/calbim/ray-tracer/src/material"
"github.com/calbim/ray-tracer/src/shape"
"github.com/calbim/ra... |
package payment
import "time"
type Receipt struct {
ID string
Price int
AccountID string
CreatedAt time.Time
}
|
package appMgr
import (
"github.com/HNB-ECO/HNB-Blockchain/HNB/common"
"github.com/HNB-ECO/HNB-Blockchain/HNB/ledger"
ssComm "github.com/HNB-ECO/HNB-Blockchain/HNB/ledger/stateStore/common"
)
type contractApi struct {
args []byte
sc *StateCache
chainID string
from common.Address
}
func GetContractA... |
package main
import (
"flag"
"io/ioutil"
"log"
"github.com/pkg/errors"
"gopkg.in/yaml.v2"
)
func init() {
}
// Config ...
type Config struct {
original string
Global *global `yaml:"global"`
}
type global struct {
Concurrent int32 `yaml:"concurrent"`
TargetNum int64 `yaml:"target_num"`
Job []*J... |
// Structs
package main
import "fmt"
// declarar un struct para la info de un usuario(nombre, dirección, edad)
type usuario struct {
nombre string
direccion string
edad int
}
func main() {
// crear un valor y lo vamos a inicializar con valores
user := usuario {
nombre: "Usuario",
direccion: "calle falsa",
... |
package main
import "fmt"
func main() {
numDays, numLikes, newLikes := 0, 2, 0
fmt.Scanf("%d", &numDays)
likes := []int{2}
for ; numDays > 1; numDays-- {
newLikes = (likes[len(likes) - 1] * 3) / 2
numLikes += newLikes
likes = append(likes, newLikes)
}
fmt.Println(numLikes)
} |
//
// Copyright © 2017 Ikey Doherty <ikey@solus-project.com>
//
// 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... |
package types_test
import (
. "code.cloudfoundry.org/cli/types"
. "github.com/onsi/ginkgo"
. "github.com/onsi/ginkgo/extensions/table"
. "github.com/onsi/gomega"
)
var _ = Describe("FilteredString", func() {
DescribeTable("ParseValue",
func(input string, expected FilteredString) {
nullString := FilteredStri... |
package main
import "fmt"
type Person struct {
Name string
}
func (p Person) speak() {
fmt.Println(p.Name, "是一goodman")
}
func (a Person) test() {
a.Name = "jack"
fmt.Println("test() name=", a.Name)
}
func main() {
var p Person
p.Name = "Tom"
p.test()
fmt.Println("main() name=", p.Name)
p.speak()
}
|
package sudoku
import (
"testing"
)
var case1 = `
_ _ _ 5 _ _ _ _ _
_ 7 _ _ _ 2 8 6 _
4 _ 2 _ 7 1 3 _ _
_ 9 _ _ _ _ _ _ 8
_ _ 7 _ 8 _ 1 _ _
8 _ _ _ _ _ _ 3 _
_ _ 3 9 4 _ 6 _ 1
_ 4 8 2 _ _ _ 9 _
_ _ _ _ _ 7 _ _ _
`
func Test_inital_processing(t *testing.T) {
p := NewPuzzle()
if err := p.Fload([]byte(case1)); er... |
package metrics
import (
"context"
"fmt"
"strings"
"time"
"gorm.io/gorm"
)
// Client ..
type Client struct {
db *gorm.DB
}
type Metrics struct {
ID int `json:"id"`
Namespace string `json:"namespace"`
Workflow string `json:"workflow"`
Revision string `json:"revision"`
Instance ... |
/*
# -*- coding: utf-8 -*-
# @Author : joker
# @Time : 2020-07-09 09:42
# @File : 124_Binary_Tree_Maximum_Path_Sum.go
# @Description : 求树的最大路径和
分治法
1. 左子树的最大路径
2. 右子树的最大路径
3. 左+右子树的最大路径
4. 取最大值
# @Attention :
*/
package v0
import (
"fmt"
"testing"
)
func Test_maxPathSum(t *testing.T) {
root := &TreeNode{
... |
package termios
import (
"syscall"
"testing"
)
func TestEquality(t *testing.T) {
if TIOCEXCL != syscall.TIOCEXCL {
t.Logf("TIOCEXCL != syscall.TIOCEXCL")
}
if TIOCNXCL != syscall.TIOCNXCL {
t.Logf("TIOCNXCL != syscall.TIOCNXCL")
}
if TIOCGPTN != syscall.TIOCGPTN {
t.Logf("TIOCGPTN != syscall.TIOCGPTN"... |
package main
import (
//"./somstructs"
somf "./somfunctions"
"fmt"
"flag"
"testing"
"os"
"bufio"
)
var Test bool
var Loadtype int
var Filename, Savename, ValidFilename string
var Saved, Train bool
var PngBefore,PngAfter string
func main() {
LoadParams()
PngBefore = "Before.png"
... |
package models
type Argument struct {
Content string `json:"content"`
Contents []string `json:"contents"`
Pointer []string `json:"pointer"`
}
|
package core
import (
"fmt"
"strings"
"github.com/cilium/kubenetbench/utils"
)
// NetperfConf base netperf configuration
type NetperfConf struct {
Timeout int
DataPort uint16
TestName string
CliCommand string
PreArgs []string
MoreArgs []string
MoreBenchArgs []string
}
// Netp... |
package caaa
import (
"encoding/xml"
"github.com/thought-machine/finance-messaging/iso20022"
)
type Document00400105 struct {
XMLName xml.Name `xml:"urn:iso:std:iso:20022:tech:xsd:caaa.004.001.05 Document"`
Message *AcceptorCompletionAdviceResponseV05 `xml:"AccptrCmpltnAdvcRspn"`
}
f... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.