text
stringlengths
11
4.05M
package main import ( "fmt" "strconv" ) func main() { param1 := 54321 param2 := 54321 if param1 == 0 && param2 == 0 { fmt.Println(0) return } var finalans []int for param1 != 0 || param2 != 0 { pop1 := param1 % 10 pop2 := param2 % 10 param1 /= 10 param2 /= 10 ans := (pop1 + pop2) % 10 fin...
package rpc var rpcs = map[uint8]map[string]func(string) ([]byte, error){} // rpcType -> {rpcMethodName -> actual func var} func RegisterRPC(rpcType uint8, rpcMethods map[string]func(string) ([]byte, error)) { rpcs[rpcType] = rpcMethods } func GetRPCMethod(rpcType uint8, rpcMethodName string) func(string) ([]byte, ...
package container //环 在循环列表上实现操作 //环是循环列表或环的元素。 戒指没有起点或终点; 指向任何环元素的指针都用作整个环的引用。 空环表示为nil环指针。 环的零值是一个零元素的环。 //New creates a ring of n elements. //func New(n int) *Ring //请按向前的顺序在环的每个元素上调用函数f。如果f改变* r,Do的行为是不确定的。 //func (r *Ring) Do(f func(interface{})) type Ring struct { Value interface{} // for use by client; ...
package main import ( "fmt" "os" "github.com/Pallinder/go-randomdata" ) const RowCount = 100000 const friendsMin = 30 const friendsMax = 100 const step = 10000 func buildVertex(f *os.File) error { var name string sql := "insert into people values " for i := 0; i < RowCount; i++ { k := randomdata.Number(10, ...
package data import ( "github.com/bububa/oppo-omni/core" "github.com/bububa/oppo-omni/model/data" ) // 广告计划-列表 func QPlanList(clt *core.SDKClient, req *data.QPlanListRequest) (*data.QListResult, error) { req.SetResourceName("data") req.SetResourceAction("Q/plan/list") var ret data.QListResponse err := clt.Post(...
package common const ( //保存任务的目录 JOB_SAVE_DIR = "/cron/jobs/" // 保存任务事件 JOB_EVENT_SAVE = 1 // 删除任务事件 JOB_EVENT_DELETE = 2 // 任务强杀事件 JOB_EVENT_KILLER = 3 // 强杀事件 JOB_KILLER_DIR = "/cron/killer/" // 锁 JOB_LOCK_DIR = "/cron/lock/" )
package http import ( "io/ioutil" "net" "net/http" "strings" "time" "github.com/jhzlf/Common/logs" ) const ( Http_req_get = iota Http_req_post ) type HttpClient struct { *http.Client } func NewHttpClient(t time.Duration) *HttpClient { return &HttpClient{ &http.Client{ Transport: &http.Transport{ ...
package main import ( "fmt" "os" "strconv" ) var pc [256]byte func init() { for i := range pc { pc[i] = pc[i/2] + byte(i&i) } } func PopCount(x uint64) int { ans := 0 for i := 0; i < 8; i++ { // it's stupid to make the type convertion // Come on compiler! ans += int(pc[byte(x>>(uint(i)*8))]) } retu...
package main import ( "bytes" "encoding/json" "fmt" "io/ioutil" "path/filepath" "regexp" "strconv" "strings" "time" "github.com/tidusant/c3m-common/c3mcommon" "github.com/tidusant/c3m-common/log" "github.com/tidusant/chadmin-repo/models" "golang.org/x/net/html" ) func RenderData(htmls...
package chat import ( "context" "fmt" "sync" "time" v1 "github.com/MuhammadChandra19/go-grpc-chat/api/v1" ) type Service struct { Repository RepositoryInterface Connnection map[string]*Connection } type PayloadInsertUser struct { Name string `json:"name" validate:"required"` Email string `json:"email" va...
package intersect import "sort" func mergeIntersect(a, b []uint64, final *[]uint64) { ma, mb := len(a), len(b) i, j := 0, 0 for i < ma && j < mb { if a[i] == b[j] { *final = append(*final, a[i]) i++ j++ } else if a[i] < b[j] { for i = i + 1; i < ma && a[i] < b[j]; i++ { } } else { for j =...
package oidc import ( "context" "crypto/sha256" "database/sql" "errors" "fmt" "time" "github.com/google/uuid" "github.com/ory/fosite" "github.com/authelia/authelia/v4/internal/authorization" "github.com/authelia/authelia/v4/internal/configuration/schema" "github.com/authelia/authelia/v4/internal/logging" ...
package main import ( "fmt" "math/rand" "time" ) type message struct { msg string wait chan bool } func main() { ch := fanIn(boring("joe"), boring("ann")) for i := 0; i < 10; i++ { msg := <-ch fmt.Printf("you say %s\n", msg.msg) msg.wait <- true } fmt.Println("just leave") } func fanIn(in1 <-chan me...
package life import ( "fmt" "testing" ) func TestLiveCell(t *testing.T) { neighborsStateMap := map[int]State{ 0: Dead, 1: Dead, 2: Alive, 3: Alive, 4: Dead, 5: Dead, 6: Dead, 7: Dead, 8: Dead, } for neighborCount, nextState := range neighborsStateMap { cell := Point{1, 1} neighbors := unbo...
// DRUNKWATER TEMPLATE(add description and prototypes) // Question Title and Description on leetcode.com // Function Declaration and Function Prototypes on leetcode.com //541. Reverse String II //Given a string and an integer k, you need to reverse the first k characters for every 2k characters counting from the start ...
package main import ( // "fmt" "github.com/nsf/termbox-go" "strings" ) const HEAVY_VERTICAL_RIGHT = "┣" const HEAVY_VERTICAL_LEFT = "┫" const HEAVY_VERTICAL = "┃" const HEAVY_HORIZONTAL = "━" const HEAVY_TOP_LEFT = "┏" const HEAVY_TOP_RIGHT = "┓" const HEAVY_BOTTOM_LEFT = "┗" const HEAVY_BOTTOM_RIGHT = "┛" type D...
package shipping_box type Product struct { Name string Len int Wid int Hei int } type Box struct { Len int Wid int Hei int } func getBestBox(availableBoxes []Box, products []Product) Box { // TODO: Complete! return Box{} }
../../../assert_test.go
package main import ( "context" "fmt" "time" pb "github.com/brotherlogic/discovery/proto" "github.com/prometheus/client_golang/prometheus" "github.com/prometheus/client_golang/prometheus/promauto" "google.golang.org/grpc/codes" "google.golang.org/grpc/peer" "google.golang.org/grpc/status" ) // ListAllServic...
package user import ( "encoding/json" "testing" lib "github.com/syedomair/plan-api/lib" "github.com/syedomair/plan-api/models" "github.com/syedomair/plan-api/test/testdata" ) func TestGetAll(t *testing.T) { env := UserEnv{Logger: lib.GetLogger(), UserRepo: &mockRepo{}, Common: lib.CommonService{Logger: lib.Get...
package sample import ( "errors" "fmt" "math" ) // Returns the 2-sided critical values of a Student-t distribution with // 'd' degrees of freedom and a percentile of 'p'. // // The values are looked up in a table, using the lower closest // approximation to 'd' and higer closest approximaiton of 'c' in the // tabl...
package validator import ( "context" "reflect" "time" "github.com/go-playground/validator/v10" "github.com/qiniu/qmgo/operator" ) // use a single instance of Validate, it caches struct info var validate = validator.New() // SetValidate let validate can use custom rules func SetValidate(v *validator.Validate) {...
package quantum import ( "math/rand" "testing" "github.com/unixpickle/essentials" ) func TestToffoliN(t *testing.T) { for i := 0; i < 1000; i++ { numBits := rand.Intn(10) + 1 target := rand.Intn(numBits) var numControl int if numBits <= 3 { numControl = rand.Intn(numBits) } else { numControl = ra...
// Copyright 2020 The Operator-SDK 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 ...
// Copyright © 2018 VMware, Inc. All Rights Reserved. // SPDX-License-Identifier: BSD-2-Clause package config import ( "fmt" "testing" "github.com/stretchr/testify/assert" ) func TestBadConfigs(t *testing.T) { inputs := [][]string{ {"--datasource", "fs"}, {"--id", "???"}, {"--log-level", "hobbit"}, {"--...
package main import ( "fmt" ) func containsDuplicate(nums []int) bool { hmap := make(map[int]bool) for _, v := range nums { if hmap[v] { return true } hmap[v] = true } return false } func main() { nums := []int{1, 2, 3, 1} fmt.Println(containsDuplicate(nums)) }
package flags import ( "errors" "fmt" "os" ) type FlagDescription struct { Flag string Description string Valid bool Execute func(...interface{}) error } var AcceptedFlags map[string]FlagDescription = map[string]FlagDescription{ "-h": FlagDescription{Flag: "-h", Description: "Help command", ...
package repo import ( "log" "time" "github.com/orourkedd/influxdb1-client/client" ) type Mearsurement struct { Timestamp time.Time `json:"timestamp"` Hummiditiy float32 `json:"hummiditiy"` Temperature float32 `json:"temperature"` } var connection client.Client // var bp client.BatchPoints const ( my...
package dummy import ( "testing" "github.com/tlmiller/garage-door-controller/door" ) func TestDoorConstruction(t *testing.T) { dummyDoor := NewDoor(door.Id("static")) if dummyDoor.Id() != door.Id("static") { t.Error("door.Id() != \"static\"") } }
// Licensed to SolID under one or more contributor // license agreements. See the NOTICE file distributed with // this work for additional information regarding copyright // ownership. SolID licenses this file to you under // the Apache License, Version 2.0 (the "License"); you may // not use this file except in compli...
/* * Copyright (c) 2020 - present Kurtosis Technologies LLC. * All Rights Reserved. */ package network_partition_test import ( "github.com/kurtosis-tech/kurtosis-client/golang/core_api_bindings" "github.com/kurtosis-tech/kurtosis-client/golang/networks" "github.com/kurtosis-tech/kurtosis-client/golang/services"...
package generator import ( "sort" "testing" "time" envoy_api_v2 "github.com/envoyproxy/go-control-plane/envoy/api/v2" "gotest.tools/assert" ) var testCluster1 = envoy_api_v2.Cluster{ Name: "test_cluster_1", } var testCluster2 = envoy_api_v2.Cluster{ Name: "test_cluster_2", } func TestSetCluster(t *testing.T...
//Copyright (c) 2017 Phil package apollo import ( "os" "testing" "time" "github.com/stretchr/testify/suite" logger "gopkg.in/logger.v1" "gopkg.in/apollo.v0/internal/mockserver" ) type StartWithConfTestSuite struct { suite.Suite changeEvent <-chan *ChangeEvent } func (s *StartWithConfTestSuite) SetupSuite(...
package main import ( "fmt" "sync" ) func main() { //Go has a garbage collector taht the instatntied objecteds will be automatically cleaned up var numCalcsCreated int calcPool := &sync.Pool{ New: func() interface{} { numCalcsCreated += 1 mem := make([]byte, 1024) return &mem }, } //Seed the pool...
package user import "errors" var ( ErrNotFound = errors.New("error not found") )
package sstable import ( "os" "syscall" ) func (t *SSTable) tryMMap() error { f, ok := t.f.(*os.File) if !ok { return errNotImplemented } fi, err := f.Stat() if err != nil { return err } if fi.Size() > int64(kmaxint) { return errNotImplemented } mmap, err := syscall.Mmap(int(f.Fd()), 0, int(fi.Siz...
package pet type Skill struct { Id int Name string Effect func(p1, p2 *Pet) string Kind int } func Glue(p1, p2 *Pet) string { p2.status.IsStop = attr{ num: 100, round: 3, from: "glue", } return "" }
package main import "fmt" type Website struct { Name string } var site = Website{Name:"test"} func main() { // 相应值的默认格式 fmt.Printf("%v \n", site) // 相应值的go语音表示法 fmt.Printf("%#v \n", site) // 相应值类型的Go语音表示法 fmt.Printf("%T \n", site) // %% 字面上的百分号, 并非值的占位符号 fmt.Printf("%% \n") // 布尔占位符 fmt.Printf("%t \n", ...
package quotegetterdb import ( "bytes" "database/sql" "fmt" "time" _ "github.com/mattn/go-sqlite3" // Import go-sqlite3 library ) // QuoteDatabase handles the database that store and retrieve quote informations. type QuoteDatabase struct { dns string db *sql.DB } // QuoteRecord is the record stored in the q...
/* Copyright 2020 Humio https://humio.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 applicable law or agreed to in writing, ...
package usecase import ( "context" "map-friend/src/domain/user" ) type IUserUseCase interface { GetUserByID(context.Context, uint) (*user.User, error) } type userUseCase struct { userRepo user.IUserRepository } func NewIUserUseCase( user user.IUserRepository, ) IUserUseCase { return &userUseCase{user} } func...
package simplestake import ( "encoding/json" "github.com/tendermint/tendermint/crypto" sdk "github.com/cosmos/cosmos-sdk/types" ) //_________________________________________________________---- // simple bond message type MsgBond struct { Address sdk.AccAddress `json:"address"` Stake sdk.Coin `json:"c...
package main import "fmt" func collectNumbers(numbers chan<- int) { for i := 1; i <= 10; i++ { numbers <- i } close(numbers) } func sortOddsAndEvens(numbers <-chan int, odd chan<- int, even chan<- int) { for { number, more := <-numbers if !more { break } if number%2 == 0 { even ...
package users import ( domain "github.com/SaratAngajalaoffl/go-todo/server/domain/users" service "github.com/SaratAngajalaoffl/go-todo/server/services" "github.com/gin-gonic/gin" ) type Userhandlers struct { Service service.UserService } func (uh *Userhandlers) CreateUser(c *gin.Context) { u := domain.UserModel...
package main import ( "fmt" "math" "strconv" "gopkg.in/mgo.v2" "gopkg.in/mgo.v2/bson" ) type Comuna struct { Nombre string `json:"nombre"` Codigo int64 `json:"codigo"` Region string `json:"region"` CodRegion int64 `json:"cod_region"` Seg2008 float32 `json:"seg2008"` Seg2009 float32 `jso...
package interceptor import ( "net/http" "varconf-server/core/moudle/router" "varconf-server/core/service" ) type UserAuthInterceptor struct { authService *service.AuthService } func InitUserAuthInterceptor(s *router.Router, authService *service.AuthService) *UserAuthInterceptor { authInterceptor := UserAuthInt...
package zerotier import ( "fmt" "net/http" "strings" ) // interface for authorizing zerotier members type ZTController interface { Authorize(e *Endpoint) error } // official zerotier controller type Controller struct { ZerotierToken string } func NewController(zerotierToken string) *Controller { return &Cont...
package session import ( "log" "net" "sync" ) var sessionLock sync.RWMutex type TCPSession struct { conn *net.TCPConn pid uint32 msgChan chan []byte } /* 创建一个session */ func CreateTCPSession(c *net.TCPConn,pid uint32) *TCPSession { sessionLock.Lock() defer sessionLock.Unlock() session:= &TCPSession{ conn...
package poly2tri import ( "io/ioutil" "os" "sort" "strconv" ) func SaveOBJ(path string, triangles []*Triangle) { id := 0 fstr := "" maps := make(map[int]string) for i := 0; i < len(triangles); i++ { t := triangles[i] ps := t.GetPoints() fstr += "f" for p := 0; p < len(ps); p++ { if ps[p].Id == 0 { ...
package Core func GetInt(v interface{}) int { return v.(int) } func GetFloat(v interface{}) float32 { return v.(float32) } func GetString(v interface{}) string { return v.(string) } func GetObj(v interface{}) GUID { return v.(GUID) }
package main type FabricCut struct { id int64 startPosition *Dimension size *Dimension } func newFabricCut() *FabricCut { instance := new(FabricCut) instance.startPosition = new(Dimension) instance.size = new(Dimension) return instance }
package deferstats import ( "fmt" "log" "math/rand" "net/http" "strconv" "sync" "time" "github.com/deferpanic/deferclient/deferclient" ) // deferHTTPList is used to keep a list of DeferHTTP objects // and interact with them in a thread-safe manner type deferHTTPList struct { lock sync.RWMutex list []DeferH...
package eventnotifier import ( "net/http" "sync" "github.com/Symantec/Dominator/lib/log" "github.com/Symantec/keymaster/proto/eventmon" ) type EventNotifier struct { logger log.DebugLogger mutex sync.Mutex // Protected by lock. transmitChannels map[chan<- eventmon.EventV0]chan<- eventmon.EventV0 } func New...
package main /* #cgo LDFLAGS: -L${SRCDIR} -lruby_process //#cgo LDFLAGS: ${SRCDIR}/../target/release/libruby.so //#include <stdio.h> void process(); */ import "C" func main() { C.process() }
package main import ( "path/filepath" "github.com/BurntSushi/toml" ) type feed struct { Name string Feed string } // Config describes our configuration type Config struct { Name string URL string `toml:"url"` Owner string Email string Cache string Timeout duratio...
package _chan import "fmt" /** * created: 2019/7/29 15:59 * By Will Fan */ func main() { stringStream := make(chan string) go func() { stringStream <- "Hello channels" }() fmt.Println(<- stringStream) }
// Copyright (c) 2015 Uber Technologies, Inc. // 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 // to use, copy, modify, merge, ...
// DRUNKWATER TEMPLATE(add description and prototypes) // Question Title and Description on leetcode.com // Function Declaration and Function Prototypes on leetcode.com //264. Ugly Number II //Write a program to find the n-th ugly number. //Ugly numbers are positive numbers whose prime factors only include 2, 3, 5. For...
package fbinterview import ( "testing" "github.com/magiconair/properties/assert" ) // tests 2 realisations func TestFindPath(t *testing.T) { for _, test := range []struct{ M, N, X, Y, K int }{ {20, 20, 1, 1, 2}, {20, 10, 1, 1, 2}, {20, 10, 1, 1, 4}, {20, 10, 1, 2, 4}, {20, 20, 10, 10, 4}, } { task...
package main import ( "fmt" "sync" "time" ) func main() { var wg sync.WaitGroup wg.Add(2) go func() { groupCounter("pipoca", 10) wg.Done() }() go func() { groupCounter("netflix", 2) wg.Done() }() wg.Wait() } func groupCounter(something string, value int) { for i := 0; i < value; i++ { fmt...
// Copyright 2019 The Dice Authors. 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 // // https://www.apache.org/licenses/LICENSE-2.0 // // Unless required by app...
package main /** 寻找两个正序数组的中位数 给定两个大小为 m 和 n 的正序(从小到大)数组 nums1 和 nums2。 请你找出这两个正序数组的中位数,并且要求算法的时间复杂度为 O(log(m + n))。 你可以假设 nums1 和 nums2 不会同时为空。 示例 1: ``` nums1 = [1, 3] nums2 = [2] 则中位数是 2.0 ``` 示例 2: ``` nums1 = [1, 2] nums2 = [3, 4] 则中位数是 (2 + 3)/2 = 2.5 ``` */ /** 执行的有点慢 */ func FindMedianSortedArrays(nums1 [...
package metrics import ( "github.com/prometheus/client_golang/prometheus" "github.com/prometheus/client_golang/prometheus/promauto" ) type Http struct { RequestsTotal *prometheus.CounterVec RequestDurationHistogram *prometheus.HistogramVec } func NewHttp() Http { return Http{ RequestsTotal: promaut...
package efclient import ( "bytes" "encoding/json" "fmt" "log" "math/rand" "net/http" "sync" "time" "syreclabs.com/go/faker" "syreclabs.com/go/faker/locales" ) // Products ... type Products = []Product // Product ... type Product struct { ID int `json:"id"` Title string...
package entity import ( "fmt" "github.com/fabric-lab/hyperledger-fabric-manager/server/pkg/store" "github.com/fabric-lab/hyperledger-fabric-manager/server/pkg/util" "io/ioutil" "path/filepath" "strings" ) type Peer struct { Name string ListenAddress string ListenPort uint16 Cha...
package main import ( "fmt" "os" "strconv" "github.com/anurse/advent-of-code/advent" "github.com/anurse/advent-of-code/day01" "github.com/anurse/advent-of-code/day02" "github.com/anurse/advent-of-code/day03" "github.com/anurse/advent-of-code/day04" "github.com/anurse/advent-of-code/day05" "github.com/anurse...
/* Copyright 2021 The KubeVela Authors. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, softw...
package unique_id_factory // use sonyflake // go get github.com/sony/sonyflake // 1 bit sign & 39 bits Millisecond & 8 bits serial number & 16 bit machine num import ( "fmt" "golang-package/utils" "time" "github.com/sony/sonyflake" ) const ( SONY_START_TIME = "Thu, 02 Sep 2021 07:10:07 GMT" // When production ...
// Copyright 2012 The go-gl Authors. All rights reserved. // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. // NEHE Tutorial 08: Blending. // http://nehe.gamedev.net/data/lessons/lesson.asp?lesson=08 package main import ( "errors" "log" "github.com/andrebq/gas...
package i2pgateconfig import ( "io" "log" "os" "path/filepath" "strconv" "strings" "github.com/ipfs/go-ipfs-util" "github.com/mitchellh/go-homedir" ma "github.com/multiformats/go-multiaddr" serialize "gx/ipfs/QmTbcMKv6GU3fxhnNcbzYChdox9Fdd7VpucM3PQ7UWjX3D/go-ipfs-config/serialize" ) // Config is a struct ...
package model import "time" //好友和群都存在这个表里面 //可根据具体业务做拆分 type Contact struct { Id int64 `xorm:"pk autoincr bigint(20)" form:"id" json:"id"` //谁的10000 FromId int64 `xorm:"bigint(20)" form:"from_id" json:"from_id"` // 记录是谁的 //对端,10001 ToId int64 `xorm:"bigint(20)" form:"to_id" json:"to_id"` // 对端信息 // Cate int ...
package main import ( "fmt" "os" "log" "bufio" _ "github.com/go-sql-driver/mysql" "strings" ) //User struct for storing data type User struct{ ID string firstName string lastName string email string } func main() { //create array of user structs. var users []User //Connect to databse db, err := Connec...
package models import ( "encoding/json" "io/ioutil" "testing" ) func TestGetReportListingId(t *testing.T) { report := ReportListing{} data, _ := ioutil.ReadFile("./tests/reports.json") json.Unmarshal(data, &report) if v := report.GetChildren()[0].GetId(); v != `t1_hw6ng9c` { t.Error( "For GetId()", "ex...
package main import ( "log" "github.com/brandur/rhttpserve/cmd" _ "github.com/brandur/rhttpserve/cmd/all" // import all commands _ "github.com/ncw/rclone/fs/all" // import all fs ) func main() { if err := cmd.Root.Execute(); err != nil { log.Fatalf("Fatal error: %v", err) } }
package acceptor import ( "errors" "strconv" ) // HighestUUID stores the current // highest UUID in memory var HighestUUID int64 // PrepareReceive checks if the incoming UUID is greater // than the one it has ever seen before and if so // sets the new one as the highest UUID func PrepareReceive(uuid string) (bool,...
package main import ( "fmt" "log" "database/sql" _ "github.com/go-sql-driver/mysql" ) func main() { db, err := sql.Open("mysql", "testuser:testpass@tcp(127.0.0.1:3306)/") if err != nil { log.Fatal(err) } defer db.Close() // Connect and check the server version var version string db.QueryRow("SELECT VERS...
package queue import ( "context" "github.com/go-redis/redis/v8" "time" ) func NewRedisClient(o *redis.Options) (*redis.Client, error){ rdb := redis.NewClient(o) ctx, cancel := context.WithTimeout(context.Background(), 2 * time.Second) defer cancel() if _, err := rdb.Ping(ctx).Result(); err != nil { return ni...
package handler import ( "errors" "fmt" "io/ioutil" "net/http" "os" "path/filepath" "syscall" "git.hoogi.eu/snafu/go-blog/httperror" "git.hoogi.eu/snafu/go-blog/logger" "git.hoogi.eu/snafu/go-blog/middleware" "git.hoogi.eu/snafu/go-blog/models" ) type FileHandler struct { Context *middleware.AppContext }...
// MIT License // // Copyright (c) 2017 Ryan Fowler // // 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 // to use, copy, modify,...
package network import ( "../config" "./bcast" "./localip" "./peers" "fmt" ) func Network(messageTx chan config.Message, messageRx chan config.Message, lostPeers chan []string) { localIP, err := localip.LocalIP() if err != nil { fmt.Println(err) localIP = "DISCONNECTED" } var ID string = fmt.Sprintf(loc...
package main import ( // "fmt" termbox "github.com/nsf/termbox-go" // "gopkg.in/mattn/go-runewidth.v0" ) func debug(n, y int, msg string) { w, h := termbox.Size() tbPrint(w-y, h-n, cldef, termbox.ColorRed, msg) }
// Copyright 2016 Google Inc. All rights reserved. // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. package utils import ( "crypto/rand" "fmt" "io" "io/ioutil" "log" "math/big" "os" "path/filepath" "time" "github.com/ethereum/go-ethereum/accounts/keys...
package policymaker import ( "fmt" "io/ioutil" "os" "github.com/tidwall/gjson" ) const ( tfplanExt = "tfplan" tfplanStdoutFilename = "terraform-plan.stdout" tfplanJSONFilename = "terraform-plan.json" ) // PlanParser downloads and parses the source code for a given provider type PlanParser struct...
package main import ( "database/sql" _ "github.com/go-sql-driver/mysql" "log" ) func Execute(sqlStmt string, db *sql.DB, message string) { _, err := db.Exec(sqlStmt) if err != nil { log.Fatal(err, sqlStmt) return } else { log.Println(message) } } func deleteDbs(db *sql.DB) { sqlStmt := `drop table user...
// Copyright (c) 2015 RxnWeaver // // Part of the RxnWeaver suite of projects. See README.md and LICENSE // for more details. package tokenizer // NonTermAbbrevs lists the common abbreviations that could end with a // full stop, but without ending the sentence. The abbrevs are in // lowercase. var NonTermAbbrevs ma...
package commands import ( "time" "github.com/argoproj/pkg/stats" log "github.com/sirupsen/logrus" "github.com/spf13/cobra" ) func NewWaitCommand() *cobra.Command { var command = cobra.Command{ Use: "wait", Short: "wait for main container to finish and save artifacts", Run: func(cmd *cobra.Command, args ...
package main import ( "./network" "flag" "fmt" "time" ) func main() { messageTx := make(chan network.Message) messageRx := make(chan network.Message) // Our id can be anything. Here we pass it on the command line, using // `go run main.go -id=our_id` // need to add some automatic way here to assign id ...
package mhfpacket import ( "errors" "github.com/Andoryuuta/Erupe/network" "github.com/Andoryuuta/Erupe/network/clientctx" "github.com/Andoryuuta/byteframe" ) // The server sends different responses based on these values. const ( TowerInfoTypeUnk0 = iota TowerInfoTypeTowerRankPoint TowerInfoTypeGetOwnTowerSkil...
// Copyright 2019 GoAdmin Core Team. All rights reserved. // Use of this source code is governed by a Apache-2.0 style // license that can be found in the LICENSE file. package db import ( "context" "database/sql" "regexp" "strings" ) // CommonQuery is a common method of query. func CommonQuery(db *sql.DB, query...
package main /** 116. 填充每个节点的下一个右侧节点指针 给定一个完美二叉树,其所有叶子节点都在同一层,每个父节点都有两个子节点。 二叉树定义如下: ``` struct Node { int val; Node *left; Node *right; Node *next; } ``` 填充它的每个 next 指针,让这个指针指向其下一个右侧节点。如果找不到下一个右侧节点,则将 next 指针设置为 NULL。 初始状态下,所有 next 指针都被设置为 NULL。 示例: ![_1.png](./source/_1.png) ``` 输入:{"$id":"1","left":{"$i...
package router import ( "github.com/bearname/videohost/internal/common/db" "github.com/bearname/videohost/internal/common/infrarstructure/amqp" "github.com/bearname/videohost/internal/common/infrarstructure/profile" caching "github.com/bearname/videohost/internal/common/infrarstructure/redis" "github.com/bearname...
package core import ( . "github.com/onsi/ginkgo" . "github.com/onsi/gomega" ) var _ = Describe("Order", func() { var ( order Order ) BeforeEach(func() { order = Order{} }) Describe("Testing Order", func() { Context("Considering orders with fees", func() { It("should return the correct volume out", ...
package main import ( "fmt" "log" "math/rand" "regexp" "strings" "time" "github.com/google/uuid" "github.com/lancer-kit/sam" ) const ( KeyMethodGet = "GET" KeyMethodHead = "HEAD" KeyMethodPost = "POST" KeyMethodPut = "PUT" KeyMethodPatch = "PATCH" KeyMethodDelete = "DELETE" KeyMethodO...
package bridge import ( "encoding/json" "incognito-chain/common" metadataCommon "incognito-chain/metadata/common" ) type UnshieldResponse struct { metadataCommon.MetadataBase Status string `json:"Status"` RequestedTxID common.Hash `json:"RequestedTxID"` } func NewUnshieldResponse() *UnshieldRespon...
package libtsm // #cgo pkg-config: libtsm // #include <libtsm.h> // #include "bitfields.h" import "C" type ScreenFlags uint32 const ( ScreenInsertMode ScreenFlags = C.TSM_SCREEN_INSERT_MODE ScreenAutoWrap ScreenFlags = C.TSM_SCREEN_AUTO_WRAP ScreenRelOrigin ScreenFlags = C.TSM_SCREEN_REL_ORIGIN ScreenInverse ...
package mock import ( "os" "os/user" "strings" "time" "gopkg.in/yaml.v2" ) type Mock struct { Duration time.Duration `yaml:"duration"` Exitstatus int `yaml:"exit-status"` Stderr string `yaml:"stderr"` Stdout string `yaml:"stdout"` } // MockApp takes an application name as ...
package sdk import ( "context" "encoding/json" "fmt" "io/ioutil" "net/http" "net/http/httptest" "testing" rmTesting "github.com/brigadecore/brigade/sdk/v3/internal/restmachinery/testing" // nolint: lll metaTesting "github.com/brigadecore/brigade/sdk/v3/meta/testing" "github.com/stretchr/testify/require" ) ...
/* hasaki-quant server log system 管理数据中台运行的所有日志数据 包括系统日志,debug日志,错误日志,日志保存,日志发送到用户前端,终端日志 */ package main type Log struct{ DingAddress string EmailAddress string Ding bool Email bool PhoneMsg bool } type logInterface interface{ setting(ding bool,email bool,phoneMsg bool) ding(dingAddress string)...
package alibabacloud import ( "github.com/openshift/installer/pkg/types" "github.com/openshift/installer/pkg/types/alibabacloud" ) // Metadata converts an install configuration to Alibaba Cloud metadata. func Metadata(config *types.InstallConfig) *alibabacloud.Metadata { return &alibabacloud.Metadata{ Region: ...
package cmd import ( "fmt" "os" "github.com/nitschmann/scdns/pkg/cloudflare" scdnsOutput "github.com/nitschmann/scdns/pkg/scdns/output" // "github.com/nitschmann/scdns/pkg/util/cli" // "github.com/nitschmann/scdns/pkg/util/output" "github.com/spf13/cobra" ) func newDnsDeleteCmd() *cobra.Command { cmd := &co...