text
stringlengths
11
4.05M
// 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...
package gps import "encoding/json" var ( DefaultValueCodec Codec = &JSONCodec{} DefaultStreamCodec Codec = &JSONCodec{} ) type Codec interface { Encode(value interface{}) ([]byte, error) Decode(v []byte, value interface{}) error } type JSONCodec struct{} func (c *JSONCodec) Encode(value interface{}) ([]byte, ...
package main /** 回文数 判断一个整数是否是回文数。回文数是指正序(从左向右)和倒序(从右向左)读都是一样的整数。 示例1: ``` 输入: 121 输出: true ``` 示例2: ``` 输入: -121 输出: false 解释: 从左向右读, 为 -121 。 从右向左读, 为 121- 。因此它不是一个回文数。 ``` 示例2: ``` 输入: 10 输出: false 解释: 从右向左读, 为 01 。因此它不是一个回文数。 ``` 进阶: 你能不将整数转为字符串来解决这个问题吗? ``` */ /** 还是暴力吧,简单,明了 */ func DailyTemperatures(T []i...
package main import ( "bytes" "fmt" "net/url" "os" "strconv" "strings" "github.com/BurntSushi/toml" "github.com/docopt/docopt-go" "github.com/mitchellh/go-homedir" "github.com/root-gg/plik/plik" "github.com/root-gg/plik/server/common" ) // CliConfig object type CliConfig struct { Debug bool Qu...
package utility import ( "bytes" "fmt" "github.com/vallard/spark" "io/ioutil" "net/http" ) //SendJSON allows us to send JSON to a remote device func SendJSON(jsonStr []byte, url string) { req, err := http.NewRequest("POST", url, bytes.NewBuffer(jsonStr)) req.Header.Set("X-Custom-Header", "myvalue") req.Heade...
package types import ( "bytes" "fmt" "strings" "time" sdk "github.com/cosmos/cosmos-sdk/types" sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" paramtypes "github.com/cosmos/cosmos-sdk/x/params/types" ) // DefaultParamspace defines the default auth module parameter subspace const ( // todo: implement or...
/* * Remove a secondary network adapter from a given server. */ package main import ( "encoding/hex" "flag" "fmt" "os" "path" "github.com/grrtrr/clcv2/clcv2cli" "github.com/grrtrr/exit" ) func main() { var net = flag.String("net", "", "ID or name of the Network to use (REQUIRED)") var location = flag.Stri...
/* Copyright 2022 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, softw...
package main import ( "fmt" "time" ) func FirstDataBase(out1 chan string) { time.Sleep(2 * time.Second) out1 <- "Answer from DB1" } func SecondDataBase(out2 chan string) { time.Sleep(1 * time.Second) out2 <- "Answer from DB2" } func main() { out1 := make(chan string) out2 := make(chan string) go FirstDataB...
package metrics // SortMetrics ... type SortMetrics []PodMetric func (ms SortMetrics) Len() int { return len(ms) } func (ms SortMetrics) Less(i, j int) bool { switch ms[0].SortBy { case "cpu": return ms[i].CPU > ms[j].CPU case "memory": return ms[i].Memory > ms[j].Memory default: return false } } func ...
package webui import ( "os" "strings" "time" "github.com/go-macaron/binding" "github.com/toni-moreno/snmpcollector/pkg/agent" "github.com/toni-moreno/snmpcollector/pkg/config" "github.com/toni-moreno/snmpcollector/pkg/data/snmp" "gopkg.in/macaron.v1" ) // NewAPIRtAgent Runtime Agent REST API creator func New...
package main import ( "net" "strconv" "sync" ) type Peers struct { sync.Mutex peerList []*peerState } func newPeers() *Peers { return &Peers{peerList: make([]*peerState, 0)} } func (lp *Peers) Know(peer, id string) bool { lp.Lock() defer lp.Unlock() for _, p := range lp.peerList { if p.id != id { con...
package loadbalance_test import ( "fmt" "log" "time" providerRestApi "code.huawei.com/cse/api/provider/rest" "code.huawei.com/cse/common" "code.huawei.com/cse/testkit" "code.huawei.com/cse/util" . "github.com/onsi/ginkgo" . "github.com/onsi/gomega" ) func IsRoundRoubin(cycle int, n ...string) bool { Expec...
package depmain_test import ( "os" "testing" "github.com/onemedical/depmain" ) func TestEnv(t *testing.T) { os.Setenv("DEPMAIN_TEST_VALUE", "set") ext := depmain.New() if e := ext.Getenv("DEPMAIN_TEST_VALUE"); e != "set" { t.Errorf("Getenv: want %s got %s", "set", e) } if e := ext.Getenv("DEPMAIN_UNKNOWN_T...
package main import ( // "fmt" "fmt" "golang-web-api/book" "golang-web-api/handler" "log" "github.com/gin-gonic/gin" "gorm.io/driver/mysql" "gorm.io/gorm" ) func main(){ //connection database Mysql dsn := "root:@tcp(127.0.0.1:3306)/golang_web?charset=utf8mb4&parseTime=True&loc=Local" db, err := gorm.Op...
package main import ( "log" "fmt" "github.com/gotk3/gotk3/gtk" // config "./config" file_transfer "./file_transfer" // utils "./utils" video_stream "./video_stream" widgets "./widgets" ) var ( role = "server" close = false win *gtk.Window ) func addClientSide(win *gt...
package main import ( "context" "fmt" "net/http" "github.com/PacktPublishing/Go-Programming-Cookbook-Second-Edition/chapter7/twirp/rpc/greeter" ) func main() { // you can put in a custom client for tighter controls on timeouts etc. client := greeter.NewGreeterServiceProtobufClient("http://localhost:4444", &htt...
package space import ( "github.com/gomeetups/gomeetups/fixtures" "github.com/gomeetups/gomeetups/models" ) // ServiceMemory Address store uses an in memory store type ServiceMemory struct{} // Get Returns space details for given space id func (*ServiceMemory) Get(spaceID string) (space *models.Space, err error) { ...
package collector import ( "time" "github.com/jtaczanowski/tcp-pinger/pkg/config" "github.com/jtaczanowski/tcp-pinger/pkg/models" ) func Start(config *config.Config, pingerToCollectorChan chan models.Ping, collectorToAggregatorChan chan models.PingsCollection) { collection := models.PingsCollection{} ticker := ...
package tools import ( config "Web_Api/tools/config" "Web_Api/models/tools" "Web_Api/pkg" "Web_Api/pkg/app" "github.com/gin-gonic/gin" "net/http" ) // @Summary 分页列表数据 / page list data // @Description 数据库表分页列表 / database table page list // @Tags 工具 / Tools // @Param tableName query string false "tableName / 数据表名...
package schema import ( "time" "gopkg.in/mgo.v2/bson" ) // MemberRole describes the Membership role type MemberRole int // Member roles const ( MemberRoleOwner MemberRole = iota MemberRoleMember MemberRoleGuest ) var roles = [...]string{"owner", "member", "guest"} func (m MemberRole) String() string { retur...
package main import ( "fmt" "crypto/sha256" "os" "io" ) func main() { /*//hash函数第一种 sum := sha256.Sum256([]byte("audiRStony")) fmt.Printf("%X\n",sum)*/ //第二种 /* h := sha256.New() h.Write([]byte("audiRStony")) fmt.Printf("%X\n",h.Sum(nil))*/ //第三种。文件操作 h := sha256....
package aws import ( "context" "github.com/aws/aws-sdk-go/aws" "github.com/aws/aws-sdk-go/aws/awserr" "github.com/aws/aws-sdk-go/aws/session" "github.com/aws/aws-sdk-go/service/ec2" "github.com/pkg/errors" ) // InstanceTypeInfo describes the instance type type InstanceTypeInfo struct { Name string vCPU int64...
package authority import ( "time" "github.com/aghape/core" "github.com/aghape/core/utils" "github.com/moisespsena/go-route" ) // ClaimsContextKey authority claims key var ClaimsContextKey utils.ContextKey = "authority_claims" // Middleware authority middleware used to record activity time func (authority *Autho...
package database import ( "github.com/jinzhu/gorm" ) // Package is the ORM mapping for the packages table in MySql type Package struct { gorm.Model UserID uint Name string `gorm:"type:varchar(100)"` Path string `gorm:"not null"` Version string `gorm:"type:varchar(40);not null"` IsLatest bool }
package alicloud import ( "github.com/hashicorp/terraform/helper/resource" "testing" ) func TestAccAlicloudDnsDomainGroupsDataSource_name_regex(t *testing.T) { resource.Test(t, resource.TestCase{ PreCheck: func() { testAccPreCheck(t) }, Providers: testAccProviders, Steps: []resource.TestStep{ { C...
package main import ( "fmt" "html/template" "os" ) type Person struct { Name string Age int } func main() { t,err:=template.ParseFiles("E:/Project/src/GoRoutine/Web/template/index.html") //加载模板 if err!=nil{ fmt.Println("parse file err",err) return } p:=Person{"张三",19} err=t.Execute(os.Stdout,p) //渲染模板...
package dbserver_test import ( "os" "time" "io/ioutil" "gopkg.in/mgo.v2" . "github.com/onsi/ginkgo" . "github.com/onsi/gomega" "themis/mockdb" ) var _ = Describe("Dbserver", func() { type M map[string]interface{} var oldCheckSessions string var server dbserver.DBServer BeforeEach(func() { oldCheckSes...
package gorms import ( "gorm.io/driver/mysql" ) func NewMySqlAdapter(settings GormSettings) *adapter { return &adapter{ dialector: mysql.Open(settings.ConnectionString), settings: settings, } }
package main import ( "encoding/json" "net" ) type udpMesh struct { conn *net.UDPConn address *net.UDPAddr onPacket func(packet *adPacket) } func newUdpMesh(udpHostAndPort string, onPacket func(packet *adPacket)) (udp *udpMesh, err error) { var udpaddr *net.UDPAddr if udpaddr, err = net.ResolveUDPAddr("...
package kbucket import ( "math/rand" "testing" "time" peer "gx/ipfs/QmPJxxDsX2UbchSHobbYuvz7qnyJTFKvaKMzE2rZWJ4x5B/go-libp2p-peer" pstore "gx/ipfs/QmQFFp4ntkd4C14sP3FaH9WJyBuetuGUVo6dShNHvnoEvC/go-libp2p-peerstore" tu "gx/ipfs/QmVnJMgafh5MBYiyqbvDtoCL8pcQvbEGD2k9o9GFpBWPzY/go-testutil" ) // Test basic features...
/* The challenge is simply; output the following six 2D integer arrays: [[ 1, 11, 21, 31, 41, 51], [ 3, 13, 23, 33, 43, 53], [ 5, 15, 25, 35, 45, 55], [ 7, 17, 27, 37, 47, 57], [ 9, 19, 29, 39, 49, 59]] [[ 2, 11, 22, 31, 42, 51], [ 3, 14, 23, 34, 43, 54], [ 6, 15, 26, 35, 46, 55], [ 7, 18, 27, 38, 47, 58], [...
package feed import ( "encoding/json" "net/http" "camp/lib" "camp/skel/api" "camp/skel/service" "github.com/simplejia/clog/api" ) // GetReq 定义输入 type GetReq struct { ID int `json:"id"` Txt string `json:"txt"` } // Regular 用于参数校验 func (getReq *GetReq) Regular() (ok bool) { if getReq == nil { return } ...
package main func deleteDuplicates(head *ListNode) *ListNode { p := head for p != nil && p.Next != nil{ if p.Val == p.Next.Val{ p.Next = p.Next.Next }else{ p = p.Next } } return head }
package spidercore import ( "fmt" "io/ioutil" "net/http" ) func getRequest(request *http.Request) (string, error) { client := &http.Client{} res, err := client.Do(request) if err != nil { fmt.Println("client.Do error") return "", err } defer res.Body.Close() content, err := ioutil.ReadAll(res.Body) ...
package main import ( "fmt" "os/exec" "strings" ) func getOpenPorts() []string { // Bash file containing command that gets battery level cmd := "./Bash Functions/getOpenPorts.sh" // Gets battery level openPortsByte, _ := exec.Command(cmd).Output() openPortsString := string(openPortsByte) openPortsString = s...
package bilibili import ( "bytes" "encoding/binary" "fmt" ) const ( headerLENGTH = 16 // in bytes deviceTYPE = 1 device = 1 ) const ( // cmd types danmuMSG = "DANMU_MSG" danmuGIFT = "DANMU_GIFT" danmuWelcome = "WELCOME" DANMU_MSG = "DANMU_MSG" // 停播 LIVE_OFF = 0 // 直播 LIVE_ON = 1 //...
package main import ( "fmt" "log" "gopkg.in/couchbase/gocb.v1" ) func main() { // Uncomment following line to enable logging // gocb.SetLogger(gocb.VerboseStdioLogger()) endpoint := "cb.e493356f-f395-4561-a6b5-a3a1ec0aaa29.dp.cloud.couchbase.com" bucketName := "couchbasecloudbucket" username := "user" passw...
// ========================================================================== // 云捷GO自动生成业务逻辑层相关代码,只生成一次,按需修改,再次生成不会覆盖. // 生成日期:2020-02-18 15:44:13 // 生成路径: app/service/module/job/job_service.go // 生成人:yunjie // ========================================================================== package job import ( "errors" ...
package nginx import ( "sort" "testing" "time" ) func expectDate(t *testing.T, a Date, i int, yy int, mm time.Month, dd int) { if a.Year != yy { t.Errorf("Unexpected year for index %d: %d", i, a.Year) } if a.Month != mm { t.Errorf("Unexpected month for index %d: %s", i, a.Month) } if a.Day != dd { t.Err...
package main import ( "fmt" "os" "strconv" ) func isError(err error) bool { //for handling errors while creating or writing file if err != nil { fmt.Println(err.Error()) } return (err != nil) } func createFile(path string) { //creates a file in a path //path is the location at which the file will be crea...
package runtime import ( "github.com/devfeel/dotweb/test" "sync" "testing" "time" ) const ( DefaultTestGCInterval = 2 TEST_CACHE_KEY = "joe" TEST_CACHE_VALUE = "zou" //int value TEST_CACHE_INT_VALUE = 1 //int64 value TEST_CACHE_INT64_VALUE = 1 ) func TestRuntimeCache_Get(t *testing.T) { cache := NewT...
// Copyright 2023 PingCAP, Inc. Licensed under Apache-2.0. package operator import ( "time" "github.com/pingcap/tidb/br/pkg/task" "github.com/spf13/pflag" ) type PauseGcConfig struct { task.Config SafePoint uint64 `json:"safepoint" yaml:"safepoint"` TTL time.Duration `json:"ttl" yaml:"ttl"` } f...
package pgsql import ( "testing" ) func TestInt8(t *testing.T) { testlist2{{ data: []testdata{ { input: int(-9223372036854775808), output: int(-9223372036854775808)}, { input: int(9223372036854775807), output: int(9223372036854775807)}, }, }, { data: []testdata{ { input: int8(...
package app import "net/http" func (a *App) checkSession(w http.ResponseWriter, r *http.Request) { s, err := a.getSession(w, r) hdrs := w.Header() hdrs.Set("Content-Type", "text/plain; charset=utf-8") if err != nil { a.ctrCheckSessionErr.Inc() internalError(w, err, "getting session on check") return } ud ...
// Package inptils contains utilities to read the input required for the // application package inptils import ( "bufio" "bytes" "log" "github.com/google/uuid" c "github.com/pedromss/kafli/config" "github.com/pedromss/kafli/model" ) func createChannel() chan *model.RecordToSend { return make(chan *model.Recor...
package main import ( "bytes" "crypto/sha1" "encoding/hex" "io/ioutil" "net/http" "sort" "strings" "time" ) // RemoteCallWithBody send http func RemoteCallWithBody(method, url string, token, user string, body []byte, contentType string) (*http.Response, []byte, error) { var request *http.Request var err er...
package main import ( "fmt" "math/rand" "time" ) // 1生成一个随机1维数组,10个元素,int类型 // 随机数seed生成一个10维数组函数 func createArr(arr *[10]int) { rand.Seed(time.Now().Unix()) // 以当前时间的unix秒作为种子 for i := 0; i < len(arr); i++ { (*arr)[i] = rand.Intn(100) // 随机产生100以内的整数 } } // 2倒置数组输出 // 递归调用一下试试? /* func convert(arr [10]...
package discovery import ( "os" "time" "github.com/alecthomas/log4go" "github.com/wanghongfei/go-eureka-client/eureka" "github.com/wanghongfei/gogate/conf" "github.com/wanghongfei/gogate/utils" ) var euClient *eureka.Client var gogateApp *eureka.InstanceInfo func InitEurekaClient() { c, err := eureka.NewClie...
package gogen import ( "go/ast" "strings" ) // Import is a structure representing import string in ast tree type Import struct{ BaseType parent *ast.ImportSpec importString string } // String will return import string func (i *Import) String() string { return i.importString } // NewImport will construc...
/* Copyright 2021 The Nuclio 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, soft...
package dalmodel import "github.com/jinzhu/gorm" type Notification struct { gorm.Model UserID uint text string }
package main import ( "github.com/hashicorp/terraform/plugin" "github.com/hashicorp/terraform/terraform" "github.com/nukosuke/terraform-provider-zendesk/zendesk" ) func main() { plugin.Serve(&plugin.ServeOpts{ ProviderFunc: func() terraform.ResourceProvider { return zendesk.Provider() }, }) }
package constants const ServerAddress = ":9090"
/* A Pythagorean triplet is a set of three natural numbers, a < b < c, for which, a^2 + b^2 = c^2 For example, 32 + 42 = 9 + 16 = 25 = 52. There exists exactly one Pythagorean triplet for which a + b + c = 1000. Find the product abc. */ package main import ( "flag" "fmt" "strconv" ) func m...
package service import ( "context" client2 "krpc/client" "log" "net" "sync" "testing" "time" ) //type Foo int //type Args struct {Num1, Num2 int} //func (f Foo) Sum(args Args, reply *int) error { // *reply = args.Num2 + args.Num1 // return nil //} func startServer(addr chan string) { var foo Foo if err := ...
package main import ( "github.com/notassigned/p2p-tools/cli" ) // main func main() { cli.Root.Run() }
package main import ( "testing" ) func TestAssignmentOperator(t *testing.T) { // ---------------- 赋值运算符 ------------------------ // = += -= *= /= t.Log(".......") a := 10 b := 20 c := a a = b b = c t.Logf("%d,%d \n", a, b) n, m := 10, 20 x := n + m n = x - n m = x - n t.Logf("%d,%d \n", n, m) } fu...
package utils import ( "bufio" "fmt" "github.com/fatih/color" "golang.org/x/crypto/ssh/terminal" "os" "strings" "syscall" ) func GetInput(prompt string) (string, error) { reader := bufio.NewReader(os.Stdin) printPrompt(prompt) userInput, err := reader.ReadString('\n') if err != nil { return "", err } ...
package server import ( "encoding/base64" "errors" "github.com/golang/glog" "net/http" "strconv" "time" ) func CheckToken(token string, w http.ResponseWriter, req *http.Request)(user_uuid string, err error){ req.ParseForm() glog.Info("rec token:", token, " token length:", len(token)) if len(token) > 18 { ...
package leetcode /*给定一棵二叉搜索树,请找出其中第k大的节点。*/ /** * Definition for a binary tree node. * type TreeNode struct { * Val int * Left *TreeNode * Right *TreeNode * } */ func kthLargest(root *TreeNode, k int) int { nums := make([]int, 0, k) getNums(root, &nums) return nums[k-1] } func getNums(root *Tree...
package slack import ( "encoding/json" "testing" "github.com/stretchr/testify/assert" ) const ( dialogSubmissionCallback = `{ "type": "dialog_submission", "submission": { "name": "Sigourney Dreamweaver", "email": "sigdre@example.com", "phone": "+1 800-555-1212", "meal": "burrito", "comment": "...
package mymath /**/ func GetSum(n int) int { var sum = 0 for i := 1;i<n+1;i++{ sum += i } return sum } func GetSumRecursively(n int) int { if n == 1{ return 1 } return n + GetSumRecursively(n-1) }
package romaininteger import ( "strconv" "testing" ) var isIntegerRoman = []struct { roman string numero int }{ {"IV", 4}, {"III", 3}, {"MM", 2000}, {"LVIII", 58}, {"MCMXCIV", 1994}, {"MCCXLIX", 1249}, {"CMXCIX", 999}, } func TestRomanToInt(t *testing.T) { for _, tt := range isIntegerRoman { t.Run(str...
package types import ( "app-auth/db" "context" "fmt" "log" "github.com/mongodb/mongo-go-driver/bson" "github.com/mongodb/mongo-go-driver/mongo/options" ) type TeamMapType = map[string]interface{} type OrganisationMapType = map[string]interface{} type ScopeObjectMapping = map[string]OrganisationMapType type S...
package main import ( "fmt" "net/http" "flag" "net/url" "strings" "io/ioutil" "encoding/json" ) var opType, from, to, date, page *string var state, t *int type Result struct { Success bool Content Content } type Content struct { BusNumberList []BusNumber } type BusNumber struct { BeginStationName string...
package main import ( "fmt" "os" "strconv" "strings" ) func parseStdin(args []string) [][]int { result := make([][]int, len(args)) for i, arg := range args { s := strings.Split(arg, "") inner := make([]int, len(s)) for j, str := range s { inty, _ := strconv.Atoi(str) inner[j] = inty ...
package main import ( "bytes" "compress/gzip" "encoding/base64" "encoding/json" "errors" "fmt" "github.com/denisbrodbeck/machineid" "github.com/kbinani/screenshot" "golang.org/x/net/websocket" "image/png" "io/ioutil" "os" "strconv" "syscall" "time" "unsafe" ) const ( ON_SCREEN = "70" //打开监控屏幕 OFF_S...
package rakuten // IchibaService に メソッドを追加していく type IchibaService service
package controller import ( "net/http" "time" "feeyashop/models" "github.com/gin-gonic/gin" "gorm.io/gorm" ) type categoryInput struct { Name string `json:"name"` } // GetAllCategory godoc // @Summary Get all Category. // @Description Get a list of Category. // @Tags Category // @Produce json // @Success 200...
package model type Hand struct { Cards } func (h *Hand) Discard(c Card) bool { return h.Cards.Remove(c) }
package serverconfigs import ( "github.com/iwind/TeaGo/assert" "testing" ) func TestServerGroup_Protocol(t *testing.T) { a := assert.NewAssertion(t) { group := NewServerGroup("tcp://127.0.0.1:1234") a.IsTrue(group.Protocol() == ProtocolTCP) a.IsTrue(group.Addr() == "127.0.0.1:1234") } { group := NewSe...
package lookuptree import ( "errors" "strconv" "strings" ) /* * 获得IP地址第level层的整型数(从前往后数,0至3位) */ func GetIpSection(ip string, level int) (ipsec int, err error) { ipsecs := strings.Split(ip, ".") if level < 0 || level >= len(ipsecs) { err = errors.New("Wrong index when parsing ip.") return } return strco...
package raindrops import ( "math" "strconv" ) //Convert - converts numbers to raindrops :mindblown: func Convert(num int) string { rain := "" rain += AddStringIfFactor(num, 3, "Pling") rain += AddStringIfFactor(num, 5, "Plang") rain += AddStringIfFactor(num, 7, "Plong") if rain == "" { rain = strconv.Itoa(n...
// Copyright (c) 2018 SAP SE or an SAP affiliate company. All rights reserved. This file is licensed under the Apache Software License, v. 2 except as noted otherwise in the LICENSE file // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the Lice...
// Copyright 2018 Clivern. All rights reserved. // Use of this source code is governed by the MIT // license that can be found in the LICENSE file. package module import ( "fmt" "github.com/clivern/walrus/core/driver" log "github.com/sirupsen/logrus" "github.com/spf13/viper" ) // Stats type type Stats struct {...
package main import ( "bytes" "encoding/json" "fmt" "io/ioutil" "net" "net/http" "os" ) // Config is used to store the vars from the json config file type Config struct { URL string `json:"url"` APIKey string `json:"api_key"` } // Interface stores the interface information found from the server type Inte...
package config import ( "strings" "github.com/layer5io/meshery-adapter-library/adapter" "github.com/layer5io/meshery-adapter-library/meshes" smp "github.com/layer5io/service-mesh-performance/spec" ) var ( ConsulOperation = strings.ToLower(smp.ServiceMesh_CONSUL.Enum().String()) ) func getOperations(dev adapter...
/* 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 sqlbuilder // Add a HAVING clause to your query with one or more constraints (either Expr instances or And/Or functions) func (q *Query) Having(constraints ...SQLProvider) *Query { if q.having == nil { q.having = new(constraint) q.having.gate = gate_and } q.having.children = append(q.having.children, c...
package ikgo const ( HIT_UNMATCH = 0x00000000 HIT_MATCH = 0x00000001 HIT_PREFIX = 0x00000010 ) type Hit struct { hitState int //该HIT当前状态,默认未匹配 matchedDictSegment *DictSegment //记录词典匹配过程中,当前匹配到的词典分支节点 beg, end int //词段起止位置 } /** * 判断是否完全匹配 */ func (h *Hit) isMatch() bo...
package ircserver import ( "testing" "github.com/robustirc/robustirc/internal/robust" "gopkg.in/sorcix/irc.v2" ) func TestServerQuit(t *testing.T) { i, ids := stdIRCServerWithServices() i.ProcessMessage(&robust.Message{Session: ids["services"]}, irc.ParseMessage(":services.robustirc.net NICK blorgh 1 14255427...
package client /* #cgo CFLAGS: -std=c11 #cgo LDFLAGS: -lcomedi -lm */ import "C" const N_FLOORS = 4 const N_BUTTONS = 3 const MOTOR_SPEED = 2800 type elevMotorDirection int const ( DIRN_DOWN elevMotorDirection = -1 << iota DIRN_STOP DIRN_UP ) type elevButtonType int const ( BUTTON_CALL_UP elevButt...
package sql_test import ( "reflect" "strings" "testing" "github.com/messagedb/messagedb/sql" ) // Ensure the scanner can scan tokens correctly. func TestScanner_Scan(t *testing.T) { var tests = []struct { s string tok sql.Token lit string pos sql.Pos }{ // Special tokens (EOF, ILLEGAL, WS) {s: ``...
package util import ( "encoding/json" "log" "net/http" ) // Handler is a handler for a request to this service. Use MakeHTTPHandler to // wrap a Handler with the logic necessary to produce a handler which can be // registered with the "net/http" package. type Handler = func(ctx *Context) StatusError // MakeHTTPHa...
package acmt import ( "encoding/xml" "github.com/thought-machine/finance-messaging/iso20022" ) type Document02100101 struct { XMLName xml.Name `xml:"urn:iso:std:iso:20022:tech:xsd:acmt.021.001.01 Document"` Message *AccountClosingAdditionalInformationRequestV01 `xml:"AcctCls...
package logger import ( "encoding/json" "fmt" "log" "log/syslog" "os" "strings" ) /** * Logger class that can be instantiated to start doing all of the * logging that's necessary. */ type LoLLogger struct { logger *syslog.Writer initialized bool } type LoLLogEvent struct { Priority syslog.Priority ...
package fetcher import ( "bufio" "errors" "fmt" "golang.org/x/net/html/charset" "golang.org/x/text/encoding" "golang.org/x/text/transform" "io/ioutil" "net" "net/http" "time" ) var timeout = time.Duration(5 * time.Second) func dialTimeout(network, addr string) (net.Conn, error) { return net.DialTimeout(ne...
package main import ( "fmt" "io" "io/ioutil" "os" ) type CountingWriterImpl struct { w io.Writer c int64 } func (c *CountingWriterImpl) Write (p []byte) (int, error) { c.w.Write(p) c.c += int64(len(p)) return len(p), nil } func CountingWriter(w io.Writer) (io.Writer, *int64) { cw := CountingWriterImpl{w: ...
/** * ShortURL: Bijective conversion between natural numbers (IDs) and short strings * Licensed under the MIT License (https://opensource.org/licenses/MIT) * * ShortURL::encode() takes an ID and turns it into a short string * ShortURL::decode() takes a short string and turns it into an ID * * Features: * + larg...
package main import ( "bufio" "fmt" "log" "os" "sync" ) func getBoxID(fname string, c chan<- string, wg *sync.WaitGroup) { file, err := os.Open(fname) if err != nil { log.Fatal(err) } defer file.Close() scanner := bufio.NewScanner(file) for scanner.Scan() { c <- scanner.Text() } if err := scanner.E...
package routes import( book "restfulalta/part-4-middleware/controllers/book" "restfulalta/part-4-middleware/middlewares" ) func registerBookRoutes() { e.GET("/books", book.GetBooksController) e.GET("/books/:id", book.GetBookByIdController) e.POST("/books", book.AddBookController, middlewares.AuthenticateUser) ...
package postgres import ( "sync" "github.com/frk/gosql/internal/analysis" "github.com/frk/gosql/internal/postgres/oid" ) //////////////////////////////////////////////////////////////////////////////// // Result Types // type ( // FieldWrite holds the information needed by the generator to produce the // expres...
package main import "fmt" func main() { start := 65 end := 90 for i := start; i <= end; i++ { fmt.Printf("%d\n", i) for j := 0; j < 3; j++ { fmt.Printf("\t%#U\n", i) } } }
package utils import ( "github.com/astaxie/beegae" "fareastdominions.com/evepaste/eve/entity" ) type RefineItem struct { Outputs []RefineOutput RefineCategory string } type RefineOutput struct { TypeId int32 Quantity float64 } var REFINE_TABLE = map[int32]RefineItem{ // Veldspar 1230: Refin...
package security import ( "encoding/json" "github.com/dintel/budget-backend/util" "io/ioutil" "log" ) type Processor struct { dataDir string users map[string]User permits Permits done chan bool RequestCh chan Request ResultCh chan Result } func loadUsers(dataDir string) map[string]User { res...
package multiline_test import ( "fmt" "math/rand" "time" "github.com/byounghoonkim/multiline" ) func ExampleMultiLine() { for i := 0; i < 10; i++ { line := multiline.GetLine(fmt.Sprintf("%d job - ", i)) go func(line *multiline.Line) { defer line.Close() fmt.Fprint(line, "🚚 Preparing ...") time.Sl...
package main import ( "fmt" "os" "log" "net/http" "github.com/alehano/gobootstrap/sys/cmd" "github.com/go-chi/chi" "github.com/go-chi/chi/middleware" "github.com/alehano/gobootstrap/config" "github.com/spf13/cobra" "github.com/alehano/gobootstrap/sys/urls" _ "github.com/alehano/gobootstrap/models" _ "githu...
package gcp import ( "context" "fmt" "os" "path/filepath" "strings" "sync" "github.com/AlecAivazis/survey/v2" "github.com/pkg/errors" "github.com/sirupsen/logrus" googleoauth "golang.org/x/oauth2/google" compute "google.golang.org/api/compute/v1" ) var ( authEnvs = []string{"GOOGLE_CREDENTIALS...
package models import ( "fmt" "testing" "github.com/c2h5oh/datasize" ) func TestUsage(t *testing.T) { var bm = NewUsageManager(newTestDB(t, &Usage{})) type args struct { username string tier DataUsageTier testUploadSize uint64 } tests := []struct { name string args args wantE...