text
stringlengths
11
4.05M
package client import ( "net/http" "time" "github.com/docker/distribution/registry/client/auth" "github.com/docker/distribution/registry/client/auth/challenge" "github.com/docker/distribution/registry/client/transport" ) var serverBase = "https://registry-1.docker.io" func backendAuthTransport(server, image st...
package graph import "fmt" func ExampleScc() { args := []struct { from, to int }{ {1, 2}, {2, 1}, {2, 3}, {4, 3}, {4, 1}, {1, 4}, {2, 3}, } n, m := 4, 7 scc := NewScc(n) for i := 0; i < m; i++ { a, b := args[i].from, args[i].to a-- b-- scc.AddEdge(a, b) } scc.Do() mp := make(map[in...
package request type Codec interface { Marshaller Unmarshaller } type Marshaller interface { Marshal(v interface{}) ([]byte, error) } type Unmarshaller interface { Unmarshal(data []byte, v interface{}) error } type CodecFuncs struct { MarshalFunc UnmarshalFunc } type MarshalFunc func(v interface{}) ([]byte, e...
package main import "fmt" //函数外只可以放标识符的声明,也就是变量 常量 函数 类型 的声明,不可以放语句 //go语言的变量需要先声明再使用 //同一个作用域不可以声明相同的变量 var name string func main() { name = "hello" fmt.Printf("name:%s\n", name) fmt.Println(name) fmt.Print(name) //声明变量同时赋值 var s1 string ="hello" //类型推导 var s2="20" //简短变量声明 s3:=5 //匿名变量用于接收不想要的变量 const...
package main import ( _ "github.com/IBM-Cloud/terraform-provider-ibm" )
package v1alpha5 // ClusterCloudWatch contains config parameters related to CloudWatch type ClusterCloudWatch struct { //+optional ClusterLogging *ClusterCloudWatchLogging `json:"clusterLogging,omitempty"` } // ClusterCloudWatchLogging container config parameters related to cluster logging type ClusterCloudWatchLog...
package rectangle //Perimeter is function for ..... func Perimeter(width, length float64) float64 { return 2*(width+length) + b }
/* Package config contains data structures and methods for handling application configuration */ package config import ( "encoding/json" "github.com/alewgbl/fdwctl/internal/logger" "github.com/alewgbl/fdwctl/internal/model" "github.com/alewgbl/fdwctl/internal/util" "github.com/spf13/afero" "gopkg.in/yaml.v3" "o...
package app import ( "github.com/cosmos/cosmos-sdk/baseapp" "github.com/cosmos/cosmos-sdk/codec" sdk "github.com/cosmos/cosmos-sdk/types" "github.com/cosmos/cosmos-sdk/x/auth" "github.com/cosmos/cosmos-sdk/x/params" tmos "github.com/tendermint/tendermint/libs/os" dbm "github.com/tendermint/tm-db" "github.com/t...
package goSolution import "testing" func TestSuperpalindromesInRange(t *testing.T) { AssertEqual(t, 1, superpalindromesInRange("1", "1000000000000000000")) AssertEqual(t, 4, superpalindromesInRange("4", "1000")) }
package main import ( "bytes" "encoding/json" "flag" "fmt" "io/ioutil" "net/http" "strconv" ) func migrate(source_url, dest_url string) { doc_batch := 10 search_query := []byte(`{ "query": { "match_all": {} } }`) from := 0 for from != -1 { request, err := http.NewRequest("XGET", source_url+"_search/?si...
package types const ( HeaderKeyServiceID = "@service" ) // GetServiceID returns a service ID from a given header func GetServiceID(h HeaderI) (string, bool) { v, ok := h.Get(HeaderKeyServiceID) if !ok { return "", false } return string(v), true } // SetServiceID sets ID to a given header func SetServiceID(h H...
package 设计题 type Node struct { Key int Value int } const m = 10003 type MyHashMap struct { arr [10005][]Node } /** Initialize your data structure here. */ func Constructor() MyHashMap { return MyHashMap{[10005][]Node{}} } /** value will always be non-negative. */ func (this *MyHashMap) Put(key int, value int...
package storage import ( "github.com/emicklei/go-restful" api "github.com/emicklei/go-restful-openapi" "storage-manager/dbcentral/etcd" "storage-manager/dbcentral/pg" . "storage-manager/types" "grm-service/geoserver" . "grm-service/util" ) type StorageSvc struct { SysDB *pg.SystemDB DynamicDB *etcd.Dyn...
package main import ( "log" "github.com/gofiber/websocket/v2" ) type client struct{} // Add more data to this type if needed // NOTE: although large maps with pointer-like types (e.g. strings) as keys are slow, using pointers themselves as keys is acceptable and fast var clients = make(map[*websocket.Conn]clien...
package main import "time" func main() { go func() { Loop() }() for { time.Sleep(time.Second * 10) } }
package main import ( "log" "net/http" "os" "github.com/99designs/gqlgen/graphql/handler" "github.com/99designs/gqlgen/graphql/playground" "github.com/bb3104/gqlgen_template_project/internal/graph/generated" "github.com/bb3104/gqlgen_template_project/internal/graph/resolvers" "github.com/bb3104/gqlgen_templa...
package main import ( "bufio" "fmt" "os" "strings" ) func main() { dict := make(map[string]string) scanner := bufio.NewScanner(os.Stdin) line := "" keyPair := make([]string, 2) // Loop and read input for scanner.Scan() { line = scanner.Text() // End loop on a blank line if line == "" { break ...
package main import ( solcast "github.com/Siliconrob/solcast-go/solcast" datatypes "github.com/Siliconrob/solcast-go/solcast/types" "errors" "fmt" "log" "os" ) var YOUR_API_KEY = "<API KEY HERE>" func testRadiationForecast(location datatypes.LatLng) error { result := solcast.RadiationForecast(location) if le...
package jwker import ( "fmt" "os" ) func throwParseError(message string) { fmt.Fprintf(os.Stderr, "Could not parse key: %v\n", message) os.Exit(1) } func stopOnParseError(err error) { if err != nil { throwParseError(err.Error()) } }
package azure import ( "context" "errors" "fmt" "strings" "time" aznetwork "github.com/Azure/azure-sdk-for-go/services/network/mgmt/2018-12-01/network" azdns "github.com/Azure/azure-sdk-for-go/services/preview/dns/mgmt/2018-03-01-preview/dns" azprivatedns "github.com/Azure/azure-sdk-for-go/services/privatedns...
package iredis import "github.com/garyburd/redigo/redis" type IRedisPool interface { StartMasterPool(addr string, password string, maxIdle int, maxActive int) bool StartSlavePool(addr string, password string, maxIdle int, maxActive int) bool GetMasterConn() IValue GetSlaveConn() IValue CloseMaster() error Close...
package omigad type httpconfig struct { Server struct { Appname string `yaml:"appname"` Httpport string `yaml:"httpport"` Runmodel string `yaml:"runmode"` Copy bool `yaml:"copyrequestbody"` Endpoint string `yaml:"endpoint"` AccessKey string `yaml:"accesskey"` SecretKey string `yaml:"s...
package acs_test import ( "bytes" "io" "testing" "github.com/mdouchement/acs" ) var ( key = []byte("f>Gp@U-y4;$8`C@QP#^s]]ptuN='mD7,") data = []byte("Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.") ) func TestACS(t *testing.T) { v...
// Copyright 2015 The Chromium 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 main import ( "errors" "fmt" "os" "path/filepath" "strings" "sync" "time" "github.com/luci/luci-go/client/archiver" "github.com/luci/lu...
package iirepo_stage const name string = "stage" // Name returns the name of the repo stage directory. func Name() string { return name }
package main import ( "fmt" "github.com/bogdanov-d-a/gocourse2018/workshop1/task2/fizzbuzz" ) func main() { fmt.Print(fizzbuzz.Get(100)) }
// generated by jsonenums -type=ConversationType -suffix=_enum; DO NOT EDIT package schema import ( "encoding/json" "fmt" ) var ( _ConversationTypeNameToValue = map[string]ConversationType{ "ConversationTypePrivate": ConversationTypePrivate, "ConversationTypeGroup": ConversationTypeGroup, "ConversationTyp...
package main import ( "fmt" "os/exec" "os" "bufio" ) func main(){ i := 5 if (i < 0){ return } pwd,_ := os.Getwd() name := fmt.Sprintf("Sully_%d.go", i) exe := fmt.Sprintf("%s/Sully_%d", pwd, i) file,_ := os.Create(name) buff := bufio.NewWriter(file) content := "package main%c%cimport (%c %cfmt%c%c %cos...
package cmdline import ( "strconv" "strings" ) const ( _1k = 1024 _1m = _1k * _1k _1g = _1k * _1m ) type Options struct { argReader *ArgReader classpath string verboseClass bool xss int Xcpuprofile string XuseJavaHome bool } func newOptions(argReader *ArgReader) *Options { return &Option...
package v1 import ( "testing" ) func TestYamlParse(t *testing.T) { y1 := []byte(` - hi - hello - key1: - val1 - innnerKey1: innerval1 innerKey2: innerval2 - val3 key2: - val4 `) if err := walkYAML(y1); err != nil { t.Errorf("Failed to walk YAML: %v", err) } }
/* Write a program that takes R, G, and B values as command arguments and then displays that color some way. It doesn't matter how, as long as at least 100 pixels have the color. Shortest code wins. */ package main import ( "flag" "fmt" "image" "image/color" "image/draw" "image/png" "os" "strconv" ) func m...
package wps import ( `fmt` `net/http` `net/url` `github.com/go-resty/resty/v2` `github.com/google/go-querystring/query` log `github.com/sirupsen/logrus` ) // UploadNetworkFile 上传网络文件 // 可以是Http和Https地址,且只支持这两种地址 func (w *Wps) UploadNetworkFile(fileUrl string) (rsp UploadFileRsp, err error) { var ( params ur...
package sqlite import ( "strings" ) type QueryStringParser struct { q string } func NewQueryStringParser(q string) *QueryStringParser { return &QueryStringParser{ q: q, } } func (p *QueryStringParser) nextString() (s string) { // Skip leading white space. for { if p.q[0] == ' ' { p.q = p.q[1:] } else...
package elastic import ( "context" "fmt" stdLog "log" "os" "github.com/olivere/elastic/v7" ) type ( store struct { Client *elastic.Client } ) func New(elasticURL string) *store { errorlog := stdLog.New(os.Stdout, "APP ", stdLog.LstdFlags) client, err := elastic.NewClient( elastic.SetURL(elasticURL), ...
package main import "fmt" func main() { com := Computer{} pho := Phone{} cam := Camera{} com.Working(pho) com.Working(cam) //接口是一个指针类型 stu := Stu{} stu.Name = "jimmy" fmt.Println(stu.Name) //接口的继承 var e BInterface = E{} e.Test01() } //Usb:引入一个usb插camera和手机的接口 //Usb: to insert or convert power type Usb...
package main import ( "../SftpPb" "context" "fmt" "google.golang.org/grpc" "log" "strconv" "time" ) func main() { fmt.Println("Starting SFTP client") conn, err := grpc.Dial("localhost:50051", grpc.WithInsecure()) if err != nil { log.Fatalf("could not connect: %v", err) } defer conn.Close() c := sftpp...
package new_storage import ( "archive/tar" "context" "encoding/json" "fmt" "io" "io/ioutil" "os" "path" "path/filepath" "sort" "strings" "time" "github.com/AlexAkulov/clickhouse-backup/config" "github.com/AlexAkulov/clickhouse-backup/internal/progressbar" "github.com/AlexAkulov/clickhouse-backup/pkg/me...
// Copyright 2016 Tamás Gulácsi. All rights reserved. // Use of this source code is governed by The MIT License // found in the accompanying LICENSE file. package ora /* #include <stdlib.h> #include <oci.h> #include "version.h" */ import "C" import "unsafe" type nullp struct { p *C.sb2 } func (np *nullp) Pointer()...
package problem0677 import "testing" func TestSolve(t *testing.T) { mapSum := Constructor() ops := []string{"insert", "sum", "insert", "sum"} strs := []string{"apple", "ap", "app", "ap"} vals := []int{3, 0, 2} for i := 0; i < len(ops); i++ { op := ops[i] if op == "insert" { mapSum.Insert(strs[i], vals[i])...
// Copyright 2021 Clivern. All rights reserved. // Use of this source code is governed by the MIT // license that can be found in the LICENSE file. package definition import ( "fmt" "strings" "testing" "github.com/franela/goblin" ) // TestUnitEtcd test cases func TestUnitEtcd(t *testing.T) { g := goblin.Goblin...
package token import ( "encoding/base64" "errors" "strconv" "strings" "time" "ziyun/util/log" "ziyun/util/redis" ) //access_token用jwt编码 //refresh-token用base64编码 var ( ErrNotSupportOperation = errors.New("no support operation") ErrRefreshTokenExpired = errors.New("refresh_token expired") ErrIn...
package helpers import ( "math/rand" "regexp" ) var emailRegex = regexp.MustCompile("\\w+([-+.]\\w+)*@\\w+([-.]\\w+)*\\.\\w+([-.]\\w+)*") func IsEmail(input string) bool { var output = true Block{ Try: func() { output = emailRegex.MatchString(input) }, Catch: func(e Exception) { output = false }, ...
package vips import ( "github.com/sherifabdlnaby/bimg" cfg "github.com/sherifabdlnaby/prism/pkg/config" "github.com/sherifabdlnaby/prism/pkg/payload" ) // TODO : ONLY PNG type label struct { Raw labelRawConfig `mapstructure:",squash"` width cfg.Selector dpi cfg.Selector margin cfg.Selector ...
package util import( "os" "io/ioutil" "fmt" "strings" ) func Create(filename string) (*os.File, error) { pos := strings.LastIndex(filename, "/") if pos > 0 { filepath := filename[0: pos] if filepath != "." || filepath != ".." { os.MkdirAll(filepath, 0777) } ...
package ebakusdb import ( "fmt" "syscall" "unsafe" ) func (db *DB) mmap(sz int) error { b, err := syscall.Mmap(int(db.file.Fd()), 0, sz, syscall.PROT_WRITE|syscall.PROT_READ, syscall.MAP_SHARED) if err != nil { return err } _, _, e := syscall.Syscall(syscall.SYS_MADVISE, uintptr(unsafe.Pointer(&b[0])), uint...
// 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 rest import ( "fmt" "net/url" "github.com/jinmukeji/jiujiantang-services/pkg/rest" proto "github.com/jinmukeji/proto/v3/gen/micro/idl/partner/xima/core/v1" "github.com/kataras/iris/v12" ) // Payment 支付 type Payment struct { RecordID int32 `json:"record_id"` } // MakePayment 支付 func (h *handler) MakePa...
package main import ( "fmt" "io/ioutil" "runtime" "strings" ) func checkErr(error error) { if error != nil { panic(error) } } func getFileContent(path string) string { _, currentPath, _, _ := runtime.Caller(1) dat, err := ioutil.ReadFile(currentPath + path) checkErr(err) return string(dat[:]) } func m...
// Copyright 2019 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 main import ( "fmt" "github.com/vugu/vjson" "github.com/vugu/vugu" "github.com/vugu/vugu/domrender" ) func main() { var r vjson.RawMessage var be vugu.BuildEnv var jr domrender.JSRenderer // log.Printf("hello there!") fmt.Printf("hello testpgm: %v %v %v\n", r, be, jr) fmt.Printf("hello testpgm: ...
/* * @lc app=leetcode.cn id=198 lang=golang * * [198] 打家劫舍 */ package main import "fmt" func rob(nums []int) int { if len(nums) == 0 { return 0 } if len(nums) == 1 { return nums[0] } dp := make([]int, len(nums)) dp[0] = nums[0] dp[1] = max(nums[0], nums[1]) for i :...
/* * Copyright @ 2020 - present Blackvisor Ltd. * * 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 l...
package passgen import "errors" var ( alpLower = []byte{'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z'} alpUpper = []byte{'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S...
package redis_api import ( "github.com/go-redis/redis" "strconv" "errors" ) type redisConnections map[string]*redisConnection type redisConnection struct { *redis.Client Conf *RedisConfig `json:"conf"` AllKeys [][]string `json:"all_keys"` Err error `json:"err"` } func (rcons redisConnections) Remove(con...
package stringutil type Converter interface { Process(text string) string }
// Copyright (c) 2020 twihike. All rights reserved. // Use of this source code is governed by a MIT license // that can be found in the LICENSE file. package structconv import ( "errors" "reflect" "testing" ) type testMapInterface struct { A int } func (t *testMapInterface) test() {} func TestDecodeMap(t *test...
// walker. // // go run ./main [Path]... // package main import ( "flag" "fmt" "io/ioutil" "os" "path/filepath" "runtime" "sync" ) type Walker struct { fileQueue chan string dirQueue chan []string checked map[string]bool mu sync.Mutex wg sync.WaitGroup } func NewWalker() *Walker { return &Walker{chec...
package aoc2016 import ( "sort" "strconv" "strings" "unicode" aoc "github.com/janreggie/aoc/internal" "github.com/pkg/errors" ) // room represents a room (Year 2016 Day 4). // // Syntax // // RAW is represented by ENCRYPTEDNAME-SECTORID[CHECKSUM], // where ENCRYPTEDNAME is a string of length at least 1 contain...
package run import ( "sync" "testing" "time" "github.com/stretchr/testify/require" ) func Test_LazyRunner(t *testing.T) { var result []int before := time.Now() runner := LazyRunner{ Run: func(stopCh <-chan struct{}) { t.Log("Start") EachUntilImmediately(func() { ms := time.Since(before) / time.Mil...
package models import ( "fmt" "strings" "github.com/ymomoi/goval-parser/oval" ) // ConvertSUSEToModel Convert OVAL to models func ConvertSUSEToModel(root *oval.Root, suseType string) (roots []Root) { m := map[string]Root{} for _, ovaldef := range root.Definitions.Definitions { rs := []Reference{} for _, r :...
package resources import ( "github.com/containers-ai/alameda/datahub/pkg/dao/interfaces/clusterstatus/types" "github.com/containers-ai/api/alameda_api/v1alpha1/datahub/resources" ) type NodeExtended struct { *types.Node } func (p *NodeExtended) ProduceNode() *resources.Node { node := resources.Node{} node.Objec...
package healthz import ( "errors" "net/http" "net/http/httptest" "testing" "github.com/DataDog/datadog-go/statsd" "github.com/labstack/echo/v4" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/mock" ) type MockPinger struct { mock.Mock } func (m *MockPinger) Ping() error { args := m.Calle...
/************************************************************ Galaxy : The road is long and long, and I look for it Package : yh_tool Time : 2018/3/19 下午9:30 Author : LiuJun Email : 1035841713@qq.com ************************************************************/ package legal import ( "regexp" ) const ( //手机...
/* * @lc app=leetcode.cn id=1802 lang=golang * * [1802] 有界数组中指定下标处的最大值 */ // @lc code=start func maxValue(n int, index int, maxSum int) int { ret := 1 maxSum -= n left := index right := index for maxSum >= right-left+1 { if left == 0 && right == n-1 { ret += maxSum / n return ret } ret += 1 maxS...
package gui import ( "github.com/andlabs/ui" ) type modelHandler struct{} func (mh *modelHandler) ColumnTypes(m *ui.TableModel) []ui.TableValue { return []ui.TableValue{ ui.TableString(""), ui.TableString(""), ui.TableString(""), ui.TableString(""), ui.TableString(""), } } func (mh *modelHandler) NumRo...
package main import ( "fmt" "log" "net/http" "context" "math/rand" "strconv" "time" "io" "os" "io/ioutil" "golang.org/x/oauth2" "golang.org/x/oauth2/google" "google.golang.org/api/calendar/v3" "cloud.google.com/go/storage" ) var stateString string; func getSta...
package main type Base64ImgStruct struct { Img []byte `json:"img,omitempty"` }
package article import ( "github.com/gin-gonic/gin" ) func InitRouter(r *gin.RouterGroup) { { //获取标签列表 r.GET("/tags", GetTags) //新建标签 r.POST("/tags", AddTag) //更新指定标签 r.PUT("/tags/:id", EditTag) //删除指定标签 r.DELETE("/tags/:id", DeleteTag) r.GET("/articles", GetArticles) //获取指定文章 r.GET("/article...
package main import ( "encoding/json" "os" "time" ) type CacheFeed struct { ItemPubDate time.Time `json:"itemPubDate"` } type Cache struct { f *os.File `json:"-"` Feeds map[string]CacheFeed `json:"feeds"` ItemPubDate time.Time `json:"itemPubDate"` Items []Item ...
package main //client.go import ( "fmt" "log" "math/rand" "time" "net" // "github.com/sercand/kuberesolver" // "google.golang.org/grpc/resolver" "google.golang.org/grpc/balancer/roundrobin" pb "gitlab.bj.sensetime.com/SenseGo/grpc-gateway-demo/proto" "golang.org/x/net/context" "google.golang.org/gr...
package metrics import ( "fmt" "net/http" "testing" "time" ) func Test_Register_ProvidesBytes(t *testing.T) { metricsPort := 31111 metricsServer := MetricsServer{} metricsServer.Register(metricsPort) cancel := make(chan bool) go metricsServer.Serve(cancel) defer func() { cancel <- true }() retries ...
package internalapi import ( "encoding/json" "fmt" "net" "net/http" "net/http/pprof" "sync" "time" "github.com/jonas747/yagpdb/common" "github.com/jonas747/yagpdb/common/config" "goji.io" "goji.io/pat" ) var _ common.PluginWithCommonRun = (*Plugin)(nil) func RegisterPlugin() { common.RegisterPlugin(&Plu...
package server import ( "encoding/json" "encoding/xml" "fmt" "net" "github.com/ghetzel/canibus/api" "github.com/ghetzel/canibus/logger" ) const ( LANG_XML = iota LANG_JSON ) const ( STATE_UNAUTH = iota STATE_LOBBY ) // Main Client Structure type Client struct { Name string Incoming chan string Out...
package config import ( "GoCRUDs/pkg/utils" log "github.com/sirupsen/logrus" "sync" ) var ( config *Config once sync.Once ) type Config struct { ServiceConfig *ServiceConfigs DBConfigs *DBConfigs Env string } type DBConfigs struct { Url string Port string DatabaseName str...
package models import ( "time" ) func init() { //db , err := mysql.GetMysqlDb() //if err != nil { // fmt.Println(err) // return //} //if !db.HasTable(&Users{}) { // db.Set("gorm:table_options", "ENGINE=InnoDB DEFAULT CHARSET=utf8").CreateTable(&Users{}) //} } type Model struct { CreatedAt time.Time Update...
package query import ( "testing" "github.com/inazo1115/toydb/lib/util" ) func TestParse0(t *testing.T) { input := []*LexToken{ &LexToken{TokenCREATE, "create", 0, 0}, &LexToken{TokenTABLE, "table", 7, 0}, &LexToken{TokenKEY, "table_name", 13, 0}, &LexToken{TokenLPAREN, "(", 24, 0}, &LexToken{TokenKEY, "...
package bot // InScope is used to look up the scope of the message. This can be public, a channel or private func (b *Bot) InScope(scope string) bool { if _, ok := b.Scope[scope]; ok { return true } return false }
package api import ( "context" "github.com/gremlinsapps/avocado_server/api/model" "github.com/gremlinsapps/avocado_server/dal/model" "github.com/gremlinsapps/avocado_server/dal/sql" "github.com/gremlinsapps/avocado_server/helpers" ) func (r *queryResolver) ChatsByUserID(ctx context.Context, id int) ([]apimodel.C...
package status import ( "encoding/json" "log" "net" ) type UDPResponder struct { raddr *net.UDPAddr conn *net.UDPConn } func (ur *UDPResponder) Reply(fr *friendResponse) error { data, err := json.Marshal(fr) if err != nil { log.Println(err) return nil } data = append(data, []byte("\n")...) _, err = ur...
// Code references : https://github.com/netsec-ethz/scion-homeworks/blob/master/bottleneck_bw_est/v1_bw_est_client.go and reference https://github.com/perrig/scionlab/blob/master/sensorapp/sensorserver/sensorserver.go package main import ( "flag" "encoding/binary" "fmt" //importing fmt package for printing ...
package zoom type ComplianceRequest struct { ClientID string `json:"client_id"` UserID string `json:"user_id"` AccountID string `json:"account_id"` DeauthorizationEventReceived DeauthorizationPayload `json:...
package _151_翻转字符串里的单词 import "strings" func reverseWords(s string) string { parsed := strings.Fields(s) for left, right := 0, len(parsed)-1; left < right; { parsed[left], parsed[right] = parsed[right], parsed[left] left++ right-- } return strings.Join(parsed, " ") }
package handlers import ( "GameReviews/servers/gateway/models/users" "errors" "golang.org/x/crypto/bcrypt" "time" ) type MockStore struct { } // LogUserSignIn logs a user sign in func (ms *MockStore) LogUserSignIn(id int64, time time.Time, addr string) error { return nil } func (ms *MockStore) GetByID(id int6...
package config import ( "io/ioutil" "gopkg.in/yaml.v2" "github.com/op/go-logging" fritzctlConfig "github.com/bpicode/fritzctl/config" ) type Config struct { FritzBox *ConfigFritzBox `yaml:"fritzbox"` Exporter *ConfigExporter `yaml:"exporter"` } type ConfigFritzBo...
package main import ( "flag" "fmt" "github.com/golang/glog" "github.com/aws/aws-sdk-go/aws" "github.com/aws/aws-sdk-go/aws/credentials" "github.com/aws/aws-sdk-go/aws/session" "github.com/aws/aws-sdk-go/service/sns" ) var ( region = flag.String("region", "us-east-1", "aws region") credFile = flag.S...
package model //密码:Password //旧密码 OldPassword //新密码 NewPassword //确认密码 ConfirmPassword type Password struct { Id int OldPassword string NewPassword string ConfirmPassword string }
package routes import ( "orion/controller" "os" // _ "orion/docs" //swagger docs, you should import it "github.com/go-chi/chi" "github.com/go-chi/chi/middleware" "github.com/go-chi/cors" httpSwagger "github.com/swaggo/http-swagger" ) //SetupRouter handles application routing func SetupRouter(appPort string) ...
// Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. package engine import ( "net/http" "net/http/httptest" "testing" ) var ( mux *http.ServeMux server *httptest.Server ) func setup() func() { mux = http.NewServeMux() server = httptest.NewServer(mux) return fun...
package webscraper import ( "testing" ) func TestGetPageProductData(t *testing.T) { // GIVEN pageStr := ` <!DOCTYPE html> <html lang="en"> <head> <title>Title</title> </head> <body> <div class="productSummary"> <div class="productTitleDescriptionContainer"> <h1>Sainsbury's Avocado, Ripe & Ready x2<...
package mavlink2 /* Generated using mavgen - https://github.com/ArduPilot/pymavlink/ Copyright 2020 queue-b <https://github.com/queue-b> Permission is hereby granted, free of charge, to any person obtaining a copy of the generated software (the "Generated Software"), to deal in the Generated Software without restric...
// 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 auth import ( "context" "github.com/aws/aws-sdk-go-v2/aws" "github.com/aws/aws-sdk-go-v2/service/cognitoidentityprovider" "github.com/aws/aws-sdk-go-v2/service/cognitoidentityprovider/types" "github.com/gofor-little/xerror" ) // UpdateExpiredPassword updates a password for a user that has a requirement ...
package main import ( "context" "github.com/blendle/zapdriver" "github.com/petomalina/fcm-companion/pkg/companion" "github.com/petomalina/fcm-companion/pkg/serverutil" "go.uber.org/zap" "go.uber.org/zap/zapcore" "os" ) func main() { ctx := context.Background() config := zapdriver.NewProductionConfig() conf...
/* * Copyright 2017 - 2019 KB Kontrakt 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 require...
package database import ( "fmt" "garduino/utils" _ "github.com/go-sql-driver/mysql" "github.com/jinzhu/gorm" _ "github.com/jinzhu/gorm/dialects/mysql" ) //Conection to DB var Connection *gorm.DB var err error // Connect will handle DB connections via GORM and migrate table structure. func Connect() { dbHost ...
package main import ( "net/http" "strconv" "strings" "time" "github.com/go-chi/chi" //"io/ioutil" ) type eventDetailContextData struct { Event Event FormErrors string FormMessages string Donate string } type eventCreateContextData struct { FormErrors []string FormMessages string Redire...
// Copyright 2019-present 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 agr...
package main import ( "fmt" "github.com/shopify/sarama" ) func main(){ fmt.Println("kafka") config:=sarama.NewConfig() config.Producer.RequiredAcks=sarama.WaitForAll //ack config.Producer.Partitioner=sarama.NewRandomPartitioner //随机分区 config.Producer.Return.Successes=true client,err:=sarama.NewSyncProduc...
/* * Strava API v3 * * The [Swagger Playground](https://developers.strava.com/playground) is the easiest way to familiarize yourself with the Strava API by submitting HTTP requests and observing the responses before you write any client code. It will show what a response will look like with different endpoints depen...