text
stringlengths
11
4.05M
package exceltitle import ( "bytes" "math" ) /* 1 A 0*26 + 1 26 Z 0*26 + 26 27 AA 1*26 + 1 52 AZ 1*26 + 26 53 BA 2*26 + 1 701 ZY 26*26 + 25 702 ZZ 26*26 + 26 703 AAA 1*678 + 1*26 + 1 */ var placeValues = make(map[int]int) // excelDigit...
package endpoint import ( "errors" "github.com/skidder/streammarker-writer/config" "github.com/skidder/streammarker-writer/db" "github.com/skidder/streammarker-writer/msg" "golang.org/x/net/context" ) // MessageWriter provides functions for writing messages to storage type MessageWriter interface { Run(context...
package webapp import ( "github.com/dblokhin/config" "context" "errors" ) // key is used by context.Context type key int const ( keyParams key = iota keyClient keyCSRFToken ) var ( noClientError = errors.New("no client data") noConfig = errors.New("error on load app config") noInstance = errors.New("no we...
package query import ( "encoding/json" "net/http" "github.com/gorilla/mux" ) func Configure(router *mux.Router) { router.HandleFunc("/account/{id}", getAccount).Methods("GET") } func handleAccountCreated(evt AccountCreated) { writeAccount(BankAccount{ Name: evt.Name, Balance: evt.Balance, }) } func ...
package game import ( "context" "encoding/json" "errors" "fmt" "net/http" "sort" "strconv" "time" dbfile "github.com/HanYu1983/gomod/lib/db/file" "github.com/HanYu1983/gomod/lib/tool" "google.golang.org/appengine" "google.golang.org/appengine/datastore" ) var _ = time.Millisecond func CreateUser(w http...
package main import ( "flag" "fmt" "github.com/shybily/beansproxy/resources" "github.com/shybily/beansproxy/server" "os" ) var ( config string ) func main() { flag.StringVar(&config, "config", "", "config file") flag.Parse() if len(config) <= 0 { flag.Usage() os.Exit(1) } opt, err := server.NewYamlP...
package client import ( "IMServer/internal/client/conf" "io" "net" "gogit.oa.com/March/gopkg/protocol/bypack" "gogit.oa.com/March/gopkg/util" ) func Run() { reader := SendAndRecv(buffer888()) conf.L.Info(reader.String()) } func Send(data []byte) { _, err := Conn().Write(data) util.MustNil(err) } func Sen...
package main import ( "compress/bzip2" "io" "io/ioutil" "log" "os" "strconv" "strings" "github.com/cheuka/dota-parser/dota2" "github.com/cheuka/dota-parser/getStats" _ "github.com/go-sql-driver/mysql" "github.com/jinzhu/gorm" ) func main() { //demFileName := decompressBzip2ToDemFile("C:/2545299883.dem...
package management import ( "context" "math/rand" "sync/atomic" ) const ( // Indicates how many log messages the listener will hold before dropping. // Provides a throttling mechanism to drop latest messages if the sender // can't keep up with the influx of log messages. logWindow = 30 ) // session captures a...
package backup import ( "encoding/json" "fp-dynamic-elements-manager-controller/api/util" "fp-dynamic-elements-manager-controller/internal/backup" "fp-dynamic-elements-manager-controller/internal/backup/structs" notificationfuncs "fp-dynamic-elements-manager-controller/internal/notification" "github.com/rs/zerol...
package main import ( "context" "fmt" "os" "encoding/csv" "strings" "log" "io" "github.com/coreos/go-semver/semver" "github.com/google/go-github/github" ) // LatestVersions returns a sorted slice with the highest version as its first element and the highest version of the smaller minor versions in a descend...
package main //接口和反射 //类型不需要显式声明它实现了某个接口:接口被隐式地实现。多个类型可以实现同一个接口。 //实现某个接口的类型(除了实现接口方法外)可以有其他的方法。 //一个类型可以实现多个接口。 //接口类型可以包含一个实例的引用, 该实例的类型实现了此接口(接口是动态类型)。 //type Shaper interface { // Area() float32 //} // //type Square struct { // side float32 //} // //func (sq *Square) Area() float32 { // return sq.side * sq.side /...
package types type User struct { Id int `gorm:"primary_key"` Username string `sql:"unique"` MimeType string } func (User) SwaggerDoc() map[string]string { return map[string]string{ "": "A user object", "id": "The id of the user", "username": "The username of the user", } }
package main import ( "encoding/json" "flag" "fmt" "io/ioutil" "log" ) func (bot *Bot) loadConfiguration(filepath string) { configFile, err := ioutil.ReadFile(filepath) if err != nil { flag.Usage() log.Fatal(err.Error()) } err = json.Unmarshal(configFile, &bot) if err != nil { log.Fatal(err.Error())...
package integration // Collection of utilities to share between our various load tests import ( "io/ioutil" "os" "path/filepath" "strconv" "time" "github.com/cortexproject/cortex/integration/e2e" cortex_e2e "github.com/cortexproject/cortex/integration/e2e" "github.com/cortexproject/cortex/pkg/util" "github....
package roman import ( "testing" "github.com/stretchr/testify/assert" ) func TestToArabicI(t *testing.T) { assert.Equal(t, 1, ToArabic("I")) } func TestToArabicV(t *testing.T) { assert.Equal(t, 5, ToArabic("V")) } func TestToArabicX(t *testing.T) { assert.Equal(t, 10, ToArabic("X")) } func TestToArabicL(t *t...
package dbconfig_test import ( "testing" "github.com/adlerhsieh/dbconfig" ) func TestReadFile(t *testing.T) { config := dbconfig.ReadFile("./example/database.yml", "development") username := "foo" password := "bar" if config["username"] != username { t.Error("Expecting config username as " + username + ". Go...
/* * Npcf_SMPolicyControl API * * Session Management Policy Control Service © 2019, 3GPP Organizational Partners (ARIB, ATIS, CCSA, ETSI, TSDSI, TTA, TTC). All rights reserved. * * API version: 1.0.4 * Generated by: OpenAPI Generator (https://openapi-generator.tech) */ package openapi // QosFlowUsage - Possib...
package pubsub import ( "context" "flag" "fmt" "hash/fnv" "os" "runtime" "sync" "time" "cloud.google.com/go/pubsub" "github.com/GoogleCloudPlatform/cloud-ingest/agent/tasks/list" "github.com/golang/glog" ) const ( listProgressTopicID = "cloud-ingest-list-progress" copyProgressTopicID = "cloud-ingest...
package animals func ElephpantFeed() string{ return "Grass" }
package streaming_transmit import ( "net" "testing" "github.com/stretchr/testify/require" "go.uber.org/goleak" ) func TestServerShutdown(t *testing.T) { defer goleak.VerifyNone(t) srv := &Server{} ln, err := net.Listen("tcp", ":0") require.NoError(t, err) go func() { srv.Shutdown() ln.Close() }() ...
package array // GetMapIntKeys get map keys,return slice func GetMapIntKeys(m map[int]interface{}) []int { keys := make([]int, 0, len(m)) for i := range m { keys = append(keys, i) } return keys }
package notaryctl import ( "context" "github.com/operator-framework/operator-lib/status" regv1 "github.com/tmax-cloud/registry-operator/api/v1" "github.com/tmax-cloud/registry-operator/internal/schemes" "github.com/tmax-cloud/registry-operator/internal/utils" corev1 "k8s.io/api/core/v1" "k8s.io/apimachinery/pk...
package game import ( "github.com/talesmud/talesmud/pkg/entities" "github.com/talesmud/talesmud/pkg/entities/characters" ) // Avatar ... default active entity that moves in the world // Avatars can be either controlled by Players/Users or be attached/belong to bots // Once a user is logged in he automatically gets ...
package util //物流 import ( "encoding/json" "log" "net/http" "JsGo/JsConfig" "JsGo/JsLogger" "crypto/md5" "fmt" "io/ioutil" "strings" ) type ExpressFlow struct { Time string `json:"time"` //时间,原始格式 Ftime string `json:"ftime"` //格式化后时间 Context string `json:"context"` //内容 } type ExpressInfo stru...
package main import "github.com/jwt/controller" func main() { controller.RunController(":8080") }
package basiccron import ( "fmt" "sync" "testing" "time" ) func TestCronError(t *testing.T) { cron := New(time.Second) if _, err := cron.AddFunc(time.Now().Add(time.Second*2), time.Hour, func () { fmt.Println("Hello, world") }, 10); err == nil { t.Error("This AddFunc should return Error, wrong number of arg...
package main import "sort" //1738. 找出第 K 大的异或坐标值 //给你一个二维矩阵 matrix 和一个整数 k ,矩阵大小为m x n 由非负整数组成。 // //矩阵中坐标 (a, b) 的 值 可由对所有满足 0 <= i <= a < m 且 0 <= j <= b < n 的元素 matrix[i][j](下标从 0 开始计数)执行异或运算得到。 // //请你找出matrix 的所有坐标中第 k 大的值(k 的值从 1 开始计数)。 // // // //示例 1: // //输入:matrix = [[5,2],[1,6]], k = 1 //输出:7 //解释:坐标 (0,1)...
package commander // actor Assigned to execute the command type actor struct { names []string // the keys contain one of names than execute action triggers map[string]bool // the keys contain all true values and none false value in triggers than execute action action Action // executed comma...
package impala import ( "context" "database/sql/driver" "log" "time" "github.com/apache/thrift/lib/go/thrift" "github.com/bippio/go-impala/hive" ) // Conn to impala. It is not used concurrently by multiple goroutines. type Conn struct { t thrift.TTransport session *hive.Session client *hive.Client l...
package injection import ( "context" "github.com/stretchr/testify/assert" "github.com/surmus/injection/test" "net/http" "reflect" "testing" ) var middlewareFnExecuted bool type testRoutes struct { t *testing.T } func (r *testRoutes) Use(handlerFnValues ...reflect.Value) Routes { ctx := context.WithValue(con...
// Copyright 2019 The Cockroach Authors. // // Use of this software is governed by the Business Source License // included in the file licenses/BSL.txt. // // As of the Change Date specified in that file, in accordance with // the Business Source License, use of this software will be governed // by the Apache License, ...
package bucket import ( "fmt" "testing" ) func TestCRUDValue(t *testing.T) { b := NewLocalBucket("my.db") if err := b.Open(); err != nil { t.Error(err) } defer b.Close() n := 10 for i := 0; i < n; i++ { err := b.Put(fmt.Sprintf("Key#%d", i+1), []byte(fmt.Sprintf("Value#%d", i+1))) if err != nil { t...
/* Copyright 2018 Bitnine Co., 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 law or agreed to in writing, softwar...
package main import "fmt" /** 值传递与指针传递 */ func main_() { a := 10 b := 20 swap(a, b) //新建内存空间,存值,即10 ,20 fmt.Printf("main: a = %d,b= %d\n", a, b) } /** 传值:交换a,b的值 */ func swap(a, b int) { a, b = b, a fmt.Printf("swap: a = %d,b= %d\n", a, b) } func main() { a := 10 b := 20 fmt.Println("main:指针&a指向的值为,", *&a)...
package main import ( "bytes" "encoding/json" "fmt" "io" "net" "net/http" "time" ) type HttpClient struct { c *http.Client endpoint string } func NewHttpClient(endpoint string) *HttpClient { hc := &http.Client{ Transport: &http.Transport{ Dial: func(...
package model type Product struct { HotelId int64 `json:"hotel,omitempty"` Id int64 `json:"id,omitempty"` UserId int64 `json:"usuario,omitempty"` GroupId int64 `json:"grupo,omitempty"` CfpopId int64 `json:"cfop,omitempty"` Code string `json:"codigo,omitempt...
package controller import ( "golang.org/x/net/context" "google.golang.org/grpc" "github.com/brocaar/loraserver/api/nc" ) // NopNetworkControllerClient is a dummy network-controller client which is // used when no network-controller is present / configured. type NopNetworkControllerClient struct{} // HandleRXInfo...
package main import ( "sync" "math/rand" "time" "fmt" ) var count int //定义一个全局变量 var rwMutex sync.RWMutex func main() { quit := make(chan bool) for i := 0; i < 5; i++ { go write() } for i := 0; i < 5; i++ { go read() } <-quit } func read() { for { rwMutex.RLock() fmt.Println("读取", count) rwMutex...
package messageBus import ( "fmt" "os" "github.com/streadway/amqp" ) const ( host = "localhost" port = 5672 user = "guest" password = "guest" ) // Connect establishes a connection // to the RabbitMQ instance func Connect() (*amqp.Connection, error) { var url string if os.Getenv("RABBITMQ_HOST"...
package main import ( "fmt" "io/ioutil" "log" ) func GetAllFile(filepath string, s []string) ([]string, error){ fileInfo, err := ioutil.ReadDir(filepath) if err != nil { log.Println("read dir failed: ", err) return s, nil } level := 2 for _, child := range fileInfo { if level < 0 { return s, nil } ...
package ledger import ( "context" "time" ) type MerchantRepository interface { Merchant(ctx context.Context, id string) (*Merchant, error) MerchantByAlias(ctx context.Context, alias string) (*Merchant, error) Merchants(ctx context.Context) ([]*Merchant, error) CreateMerchant(ctx context.Context, merchant *Merch...
package order import ( "context" "fmt" "net" "net/http" "strings" "time" "github.com/bakins/kubernetes-envoy-example/api/item" "github.com/bakins/kubernetes-envoy-example/api/order" "github.com/bakins/kubernetes-envoy-example/util" grpc_middleware "github.com/grpc-ecosystem/go-grpc-middleware" grpc_zap "gi...
package cache import "sync" type lockCache struct { mu sync.RWMutex items map[string]interface{} } func newLockCache() Cache { return &lockCache{items: make(map[string]interface{})} } func (lc *lockCache) Get(k string) (interface{}, bool, error) { lc.mu.RLock() v, ok := lc.items[k] lc.mu.RUnlock() return...
// tx_test package tx import ( "encoding/hex" "testing" ) const ( txHex = "01000000" + // version "01" + // n inputs "26c07ece0bce7cda0ccd14d99e205f118cde27e83dd75da7b141fe487b5528fb" + //prev txid "00000000" + // output index "8b" + // length of scriptSig "48304502202b7e37831273d74c8b5b1956c23e79acd6606...
package date import ( "errors" "strconv" "time" ) //FromString converts YYYY-MM-DD string to time.Time func FromString(s string) (time.Time, error) { if len(s) != 10 { return time.Time{}, errors.New("wrong format") } year := s[:4] month := s[5:7] day := s[8:] y, err := strconv.Atoi(year) if err != nil { ...
package odoo import ( "fmt" ) // WebTourTour represents web_tour.tour model. type WebTourTour struct { LastUpdate *Time `xmlrpc:"__last_update,omptempty"` DisplayName *String `xmlrpc:"display_name,omptempty"` Id *Int `xmlrpc:"id,omptempty"` Name *String `xmlrpc:"name,omptempty"` Us...
package api import ( "fmt" "net/http" "strings" "github.com/ledisdb/ledisdb/ledis" "github.com/mylxsw/adanos-alert/agent/store" "github.com/mylxsw/adanos-alert/internal/extension" "github.com/mylxsw/adanos-alert/internal/repository" "github.com/mylxsw/adanos-alert/pkg/misc" "github.com/mylxsw/adanos-alert/rp...
package types import ( "fmt" "github.com/zhaohaijun/matrixchain/common" ct "github.com/zhaohaijun/matrixchain/core/types" "github.com/zhaohaijun/matrixchain/errors" comm "github.com/zhaohaijun/matrixchain/p2pserver/common" ) type Block struct { Blk *ct.Block } //Serialize message payload func (this *Block) Se...
/* Copyright 2017 Adobe. All rights reserved. This file is licensed to you 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 agre...
package main import ( "fmt" "hash/crc32" "io" "os" ) func getHash(filename string) (uint32, error) { // open the file file, err := os.Open(filename) if err != nil { return 0, err } // remember to always close opened files defer file.Close() // create a hasher hasher := crc32.NewIEEE() // copy the file ...
package worker import ( "../object" log "github.com/sirupsen/logrus" "io/ioutil" "net/http" "time" ) // Declaration of the repository, using the interface from object package var Repo object.ObjectRepository // Exported method to start the worker. Made this way so it doesn't require explicit goroutine usage fun...
package health_test import ( "encoding/binary" "fmt" "io/ioutil" "net/http" "net/http/httptest" "github.com/cerana/cerana/acomm" healthp "github.com/cerana/cerana/providers/health" ) func (s *health) TestHTTPStatus() { ts := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { ...
/* Populating Next Right Pointers in Each Node Given a binary tree struct TreeLinkNode { TreeLinkNode *left; TreeLinkNode *right; TreeLinkNode *next; } Populate each next pointer to point to its next right node. If there is no next right node, the next pointer should be set to NULL. Initially,...
package markdown import ( "os" "testing" "github.com/gebv/pikchr/markdown/syntax" ) func TestMain(m *testing.M) { syntax.Debug() syntax.ErrorVerbose() os.Exit(m.Run()) }
package blockchain import ( "errors" "github.com/ChainStack-Official/simple_blockchain/common/hash_util" "github.com/ChainStack-Official/simple_blockchain/core/bcerr" "github.com/ChainStack-Official/simple_blockchain/core/block" "sync" "time" "github.com/ethereum/go-ethereum/log" ) // 区块链 type Blockchain stru...
package prometheus import ( "time" prom_v1 "github.com/prometheus/client_golang/api/prometheus/v1" "github.com/prometheus/common/model" ) // BaseMetricsQuery holds common parameters for all kinds of queries type BaseMetricsQuery struct { prom_v1.Range RateInterval string RateFunc string Quantiles []str...
package main import ( "fmt" "net" ) func hErr(err error) { if err != nil { panic(err) } } func main() { conn, err := net.Dial("tcp", "127.0.0.1:18000") hErr(err) defer conn.Close() fmt.Println("local addr: ", conn.LocalAddr()) fmt.Println("remote addr", conn.RemoteAddr()) _, err = conn.Write([]byte("Are...
package messages import ( "bytes" "encoding/binary" ) //路由消息接口 type IGateMessage interface { // GetMsgID() uint32 // GetMyID() uint32 // GetTargetID() uint32 // SetMsgID(msgid uint32) // SetMyID(myid uint32) // SetTargetID(targetid uint32) //编码,传出编码的数据和数据的长度 GateMarshal() ([]byte, uint32) //解码,传入数据,传出使用后剩...
// 12 december 2015 package ui import ( "unsafe" ) // #include "ui.h" import "C" // RadioButtons is a Control that represents a set of checkable // buttons from which exactly one may be chosen by the user. // // Due to platform-specific limitations, it is impossible for a // RadioButtons to have no button selecte...
// Copyright 2018 The Cockroach Authors. // // Use of this software is governed by the Business Source License // included in the file licenses/BSL.txt. // // As of the Change Date specified in that file, in accordance with // the Business Source License, use of this software will be governed // by the Apache License, ...
package mintinterfaces import "net" // Interface Connector type ConnectorInterface interface { // Connection start to work Start() // Stop the connection Stop() // Get TCP connection GetClientConnection() *net.TCPConn // Get connection ID GetClientConnID() uint32 // Get IP:Port GetClientAddr() net.Addr ...
package restic // Backend is used to store and access data. type Backend interface { // Location returns a string that describes the type and location of the // repository. Location() string // Test a boolean value whether a File with the name and type exists. Test(t FileType, name string) (bool, error) // Rem...
package kademlia import ( "context" "errors" "fmt" "time" "go.uber.org/zap" ) // BucketSize is a constant value of the total number of peer ID entries a single routing table bucket hold. const BucketSize int = 16 // PingTimeout is a constant value of ping timeout const PingTimeout time.Duration = 3 * time.Seco...
package p24 import ( "fmt" "io/ioutil" "log" "strconv" "strings" ) func Main(args []string) { if len(args) != 2 { log.Fatal("usage: advent-of-code-2017 24[a|b] filename") } switch args[0] { case "24a", "24": fmt.Print(Strongest(args[1])) case "24b": fmt.Print(Longest(args[1])) } } type Conn [2]int ...
package repository import ( "github.com/porter-dev/porter/internal/models" ) type NotificationConfigRepository interface { CreateNotificationConfig(am *models.NotificationConfig) (*models.NotificationConfig, error) ReadNotificationConfig(id uint) (*models.NotificationConfig, error) UpdateNotificationConfig(am *mo...
package commands import ( "github.com/codegangsta/cli" "github.com/mitsuse/parser-go" ) func NewTrainCommand(c *parser.Config) cli.Command { command := cli.Command{ Name: "train", ShortName: "t", Usage: "Trains a dependency parser with data.", Action: newTrainAction(c), Flags: []cli.Flag{ ...
package sLSM type KVIntPair struct { kvp KVPair i int } func NewKVIntPair(pair KVPair, i int) *KVIntPair { return &KVIntPair{ kvp: pair, i: i, } } type StaticHeap struct { h []KVIntPair cmp Comparer } func NewStaticHeap(size int, cmp Comparer) *StaticHeap { return &StaticHeap{ h: make([]KVIntPa...
package yelp import "testing" // TestParseURL tests the expected case for transforming a URL to Yelp ID func TestParseURL(t *testing.T) { example := "http://www.yelp.com/biz/kona-club-oakland" if ParseURL(example) != "kona-club-oakland" { t.Errorf("Error parsing URL. Expected: %v got: %v", "kona-club-oakland", Pa...
// API between the Go application and the MySql database. package main import ( "log" "net/url" "strconv" "time" ) type SABReports struct { Central1 float64 `json:"central1"` Central2 float64 `json:"central2"` Central3 float64 `json:"central3"` Central4 float64 `json:"central4"` Central6 float6...
package main import ( "strings" "testing" "github.com/stretchr/testify/assert" ) func TestRead_OK(t *testing.T) { bsonService := defaultBsonService{} bson := "\x16\x00\x00\x00\x02hello\x00\x06\x00\x00\x00world\x00\x00" result, err := bsonService.ReadNextBSON(strings.NewReader(bson)) assert.NoError(t, err, ...
package sharding import "math/rand" func SetUUIDRand(r *rand.Rand) { uuidRand = r }
package leetcode func findMin(nums []int) int { low, mid, high := 0, 0, len(nums)-1 for low+1 < high { mid = low + (high-low)>>1 if nums[mid] == nums[high] { high = mid } else if nums[mid] > nums[high] { low = mid } else { high = mid } } if nums[low] <= nums[high] { return nums[low] } re...
package main import "fmt" func main() { array := []int{3, 2, 1, 20, 5, 6, 42, -2, 4, 3} sort(array) fmt.Println(array) } func sort(array []int) { sorted := false for !sorted { withoutSwap := true for i := 0; i < len(array)-1; i++ { if array[i] > array[i+1] { swap(array, i, i+1) withoutSwap = f...
package gmapssvc import ( "encoding/json" "fmt" "golang.org/x/net/context" googlemap "googlemaps.github.io/maps" "github.com/moul/gmaps-uservice/gen/pb" ) type Service struct { gm *googlemap.Client } func New(gm *googlemap.Client) gmapspb.GmapsServiceServer { return &Service{gm: gm} } func (s *Service) Dir...
package main import ( "fmt" "io/ioutil" "net/http" "os" "strings" ) func metaPublisher(resourceKey string) { if resourceKey == "list" { resourceKey = "" } res, err := http.Get("http://169.254.169.254/latest/meta-data/" + resourceKey) if err != nil { fmt.Printf("an ...
package src import ( "github.com/kataras/iris" "os" ) func GetDelete(ctx iris.Context) { if auth, _ := sess.Start(ctx).GetBoolean("IsLog"); !auth { ctx.StatusCode(iris.StatusForbidden) return } filename := ctx.Params().Get("filename") err := os.Remove(FilePath + filename) if err != nil { RtData := flag {...
type ActorState union { | InitActorState | AccountActorState | StorageMarketActorState | StorageMinerActorState | PaymentChannelBrokerActorState | MultisigActorState } // representation kinded
package models type Lead map[string]interface{} func (l *Lead) Get(key string, alterValue interface{}) interface{} { temp := *l if _, ok := temp[key]; !ok { return alterValue } return temp[key] }
package conv import ( "fmt" "log" "reflect" "strconv" ) // ToBool converts i to bool // i can be bool, integer or string func ToBool(i interface{}) (bool, error) { i = Indirect(i) switch v := i.(type) { case bool: return v, nil case nil: return false, errNilValue case string: return strconv.ParseBool(v...
package imageComparator import ( "fmt" "github.com/rs/zerolog/log" "github.com/vitali-fedulov/images" ) func SelectImgToCompare(uploadedImg string, compareImg string) error{ imgA, err := images.Open(uploadedImg) if err != nil { log.Error().Timestamp().Err(err) } imgB, err := images.Open(compareImg) if err !...
package main import ( "bufio" "fmt" "log" "os" "strings" ) func absurd(n int, t []string) int { var v int m := make([]bool, n-1) for _, i := range t { fmt.Sscanf(i, "%d", &v) if m[v] { return v } m[v] = true } return -1 } func main() { var n int data, err := os.Open(os.Args[1]) if err != nil ...
package hivesql import ( "reflect" "testing" ) func Test_parseDSN(t *testing.T) { type args struct { dsn string } tests := []struct { name string args args wantCfg *config wantErr bool }{ { "simple DSN", args{"user:pass@localhost/"}, &config{ user: "user", password: "pass"...
package section import( //"github.com/codebuff95/uafm" //"github.com/codebuff95/uafm/usersession" "github.com/codebuff95/uafm/formsession" "feedback-admin/user" "feedback-admin/course" "feedback-admin/database" "feedback-admin/faculty" "feedback-admin/college" "feedback-admin/password" "feedback-ad...
package main import ( //"fmt" ) // immutable struct to keep track of characters used for a combination of words type CharList struct { Chars []int //length 26, chars[0] is # of 'a's, chars[1] is # of 'b's, etc Components []string } func NewCharList() CharList { return CharList{ Chars: make([]int, 26...
// Copyright 2020 The ChromiumOS Authors // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. package crostini import ( "context" "io" "io/ioutil" "os" "path/filepath" "strings" "time" "chromiumos/tast/common/testexec" "chromiumos/tast/local/chrome/vmc" "c...
// Copyright (C) 2017 Google 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 t...
package websupport import ( "net/url" "net/http" "encoding/json" "io" "bytes" "encoding/base64" ) const ( DefaultEndpoint = "https://rest.websupport.sk" mediaType = "application/json" ) type Client struct { BaseURL *url.URL UserAgent string httpClient *http.Client headers map[string]string ...
// Copyright 2019 Yunion // // 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 writi...
package main import "fmt" // task 1 func avgScores(scores [5]float64) float64 { total := 0.0 for _, score := range scores { total += score } return total / 5 } // task 2 var pets map[string]string = map[string]string{ "Fido": "Dog", "Jutsu": "Cat", } func petNames(name string) bool { if _, ok := pets[name...
package jago import ( "fmt" "math" ) /*148 (0X94)*/ func LCMP(opcode uint8, f *Frame, t *Thread, c *Class, m *Method) { panic(fmt.Sprintf("Not implemented for opcode %d\n", opcode)) } /*149 (0X95)*/ func FCMPL(opcode uint8, f *Frame, t *Thread, c *Class, m *Method) { value2 := f.pop().(Float) value1 := f.pop()....
package esbulk import ( "bufio" "compress/gzip" "errors" "fmt" "io" "log" "net/http" "os" "path/filepath" "strings" "sync" "time" ) // Options represents bulk indexing options. type Options struct { Servers []string Index string Purge bool Mapping string DocType string NumWor...
package endpoint import ( "context" "encoding/json" "math" "github.com/go-kit/kit/endpoint" "github.com/sapawarga/userpost-service/lib/constant" "github.com/sapawarga/userpost-service/lib/convert" "github.com/sapawarga/userpost-service/model" "github.com/sapawarga/userpost-service/usecase" ) func MakeGetList...
package main import ( "fmt" ) const ( LAST_ELEMENT = 1<<16 // insert to the end of list FIRST_ELEMENT = 0 // insert to the beginning ) type list struct { value string next *list // next node prev *list // previous node first *list // head of the list last *list // tail of the list } func (l *list) String(...
package processor import ( "change.com/auth/domain" "context" ) /** * 用户认证处理器 */ type CommonProcessor interface { Authenticate(request *domain.UnifyAuthRequest, ctx context.Context) domain.UnifyAuthResponse }
package main import ( "bytes" "encoding/json" "fmt" "io/ioutil" "net/http" "ocr.service.worker/config" "ocr.service.worker/model" "ocr.service.worker/module" "os" "time" ) type Worker struct { client *http.Client rabbitmq *module.RabbitMQ imageSuccessQueue string imageErrorQueue st...
package main import ( "encoding/json" "fmt" "github.com/google/uuid" "github.com/micro/go-micro/v2" "strconv" "github.com/micro/go-micro/v2/broker" "github.com/micro/go-plugins/broker/rabbitmq/v2" "go-micro-demos/broker/rabbitmq/config" proto "go-micro-demos/broker/rabbitmq/proto" ...
package execshim import ( "io" "os/exec" "syscall" ) //go:generate counterfeiter -o exec_fake/fake_cmd.go . Cmd type Cmd interface { Start() error StdoutPipe() (io.ReadCloser, error) StderrPipe() (io.ReadCloser, error) Wait() error Run() error CombinedOutput() ([]byte, error) SysProcAttr() *syscall.SysPro...
package main import ( "fmt" "github.com/mattbaird/gosaml" ) func main() { // Configure the app and account settings appSettings := saml.NewAppSettings("http://www.onelogin.net", "issuer") accountSettings := saml.NewAccountSettings("cert", "http://www.onelogin.net") // Construct an AuthnRequest authRequest :=...
package leetcode // 3,2,2,3 val = 3 // 倒叙遍历 k初始化指向最后一个元素下标 // 第一次 nums[l] = 3 val 3 相等. 把 nums[l] 放在第k位置上面.此时应该把nums[k] 位置的元素放在第l位置上面 // 第二次 nums[l] = 2 val 3 不相等. 跳过 // 第三次 nums[l] = 2 val 3 不相等. 跳过 // 第四次 nums[l] = 3 val 3 相等. 把 nums[l](3) 放在第k(3-1)位置上面.此时应该把nums[k](2) 位置的元素放在第l(0)位置上面 func removeElement(num...