text
stringlengths
11
4.05M
package matchmaker import ( "encoding/json" "io" "log" "net/http" "net/url" "time" "github.com/garyburd/redigo/redis" "github.com/pkg/errors" ) const ( maxRetries = 20 ) // Session represents a game session. type Session struct { ID string `json:"id"` Port int `json:"port,omitempty"` IP string `j...
package internal import ( "errors" "github.com/mmatur/aws-mfa/internal/types" survey "gopkg.in/AlecAivazis/survey.v1" ) // PromptSurvey prompts survey to user func PromptSurvey(devices []string) (*types.SurveyAnswer, error) { if len(devices) == 0 { return nil, errors.New("no devices") } var qs []*survey.Que...
package main import ( "testing" "fmt" ) const N = 3000000 // string常量会在编译期分配到只读段,对应数据地址不可写入,并且相同的string常量不会重复存储。 // fmt.Sprintf生成的字符串分配在堆上,对应数据地址可修改。 func Benchmark_Normal(b *testing.B) { b.N = N for i := 1; i < N; i++ { s := fmt.Sprintf("12345678901234567890123456789012345678901234567890") bb := []byte(s)...
// Go support for Protocol Buffers RPC which compatiable with https://github.com/Baidu-ecom/Jprotobuf-rpc-socket // // Copyright 2002-2007 the original author or authors. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // Yo...
// // Copyright (C) 2019-2021 vdaas.org vald team <vald@vdaas.org> // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // // https://www.apache.org/licenses/LICENSE-2.0 // // Unless requir...
package arraylist import ( "LimitGo/limit/collection" "testing" ) type Student struct { Id int Name string } func TestArrayListAll(t *testing.T) { TestNew(t) TestArrayList_Append(t) TestArrayList_AddAll(t) TestArrayList_Clear(t) TestArrayList_Contains(t) TestArrayList_Empty(t) TestArrayList_Equals(t) Tes...
// @APIVersion 1.0.0 // @Title beego Test API // @Description beego has a very cool tools to autogenerate documents for your API // @Contact astaxie@gmail.com // @TermsOfServiceUrl http://beego.me/ // @License Apache 2.0 // @LicenseUrl http://www.apache.org/licenses/LICENSE-2.0.html package routers import ( "nepliteA...
package api import ( "github.com/MiteshSharma/gateway/common/middleware" "github.com/MiteshSharma/gateway/gateway/middleware" "github.com/MiteshSharma/gateway/gateway/model" "github.com/gorilla/mux" "github.com/urfave/negroni" ) func InitApi(router *mux.Router) *negroni.Negroni { InitProxy(router) n := negroni...
package main import "fmt" func swap(a,b string)(string,string){ return b,a } func main() { fmt.Println(swap("String A","String B")) }
// This is a runnable example of making an oauth authorized request // to the Twitter api // Enter your consumer key/secret and token key/secret as command line flags // ex: go run example.go -ck ABC -cs DEF -tk 123 -ts 456 package main import ( "flag" "fmt" "io/ioutil" "net/http" "github.com/nhjk/oauth" ) var...
package repository import ( "github.com/bearname/videohost/internal/videoserver/domain/dto" "github.com/bearname/videohost/internal/videoserver/domain/model" ) type PlaylistRepository interface { Create(playlist dto.CreatePlaylistDto) (int64, error) FindPlaylists(userId string, privacyType []model.PrivacyType) ([...
package mr import "strconv" func isElementInSLice(ele int, s []int) (judge bool) { for _, v := range s { if v == ele { return true } } return false } func makeMapOutFileName(fileIndex int, partIndex int) string { return "mr-" + strconv.Itoa(fileIndex) + "-" + strconv.Itoa(partIndex) } func makeReduceOutF...
package recursion func canPartitionKSubsets(nums []int, k int) bool { sum := 0 for _, num := range nums { sum += num } if k <= 0 || sum%k != 0 { return false } visited := make([]int, len(nums)) return help698(nums, visited, 0, k, 0, 0, sum/k) } func help698(nums []int, visited []int, start int, k int, cur_...
package tasks // Task describes a single step in a plan. This could i.e. be the renaming/deleting of a file. type Task interface { Execute() Result GetDescription() string } // RunnableTask defines a basic task containing preferences stored as a map. type RunnableTask struct { Description string Preferences map[s...
package main import "fmt" func main(){ filename := "deckfile.txt" deck := newDeck() if err := deck.saveToFile(filename); err != nil { fmt.Println("Some error occured:- ", err) } // deck.print() // hand, remainingDeck := deal(deck, 5) // hand.print() // remainingDeck.print() // fmt.Println(deck.deckToStr...
package record import "time" // Record represents a record. type Record struct { ID string `json:"instapi:id"` CreatedAt time.Time `json:"instapi:createdAt"` UpdatedAt *time.Time `json:"instapi:updatedAt"` } // Batch represents a record batch acknowledge record count. type Batch struct { Count int `j...
package main import ( "flag" "fmt" ) // Possible fractals var fractals = []string{ "mandelbrot", "sierpinski", "julia", } func main() { // Various flags we use pointers otherwise default value won't change size := flag.Int("size", 400, "Size of the fractal image in px") name := flag.String("name", "mandelb...
package main import ( "bytes" "os" "os/exec" "os/user" "text/template" "time" ) const emailTemplate = `From: {{.From}} To: {{.To}} Subject: {{.Subject}} Cmd: {{.Result.Cmd.Args}} Start: {{.Result.Start}} End: {{.Result.End}} Duration: {{.Result.Duration}} total {{.Result.Cmd.ProcessState.UserTime}} user {{.Res...
package main import ( "log" "math/rand" "time" "github.com/fjdumont/exp/pkg/evo" ) const () func main() { target := []rune("You cannot parse HTML with Regular Expressions. Regular Expressions can not parse HTML.") runes := []rune("abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ,.-!\"§$%&/()=? 0123456789"...
package main import ( idgenerator "github.com/Qihoo360/poseidon/service/idgenerator/module" meta "github.com/Qihoo360/poseidon/service/meta/module" proxy "github.com/Qihoo360/poseidon/service/proxy/module" searcher "github.com/Qihoo360/poseidon/service/searcher/module" "github.com/zieckey/simgo" ) func main() { ...
package cli import ( "runtime" "syscall" "unsafe" ) // For calculating the size of the console window; this is pretty important when we're writing // arbitrary-length log messages around the interactive display. type winsize struct { Row uint16 Col uint16 Xpixel uint16 Ypixel uint16 } // WindowSize find...
package widgets import ( "log" // "fmt" // "github.com/gotk3/gotk3/glib" "github.com/gotk3/gotk3/gtk" ) func WindowNew(title string, width, height int) (*gtk.Window){ win, err := gtk.WindowNew(gtk.WINDOW_TOPLEVEL) if err != nil { log.Fatal("Unable to create window: ", err) } w...
package inmemoryrepo import "backend/internal/domain" type gameRepository struct { games map[domain.GameId]*domain.Game } func NewGameRepository() domain.GameRepository { return &gameRepository{ games: map[domain.GameId]*domain.Game{}, } } func (r *gameRepository) Save(game *domain.Game) error { r.games[game....
package commands import ( "fmt" "os" "github.com/fatih/color" ) func fail(err error) { fmt.Fprintln(os.Stderr, color.RedString("error:"), err) os.Exit(1) } func failIf(err error) { if err != nil { fail(err) } }
/* Two random numbers A and B have been generated to be either 1, 2, or 3 your job is to randomly pick a third number C that can also be 1, 2 or 3. But, C cannot equal A or B. A can equal B. If A = B, then C has only two numbers left it can be. If A ≠ B, C has only one number it can be. Assume A and ...
package stapi import ( "fmt" "net/http" ) // ApiUrl - the base url for stapi rest api const ApiUrl = "http://stapi.co/api/v1/rest" // Client - the stapi app type Client struct { ApiUrl string HttpClient *http.Client Character Entity } // New - create a new stapi client func New(httpClient *http.Client) Cl...
package SQLite3 /* #include <sqlite3.h> #include <stdlib.h> */ import "C" import ( "database/sql" "database/sql/driver" "errors" "io" "unsafe" ) /* SQLite3驱动,参考: https://www.sqlite.org https://golang.org/pkg/database/sql/driver https://www.cnblogs.com/5211314jackrose/p/5816532.html https://github.com/astaxie/bu...
package weather import ( "encoding/json" "fmt" "github.com/sirupsen/logrus" "io/ioutil" "net/http" "strings" ) func GetWeatherData() string { //resp, err := http.Get("http://www.weather.com.cn/data/sk/101110101.html") //if err != nil { // fmt.Println(err) //} //body, err := ioutil.ReadAll(resp.Body) //fm...
// // Copyright (C) 2021 IOTech Ltd // // SPDX-License-Identifier: Apache-2.0 package application import ( "context" "github.com/edgexfoundry/edgex-go/internal/pkg/correlation" v2SchedulerContainer "github.com/edgexfoundry/edgex-go/internal/support/scheduler/v2/bootstrap/container" "github.com/edgexfoundry/go-m...
package bplus // B+ 树非叶子节点 // 假设 keywords = {3,5,8,10} // 4 个键值将数据分为 5 个区间:(-INF, 3), (3, 5), (5, 8), (8, 10), (10, INF) // 5 个区间分别对应 children[0]...children[4] // m 是事先计算得到的,其依据是让所有信息的大小正好等于页的大小 // PAGE_SIZE=(m-1)*4[keywords 大小] + m*8[children 大小] type TreeNode struct { m int // m 叉树 keywords []int ...
// Unless explicitly stated otherwise all files in this repository are licensed // under the Apache License Version 2.0. // This product includes software developed at Datadog (https://www.datadoghq.com/). // Copyright 2019 Datadog, Inc. package service import ( "context" "reflect" "testing" "time" corev1 "k8s....
package main import "fmt" //给定两个整数 n 和 k,返回 1 ... n 中所有可能的 k 个数的组合。 // //示例: // //输入: n = 4, k = 2 //输出: //[ //[2,4], //[3,4], //[2,3], //[1,2], //[1,3], //[1,4], //] func main() { fmt.Println(combine1(2, 3)) } //使用回溯 func combine1(n int, k int) [][]int { res := [][]int{} var dfs func(n, k, start int, path []in...
package logs import ( "os" "github.com/astaxie/beego/logs" ) // RFC5424 log message levels. const ( LevelEmergency = iota LevelAlert LevelCritical LevelError LevelWarning LevelNotice LevelInformational LevelDebug ) func init() { // logs.Async() logs.SetLogFuncCall(true) logs.SetLevel(logs.LevelDebug) ...
package calendar import ( "booking-calendar/schedule" "booking-calendar/utils" "log" "testing" "time" ) var operatingSchedule = schedule.CompileBusinessWeekSchedule(parseTime("9:00AM"), parseTime("05:00PM")) func TestCalendar_CheckAvailability(t *testing.T) { var providerCalendar = NewCalendar(operatingSchedul...
package aoc2020 import ( "testing" aoc "github.com/janreggie/aoc/internal" "github.com/stretchr/testify/assert" ) func Test_waitingArea(t *testing.T) { assert := assert.New(t) // variables for later const e, o, f = empty, occupied, floor area, err := generateWaitingArea(day11sampleInput) assert.NoError(err) ...
package lmqtt import ( "net" "github.com/lab5e/lmqtt/pkg/config" ) // Options is the options for a the server type Options func(srv *server) // WithConfig set the config of the server func WithConfig(config config.Config) Options { return func(srv *server) { srv.config = config } } // WithTCPListener set tc...
package runtime import ( "fmt" "os" "os/exec" "syscall" "github.com/k82cn/myoci/pkg/subsystem" "k8s.io/klog" ) // RunFlags is the flags of run command. type RunFlags struct { Terminal bool Interactive bool Command string Args []string subsystem.ResourceConfig } // Run run target command i...
package presence import "testing" func TestStringer(t *testing.T) { e := &Event{} if e.Status.String() != unknown { t.Errorf("status string should be %s for uninitialized Event, got: %s ", unknown, e.Status.String()) } e.Status = Online if e.Status.String() != online { t.Errorf("status string should be %s f...
package tmp const ( DirCore = "core" DirCmd = "cmd" DirDatabase = "database" DirHub = "hub" DirHubHelper = "hub_helper" DirHelper = "helper" DirHandlers = "handlers" DirHandler = "%v_handler" DirHandlerHelper = "%v_helper" DirStore = "store" Di...
package edit import ( "fmt" "regexp" "github.com/MakeNowJust/heredoc" "github.com/cli/cli/pkg/iostreams" "github.com/heaths/gh-label/internal/github" "github.com/heaths/gh-label/internal/options" "github.com/heaths/gh-label/internal/utils" "github.com/spf13/cobra" ) type editOptions struct { name str...
// Copyright Amazon.com Inc. or its affiliates. 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. A copy of the // License is located at // // http://aws.amazon.com/apache2.0/ // // or in the "license" file acco...
package cacheProvider import ( "time" "github.com/BorisBorshevsky/GolangDemos/catapult/addons/cache" "gopkg.in/redis.v5" ) func RedisTTLCache(ttl time.Duration) *RedisTTLCacheProvider { client := redis.NewClient(&redis.Options{ Addr: "127.0.0.1" + ":6379", Password: "", // no password set MaxRe...
package main import "fmt" func main() { arr := []int{3, 232, -1, 34, 6565, 43434} Sort(arr) fmt.Println(arr) } func Sort(arr []int) { for k, v := range arr { if k != 0 { for k >= 1 && arr[k-1] > v { arr[k] = arr[k-1] k-- } arr[k] = v } } }
package main import "fmt" func isValid(s string) bool { if len(s) % 2 == 1 { return false } stackArray := make([]string, len(s)/2) lastIndex := -1 var checkChar string for _, tmp := range s[:] { tmpChar := string(tmp) // fmt.Println(stackArray) checkChar = "0" switch tmpChar { case "{": fallthrou...
package gouldian import ( "fmt" "strings" ) /* Node of trie */ type Node struct { Path string // substring from the route "owned" by the node Heir []*Node // heir nodes Func Endpoint // end point associated with node /* TODO - Wild *Node // special node that captures any path - Type int ...
package main import ( "fmt" facebook "github.com/madebyais/facebook-go-sdk" ) // BasicFeed represents the basic of // how to use facebook-go-sdk func BasicFeed() { // initalize facebook-go-sdk fb := facebook.New() // set your access token // NOTES: Please exchange with your access token fb.SetAccessToken(`.....
package main import ( "bytes" ) func defangIPaddr(address string) string { var s bytes.Buffer for j := 0 ;j < len(address); j++ { if (address[j] == '.') { s.WriteByte('[') s.WriteByte('.') s.WriteByte(']') }else{ s.WriteByte(address[j]) } } return s.String() } func main() { }
package _713_Subarray_Product_Less_Than_K func numSubarrayProductLessThanK(nums []int, k int) int { return numSubarrayProductLessThanKWithSlidingWindow(nums, k) } func numSubarrayProductLessThanKWithSlidingWindow(nums []int, k int) int { var ( count int p, q int // 前后idx prod int = 1 // 乘积 ) for q = 0...
// Copyright 2015 Keybase, Inc. All rights reserved. Use of // this source code is governed by the included BSD license. package updater import ( "fmt" "os" "path/filepath" "strconv" "github.com/keybase/go-updater/util" ) // Version is the updater version const Version = "0.2.8" // Updater knows how to find a...
package main import ( "bufio" "flag" "fmt" "log" "os" ) var changelog = "Changelog" func main() { a := flag.String("a", "", "Author name") m := flag.String("m", "", "Commit message") flag.Parse() Wlog(*a, *m) } func MultiMsg() error { logFile, err := os.OpenFile(changelog, os.O_WRONLY|os.O_APPEND|os.O_CR...
package _020_10_24 import ( "testing" "github.com/stretchr/testify/assert" ) func Test_findMedianSortedArrays(t *testing.T) { table := []struct { input1 []int input2 []int output float64 }{ { []int{1, 3}, []int{2}, 2, }, { []int{1, 2}, []int{3, 4}, 2.5, }, { []int{}, []int...
// // MinIO Object Storage (c) 2021 MinIO, 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 l...
package crypto // Crypto interface for signing algorithm type Crypto interface { Name() string Sign(msg string, secret string) ([]byte, error) }
package logic import ( "context" "github.com/just-coding-0/learn_example/micro_service/zero/internal/svc" "github.com/just-coding-0/learn_example/micro_service/zero/internal/types" "github.com/just-coding-0/learn_example/micro_service/zero/rpc/history/history" "github.com/tal-tech/go-zero/core/logx" ) type LastE...
package main import "fmt" func main() { ten := 10 if ten == 20 { println("ten equals 20") } else { println("ten equals something else") } if "a" == "bb" || true && 1 > 10 { println("Option 1") } else if true { println("Option 2") } else { println("Option 3") } val := 3 switch val { case 1: pri...
package domain var () // ServiceInstanceAlreadyExistsError is an error type used to //indicate that this service instance has already been // provisioned. type ServiceInstanceAlreadyExistsError string // Error returns a string representation of the error message. func (e ServiceInstanceAlreadyExistsError) Error() st...
// Copyright 2022 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 connlib import ( "bufio" "os" "regexp" "strconv" ) func filterConnections(connections []Connection, filter func(Connection) bool) []Connection { filteredConnections := []Connection{} for _, conn := range connections { if filter(conn) { filteredConnections = append(filteredConnections, conn) } }...
package utils import ( "os" "path" "path/filepath" "runtime" log "github.com/sirupsen/logrus" hocon "github.com/go-akka/configuration" ) // HoconConfig encapsulates application's configurations in HOCON format type HoconConfig struct { File string // config file Conf *hocon.Config // configurations }...
package calc import ( "gonum.org/v1/plot" "gonum.org/v1/plot/plotter" "gonum.org/v1/plot/vg" "image/color" ) /* https://github.com/gonum/plot/wiki/Example-plots */ func CreateGraph(f func(float64) float64) { p, err := plot.New() if err != nil { panic(err) } p.Title.Text = "Functions" p.X.Label.Text = "X" ...
package impl2 import "github.com/sko00o/leetcode-adventure/queue-stack/queue" /* Notes: ○ 用队列模拟栈 § 若使用两个队列,分别记为 Q 和 tmp ,压栈操作时,元素入队 tmp, 然后 Q 元素全部出队再入队 tmp, 最后交换 Q 和 tmp;出栈操作时, 保持所有元素都在 Q,方便维护,从 Q 出队。 */ // Queue is a FIFO Data Structure. type Queue struct { queue.SliceQueue } // MyStack is a stack using qu...
package donothing import ( "bufio" "bytes" "errors" "fmt" "io" "os" "strings" ) // A Procedure is a sequence of Steps that can be executed or rendered to markdown. type Procedure struct { // The root step of the procedure, of which all other steps are descendants. rootStep *Step stdin io.Reader stdout io...
package vespa import ( "bytes" "crypto/tls" "encoding/json" "fmt" "math" "net/http" "sort" "strconv" "time" "github.com/vespa-engine/vespa/client/go/auth/auth0" "github.com/vespa-engine/vespa/client/go/auth/zts" "github.com/vespa-engine/vespa/client/go/util" "github.com/vespa-engine/vespa/client/go/versi...
package spec // Mod is type Mod struct { ModName string Event Kls DataClasses []Kls }
package service import ( "database/sql" "github.com/google/uuid" "time" "varconf-server/core/dao" ) type AppService struct { appDao *dao.AppDao manageTxDao *dao.ManageTxDao } func NewAppService(db *sql.DB) *AppService { appService := AppService{ appDao: dao.NewAppDao(db), manageTxDao: dao.NewMa...
package main import ( "fmt" "net/http" "github.com/gorilla/mux" ) func main() { r := mux.NewRouter() r.HandleFunc("/chord/{root}/{pattern}", ChordHandler) r.HandleFunc("/notes/{notes}", NotesHandler) http.ListenAndServe(":8080", r) } func ChordHandler(w http.ResponseWriter, r *http.Request) { vars := mux.Va...
package dict_data import ( "errors" "xorm.io/builder" "yj-app/app/yjgframe/db" "yj-app/app/yjgframe/utils/excel" "yj-app/app/yjgframe/utils/page" ) // Fill with you ideas below. //新增页面请求参数 type AddReq struct { DictLabel string `form:"dictLabel" binding:"required"` DictValue string `form:"dictValue" binding:"...
package main import ( "fmt" "net/http" "os" ) func main() { initBeacon() err := http.ListenAndServe(fmt.Sprintf(":%v", getPort()), nil) if err != nil { panic(err) } } func getPort() string { if configuredPort := os.Getenv("PORT"); configuredPort == "" { return "8080" } else { return configuredPort } ...
// Copyright © 2017 Daniel Jay Haskin <djhaskin987@gmail.com> // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // // http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by...
package config import ( "github.com/spf13/cobra" "github.com/wish/ctl/pkg/client" ) // Cmd returns the config subcommand func Cmd(c *client.Client) *cobra.Command { config := &cobra.Command{ Use: "config", Short: "Edit ctl configuration", Long: "Tool for changing the behaviour of ctl", } config.AddComm...
package main import ( "os" "testing" "github.com/jinzhu/gorm" ) var db *gorm.DB func TestMain(m *testing.M) { db = loadDatabase(DBFilenameTest) seedData(db) m.Run() os.Remove(DBFilenameTest) }
package recorder import ( "context" "encoding/json" "errors" "fmt" "github.com/go-redis/redis/v8" "github.com/team-bonitto/bonitto/internal/model" "github.com/team-bonitto/bonitto/internal/queue/consumer" "github.com/team-bonitto/bonitto/internal/queue/producer" "time" ) const QueueName = "recorder" const DB...
package typeswitch import ( "go/ast" "go/types" "strings" "golang.org/x/tools/go/analysis" "golang.org/x/tools/go/analysis/passes/inspect" "golang.org/x/tools/go/ast/inspector" ) var Analyzer = &analysis.Analyzer{ Name: "typeswitch", Doc: Doc, Run: run, Requires: []*analysis.Analyzer{ inspect.Analyzer,...
package models import "time" // A Sensor record is a specific sensor. type Sensor struct { ID uint `gorm:"primary_key"` SensorTypeID int `gorm:"index"` Name string Description string CreatedAt time.Time }
package mlapi import ( "time" "github.com/freignat91/mlearning/mlserver/server" "golang.org/x/net/context" "google.golang.org/grpc" ) type mlClient struct { api *MlAPI client mlserver.MLearningServiceClient nodeHost string ctx context.Context conn *grpc.ClientConn } func (g *mlClient) init(...
package schedule import ( "io/ioutil" "os" "strings" "BearApp/internal/bootstrap" "github.com/naoina/toml" ) func loadSchedule() ([]*CronJob, error) { configDir := bootstrap.GetAppRoot() + "/config/schedule/" + bootstrap.GetAppEnv() dir, err := os.Open(configDir) if err != nil { return nil, err } var ...
package kinesis import ( "context" "fmt" "github.com/aws/aws-lambda-go/events" "github.com/golang/protobuf/proto" "github.com/hill-daniel/iot-protobuf-lambda" pb "github.com/hill-daniel/iot-protobuf-lambda/proto" "github.com/pkg/errors" ) // Handler accepts and processes KinesisEvents type Handler struct { db...
package response func CreateResponse(data interface{}) interface{} { return map[string]interface{}{ "result": data, } }
package webauthnutil import ( "time" "github.com/google/uuid" "github.com/pomerium/pomerium/pkg/cryptutil" ) // NewEnrollmentToken creates a new EnrollmentToken. func NewEnrollmentToken(key []byte, ttl time.Duration, deviceEnrollmentID string) (string, error) { id, err := uuid.Parse(deviceEnrollmentID) if err ...
/* * Copyright (c) 2019. Alexey Shtepa <as.shtepa@gmail.com> LICENSE MIT * * The above copyright notice and this permission notice shall be included * in all copies or substantial portions of the Software. */ package bindata import ( "fmt" "unsafe" ) func inspect_t(v interface{}) (unsafe.Pointer, uintptr) { ...
package messages import ( "fmt" "github.com/button-tech/BNBTextWallet/config" ) var ( MsgForDeleteIfUserExist = "You do not need to delete your account" MsgForCreate = "You have't got account.\nYou can create it by typing command /create" MsgIfCreate = "Account already created" MsgForFoll...
package ptp import "net" // DevKind Type of the device type DevKind int const ( // DevTun Receive/send layer routable 3 packets (IP, IPv6...). Notably, // you don't receive link-local multicast with this interface // type. DevTun DevKind = iota // DevTap Receive/send Ethernet II frames. You receive all packets ...
// Copyright 2020 IOTA Stiftung // SPDX-License-Identifier: Apache-2.0 package testcore import ( "github.com/iotaledger/goshimmer/dapps/valuetransfers/packages/balance" "github.com/iotaledger/wasp/packages/coretypes" "github.com/iotaledger/wasp/packages/solo" "github.com/iotaledger/wasp/packages/testutil" "githu...
package Problem0399 func calcEquation(equations [][]string, values []float64, queries [][]string) []float64 { // 建立变量之间的转换关系 m := make(map[string]map[string]float64) for i, e := range equations { a, b := e[0], e[1] v := values[i] // 添加 a / b 的记录 if _, ok := m[a]; !ok { m[a] = make(map[string]float64) }...
package querydigest import ( "bytes" "fmt" "io" "os/exec" "github.com/kaz/pprotein/internal/collect" ) type ( processor struct{} ) func (p *processor) Cacheable() bool { return true } func (p *processor) Process(snapshot *collect.Snapshot) (io.ReadCloser, error) { bodyPath, err := snapshot.BodyPath() if e...
package dynamo import ( "github.com/aws/aws-sdk-go/service/dynamodb" ) const ( awsErrConditionalCheckFailed = "ConditionalCheckFailed" ) type DuplicateEntryException struct { Message string } type ItemDoesNotExistException struct { Message string } type UniqueViolationException struct { Message string } func...
package storage import ( "docktor/server/types" "github.com/globalsign/mgo" "github.com/globalsign/mgo/bson" ) // ServicesRepo is the repo for services type ServicesRepo interface { // Drop drops the content of the collection Drop() error // Save a service into database Save(service types.Service) (types.Serv...
package flock import ( "os" ) // LockFile places an exclusive lock on the file. // If the file is already locked, exists with error. func LockFile(f *os.File) error { return LockFd(f.Fd()) } // UnlockFile removes an existing lock held by this process. func UnlockFile(f *os.File) error { return UnlockFd(f.Fd()) }
// 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 apimessages import ( "github.com/google/uuid" ) // Message domain message struct type Message struct { ID uuid.UUID `json:"id"` UserName string `json:"username"` Message string `json:"message"` } // MapToCreateResponse maps a message to a response func (m *Message) MapToCreateResponse() Crea...
package gen import ( "testing" "github.com/stretchr/testify/assert" ) func TestGetEmployeeRows(t *testing.T) { n := 20 rows := GetEmployeeRows(0, n) assert.NotNil(t, rows) nrows := len(rows) var x bool if nrows == n { x = true } assert.True(t, x) } func TestGetDeptEmp(t *testing.T) { n := 20 empRow...
package apiserver type Config struct { Addr string `toml:"bind_addr"` DBURL string `toml:"database_url"` JWTSecret string `toml:"jwt_secret"` }
package util import ( fmt "fmt" "net" "strings" ) // Connect dials the given address and returns a net.Conn. The protoAddr argument should be prefixed with the protocol, // eg. "tcp://127.0.0.1:8080" or "unix:///tmp/test.sock" func Connect(protoAddr string) (net.Conn, error) { proto, address := ProtocolAndAddress...
package main import ( "fmt" ) const ( iterations = 5000000 factorA = 16807 factorB = 48271 modValue = 2147483647 //2^32 - 1 comparisonMod = 65336 //2^16 ) func simulation(a,b int) (equal int) { for i := 0; i < iterations; i++ { a,b = genVal(a,factorA),genVal(b,factorB) if compareValues(a,b) { equal++ ...
package cacheCheck import ( "github.com/garyburd/redigo/redis" "log" "net/http" "strings" ) /* TODO: What we need to do here is to create our own response writer This response writer will wait for responses and write them to the cache automaticaly. */ var cacheHit bool = false type Middleware struct { h...
package main import ( "fmt" ) func LongestNonrepeatingSubstr(s string) int { pos := 0 longest := 0 seen := make(map[byte]int) for pos < len(s) { char := s[pos] if _, ok := seen[char]; ok { if len(seen) > longest { longest = len(seen) } pos = seen[char] + 1 seen = make(map[byte]int) } el...
package request type ( // ID struct ID struct { ID string `json:"id"` } ) // Rules ... func (ID) Rules() map[string][]string { return map[string][]string{ "id": []string{"required"}, } } // Messages ... func (ID) Messages() map[string][]string { return nil }
package main // MIT License // // Copyright (c) 2018 Yuwono Bangun Nagoro // // Permission is hereby granted, free of charge, to any person obtaining a copy // of this software and associated documentation files (the "Software"), to deal // in the Software without restriction, including without limitation the rights /...
package main import ( "encoding/json" "flag" "fmt" "io/ioutil" "os" "os/signal" "strings" "syscall" "time" "github.com/bwmarrin/discordgo" "github.com/davecgh/go-spew/spew" "github.com/getsentry/sentry-go" "github.com/kuzmik/goelo2/src/bebot" // "github.com/kuzmik/goelo2/src/twitter" ) var ( //Debug -...
package worker import "sync" import "github.com/nylo-andry/playupdate" type Pool struct { workerCount int updateService playupdate.UpdateService } func NewPool(workerCount int, updateService playupdate.UpdateService) *Pool { return &Pool{ workerCount, updateService, } } func (p *Pool) Start(macAddresses [...