text
stringlengths
11
4.05M
package pubsub import ( "fmt" pb "gx/ipfs/QmWL6MKfes1HuSiRUNzGmwy9YyQDwcZF9V1NaA2keYKhtE/go-libp2p-pubsub/pb" crypto "gx/ipfs/QmNiJiXwWE3kRhZrC5ej3kSjWHm337pYfhjLGSCDNKJP2s/go-libp2p-crypto" peer "gx/ipfs/QmPJxxDsX2UbchSHobbYuvz7qnyJTFKvaKMzE2rZWJ4x5B/go-libp2p-peer" ) const SignPrefix = "libp2p-pubsub:" func ...
/* Introduction Wardialing was a very interesting way to try to hack people back in the '80s and '90s. When everyone used dial-up, people would dial huge amounts of numbers to search for BBS's, computers, or fax machines. If it was answered by a human or answering machine, it hung up and forgot the number. If it was ...
package redis import "strconv" // encode - function translates arguments to array of bulk string func encode(args []string) []byte { quantity := strconv.Itoa(len(args)) str := "*" + quantity + RN for _, k := range args { length := strconv.Itoa(len(k)) str += "$" + length + RN + k + RN } return []byte(str) }
package gol import "strings" import "strconv" type Point struct { x,y int } const SEPARATOR = "," func NewPoint(x,y int) *Point { return &Point{x,y} } func PointFromString(k string) *Point { el := strings.Split(k, SEPARATOR) x, _ := strconv.Atoi(el[0]) y, _ := strconv.Atoi(el[1]) return NewPoint(x, y) ...
/* * Copyright 2018- The Pixie 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 ag...
package tripper import ( "fmt" "io" "net/http" "net/http/httptest" "testing" ) type mockTransport struct { id string } func (t *mockTransport) RoundTrip(_ *http.Request) (*http.Response, error) { w := httptest.NewRecorder() w.WriteString(t.id) return w.Result(), nil } // mockMiddleware appends the id into...
package main import "fmt" type pair struct { a, b byte } type recipes []byte var transformmap map[pair]recipes func buildtransforms() (result map[pair]recipes) { result = map[pair]recipes{} for i := 0; i < 10; i++ { for j := 0; j < 10; j++ { source := pair{byte(i), byte(j)} total := byte(i + j) if to...
package main import ( "bufio" "flag" "fmt" "github.com/kjx98/gobot" "github.com/kjx98/jabot" "github.com/op/go-logging" "time" "os" "strings" ) var log = logging.MustGetLogger("wxJabot") var username = flag.String("user", "mon@quant.zqhy8.com", "username") var password = flag.String("pass", "testme", "passw...
package rest import ( "time" "fmt" "github.com/golang/protobuf/ptypes" "github.com/jinmukeji/jiujiantang-services/pkg/rest" proto "github.com/jinmukeji/proto/v3/gen/micro/idl/partner/xima/user/v1" "github.com/kataras/iris/v12" ) const ( // PhoneMvc 手机号验证码 PhoneMvc = "phone_mvc" // UsernamePassword 用户名密码 U...
package main import ( "database/sql/driver" sq "github.com/mattn/go-sqlite3" "strconv" ) func createDB(dbname string) (driver.Conn, error) { d, e := new(sq.SQLiteDriver).Open(dbname) if e != nil { return nil, e } return d, nil } func addBus(b *busdet, table string, dbcon driver.Conn) error { jmin := strcon...
package tx import ( "github.com/cosmos/cosmos-sdk/client" "github.com/cosmos/cosmos-sdk/client/tx" cryptotypes "github.com/cosmos/cosmos-sdk/crypto/types" sdk "github.com/cosmos/cosmos-sdk/types" "github.com/cosmos/cosmos-sdk/types/tx/signing" authsigning "github.com/cosmos/cosmos-sdk/x/auth/signing" core "git...
package dushengchen /** */ //func maximumGap(nums []int) int { // gap, s, i := 0, 0, 1 // for ; i < len(nums); i++ { // if nums[i] - nums[s] > gap { // gap = nums[i] - nums[s] // } // if nums[i] < nums[s] { // s = i // } // } // return gap //}
// 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 utils import ( "bytes" "crypto/aes" "crypto/cipher" "crypto/md5" "crypto/tls" "crypto/x509" "encoding/hex" "encoding/json" "errors" "fmt" "io/ioutil" "net/http" "qipai/common" "sort" "strconv" "strings" ) // Struct2Map struct to map,依赖 json tab func Struct2Map(r interface{}) (s map[string]stri...
package middleware import ( "log" "net/http" "time" "github.com/VolticFroogo/Animal-Pictures/helpers" "github.com/VolticFroogo/Animal-Pictures/middleware/myJWT" "github.com/VolticFroogo/Animal-Pictures/models" "github.com/gorilla/context" ) type apiAuthResponse struct { AuthToken, RefreshToken string } // V...
package main import ( "errors" "net/http" "net/http/httptest" "testing" docker "github.com/docker/docker/client" "github.com/stretchr/testify/assert" "github.com/ubclaunchpad/inertia/common" ) func TestStatusHandlerBuildInProgress(t *testing.T) { defer func() { deployment = nil }() // Set up condition depl...
package api // VersionInfo holds details about a version of go-filecoin. type VersionInfo struct { // Commit, is the git sha that was used to build this version of go-filecoin. Commit string } // Version is the interface that defines methods to view version information about this node. type Version interface { // ...
package database import ( "time" "github.com/jinzhu/gorm" ) type Conta struct { ID uint `gorm:"primary_key"` Name string Email string Password string CreatedAt time.Time UpdatedAt time.Time } func Migrate(db *gorm.DB) { db.Debug().AutoMigrate(&Conta{}) }
package knapsack import ( "testing" ) var cap1 = 20. var testItems1 = []Item{ {Name: "clock", Value: 175, Weight: 10}, {Name: "painting", Value: 90, Weight: 9}, {Name: "radio", Value: 20, Weight: 4}, {Name: "vase", Value: 50, Weight: 2}, {Name: "book", Value: 10, Weight: 1}, {Name: "computer", Value: 200, Weig...
package userroute import ( "context" "github.com/hardstylez72/bblog/ad/pkg/group" "github.com/hardstylez72/bblog/ad/pkg/grouproute" "github.com/jmoiron/sqlx" ) type repository struct { conn *sqlx.DB } func NewRepository(conn *sqlx.DB) *repository { return &repository{conn: conn} } func (r *repository) deleteP...
package main import ( "bufio" "encoding/json" "errors" "flag" "fmt" "io/ioutil" "log" "os" "github.com/ChimeraCoder/anaconda" "github.com/dgraph-io/badger/y" ) var ( opts progOptions ) type twitterCreds struct { AccessSecret string `json:"access_secret"` AccessToken string `json:"access_token"` C...
package googleCalendarAPI import ( "api-calendar/model" "google.golang.org/api/calendar/v3" ) type Calendar struct { Service *calendar.Service } func (cal Calendar) CreatEvent(event model.Event, calendarId string) (*calendar.Event, error) { newEvent := calendar.Event{ Summary: event.Summary, Start: &event...
package tbhandler // 生成结构体文件模板 var structTemplate = `package models // tb_comment type tb_name struct{ value }`
package main import "fmt" func main() { /* MAIN TYPES string bool int int int8 int16 int32 int64 uint uint8 uint16 uint32 uint64 uintptr byte - alias for uint8 rune - alias for int32 float32 float64 complex64 complex128 */ //Using var //var name = "MistyyBoi" var age = 16 var size float...
/* * @lc app=leetcode.cn id=160 lang=golang * * [160] 相交链表 */ // @lc code=start /** * Definition for singly-linked list. * type ListNode struct { * Val int * Next *ListNode * } */ package main import "fmt" type ListNode struct { Val int Next *ListNode } func getIntersectionNode(headA, headB *List...
package compose import ( "fmt" "time" "github.com/kudrykv/latex-yearly-planner/app/components/calendar" "github.com/kudrykv/latex-yearly-planner/app/components/page" "github.com/kudrykv/latex-yearly-planner/app/config" ) func Annual(cfg config.Config, tpls []string) (page.Modules, error) { if len(tpls) != 1 { ...
package uinput import ( "fmt" "io" "os" "time" ) // TouchScreen interface type TouchScreen interface { Touch(x int32, y int32) error io.Closer } type vTouchScreen struct { devFile *os.File } func setupTouchScreen(devFile *os.File, minX int32, maxX int32, minY int32, maxY int32) error { var uinp uinputUserD...
package sol import ( "testing" ) func TestBasic(t *testing.T) { testcases := []struct { input []int want int }{ { input: []int{-2, 1, -3, 4, -1, 2, 1, -5, 4}, want: 6, }, { input: []int{1}, want: 1, }, { input: []int{-1, -2, -3}, want: -1, }, { input: []int{-1, -2, -3, 1...
package common //Aggregation Type //This constants represents available aggregations and could be safety send to node const ( AGGREGATION_NONE int32 = 0 AGGREGATION_ADD int32 = 1 AGGREGATION_MIN int32 = 2 AGGREGATION_MAX int32 = 3 AGGREGATION_AVERAGE ...
func maxProduct(nums []int) int { return sol2(nums) } // time: O(n), space: O(1) func sol2(nums []int) int { if len(nums) == 0 { return 0 } res := nums[0] pmax := nums[0] pmin := nums[0] for i := 1; i < len(nums); i++ { n := nums[i] c1 := pmax * n c2 := pmin ...
package provider import ( "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" "github.com/mrparkers/terraform-provider-keycloak/keycloak" ) func resourceKeycloakOpenIdHardcodedRoleProtocolMapper() *schema.Resource { return &schema.Resource{ Create: resourceKeycloakOpenIdHardcodedRoleProtocolMapperCreate...
package equinix import ( "context" "fmt" "net/http" "reflect" "regexp" "time" "github.com/equinix/ecx-go/v2" "github.com/equinix/rest-go" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/val...
package main import ( "fmt" "github.com/sildani/poker-hands-go/parser" ) func main() { // hand := "AD AH QS JS TC" hand := "AD AD QS JS TC" parsedHand, _ := parser.ParseHand(hand) fmt.Printf("parsedHand: %v\n", parsedHand) }
package reader import ( "encoding/json" "fmt" "io" "os" "path/filepath" "reflect" "regexp" "strings" "sync" "sync/atomic" "time" "github.com/qiniu/log" "github.com/qiniu/logkit/utils" ) type MultiReader struct { started bool status int32 fileReaders map[string]*ActiveReader scs []re...
package alchemyapi /** Copyright 2015 AlchemyAPI 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 agree...
package api import "github.com/gin-gonic/gin" // One vendor with all goods price func CreateVendorPriceList(ctx *gin.Context) { } // One vendor with all goods price func UpdateVendorPriceList(ctx *gin.Context) { } // update specified vendors with specified goods price func UpdateAllPrice(ctx *gin.Context) { // wil...
package olm import ( "strings" "testing" operatorsv1 "github.com/operator-framework/api/pkg/operators/v1" opregistry "github.com/operator-framework/operator-registry/pkg/registry" "github.com/stretchr/testify/require" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "github.com/operator-framework/operator-lifecy...
package executor import ( "github.com/alehatsman/mooncake/internal/config" "github.com/alehatsman/mooncake/internal/utils" ) func HandleIncludeVars(step config.Step, ec *ExecutionContext) error { includeVars := step.IncludeVars expandedPath, err := utils.ExpandPath(*includeVars, ec.CurrentDir, ec.Variables) if ...
package test import "testing" func TestVaultClusterS3BackendWithUbuntuAmi(t *testing.T) { t.Parallel() t.Skip("Skipping this test as it is failing intermittently.") // TODO fix this test!!! runVaultWithS3BackendClusterTest(t, "ubuntu16-ami", "ubuntu") } func TestVaultClusterS3BackendAmazonLinuxAmi(t *testing.T) {...
package main import ( "cm_liveme_im/libs/bufio" "cm_liveme_im/libs/proto" "sync/atomic" log "github.com/thinkboy/log4go" ) // Channel used by message pusher send msg to write goroutine. type Channel struct { Uid string // for logging only Rooms map[string]struct{} // act as a set CliProto...
package main import ( "log" ui "github.com/gizak/termui/v3" "github.com/gizak/termui/v3/widgets" ) // TableStruct - We can select the table rows type TableStruct struct { Table *widgets.Table ActiveRow int } // NewTableStruct - Set the basic data func NewTableStruct() TableStruct { table ...
package main func main() { a := []int{7, 6, 5, 4, 3, 2, 1} p(insertion(a)) } func insertion(arr []int) []int { arrLen := len(arr) for i := 1; i < arrLen; i++ { key := arr[i] j := i - 1 for j >= 0 && key < arr[j] { arr[j+1] = arr[j] j-- } arr[j+1] = key } return arr }
package main type Fruit int const ( Apple Fruit = iota Orange Banana ) // go:generate stringer -type Fruit fruit.go
package auto import ( "api/database" "api/models" "log" ) func Load() { db, err := database.Connect() if err != nil { log.Fatal() } defer db.Close() err = db.Debug().DropTableIfExists(&models.User).Error if err != nil { log.Fatal(err) } err = db.Debug().AutoMigrate(&models.User).Error if err != nil ...
package hash import ( "testing" "strconv" ) func TestHash(t *testing.T){ h := NewHashRing(50) m := make(map[string]int) m["127.0.0.1"] = 2 m["127.0.0.2"] = 4 m["127.0.0.3"] = 6 m["127.0.0.4"] = 4 m["127.0.0.5"] = 8 h.AddNodes(m) m = make(map[string]int) for i:=0;i<100000;i++{ l := h.GetNode("key"+strco...
package main import ( plugin "gx/ipfs/QmXZuSpcGSesFXDWwZnESp2YEcYNcR4em9P86XsZtcuzWR/iptb-plugins/local" testbedi "gx/ipfs/QmckeQ2zrYLAXoSHYTGn5BDdb22BqbUoHEHm8KZ9YWRxd1/iptb/testbed/interfaces" ) var PluginName string var NewNode testbedi.NewNodeFunc var GetAttrList testbedi.GetAttrListFunc var GetAttrDesc testbed...
package clock import ( "fmt" "strconv" "time" ) type Event struct { Type string `json:"type"` JobID string `json:"job_id"` Message string `json:"message"` Meta interface{} `json:"meta"` } //Add : Add new job func (c *Clock) Add(interval string, url string) string { id, _ := c.Cron.Add...
// Copyright 2016 Matthew Endsley // All rights reserved // // Redistribution and use in source and binary forms, with or without // modification, are permitted providing that the following conditions // are met: // 1. Redistributions of source code must retain the above copyright // notice, this list of conditions ...
package utils func Filter(mapToFilter map[string]interface{}, f func(string, interface{}) bool) map[string]interface{} { filteredMap := make(map[string]interface{}) for key, value := range mapToFilter { if f(key, value) { filteredMap[key] = value } } return filteredMap } // Create Keys // Create Values
package service import ( "net/http" "github.com/gorilla/mux" "github.com/sirupsen/logrus" "gitlab.com/NagByte/Palette/db" "gitlab.com/NagByte/Palette/service/auth" "gitlab.com/NagByte/Palette/service/checkVersion" "gitlab.com/NagByte/Palette/service/develop" "gitlab.com/NagByte/Palette/service/fileServer" "...
package main import ( "fmt" ) func main() { var chanInt chan int //宣告變數為channel,其中可傳入的值型態須為int chanInt = make(chan int,3) //為channel建立容器 ,容量為1 chanInt <- 1 //send 值 進 channel chanInt <- 2 chanInt <- 3 fmt.Printf("channel容量:%v element長度:%v\n",cap(chanInt),len(chanInt)) //check! 印出channel的容量,長度 fmt.Printf("cha...
package dao import ( "context" "github.com/mongodb/mongo-go-driver/bson" "github.com/mongodb/mongo-go-driver/bson/primitive" "github.com/SaiNageswarS/builder-factory/services/db" "github.com/mongodb/mongo-go-driver/mongo" ) func InsertOneApp(mgo db.Db, app db.App) (*mongo.InsertOneResult, error) { return mgo....
func complexNumberMultiply(a string, b string) string { p1, p2 := 0, 0 var sa []string var sb []string if strings.Contains(a, "+-") { sa = strings.Split(a, "+-"); p1 = 1 } else { sa = strings.Split(a, "+") } if strings.Contains(b, "+-") { sb = strings.Split(b, "+-"); p2 = 1 } else { sb = strings.Spl...
package golang func flipAndInvertImage(A [][]int) [][]int { length := len(A) result := make([][]int, 0, length) for _, val := range A { row := make([]int, 0, length) for i := 0; i < length; i++ { row = append(row, 1-val[length-1-i]) } result = append(result, row) } return result }
package compose import ( "fmt" "github.com/kudrykv/latex-yearly-planner/app/components/calendar" "github.com/kudrykv/latex-yearly-planner/app/components/header" "github.com/kudrykv/latex-yearly-planner/app/components/page" "github.com/kudrykv/latex-yearly-planner/app/config" ) func HeaderQuarterly(cfg config.Co...
package main import ( "flag" "strings" "time" "github.com/mostafa-asg/finch/test/users" ) func main() { var servers string var hashUsers int var getUsers int var duration int64 flag.StringVar(&servers, "servers", "http://localhost:8585", "Comma seperated list of finch servers") flag.IntVar(&hashUsers, "wr...
package main import ( "database/sql" "errors" _ "github.com/go-sql-driver/mysql" _ "github.com/mattn/go-sqlite3" ) type KeyValueDB struct { DB *sql.DB TableName string } func newKeyValueDB(config *Config) *KeyValueDB { db, err := sql.Open(config.getDriverName(), config.getDataSourceName()) if err !=...
package toolkit import ( "fmt" "testing" ) func TestRandom(t *testing.T) { fmt.Printf("Generate random integer number: %d\n", Random(100000, 999999)) }
package cats import ( "bytes" "encoding/json" "io/ioutil" "log" "net/http" "net/http/httptest" "reflect" "testing" "time" "google.golang.org/appengine/aetest" "google.golang.org/appengine/user" "github.com/NYTimes/marvin" "github.com/golang/protobuf/proto" "github.com/kr/pretty" ) var testInst aetest....
package nutanix import ( "strconv" "github.com/openshift/installer/pkg/types" "github.com/openshift/installer/pkg/types/nutanix" ) // Metadata converts an install configuration to Nutanix metadata. func Metadata(config *types.InstallConfig) *nutanix.Metadata { return &nutanix.Metadata{ PrismCentral: config.Nut...
// The following is adapted from goleveldb // (https://github.com/syndtr/goleveldb) under the following license: // // Copyright 2012 Suryandaru Triandana <syndtr@gmail.com> // All rights reserved. // // Redistribution and use in source and binary forms, with or without // modification, are permitted provided that the ...
//Package handlers : collection of handlers (aka "HTTP middleware") package handlers import ( "encoding/json" "fmt" "io/ioutil" "net/http" "strconv" "time" "google.golang.org/protobuf/encoding/protojson" "github.com/layer5io/meshery/models" SMP "github.com/layer5io/service-mesh-performance/spec" "github.c...
package postgres import ( "database/sql" "fmt" "os" "github.com/arxdsilva/olist/bill" "github.com/arxdsilva/olist/record" // pq is the postgres driver _ "github.com/lib/pq" ) type Postgres struct { db *sql.DB } func New() (postg Postgres, err error) { dbURL := os.Getenv("DATABASE_URL") dbname := os.Geten...
package ddtracer import ( "bufio" "bytes" "encoding/json" "errors" "net/http" "net/http/httptest" "net/http/httputil" "net/url" "strings" "testing" "time" "github.com/DataDog/dd-trace-go/tracer" opentracing "github.com/opentracing/opentracing-go" "github.com/opentracing/opentracing-go/ext" "github.com/...
package main import ( "bufio" "fmt" "os" "strings" ) func main() { reader := bufio.NewReader(os.Stdin) fmt.Print("What is the quote? ") quote, _ := reader.ReadString('\n') quote = strings.TrimSuffix(quote, "\n") fmt.Print("Who said it? ") name, _ := reader.ReadString('\n') name = strings.TrimSuffix(name, "...
package skpsilk import ( pmath "github.com/pkg/math" ) // silk/src/SKP_Silk_autocorr.c func autocurr(results []int32, scale *int, inputData []int16, inputDataSize int, correlationCount int) { corrCount := pmath.MinInt(inputDataSize, correlationCount) corr64 := inner_prod16_aligned_64(inputData, inputData, inputD...
package test import ( "fmt" "github.com/sinksmell/files-cmp/models" "testing" ) // 测试能否正确地计算md5值 func TestGetMd5(t *testing.T) { if hash, err := models.GetMd5("./test.txt"); err != nil { t.Fatal(err) } else { fmt.Println(hash) } } // 测试能否正确计算出二进制文件的md5值 func TestGetBMd5(t *testing.T) { if hash, err := mod...
package kademlia import ( "fmt" "sync" "testing" ) func TestContact(t *testing.T) { c1 := NewContact(NewKademliaID("0000000000000000000000000000000000000001"), "127.0.0.1:4000") c2 := NewContact(NewKademliaID("0000000000000000000000000000000000000002"), "127.0.0.2:4001") c3 := NewContact(NewKademliaID("0000000...
package main import ( "encoding/json" "fmt" "os" ) type student struct { StudentId int `json:"id,required"` LastName string `json:"lname"` FirstName string `json:"fname"` IsMarried bool `json:"-"` IsEnrolled bool `json:"enrolled,omitempty"` Courses []course `json:"classes"` } type course s...
package services import ( "KServer/manage" "KServer/proto" "KServer/server/utils" "KServer/server/utils/msg" "fmt" "gopkg.in/mgo.v2/bson" ) type Service struct { IManage manage.IManage } func NewServiceDiscovery(m manage.IManage) *Service { return &Service{IManage: m} } // 服务头 func (s *Service) ServiceHand...
package controller import ( "net/http" log "github.com/sirupsen/logrus" ) type middleware func(http.HandlerFunc) http.HandlerFunc func chainMiddleware(mw ...middleware) middleware { return func(final http.HandlerFunc) http.HandlerFunc { return func(w http.ResponseWriter, r *http.Request) { last := final ...
// Copyright 2012 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. package fs import ( "bytes" "fmt" "log" "os" "strings" "time" "github.com/hanwen/go-fuse/fuse" "github.com/hanwen/go-fuse/fuse/nodefs" "github.com/hanwen...
package board import ( "math/rand" "time" ) type Deck []Card func (deck *Deck) DealOne() Card { c := (*deck)[0] *deck = (*deck)[1:] return c } var ( BaseDeck Deck ) func init() { BaseDeck = Deck(AllCards) } func NewDeck() Deck { deck := make([]Card, 52) copy(deck, BaseDeck) r := rand.New(rand.NewSource(...
package logrusutil_test import ( "testing" "github.com/opalmer/logrusutil" "github.com/sirupsen/logrus" ) func TestCallerHook_Fire_Disabled(t *testing.T) { entry := &logrus.Entry{} hook := logrusutil.NewCallerHook( true, logrusutil.DefaultHookStackLevel, "test", logrus.DebugLevel) if err := hook.Fire(entr...
// Copyright 2016 CoreOS, Inc. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // // http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed to in...
package gameapi import ( "backend/internal/domain" "backend/internal/usecase/findgameusecase" "github.com/gorilla/mux" "github.com/stretchr/testify/assert" "net/http" "net/http/httptest" "testing" ) func Test_Get_a_game(t *testing.T) { findGameUseCase := findgameusecase.Mock() gameId, _ := domain.ParseGameId...
package cmd import ( "net/http" "strconv" "github.com/textileio/go-textile/pb" ) func Feed(threadID string, offset string, limit int, mode string) error { var list pb.FeedItemList opts := map[string]string{ "thread": threadID, "offset": offset, "limit": strconv.Itoa(limit), "mode": mode, } res, err...
// Copyright 2019-2021 Matt Layher // 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 wr...
package users import ( "testing" ) func TestFindUser(t *testing.T) { result := FindUser() expect := User{ Id: 1, LastName: "山田", FirstName: "太郎", Birthday: "2001-02-22", Prefecture: "埼玉", ProposalImg: "/img/o0809108014444716593.jpg", BloodType: "O", } if result != expect { t.E...
package controllers import ( "net/http" "github.com/dmdinh22/go-blog/api/middlewares" httpSwagger "github.com/swaggo/http-swagger" _ "github.com/dmdinh22/go-blog/docs" ) func (s *Server) initializeRoutes() { // Home Route s.Router.HandleFunc("/api", middlewares.SetMiddlewareJSON(s.Home)).Methods("GET") // L...
package main import ( "context" "fmt" "google.golang.org/grpc" "google.golang.org/grpc/codes" "google.golang.org/grpc/reflection" "google.golang.org/grpc/status" "grpc-training/calculator/calculatorpb" "io" "log" "math" "net" ) const ( network = "tcp" address = "0.0.0.0:50051" ) type CalculatorServer st...
package repository import ( "testing" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" "k8s.io/klog/klogr" "github.com/isutton/orchid/pkg/orchid/orm" "github.com/isutton/orchid/test/mocks" ) var ( containersFieldPath = []string{"spec", "template", "spec", "containers"} portsFie...
package hybrik import ( "bytes" "encoding/json" "fmt" "io" "io/ioutil" "net/http" "net/url" "regexp" "strings" "sync" "time" ) // APIInterface is interface for the underlying client object type APIInterface interface { connect() error isExpired() bool CallAPI(method string, apiPath string, params url.Va...
// Copyright 2019 The go-interpreter Authors. All rights reserved. // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. // +build !debugstack package exec // debugStackDepth enables runtime checks of the stack depth. If // the stack every would exceed or underflow ...
package server import ( "math" "runtime" "sync" "github.com/Jeffail/tunny" "github.com/pkg/errors" "github.com/rai-project/config" "github.com/rai-project/database" mongodb "github.com/rai-project/database/mongodb" "github.com/rai-project/dlframework" "github.com/rai-project/evaluation" "github.com/spf13/c...
// Copyright 2013 Benjamin Gentil. All rights reserved. // license can be found in the LICENSE file (MIT License) package zlang /* import ( "github.com/go-llvm/llvm" ) type Module struct { name string module llvm.Module funcs map[string]Function vars map[string]Variable } func NewModule(name string) *Modul...
package cloudflare import ( "testing" "github.com/stretchr/testify/assert" ) func TestNewCredentials(t *testing.T) { authKey := "auth-key" email := "tester@testing.com" credentials := NewCredentials(email, authKey) assert.NotNil(t, credentials) assert.Equal(t, authKey, credentials.authKey) assert.Equal(t, e...
/* Package dev ... Connect to Pi: - +V5: any 5v - GND: any gnd pin - SM : any data pin - Rx: PCF8591->AIN0 - Ry: PCF8591->AIN1 */ package dev import ( "github.com/stianeikeland/go-rpio" ) // Joystick ... type Joystick struct { swPin rpio.Pin ads *ADS1015 } // NewJoystick ... func NewJoystick(sw uint8) (*J...
//********************************************************** // // Copyright (C) 2018 - 2021 J&J Ideenschmiede UG (haftungsbeschränkt) <info@jj-ideenschmiede.de> // // This file is part of tillhub. // All code may be used. Feel free and maybe code something better. // // Author: Jonas Kwiedor // //*********************...
package queries import ( "database/sql" "encoding/json" "net/url" "strconv" "github.com/pwang347/cs304/server/common" ) // CreateVirtualMachine creates a new virtual machine func CreateVirtualMachine(db *sql.DB, params url.Values) (data []byte, err error) { var ( result sql.Result respon...
package main import ( "log" "net/http" "go-cqrs/db" "go-cqrs/util" "github.com/gorilla/mux" ) func newRouter() (router *mux.Router) { router = mux.NewRouter() router.HandleFunc("/woofs", listWoofsHandler).Methods("GET") return } func main() { defer db.Close() // Connect to Postgres addrDB := "postgres:/...
package main import ( "bufio" "fmt" "os" "strings" "day2/move" ) func getInput(path string, constructor func([]string) move.Action) []move.Action { file, _ := os.Open(path) defer file.Close() var actions []move.Action scanner := bufio.NewScanner(file) for scanner.Scan() { curr := constructor(strings.Spl...
package main import ( "log" "github.com/spf13/cobra" ) var kata = &cobra.Command{ Use: "kata", Short: "kata - kata exercises", SilenceUsage: true, SilenceErrors: true, } func main() { if err := kata.Execute(); err != nil { log.Fatal(err) } }
package postgres import ( "context" "errors" "fmt" "os" "runtime" "testing" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" "golang.org/x/sync/errgroup" "github.com/pomerium/pomerium/internal/testutil" "github.com/pomerium/pomerium/pkg/grpc/registry" "github.com/pomerium/pomeri...
package unixserver import ( "net" "log" "fmt" ) func dataHandler(c net.Conn) { buf := make([]byte, 512) nr, err := c.Read(buf) if err != nil { return } data := string(buf[0:nr]) fmt.Println(data) } func UnixServer() { l, err := net.Listen("unix", "/tmp/example.sock") if err != nil{ log.Fatal(err) ...
package main import ( "fmt" "html/template" "log" "net/http" "os" _ "github.com/go-sql-driver/mysql" "github.com/gorilla/mux" ) var indexTmpl = template.Must(template.ParseFiles("templates/index.html")) // HandleGet - HTTP GET func HandleGet(w http.ResponseWriter, r *http.Request) { err := indexTmpl.Execute...
package dwd import ( "encoding/csv" "encoding/json" "errors" "fmt" "io" "math" "net/http" "net/http/cookiejar" "os" "strconv" "time" ) var ( stations []Station ) type Station struct { Pk string Name string X float64 Y float64 Altitude int Priori...
package main import ( "net/http" "fmt" ) func main(){ //第一个参数是接口, http.HandleFunc("/",helloworld) // 这里默认是127.0.0.1 http.ListenAndServe(":8081",nil) } func helloworld(rw http.ResponseWriter, req *http.Request){ //返回字符串 fmt.Fprint(rw, "hello world") }
package main func main() { if isCheck() { check() } else { manageWatchList() } }
package transport import ( "fmt" ) func TestStateMachine() { builder := MakeTcpStateMachineBuilder(TCP_INITIAL_CLOSED) builder.RegisterTransition(TCP_INITIAL_CLOSED, TCP_PASSIVE_OPEN, TCP_RESP_DO_NOTHING, TCP_LISTEN) builder.RegisterTransition(TCP_LISTEN, TCP_CLOSE, TCP_RESP_DEL_SOCK, TCP_INITIAL_CLOSED) build...