text
stringlengths
11
4.05M
package fs_test import ( "errors" "flag" "os" "os/exec" "path/filepath" "testing" ) var childHelpers = map[string]func(){} type childProcess struct { name string fn func() } var _ flag.Value = (*childProcess)(nil) func (c *childProcess) String() string { return c.name } func (c *childProcess) Set(s str...
package goxz import ( "bytes" "compress/flate" "compress/gzip" "io/ioutil" "log" "os" "os/exec" "path/filepath" "strings" "github.com/mholt/archiver" "github.com/pkg/errors" ) type builder struct { name, version string platform *platform ...
package core import ( "fmt" "github.com/kanosaki/picwall/server/tumblr" "github.com/spbr/gotumblr" ) type Tumblr struct { Api *gotumblr.TumblrRestClient } func NewTumblr(config *TumblrConfig) (*Tumblr, error) { api := gotumblr.NewTumblrRestClient( config.ConsumerKey, config.ConsumerSecret, config.DefaultAcc...
/* * Tencent is pleased to support the open source community by making 蓝鲸 available. * Copyright (C) 2017-2018 THL A29 Limited, a Tencent company. All rights reserved. * Licensed under the MIT License (the "License"); you may not use this file except * in compliance with the License. You may obtain a copy of the Li...
package mt type AuthMethods uint32 const ( LegacyPasswd AuthMethods = 1 << iota SRP FirstSRP ) //go:generate stringer -type AuthMethods
/* Given an array of meeting time intervals consisting of start and end times[[s1,e1],[s2,e2],...](si< ei), determine if a person could attend all meetings. Example 1: Input: [[0,30],[5,10],[15,20]] Output: false Example 2: Input: [[7,10],[2,4]] Output: true */ package main import "sort" func main() { asser...
package project import "testing" func TestT(t *testing.T) { }
package main import ( "github.com/micro/go-micro" "log" "moriaty.com/cia/cia-manager/service" ) /** * @author 16计算机 Moriaty * @version 1.0 * @copyright :Moriaty 版权所有 © 2020 * @date 2020/4/7 17:22 * @Description TODO * CIA-Manager */ /** 1、生成任务 1. 组织任务信息 2. 任务信息存入数据库 3. 任务信息存入任务容器 2、任务信息 1. 获取任务执行信息 ...
package main import ( "fmt" "time" _ "github.com/go-sql-driver/mysql" "github.com/jinzhu/gorm" ) type HouseSell struct { Recordid int64 `gorm:"primary_key;type:int(11) auto_increment;not null"` Houseid int64 `gorm:"type:int(11)"` Customerid int64 `gorm:"type:int(11)"` Officerid int64 `gorm:...
// implement smart contract transaction. // smart contract transaction is value transaction with special payload package sctransaction import ( "bytes" "errors" "fmt" "github.com/iotaledger/goshimmer/dapps/valuetransfers/packages/address" "github.com/iotaledger/goshimmer/dapps/valuetransfers/packages/balance" va...
package protocol type Trigger string var Triggers = map[Trigger]Command{ PingTrigger: PingCommand{}, SetTrigger: SetCommand{}, GetTrigger: GetCommand{}, }
package parsevalidate import ( "errors" "strconv" "strings" "time" "github.com/cpusoft/goutil/asn1util" "github.com/cpusoft/goutil/belogs" "github.com/cpusoft/goutil/conf" "github.com/cpusoft/goutil/convert" "github.com/cpusoft/goutil/fileutil" "github.com/cpusoft/goutil/hashutil" "github.com/cpusoft/gouti...
package main import ( "HumoAcademy" "HumoAcademy/pkg/handler" "HumoAcademy/pkg/repository" "HumoAcademy/pkg/service" "HumoAcademy/schema" "fmt" "github.com/jasonlvhit/gocron" _ "github.com/lib/pq" "github.com/spf13/viper" "gopkg.in/natefinch/lumberjack.v2" "log" ) func main() { /***************************...
package models // github.com/growlog/things-server/internal/models import ( "database/sql" "fmt" "time" // "github.com/growlog/things-server/internal/utils" ) type Thing struct { Id int64 `db:"id"` TenantId int64 `db:"tenant_id"` UserId ...
package doorman import ( "encoding/base64" "encoding/json" "errors" "fmt" "math" "math/big" "net/http" "net/http/httptest" "reflect" "strconv" "testing" "github.com/didiercrunch/doorman/shared" ) const oid = "507f1f77bcf86cd799439011" var epsilon = 0.0 var ZERO = big.NewRat(0, 1) func newDoorman(proba...
package main import ( "fmt" ) func seekpattern(recipes []byte, currentrecipe []int, seek string) int { var seekbytes = make([]byte, len(seek)) for i, r := range seek { seekbytes[i] = byte(r - '0') } seeklen := len(seek) for i := 0; true; i++ { oldcount := len(recipes) recipes = createnewrecipes(&recipes, ...
package util import ( "github.com/astaxie/beego" "database/sql" ) func CheckErro(err string){ if(err!=nil){ beego.Debug(err) } } func ScanStruct(row sql.Row,model struct{}){ row.Scan() }
// // DISCLAIMER // // Copyright 2017 ArangoDB GmbH, Cologne, Germany // // 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 main import "fmt" func main() { sum := 0 for i := 0; i < 10; i++ { sum += i } fmt.Println(sum) // 45 } /* for Go 只有一种循环结构, for 循环 基本的 for 循环包含三个由分号分开的组成部分: 初始化语句: 在第一个循环执行前被执行 循环条件表达式: 每轮迭代开始前被求值 后置语句: 每轮迭代后被执行 初始化语句一般是一个短变量声明, 这里声明的变量仅在整个 for 循环里语句可见 如果条件...
package queenattack import "errors" const testVersion = 2 // the size is 8*8, valid position is expressed as [a-h][1-8] func CanQueenAttack(x, y string) (attack bool, err error) { if !isValidPosition(x) || !isValidPosition(y) || x == y { return false, errors.New("invalid position") } if x[0] == y[0] || x[1] ==...
package chatid import ( "fmt" "strings" "github.com/tochti/watson" "github.com/uber-go/zap" "gopkg.in/telegram-bot-api.v4" ) const TRIGGER = "chatid?" func Handler(log zap.Logger, telegramClient *tgbotapi.BotAPI) watson.TelegramWebhookHandler { return func(update tgbotapi.Update) { if update.Message == nil...
/* * KSQL * * This is a swagger spec for ksqldb * * API version: 1.0.0 * Generated by: Swagger Codegen (https://github.com/swagger-api/swagger-codegen.git) */ package swagger type ExplainResultItemQueryDescription struct { Id string `json:"id,omitempty"` St...
package main import "fmt" func main() { s3 := []int{1, 2, 3, 4, 5, 6, 7, 8} s4 := s3[3:6] // 实现切片右向扩展 s5 := s4[0:cap(s4)] fmt.Println(s3) fmt.Println(s4) fmt.Println(s5) }
/* * @lc app=leetcode.cn id=1848 lang=golang * * [1848] 到目标元素的最小距离 */ // @lc code=start // package main // // import "fmt" func getMinDistance(nums []int, target int, start int) int { length := len(nums) var left, right int if length > start { left = start right = start } else { left = length - 1 righ...
package txpool import ( "errors" "github.com/HNB-ECO/HNB-Blockchain/HNB/common" "io" ) // errNoActiveJournal is returned if a transaction is attempted to be inserted // into the journal, but no such file is currently open. var errNoActiveJournal = errors.New("no active journal") // devNull is a WriteCloser that j...
package main import ( "fmt" "io/ioutil" "os" "path/filepath" "syscall" "github.com/Cloud-Foundations/Dominator/lib/filter" "github.com/Cloud-Foundations/Dominator/lib/image" "github.com/Cloud-Foundations/Dominator/lib/log" "github.com/Cloud-Foundations/Dominator/lib/wsyscall" proto "github.com/Cloud-Foundat...
package number import ( "errors" "fmt" "strconv" ) var ( ENOSUPPORT = errors.New("no support") ) func IsNumeric(x interface{}) bool { if nil != x { switch x.(type) { // using default //case bool: // using default //case string: case int, int8, int16, int32, int64: return true case uint, uint8, ...
package movi import ( "io" "encoding/json" "log" "fmt" "sort" "time" "io/ioutil" "../dvbstp" "../epg" //"golang.org/x/text/search" //"golang.org/x/text/language" ) const ( EntryPointURI = "239.0.2.129:3937" ) var ( getreader func(string) io.Reader ) type Movi st...
package client import ( "errors" "fmt" "github.com/imroc/req" ) func (c *AppDClient) CreateAction(action *Action, applicationId int) (*Action, error) { resp, err := req.Post(c.createActionsUrl(applicationId), c.createAuthHeader(), req.BodyJSON(&action)) if err != nil { return nil, err } if resp.Response()....
// Copyright 2021 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" func mainsort() { //保存需要排序的Slice arr := []int{9, 3, 4, 7, 2, 1, 0, 11, 12, 11, 13, 4, 7, 2, 1, 0, 11, 12} //实际用于排序的Slice list := make([]int, len(arr)) copy(list, arr) bubbleSort(list) fmt.Println("冒泡排序:\t", list) copy(list, arr) selectSort(list) fmt.Println("选择排序:\t", list) cop...
package main import ( "fmt" "encoding/json" "strings" ) // struktur data jsonnya harus ditentukan terlebih dahulu // Nama field di struct harus diawali huruf besar type Mahasiswa struct { Nm_mhs string `json:"nm_mhs"` Tgl_lahir string `json:"tgl_lahir"` Jurusan string `json:"jurusan"` } func main() { ...
// 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...
package auth import ( "context" errors2 "github.com/misgorod/co-dev/errors" "time" "github.com/dgrijalva/jwt-go" ) type Claims struct { UserID string `json:"user-id"` jwt.StandardClaims } type ctxKey int const userIDKey = ctxKey(1) func SetUserID(ctx context.Context, userID string) context.Context { return...
// Copyright 2022-present Open Networking Foundation. // // 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...
package 一维数组 import ( "fmt" "sort" ) // threeSum 三数和。 (三指针朴素版) func threeSum(nums []int) [][]int { // 1. 排序数组。 sort.Ints(nums) // 2. 三指针获取和为0的子数组。 result := make([][]int, 0) isExist := make(map[string]bool) for i := 0; i <= len(nums)-1; i++ { // 2.1 确定第一个指针。 firstNumIndex := i // 2.2 利用两数和获取第二、第三个指针。 ...
package tracing import ( "io" "github.com/micro/micro/v3/service/config" "github.com/micro/micro/v3/service/logger" "github.com/micro/micro/v3/util/opentelemetry" "github.com/micro/micro/v3/util/opentelemetry/jaeger" ) func SetupOpentracing(serviceName string) io.Closer { c, _ := config.Get("jaegeraddress") o...
package protocol type UnknownCommand struct { Command }
package main import ( "fmt" "log" "net" "time" "github.com/centaur679/pegasus/client/utils" pb "github.com/centaur679/pegasus/client/api" proto "github.com/golang/protobuf/proto" ) var tag string const ( handMsg = "我是打洞消息" confPath = "client.yml" ) func main() { // 解析配置文件 var c utils.Conf conf := c.G...
package web import ( "context" "net/http" "github.com/go-openapi/loads" "github.com/yandex-cloud/examples/serverless/alice-shareable-todolist/app/generated/openapi/restapi" "github.com/yandex-cloud/examples/serverless/alice-shareable-todolist/app/generated/openapi/restapi/operations" "github.com/yandex-cloud/ex...
/* Copyright 2019 The Kubernetes 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 filestream // all fields must be used var _ = streamTracker{0, 0, 0} func (st *streamTracker) adviseDontNeed(n int, fdatasync bool) error { return nil } func (st *streamTracker) close() error { return nil }
package main import "fmt" func main() { fmt.Println(findSmallestDividend(20)) //232792560 } func findSmallestDividend(n int) int { value := 1 for { var sum int for i := n; i > 0; i-- { sum += value % i } if sum == 0 { return value } value++ } } //2520 is the smallest number that can be divide...
package util import ( "errors" "fmt" "github.com/astaxie/beego/config" "github.com/astaxie/beego/logs" ) var ( AppConfig *Config ) type Config struct{ LogLevel string LogPath string CollectConf []CollectConf ChanSize int Addr string } type CollectConf struct { LogPath string Topic string } func LoadConf(...
/* 命題 "Hi He Lied Because Boron Could Not Oxidize Fluorine. New Nations Might Also Sign Peace Security Clause. Arthur King Can." という文を単語に分解し,1, 5, 6, 7, 8, 9, 15, 16, 19番目の単語は先頭の1文字,それ以外の単語は先頭に2文字を取り出し, 取り出した文字列から単語の位置(先頭から何番目の単語か)への連想配列(辞書型もしくはマップ型)を作成せよ. */ package main import ( "strings" "fmt" ) func main()...
// +build windows package fetch import ( "bufio" "errors" "io" "os" "os/exec" path "path/filepath" ) const dumpName = "APIDUMP" var dumpCommands = [][]string{ {"RobloxPlayerBeta.exe", "--API", dumpName}, {"RobloxPlayer.exe", "-API", dumpName}, {"RobloxApp.exe", "-API", dumpName}, } func (c *Client) fetchD...
package handler import ( "crypto/md5" "encoding/hex" "fmt" "html/template" "io" "net/http" "os" entity "github.com/Surafeljava/Court-Case-Management-System/Entity" "github.com/Surafeljava/Court-Case-Management-System/caseUse" ) type AdminJudgeHandler struct { tmpl *template.Template juSrv caseUse.JudgeSe...
package bmdb import ( "fmt" "path/filepath" "sync" ) const ( TEST_DIR = "tmp" ) var ( FOO = []byte("foo") BAR = []byte("bar") ) // var r = rand.New(rand.Seed(time.Now().UnixNano())) // func getRand() int { // n := 1000000 // return r.Intn(n*9) + n // } var ( testMux sync.Mutex testDBI int ) func getID(...
package device // #cgo CFLAGS: -g -Wall // #cgo LDFLAGS: -lSoapySDR // #include <stdlib.h> // #include <stddef.h> // #include <SoapySDR/Device.h> // #include <SoapySDR/Formats.h> // #include <SoapySDR/Types.h> import "C" import ( "errors" "github.com/pothosware/go-soapy-sdr/pkg/sdrerror" "unsafe" ) // LastStatus r...
package rakuten import ( "context" "fmt" ) type TravelHotelRankingParams struct { // Genre: onsen, all, premium Carrier:0 Genre string `url:"genre,omitempty"` Carrier int `url:"carrier,omitempty"` } type TravelHotelRankingResponse struct { Rankings []struct { Ranking struct { Genre string `...
package bmoauth import ( "errors" "fmt" "github.com/alfredyang1986/blackmirror/bmredis" "github.com/go-redis/redis" "time" ) func CheckToken(token string) error { client := bmredis.GetRedisClient() defer client.Close() _, err := client.Get(token).Result() if err == redis.Nil { return errors.New("token not...
package security import ( "crypto/sha1" "encoding/hex" "encoding/json" helper "festajuninaweb/areas/helper" "fmt" "log" "net/http" "net/url" "restauranteapi/security" "strings" "github.com/go-redis/redis" ) // LoginUserV2 but not func LoginUserV2(redisclient *redis.Client, userid string, password string) ...
package main import ( "log" "reflect" "testing" ) func TestNewKeyValueDB(t *testing.T) { yaml := []byte(` --- driver_name: mysql data_source_name: '[username[:password]@][protocol[(address)]]/dbname[?param1=value1&...&paramN=valueN]' `) config := newConfig() config.load(yaml) db := newKeyValueDB(config) if ...
package models import ( "project/app/admin/models/dto" "project/common/cache" orm "project/common/global" "project/utils" ) // SysJob 岗位实体 type SysJob struct { *BaseModel Name string `json:"name"` //岗位名称 Enabled []byte `json:"enabled"` //状态:1启用(默认)、0禁用 JobSort int `json:"jobSort"` //排序 Creat...
package bus import ( "fmt" "github.com/tmtx/res-sys/pkg/validator" ) type messageBus struct { queue chan Message callbacks map[MessageKey][]Callback errorHandler ErrorHandler } func NewBasicMessageBus(errorHandler ErrorHandler) MessageBus { return &messageBus{ make(chan Message, 5), map[MessageK...
package main import ( "database/sql" _ "github.com/go-sql-driver/mysql" ) type Account struct { id uint32 name string } func createAccount(accountName string) (account *Account, err error) { _, err = db.Exec("insert into account(name) values(?)", accountName) if err != nil { return } account = &Account{n...
package cart_test import ( "testing" "github.com/amanbolat/furutsu/internal/cart" "github.com/amanbolat/furutsu/internal/product" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" ) var testCart = cart.Cart{ Id: "01", UserId: "02", Items: map[string]cart.Item{ "apple": { Id:...
package main // 1. 定义 // 2. 匿名字段 // 3. 方法集 // 4. 表达式 func main() { }
package art_of_computer_programming import ( "testing" "math" "fmt" ) // Quicker than math.pow(x, 4) by benchmark test. func X4(x float64) float64 { return x * x * x * x } //Try to get answer w^4 + x^4 + y^4 = z^4 //And w <= x <= y < z < 1000000 func TestGetAnswer(t *testing.T) { for z := float6...
// DRUNKWATER TEMPLATE(add description and prototypes) // Question Title and Description on leetcode.com // Function Declaration and Function Prototypes on leetcode.com //97. Interleaving String //Given s1, s2, s3, find whether s3 is formed by the interleaving of s1 and s2. //Example 1: //Input: s1 = "aabcc", s2 = "dbb...
package main import "fmt" // https://leetcode-cn.com/problems/happy-number/ func isHappy(n int) bool { N := 1001 hs := make([]int, N) sum := func(x int) int { s := 0 for tmp := x; tmp > 0; tmp /= 10 { s += (tmp % 10) * (tmp % 10) } return s } for i := 0; i < N; i++ { hs[i] = sum(i) } find := fu...
package main import ( "bufio" "fmt" "os" ) func main() { scanner := bufio.NewScanner(os.Stdin) scanner.Split(bufio.ScanLines) isDict := true dict := make(map[string]string) for scanner.Scan() { a := scanner.Text() if a == "" { isDict = false continue } if isDict { var b, c string fmt.S...
/* * EVE Swagger Interface * * An OpenAPI for EVE Online * * OpenAPI spec version: 0.4.1.dev1 * * Generated by: https://github.com/swagger-api/swagger-codegen.git */ package swagger import ( "net/url" "strings" "encoding/json" "fmt" ) type CorporationApi struct { Configuration *Configuration } func N...
// 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 package appender import ( "bufio" "io" "os" "sync" "github.com/urso/ecslog/bac...
/* * Copyright 2018- The Pixie Authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or ag...
package raftstore import ( "github.com/pingcap-incubator/tinykv/kv/tikv/raftstore/message" "github.com/pingcap-incubator/tinykv/proto/pkg/raft_cmdpb" "github.com/pingcap-incubator/tinykv/proto/pkg/raft_serverpb" "github.com/pingcap-incubator/tinykv/raft" ) type MsgSignificantType int const ( MsgSignificantTypeS...
package problem0448 func findDisappearedNumbers(nums []int) []int { for i := 0; i < len(nums); i++ { for nums[i] != i+1 && nums[i] != nums[nums[i]-1] { tmp := nums[nums[i]-1] nums[nums[i]-1] = nums[i] nums[i] = tmp } } result := []int{} for i := 0; i < len(nums); i++ { if nums[i] != i+1 { result ...
package scheduler import ( "context" "fmt" "github.com/marsmay/golib/logger" "strings" "time" ) type Point struct { signal bool t time.Time } type Worker struct { provider IProvider logger *logger.Logger ctx context.Context loopTimer chan *Point endSign chan bool } func (w *Worker) Send...
package service_test import ( "testing" "github.com/go-ocf/cloud/http-gateway/service" "github.com/go-ocf/cloud/http-gateway/test" "github.com/stretchr/testify/require" ) func TestBackendConfig(t *testing.T) { s := test.NewTestBackendConfig().String() _, err := service.ParseConfig(s) require.NoError(t, err) }...
package main import ( "fmt" ) type Node struct{ data int next *Node } func push(val int) { } func main() { var a [5]int fmt.Println( a) // unlike c/c++, we can't use ++i in for loop for i:=0 ; i<5 ; i++ { a[i] = i } fmt.Println(a) // Initializing an array...
// Package api implements the oftee API that can be used for injecting // packets to the open flow devices package api import ( "encoding/binary" "encoding/json" "fmt" "github.com/netrack/openflow" "io" "io/ioutil" "net/http" "os" "runtime" "runtime/pprof" "strconv" "sync" "time" "github.com/ciena/oftee...
package Models type Cart struct { Product Products `json:"product"` CategoryName string `json:"categoryName"` SubCategoryName string `json:"subCategoryName"` } type Bill struct { Product []Products `json:"product"` TotalAmount float64 `json:"totalAmount"` IsDiscountApplied b...
package quantum import ( "fmt" "math" "math/cmplx" "testing" ) func BenchmarkUnitary(b *testing.B) { for _, size := range []int{1, 5, 10} { b.Run(fmt.Sprintf("Bits%d", size), func(b *testing.B) { s := RandomSimulation(size) coeff := complex(1.0/math.Sqrt2, 0) for i := 0; i < b.N; i++ { s.Unitary(i...
package api import ( m "github.com/grafana/grafana/pkg/models" "github.com/grafana/grafana/pkg/bus" "github.com/grafana/grafana/pkg/middleware" "github.com/grafana/grafana/pkg/log" ) func addMaintenanceAlertHelper(cmd m.AddMalfunalertActivity) Response { logger := log.New("main") logger.Info("Add Proce...
package serpprovider import ( "log" "fmt" "github.com/parnurzeal/gorequest" "strings" "strconv" "net/url" ) var ( BaseUrl = "http://api.serpprovider.com/%s/%s/%s/%s/%s" ) type SearchRequest struct { Query string Engine string Country string Language string Device string Key string Mode string // live, ...
/*------------------------------------------------------------------------------ -- DATE: March 1, 2016 -- -- Source File: check_bans.go -- -- REVISIONS: (Date and Description) -- -- DESIGNER: Marc Vouve -- -- PROGRAMMER: Marc Vouve -- -- -- INTERFACE: -- func (m *manifestType) checkBans() -- func dropBan...
package login import ( "bufio" "fmt" "os" "strings" "golang.org/x/term" ) func readPasswordFromStdin(prompt string) (string, error) { var out string var err error fmt.Fprint(os.Stdout, prompt) stdinFD := int(os.Stdin.Fd()) if term.IsTerminal(stdinFD) { var inBytes []byte inBytes, err = term.ReadPasswor...
package utilities import ( "strings" "log" "io" "encoding/csv" ) type MacLookup interface { Load() LookupVendor(macAddress string) string } type StringBasedMacLookup struct { text string data map[string]string } // NewMacLookup loads mac address - vendor pairs to map func NewMacLookup() MacLookup { return ...
package api import ( "InkaTry/warehouse-storage-be/internal/http/admin/dtos" "InkaTry/warehouse-storage-be/internal/pkg/errs" "InkaTry/warehouse-storage-be/internal/pkg/http/responder" "context" "net/http" "net/url" "strconv" ) func UploadInventories(handlerfunc func(ctx context.Context, p *dtos.UploadInventor...
/* # -*- coding: utf-8 -*- # @Author : joker # @Time : 2021/8/31 8:49 上午 # @File : lt_49_字母异位词分组.go # @Description : # @Attention : */ package offer // 参考:https://leetcode-cn.com/problems/group-anagrams/solution/zi-mu-yi-wei-ci-fen-zu-by-leetcode-solut-gyoc/ // 解题关键: 异位代表着字符串出现的个数肯定相同 func groupAnagrams(strs []string)...
package main import ( "net/http" "github.com/nerdynz/datastore" "github.com/nerdynz/rcache" "github.com/nerdynz/schwifty/backend/server" "github.com/nerdynz/schwifty/backend/server/models" nats "github.com/nats-io/nats.go" "github.com/nerdynz/trove" "github.com/rs/cors" "github.com/sirupsen/logrus" "githu...
// Copyright 2013 Walter Schulze // // 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...
package errors import "net/http" var ( ErrNotFound = ResponseError{ Code: http.StatusNotFound, Title: "Not Found", Detail: "Page not found", } ErrInvalidBody = ResponseError{ Code: http.StatusBadRequest, Title: "Bad Request", Detail: "Invalid body", } ErrState = ResponseError{ Code: http.St...
package main import ( "flag" "fmt" adb "github.com/yosemite-open/go-adb" "os" "time" ) var ( port = flag.Int("p", adb.AdbPort, "") cli *adb.Adb runCost = 15 newPoints = 441 battleTimer = 90 thresholdMax = 50000 threshold3 = 10000 threshold2 = 6000 threshold1 = 3000 nextRewardMax = 1250 ...
package main import ( log "github.com/sirupsen/logrus" ) func init() { log.Info("Init: Example go project") } func main() { log.Info("Main: Example go project") }
package worker import ( "bytes" "log" "os" "strings" "sync" "testing" "time" "github.com/dmitry-vovk/csv-chg-go/api" "github.com/stretchr/testify/assert" ) type testCase struct { quantity int // quantity to return returnUUID string // UUID to return getError error // error to return on GET reques...
package engine import ( "bytes" "encoding/json" "errors" "fmt" ) const ( instanceSettingsVersion1 = "v1" ) var ErrInvalidInstanceSettings = errors.New("invalid instance settings") // InstanceSettings keeps a local copy of various namespace and workflow settings so that the engine doesn't have to look them up s...
package sip import ( "strconv" "strings" ) type SIPRequest struct { RequestsMethod SIPRequestLine RequestHeader SIPHeaders } type SIPRequestLine struct { Method string SIPURI string SIPVersion string } // RequestHandler handle all incoming sip request func RequestHandler(request []byte, length int, ...
package controllers import ( "encoding/json" "net/http" "github.com/breathingdust/house.api/db" "github.com/breathingdust/house.api/models" "github.com/gorilla/mux" ) type ( TransactionController struct { db *db.Database } ) func NewTransactionController(db *db.Database) *TransactionController { return &T...
// This file was generated for SObject LeadShare, API Version v43.0 at 2018-07-30 03:47:36.106654431 -0400 EDT m=+22.450103258 package sobjects import ( "fmt" "strings" ) type LeadShare struct { BaseSObject Id string `force:",omitempty"` IsDeleted bool `force:",omitempty"` LastModifiedBy...
// 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...
package worker import ( "fmt" "net" "time" ) type PortResp struct { // Error error Error string IsOpen bool TimeDur float64 } func PortScan(dest *string, ptype *string, verbose bool) (result PortResp) { t1 := time.Now() switch *ptype { case "tcp": _, errdial := net.Dial(*ptype, *dest) if errdial !...
// Package bindata provides ways of storing static files within an executable. // There is a packaging mechanism and a virtual filesystem that provides access // to those files. package bindata import ( "os" "path/filepath" "strings" "time" "ktkr.us/pkg/vfs" ) var ( root *dir startupTime = time.Now() ...
package main import "fmt" type Student struct { Name string Age int score float64 // 学生成绩属于秘密不能随便的修改~~~ identity string } type Pupil struct { Student } func (stu *Student) testing() { fmt.Printf("%v考试中~~~~~", stu.identity) } // 获取成绩的方法~~~~ func (stu *Student) GetPupilScoer() float64 { return stu...
package utils import ( "os" ) func FilterCurrent(files []os.FileInfo) []os.FileInfo { var newFiles []os.FileInfo for _, file := range files { if file.Name() != "current" { newFiles = append(newFiles, file) } } return newFiles }
package main import ( "fmt" "log" "net" "time" "github.com/iwita/node-agent/info" "google.golang.org/grpc" ) func main() { // initialize a timer that will check timer := time.NewTicker(info.CheckInterval) fmt.Printf("Timer was set to %v\n", info.CheckInterval) go func() { for { select { case <-tim...
package main import ( "sort" ) func search(nums []int, target int) int { return sort.Search(len(nums), func(i int) bool { return nums[i] > target }) - sort.Search(len(nums), func(i int) bool { return nums[i] > target-1 }) }
// Copyright 2011 Google Inc. All rights reserved. // Use of this source code is governed by the Apache 2.0 // license that can be found in the LICENSE file. package sharded_counter import ( "fmt" "math/rand" "golang.org/x/net/context" "google.golang.org/appengine/datastore" "google.golang.org/appengine/memcac...
package main import ( "fmt" //"time" ) func main() { c :=incrementor("foo") c1 :=incrementor("foolish") c2 :=printchan(c) c3 :=printchan(c1) //for r:=range c2{ fmt.Println(<-c2) //} //fmt.Println(<-c2) for r1:=range c3{ fmt.Println(r1) } } func incrementor(s string) chan int{ c :=make(chan int) ...
package main import ( "bufio" "fmt" "io" "io/ioutil" "net" "net/http" "os" "strings" "github.com/astaxie/beego" "github.com/astaxie/beego/context" "github.com/yl2chen/cidranger" ) var ( gChinaMainlandRange cidranger.Ranger ) func loadLookupTable(name string) cidranger.Ranger { ranger := cidranger.NewPC...