text
stringlengths
11
4.05M
package main import ( "bytes" "encoding/json" "fmt" "io/ioutil" "net/http" "net/http/httptest" "os" "reflect" "strings" "testing" webhook "github.com/ihcsim/sidecar-injector" "github.com/ihcsim/sidecar-injector/test" "github.com/sirupsen/logrus" admissionv1beta1 "k8s.io/api/admission/v1beta1" ) var tes...
package mysqldb import ( "os" "path/filepath" "strconv" "testing" "context" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/suite" ) // VCRecord 是 验证码的 testSuite type VCRecordTestSuite struct { suite.Suite db *DbClient } // SetupSuite 准备设置 Test Suite 执行 func (suite *VCRecordTestSuite) Se...
package lycamplus import ( "encoding/json" "fmt" "github.com/lycam-dev/lycamplus-go-sdk/lycamplus/lib" ) // User struct define. type User struct { client *lib.HTTPClient } // NewUser . func NewUser() *User { return &User{client: lib.NewHTTPClient()} } // Create method. func (u *User) Create(userRequestModel *...
package core import ( "bufio" "errors" "fmt" "strings" "syscall" "golang.org/x/crypto/ssh/terminal" "github.com/gookit/color" "github.com/rs/zerolog/log" ) type GetInputWrapper struct { Scanner bufio.Reader } var ( errPasswordMismatch = errors.New("The two password inserted are not the same.") ) func (t...
// application entry package main import "blog/api" func main() { api.Run() }
package sleepy import ( "fmt" "github.com/lithdew/bytesutil" "github.com/valyala/bytebufferpool" ) var _ EndpointDispatcher = (*Channel)(nil) type Channel struct { endpoint *Endpoint window *PacketBuffer readQueue chan []byte writeQueue chan []byte outQueue chan []byte queue []*bytebufferpool.ByteBuf...
package main type TreeNode struct { Val int Left *TreeNode Right *TreeNode } func main() { } func isSymmetric(root *TreeNode) bool { if root == nil { return true } return check(root.Left, root.Right) } func check(treeLeft *TreeNode, treeRight *TreeNode) bool { if treeLeft == nil && treeRight == nil { ...
package reverse import ( "errors" "fmt" ) // List is a definition of linked list. type List struct { Val byte Next *List } // Init initializes a linked list. func Init(s []byte) (*List, error) { if string(s) == "" { return nil, errors.New("list is empty") } head := &List{s[0], nil} curr := head for i :...
package function import _ "github.com/project-flogo/microgateway/internal/function/error"
package discovery import "time" type Resource interface { ID() string Name() string CreationTime() *time.Time } type resource struct { id string name string creationTime *time.Time } func (r *resource) ID() string { return r.id } func (r *resource) Name() string { return r.name } func (r...
package actions import ( "errors" "github.com/barrydev/api-3h-shop/src/factories" "github.com/barrydev/api-3h-shop/src/model" ) func GetProductItemById(productItemId int64) (*model.ProductItem, error) { productItem, err := factories.FindProductItemById(productItemId) if err != nil { return nil, err } if pr...
package storage import ( "os" "testing" "github.com/inazo1115/toydb/lib/util" ) // TestWriteAndRead tests that DiskManager can write the message to the file and // read it. func TestWriteAndRead(t *testing.T) { // Setup. dm := NewDiskManager() DataFile = "diskmanager_test_TestWriteAndRead.tmp" expected := "t...
// Package tools is used to pin specific versions of external tools in this // module's go.mod that we use for testing. package tools
package main import ( "bufio" "fmt" "os" "strings" "strconv" ) func readLines(path string) ([]string, error) { file, err := os.Open(path) if err != nil { return nil, err } defer file.Close() var lines []string scanner := bufio.NewScanner(file) for scanner.Scan() { lines = append(lines, scanner...
// Note by Leandro Motta Barros: The nice tests for OpenSimplex Noise were // originally written by Owen Raccuglia. They kind of go in the same vein as // the tests I did in my D (dlang) OpenSimples Nose implementation (see // https://github.com/lmbarros/sbxs_dlang/blob/master/src/sbxs/noise/open_simplex_noise.d), // b...
package resource // Response implements api2go.Responder type Response struct { Res interface{} Code int } // Metadata returns additional metadata func (r Response) Metadata() map[string]interface{} { return map[string]interface{}{ "author": "bhops", } } // Result returns the actual payload func (r Response) ...
package kvs import "github.com/stretchr/testify/mock" type MockKVS struct { mock.Mock } func (_m *MockKVS) Delete(key string) error { ret := _m.Called(key) var r0 error if rf, ok := ret.Get(0).(func(string) error); ok { r0 = rf(key) } else { r0 = ret.Error(0) } return r0 } func (_m *MockKVS) Get(key str...
package modules import ( "html/template" "reflect" "strconv" "github.com/sirupsen/logrus" "github.com/fatih/structs" "github.com/jinzhu/gorm" "github.com/jinzhu/inflection" "github.com/qor/admin" "github.com/qor/qor" "github.com/qor/roles" ) type CircleQor struct { QorAdmin *admin.Admin } func (m *Circl...
package priorityqueue import ( "github.com/sbromberger/gographs/heap" ) // A PriorityQueue implements heap.Interface and holds Items. type PriorityQueue []*heap.Item func (pq PriorityQueue) Len() int { return len(pq) } func (pq PriorityQueue) IsEmpty() bool { return pq.Len() == 0 } func (pq PriorityQueue) Less(i,...
package main import ( "fmt" "runtime" "time" ) func main() { quit := make(chan bool) fmt.Println("当前时间:", time.Now()) myTicker := time.NewTicker(time.Second) //周期定时器 i := 0 go func() { for { i++ nowTime := <-myTicker.C fmt.Println("当前时间:", nowTime) if i == 8 { quit <- true runtime.Goexit...
package db import ( "fmt" "time" "github.com/DynamoGraph/dbConn" param "github.com/DynamoGraph/dygparam" slog "github.com/DynamoGraph/syslog" "github.com/DynamoGraph/util" "github.com/aws/aws-sdk-go/service/dynamodb" "github.com/aws/aws-sdk-go/service/dynamodb/dynamodbattribute" "github.com/aws/aws-sdk-go/s...
package main import ( "math/rand" ) // GenerateRandomDate returns a random year, month and a day till 2018 func GenerateRandomDate() (int, int, int) { year := rand.Intn(2018) + 1 month := rand.Intn(12) + 1 daysInMonth := 31 switch month { case 2: if year%400 == 0 { daysInMonth = 29 } else { daysInMon...
package stuff import ( "fmt" "log" "os" "github.com/boltdb/bolt" // "github.com/mrityunjaygr8/go-pass/stuff" ) // Item is a struct representing an URL-username-password pair type Item struct { URL string Username string Password string } // AddItem adds a new record to the database func (s *Store) AddI...
// Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. package common import ( "net" "regexp" "github.com/pkg/errors" ) // CidrFirstIP returns the first IP of the provided subnet. func CidrFirstIP(cidr net.IP) net.IP { for j := len(cidr) - 1; j >= 0; j-- { cidr[j]++ ...
package entity import "time" //Product data type Product struct { ID ID `json:"id" bson:"_id"` Version Version `json:"version" bson:"_V"` Name string `json:"name" bson:"name"` Description string `json:"description,omitempty" bson:"description,omitempty"` Slug string `...
// Copyright 2020 Ross Light // // 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 applicable law or agreed to in ...
package channels import ( "fmt" ) // BlockChanel easy use channel block func BlockChanel(){ ch1 := make(chan int,1) //依次敲入通道变量的名称(比如ch1)、接送操作符<-以及想要发送的元素值(比如2),并且这三者之间最好用空格进行分割。 ch1 <- 1 // 接受通道表达式 //ch1 <- 2 ch2 := make(chan int,1) ch2 <- 2 // 示例3。 var ch3 chan int //ch3 <- 1 // 通道的值为nil,因此这里会造成永久的阻塞! ...
package storage import ( "testing" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" ) const ( // This is the latest schema version for the purpose of tests. LatestVersion = 11 ) func TestShouldObtainCorrectUpMigrations(t *testing.T) { ver, err := latestMigrationVersion(providerSQLite...
package classfile type ConstantInfo interface { readInfo(reader *ClassReader) } // ConstantPool /** 常量池占据了class文件很大一部分数据,里面存放着各式各样 的常量信息,包括数字和字符串常量、类和接口名、字段和方法 名等等. 于常量池中常量的数量是不固定的,所以在常量池的入口需要放置一项u2类型的数据,代表常 量池容量计数值(constant_pool_count)。 常量池中每一项常量都是一个表. 常量表类型 标志值 描述 CONSTANT_Utf8 1 UTF-8编码的Un...
package server import ( "FPproject/Frontend/models" "encoding/json" "net/http" "strconv" ) func cart(w http.ResponseWriter, r *http.Request) { var tpldata []interface{} var cart []models.CartItem data, status := newRequest(r, http.MethodGet, "/allci", nil) if status != 200 { tpl.ExecuteTemplate(w, "err.htm...
package main import ( "fmt" "os" "strconv" ) func splitNumbers(numbers []int, ref int) (lessThanRef, moreThanRef []int) { for _, n := range numbers { if n <= ref { lessThanRef = append(lessThanRef, n) } else { moreThanRef = append(moreThanRef, n) } } return lessThanRef, moreThanRef } func quicksor...
package blockattributes import ( "fmt" "regexp" "strings" "github.com/srackham/go-rimu/v11/internal/expansion" "github.com/srackham/go-rimu/v11/internal/options" "github.com/srackham/go-rimu/v11/internal/spans" "github.com/srackham/go-rimu/v11/internal/utils/stringlist" ) var ( Classes string // Space sep...
package functions func ExecuteGoFunction(package, function string, inputs []interface{}) (interface{}, error) { }
package buildinfo const ( Graffiti = " .__ __ .__ ___. __ \n ____ | |__ _____ ___.__._/ |_|__| _____ ____ \\_ |__ _____/ |_ \n / _ \\| | \\ / < | |\\ __\\ |/ \\_/ __ \\ ______ | __ \\ / _ \\ __\\\n( <_> ) Y...
package tun import ( "github.com/SUCHMOKUO/falcon-tun/tcpip" "log" ) type PacketHandler = func(*TUN, tcpip.IPv4Packet) type PacketHandlers = map[tcpip.IPProtocol]PacketHandler // register packet handlers. var packetHandlers = PacketHandlers{ // TCP packet handler. tcpip.TCP: func(tun *TUN, ipv4Packet tcpip.IPv4...
// Copyright 2023 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 model import ( "fmt" //"io" "time" ) const ( VERSION = "v0.1.0" TIMESTAMP_FMT string = "2006-01-02 15:04:05.000" ) func GenerateVersion() string { return fmt.Sprintf("---------------- generated by abnf %s %s ----------------", VERSION, time.Now().Format(TIMESTAMP_FMT)) }
package helpers import ( "fmt" "io" "log" "mime/multipart" "net/http" "strings" ) const tfeReqBodyString = `{ "password": "%s" }` // TfeBackup creates a backup of a TFE instance using the provided access details func TfeBackup(host, token, pwd string, out io.Writer) error { var body = strings.NewReader(fmt.S...
package main import ( "log" "sort" d "github.com/dosko64/distance" ) func main() { pp := []d.Point{} pp = append(pp, d.New(4, 4)) pp = append(pp, d.New(3, 3)) pp = append(pp, d.New(4, 2)) p := d.New(1.5, 1.5) log.Println(pp) pp = sortByDistance(p, pp, true) log.Println(pp) } func sortByDistance(p d.Poin...
package nsdownload_test import ( "testing" "download/nsdownload" "fmt" ) func Test_NationStatGetRoot(t *testing.T) { d := nsdownload.NewNationStatDownloader() res := d.GetRoot() fmt.Println(len(res)) } func Test_NationStatGetChild(t *testing.T){ d := nsdownload.NewNationStatDownloader() ...
package main import ( "bufio" "fmt" "io" "net" "os" "strings" ) //等待连接,并打印通信数据 func pp(con net.Conn) { reader := bufio.NewReader(os.Stdin) for { //3.读取客户端发来消息 tmp := make([]byte, 128) n, err := con.Read(tmp) if err == io.EOF { break } if err != nil { fmt.Printf("read message wrong,err:%v\n",...
package golinal import ( "github.com/stretchr/testify/suite"; "testing" ) //**************** // Global Matrices //**************** var NonsquareMatrix = NewMatrix([]float64{1}, []float64{-7}) var NonsquareMatrix2 = NewMatrix([]float64{3, 4}) var ThreeIdentity = NewMatrix([]float64{1, 0, 0}, []float64{0, 1, ...
package main import "fmt" type user struct { name string age int } type person struct { name string } func main() { var u1 user var u2 user u1.name = "abc" //var p person if u1 == u2 { // you can compare same type of struct fmt.Println("true") } else { fmt.Println("False") } // u1.name =...
package zset type ZSet struct { dict map[string]*zSkipListNode zSkipList *zSkipList } func NewZSet() *ZSet { return &ZSet{ dict: make(map[string]*zSkipListNode), zSkipList: NewZSkipList(), } } func (z *ZSet) Add(key string, score float64) { flag := ZADD_NX z.ZAdd(key, score, &flag, nil) } func (...
package main import ( "fmt" "math" ) type shape interface { area() float64 } type triangle struct { baseLength float64 height float64 } type square struct { sideLength float64 } func main() { t := triangle{baseLength: 4, height: 2} fmt.Printf("Triangle area is %.2f\n", t.area()) s := square{sideLengt...
package protocol import ( "encoding/xml" "errors" "fmt" "io" "net/http" "strings" ) type v2Service struct { resourceUrl string } func NewV2Client(url string) v2Service { return v2Service{resourceUrl: url} } func (svc v2Service) IsValid() bool { return !strings.HasSuffix(svc.resourceUrl, ".json") } func (s...
package api func decodeCity(city string) (cityCode string) { switch city { case "МОСКВА": city = "2000000" return city case "САНКТ-ПЕТЕРБУРГ": city = "2004001" return city case "ОРСК": city = "2040480" return city } return }
package main type Education struct { ObjectType string `json:"docType"` Name string `json:"Name"` // 姓名 Gender string `json:"Gender"` // 性别 Nation string `json:"Nation"` // 民族 EntityID string `json:"EntityID"` // 身份证号 Place string `json:"Place"` // 籍贯 BirthDay string `json:"Bir...
package service import ( "CloudRestaurant/dao" "CloudRestaurant/model" ) type FoodCategoryService struct { } /** * 获取美食类别 */ func (fcs *FoodCategoryService)Categories()([]model.FoodCategory,error){ //数据库操作层 foodCategoryDao:=dao.NewFoodCategoryDao() return foodCategoryDao.QueryCategories() }
package rakuten import ( "context" "fmt" ) type TravelVacantHotelSearchParams struct { LargeClassCode string `url:"largeClassCode,omitempty"` MiddleClassCode string `url:"middleClassCode,omitempty"` SmallClassCode string `url:"smallClassCode,omitempty"` DetailClassCode string `url:"detailC...
package main import ( "fmt" "time" ) func main() { /* Switch Example In this program we use time package for finding when was a sunday */ num := 2 switch num { case 1: fmt.Println("One") case 2: fmt.Println("Two") default: fmt.Println("None") } demoTime() findSaturday() } func demoTime() { fm...
package cache import ( "bytes" "encoding/json" "strings" "sync" eventpkg "github.com/serverless/event-gateway/event" "github.com/serverless/event-gateway/libkv" "go.uber.org/zap" ) type eventTypeCache struct { sync.RWMutex cache map[libkv.EventTypeKey]*eventpkg.Type log *zap.Logger } func newEventTypeCa...
package geometry import ( "math" ) // Shift the Line by the Vector. func Shift(l Line, v Vector) Line { return MustLine(NewLineFromPoints( Point{X: l.a.X + v.I, Y: l.a.Y + v.J}, Point{X: l.b.X + v.I, Y: l.b.Y + v.J}, )) } // ShortestVector returns the shortest Vector from Lines a to b. // // The Vector has le...
package utils import "strings" func UnTitle(src string) string { if src == "" { return "" } if len(src) == 1 { return strings.ToLower(string(src[0])) } return strings.ToLower(string(src[0])) + src[1:] } func UpTitle(src string) string { if src == "" { return "" } return strings.ToUpper(src) }
package services import ( "bytes" "goChat/Server/inMemoryDatabase" "goChat/Server/models" "net/http" "net/http/httptest" "testing" ) func TestNewAuthService(t *testing.T) { repo := getInMemoryUserRepo() authService := NewAuthService(repo) //userId, _ := createTestUser(repo) //user, _ := repo.GetUserByID(use...
package main import ( "fmt" "log" ) type account struct{ ID string } func newAccount(ID string) *account { return &account{ID} } func (a *account) checkAccount(ID string) error { log.Printf("checking account with %s id\n", ID) if a.ID != ID { return fmt.Errorf("account ID not verified") } log.Printf("accou...
package gonba import ( "encoding/json" "fmt" "io/ioutil" "net/http" "time" ) const baseAddress = "https://stats.nba.com/stats/" const baseAddressV2 = "http://data.nba.com/data/5s/json/cms/noseason/" const baseAddressV3 = "http://data.nba.net/prod/" // A Client is required for api calls type Client struct { bas...
package types import ( types2 "github.com/Secured-Finance/dione/blockchain/types" ) type PrePrepareMessage struct { Block *types2.Block } type PrepareMessage struct { Blockhash []byte Signature []byte } type CommitMessage PrepareMessage
package main import ( "fmt" "strings" ) func appendbit(data []byte, idx int, on bool) { byteidx := (uint)(idx / 8) bitidx := (uint)(idx % 8) if on { data[byteidx] |= 1 << (7 - bitidx) } else { data[byteidx] &^= 1 << (7 - bitidx) } } func parseinput(input string, padbytes int, postpad int) []byte { //all...
package watcher_test import ( "errors" "os" "time" "github.com/cloudfoundry-incubator/runtime-schema/bbs/fake_bbs" "github.com/cloudfoundry-incubator/runtime-schema/models" "github.com/cloudfoundry/gibson" . "github.com/onsi/ginkgo" . "github.com/onsi/gomega" "github.com/pivotal-golang/lager/lagertest" "git...
package config import ( "errors" "reflect" "testing" "github.com/go-kratos/kratos/v2/log" "github.com/stretchr/testify/assert" ) const ( _testJSON = ` { "server":{ "http":{ "addr":"0.0.0.0", "port":80, "timeout":0.5, "enable_ssl":true }, "grpc":{ ...
package main import ( "github.com/gin-gonic/gin" "github.com/pepelazz/golangLearning/uploadImage/uploadImage" "log" "net/http" ) func main() { r := gin.New() // вырубаем CORS r.Use(LiberalCORS) r.Static("/stat-img", "./image") r.Static("/static", "./webClient/dist") r.Static("/statics", "./webClient/dist/s...
package netio import ( "errors" "io" "log" "net" "reflect" "github.com/Dliv3/Venom/global" "github.com/Dliv3/Venom/utils" ) // WritePacket write packet to node.Conn func WritePacket(output io.Writer, packet interface{}) error { t := reflect.TypeOf(packet) v := reflect.ValueOf(packet) if k := t.Kind(); k !...
// Package startf implements dataset transformations using the starlark programming dialect // For more info on starlark check github.com/google/starlark package startf import ( "bytes" "fmt" "io" "io/ioutil" "github.com/qri-io/dataset" "github.com/qri-io/dataset/dsfs" "github.com/qri-io/qfs" "github.com/qri-...
// This package provides ID masking using hash ids. // // Hash IDs are a string represnetation of numerical incrementing IDs, // obfuscating the integer value. For more information see // http://hashids.org/go/ package hashseq import ( "database/sql/driver" "encoding/json" "fmt" hashid "github.com/speps/go-hashid...
package model type Node struct { *FieldDescriptor StructRoot bool // 结构体标记的dummy node // 各种类型的值 Value string EnumValue int32 Raw []byte IsEmpty bool Child []*Node // 优先遍历值, 再key SugguestIgnore bool // 建议忽略, 非repeated的普通字段导出时, 如果原单元格没填, 这个字段为true } func (self *Node) AddValue(value string) *No...
// Copyright 2020 Paul Greenberg greenpau@outlook.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 applic...
package templates import ( "fmt" th "html/template" "os" "path" "path/filepath" "reflect" "strings" tt "text/template" ) const ( envPrefix = "AUTHELIA_" envXPrefix = "X_AUTHELIA_" ) // IMPORTANT: This is a copy of github.com/authelia/authelia/internal/configuration's secretSuffixes except all uppercase. /...
package main import ( "github.com/gin-gonic/gin" "github.com/linjinglan/gittest/src/common/route" ) func main() { r := gin.New() r = route.PathRoute(r) r.Run(":8000") }
package command import ( "context" "fmt" "github.com/romantomjak/b2/b2" ) func (c *ListCommand) listBuckets() int { client, err := c.Client() if err != nil { c.ui.Error(fmt.Sprintf("Error: %v", err)) return 1 } req := &b2.BucketListRequest{ AccountID: client.Session.AccountID, } ctx := context.TODO(...
package image import ( "testing" "github.com/stretchr/testify/assert" ) func TestReleaseImageList(t *testing.T) { cases := []struct { name string pullSpec string arch string result string }{ { name: "4.10rc", pullSpec: "quay.io/openshift-release-dev/ocp-release:4.10.0-rc.1-x86_64", ...
package nntp import ( "fmt" //"math/rand" "sort" "strings" ) // implements the algorithm from http://www.jwz.org/doc/threading.html // Tree-structured wrapper around ParsedArticle. type Container struct { Article *ParsedArticle // underlying Article Parent, Child, Next *Container // link struct...
package main import ( "context" "fmt" "os" "os/exec" "os/signal" "path/filepath" "strings" "syscall" "time" "github.com/fsnotify/fsnotify" "github.com/karlkfi/kubexit/pkg/kubernetes" "github.com/karlkfi/kubexit/pkg/log" "github.com/karlkfi/kubexit/pkg/supervisor" "github.com/karlkfi/kubexit/pkg/tombston...
package api import ( "encoding/json" "github.com/asaskevich/govalidator" "github.com/fasthttp/router" "github.com/polundrra/shortlink/internal/service" "github.com/valyala/fasthttp" "log" "regexp" "strings" ) type LinkApi struct { service service.Service } func New(service service.Service) LinkApi { return...
package tyme import ( "fmt" "time" ) // LocalDate represents year, month and daae without Location // e.g) January 2, 2006 type LocalDate struct { month LocalMonth date int } // NewLocalDate returns instance of LocalDate with given year, month and date func NewLocalDate(year int, month time.Month, date int) Loc...
// Copyright (c) 2021 Alexey Khan // // Permission is hereby granted, free of charge, to any person obtaining a copy // of this software and associated documentation files (the "Software"), to deal // in the Software without restriction, including without limitation the rights // to use, copy, modify, merge, publish, d...
// ˅ package main import ( "fmt" "os" "strconv" "strings" ) // ˄ // Analyze the syntax type Context struct { // ˅ // ˄ nodes []string currentIndex int // ˅ // ˄ } func NewContext(text string) *Context { // ˅ return &Context{strings.Fields(text), 0} // ˄ } func (self *Context) NextToken() string {...
//go:build !linux package main import "syscall" var sigInfo = syscall.SIGINFO
package swag // Version of swag const Version = "v2.3.1"
package main import ( "fmt" "strconv" "strings" ) func main() { time := "09:56" timeArray := strings.Split(time, ":") fmt.Println(timeArray) isValid := true temp, _ := strconv.Atoi(timeArray[0]) if temp < 0 || temp > 23 { fmt.Println("false") return } temp2, _ := strconv.Atoi(timeArray[1]) if t...
// 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...
// Copyright 2015 The Go Authors. All rights reserved. // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. package date_test import ( "testing" "time" "github.com/fxtlabs/date" ) func TestParseISO(t *testing.T) { cases := []struct { value string year int ...
package main import ( "log" "os" "github.com/gin-gonic/gin" "supertimemachine/service" "github.com/gin-contrib/cors" "flag" "gopkg.in/mgo.v2" "time" ) func main() { // all this initialization logic should be set somewhere else. port := os.Getenv("PORT") mongoUrl := os.Getenv("MONGO_URL") mongoUser := os....
package loggermw import ( "net/http" "net/http/httptest" "testing" ) func TestWriteHeader(t *testing.T) { rec := httptest.NewRecorder() crw := customResponseWriter{ ResponseWriter: rec, status: 0, size: 0, } crw.WriteHeader(http.StatusOK) if crw.status != http.StatusOK { t.Errorf("...
package main import ( "context" "encoding/json" "fmt" "log" "time" "github.com/utilitywarehouse/go-pubsub" "github.com/utilitywarehouse/go-pubsub/amqp" ) func main() { sink, err := amqp.NewMessageSink(amqp.MessageSinkConfig{ Address: "amqp://localhost:5672/", Topic: "demo-topic", }) if err != nil {...
/* 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 ir import ( "errors" "fmt" ) type InstrCode int const ( Add InstrCode = iota Sub Mul UDiv SDiv URem SRem And Or Xor Shl AShr LShr Not ICmp Call Alloc Store Load Bitcast SExt ZExt Trunc GEP Br Brif Ret Unreachable ) var instrCodeNameMap map[InstrCode]string func init() ...
/* Copyright 2018 The NSQ-Operator 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 ( "fmt" "time" ) func main() { fmt.Println("Welcome to Cabbie") fmt.Printf("\n") fmt. Println("Our Operational areas include: \n Alakahia \n Aluu \n Choba \n Rumosi \n Rumola \n Mgbuoba") //Get users name. var name string fmt.Println("Enter your name: ") fmt.Scanf("%s", &name) fmt.Pri...
package file import ( "testing" "bldy.build/build/workspace/testws" "bldy.build/build/label" ) func TestPath(t *testing.T) { tests := []struct { name string file string pkg string wd string path string }{ { name: "fileAtRoot", file: "a.c", pkg: "//:", wd: "/home/x/src/awesomeproje...
package storage var ( impl Manager ) // Implementor returns the storage manage service implementor. func Implementor() Manager { return impl } // RegisterImplementor registers the storage manage service implementor. func RegisterImplementor(mgr Manager) { impl = mgr } type Manager interface { New(component stri...
package main import ( "gatewayManager/controllers" "gatewayManager/models" "github.com/gin-gonic/gin" "io" "os" "path" "path/filepath" ) func main() { gin.DisableConsoleColor() // Logging to a file. f, _ := os.Create("app.log") gin.DefaultWriter = io.MultiWriter(f) r := gin.Default() models.ConnectDat...
package hystrix import ( "testing" "time" "github.com/stretchr/testify/assert" ) func TestOptionsAreSet(t *testing.T) { c := NewClient( WithHTTPTimeout(10*time.Second), WithCommandName("test"), WithHystrixTimeout(1100), WithMaxConcurrentRequests(10), WithErrorPercentThreshold(30), WithSleepWindow(5),...
package validate import ( "fmt" "net" "strings" "testing" "github.com/stretchr/testify/assert" ) func TestClusterName(t *testing.T) { maxSizeName := strings.Repeat("123456789.", 5) + "1234" cases := []struct { name string clusterName string valid bool }{ {"empty", "", false}, {"only w...
package main import ( "fmt" "github.com/sanguohot/medichain/util" "github.com/urfave/cli" "os" "time" ) func InitApp() error { app := cli.NewApp() app.Name = "medichain" app.Usage = "command line for medichain!" app.Version = "1.0.1" app.Compiled = time.Now() app.Authors = []cli.Author{ cli.Author{ Na...
package monitors import ( "reflect" "testing" "time" "github.com/janwiemers/up/models" ) func TestPopulateDefaults(t *testing.T) { tests := []struct { name string args models.Application want models.Application }{ { name: "Populate all defaults", want: models.Application{ Name: "test",...
package service type Service interface { Start() }
package oauth2state import ( "fmt" "sync" ) // MemStateStore is an in-memory implementation of StateStorer that // can be used safely by concurrent goroutines in a single server instance type MemStateStore struct { states map[string]string mutex sync.RWMutex valueGenerator ValueGenerator } // N...
package main import ( "html/template" "net/http" ) // create stucture เก็บข้อมูล type Product struct { Name string Price int } func main() { // สร้างตัวแปร var ให้เก็บค่า template ไปแสดงยัง index var templates = template.Must(template.ParseFiles("index.html")) // แสดงหน้าแรก http.HandleFunc("/index", func(w...
package req import ( "github.com/DanielRenne/mangosNode/rep" "log" "testing" ) const url = "tcp://127.0.0.1:600" var tGlobal *testing.T var messages chan string var messages2 chan string func TestReq(t *testing.T) { tGlobal = t messages = make(chan string) messages2 = make(chan string) var replyNode rep.Nod...