text
stringlengths
11
4.05M
package main import ( "fmt" "strconv" ) func main() { a2 := a.(string) i, _ = strconv.Atoi(a2) fmt.Println(i) // -> 1234 } var i int var a interface{} = "1234"
package tsdb import ( "encoding/json" "errors" "io/ioutil" "os" "strings" ) func parse(path string) (*string, error) { res, err := ioutil.ReadFile(path) if err != nil { return nil, errors.New("file not existed. create a new chain") } str := string(res) return &str, nil } func loadFromStorage(raw *string)...
package server import ( "fmt" "time" "../../internal/db" "github.com/google/uuid" ) func StoreEstimate (dbHandle *db.Handle, property *db.Property, estimatedPrice int) error { if estimatedPrice != 0 { updates := map[string]interface{}{ "estimate": estimatedPrice, } // TODO: el (look into batching o...
package region import ( "database/sql" "github.com/m-o-s-e-s/mgm/core/persist" "github.com/m-o-s-e-s/mgm/mgm" "github.com/satori/go.uuid" ) type regionDatabase struct { mysql persist.Database } // GetRegionsForUser retrieves region records for a user where the user owns the estate they are in, or is a manager ...
// check Read() method package main import ( "bytes" "fmt" "io" ) func main() { b := make([]byte, 1<<1) fmt.Println("b:len,cap", len(b), cap(b)) // バッファの容量不足時 // reader 内部の index は途中まで動く src := []byte("hello world") r := bytes.NewReader(src) fmt.Println("r.len:", r.Len(), "src.len:", len(src)) // 記録されてい...
package main import ( "fmt" "github.com/bitly/go-simplejson" formatjson "github.com/heyuan110/gorepertory/json" "os" "os/signal" "syscall" ) func main() { done := make(chan os.Signal, 1) signal.Notify(done, os.Interrupt, syscall.SIGINT, syscall.SIGTERM) fmt.Println("hello") js,err := simplejson.NewJson([]b...
// Copyright (C) 2021 Cisco Systems Inc. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // // http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agr...
// DRUNKWATER TEMPLATE(add description and prototypes) // Question Title and Description on leetcode.com // Function Declaration and Function Prototypes on leetcode.com //529. Minesweeper //Let's play the minesweeper game (Wikipedia, online game)! //You are given a 2D char matrix representing the game board. 'M' repres...
package commands import ( "fmt" // "encoding/json" "github.com/pkg/errors" "github.com/spf13/cobra" "github.com/cosmos/cosmos-sdk/client/context" "github.com/cosmos/cosmos-sdk/wire" "github.com/ixofoundation/ixo-cosmos/x/project" ) // take the coolness quiz transaction func CreateProjectCmd(cdc *wire.Codec)...
package dictionary // import( // "github.com/Evedel/fortify/src/say" // ) // // func ruleMath(ttail []Token) (resCode int, stopInd int, resNode TokenNode, errmsg string) { // thisName := "ruleMath: " // resCode = UndefinedError // stopInd = 0 // index := 0 // inBrackets := false // chStopIndx := 0 // chchilds...
package log import ( "fmt" "os" "testing" ) func TestFlags(t *testing.T) { json := new(JSON) json.SetOutput(os.Stdout) console := new(Console) console.SetOutput(os.Stdout) log := New(json, console) for flag := 0; flag < Lindent<<1; flag++ { json.SetFlags(flag) console.SetFlags(flag) log.WithField("fla...
package 一维子序列问题 import "sort" func largestDivisibleSubset(nums []int) []int { sort.Ints(nums) /* 1. 搞清楚定义后,初始化dp数组 */ dp := make([][]int, len(nums)) // 这里定义dp[i]为: 以nums[i]为结尾的最大整除子集 for i := 0; i < len(nums); i++ { /* 2. dp[i]基础情况处理 (指子序列只有一个元素时) */ dp[i] = append(dp[i], nums[i]) for t := 0; t < i; t++...
// Copyright 2018 Diego Bernardes. All rights reserved. // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. package http import ( "encoding/json" "io" "net/http" "strings" "github.com/pkg/errors" "github.com/diegobernardes/flare" infraHTTP "github.com/diego...
/* * Licensed to the OpenSkywalking under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The OpenSkywalking licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use...
package dependency import ( "io/ioutil" "os" "path/filepath" "testing" fakebuild "github.com/devspace-cloud/devspace/pkg/devspace/build/testing" "github.com/devspace-cloud/devspace/pkg/devspace/config/generated" fakegeneratedloader "github.com/devspace-cloud/devspace/pkg/devspace/config/generated/testing" "gi...
// Package uniswap provdies a Golang client wrapper for UniswapV2 package uniswap
/* * Copyright (c) 2020 - present Kurtosis Technologies LLC. * All Rights Reserved. */ package networks /* A marker interface for representing a generic test network. Developers should add their own interface that extends this interface. */ type Network interface{}
package common // AuthenticationSignatureKeySettingKey setting key for authentication_signature_key const AuthenticationSignatureKeySettingKey = "authentication_signature_key" // Setting is a config object meant to be shard by all Plik instances using the metadata backend type Setting struct { Key string `gorm:"pr...
package camt import ( "encoding/xml" "github.com/thought-machine/finance-messaging/iso20022" ) type Document08800101 struct { XMLName xml.Name `xml:"urn:iso:std:iso:20022:tech:xsd:camt.088.001.01 Document"` Message *NetReportV01 `xml:"NetRpt"` } func (d *Document08800101) AddMessage() *NetReportV01 { d.Me...
package main import ( "fmt" ) func main() { const v = 9.0 const a = 5.9 fmt.Printf("a's type %T value %v", a, a) }
package main import( "github.com/sylver-john/Debugo/dump" ) type A struct { Foo string Fuu int } func main() { a := A{"test", 10} dump.Dump(a, "a") }
package batch import ( "runtime" "syscall" "unsafe" ) const ( e_WSAEMSGSIZE = syscall.Errno(10040) ) // iovec isn't used in the general case. type iovec struct{} // Read reads from the RawConn multiple messages in a single syscall. func Read(sc syscall.RawConn, msgs []*Message) (int, error) { if len(msgs) == 0...
package main import ( "io/ioutil" "log" "os" "path" ) const ( testdir = "./testdata" filename = "myfile" ) func main() { if err := os.Mkdir(testdir, 0777); err != nil { log.Println(err) } if err := ioutil.WriteFile(path.Join(testdir, filename), []byte("hello"), 0644); err != nil { log.Fatal(err) } if...
package sorter import ( "ChangeInspector/gitlog" "ChangeInspector/utils" ) /*LogItem ...*/ type LogItem struct { FileName string Info gitlog.FileInfo } /*SortableLogs ...*/ type SortableLogs struct { logs []LogItem } /*NewSorter ...*/ func NewSorter(gitLog *gitlog.GitLog, filter []string) SortableLogs { a...
/* Command Line Arguments We have a package called as os package that contains an array called as “Args”. Args is an array of string that contains all the command line arguments passed. */ package main import ( "fmt" "os" ) func main() { // The first argument is always program name / filepath myProgramName...
package define import "strconv" type StrconvWrapper struct {} func (s *StrconvWrapper)FormatInt(i int64, base int) string { return strconv.FormatInt(i, base) } func (s *StrconvWrapper)FormatBool(b bool) string { return strconv.FormatBool(b) } func (s *StrconvWrapper)FormatFloat(f float64, fmt byte, prec, bitSiz...
package clipboard import ( "os/exec" "github.com/pkg/errors" ) // Clipboard interface for xclip and xsel utilities type ClipBoard interface { // Write to clipboard Copy(text []byte) error // Read from clipboard to output Paste() ([]byte, error) } // Generic clipboard struct typ...
package main import ( "errors" "fmt" ) type MyError string func (e MyError) Error() string { return string(e) } const MyError400 MyError = "not found" const MyError500 MyError = "internal server error" func main() { e1 := MyError400 fmt.Println(errors.Is(e1, MyError400)) fmt.Println(errors.Is(e1, MyError500)...
package stream import ( "bytes" "context" "encoding/binary" "fmt" "io" "time" "github.com/golang/glog" "github.com/yobert/alsa" ) type Sample int32 func (s Sample) Encode(buf io.Writer, format alsa.FormatType) { switch format { case alsa.S16_LE: binary.Write(buf, binary.LittleEndian, int16(s>>16)) case...
// Please use library. package main import ( _ "github.com/winlinvip/go-fdkaac/dec" ) func main() { return }
package builder import "fmt" type Parameter struct { id int cpc float64 cpi float64 tag string } type ParameterBuilder struct { id int cpc float64 cpi float64 tag string } func (param *Parameter) print() { fmt.Println("id : ", param.id, "\ncpc : ", param.cpc, "\ncpi : ", param.cpi, "\ntag : ", param.tag)...
package admin import ( "fmt" "github.com/astaxie/beego" "go_blog/models" "go_blog/utils" ) func (c *AdminController) GetCategory() { director := GetCategoryDirector(c, &GetCategory{}) director.getModel() } func (c *AdminController) EditCategory() { director := GetCategoryDirector(c, &EditCategory{}) director...
// Package index - пакет индексирует документы и хранит их обратный индекс package index import ( "go.core/lesson5/pkg/crawler" ) type Service map[string][]int func New() Service { return make(Service) } // Index - создает и сохраняет обратный индекс переданных документов func (s Service) Index(d []crawler.Docume...
package sleepytcp import ( "bufio" "errors" "fmt" "io" "net" "sync" "sync/atomic" "time" ) type HostClient struct { Addr string Dial DialFunc DialDualStack bool MaxConns int MaxConnWaitTimeout time.Duration MaxIdleConnDuration time.Duration MaxIdempotentCallAtte...
package web import ( "github.com/gin-gonic/gin" "net/http" qa "farmer/autocs/models" "strconv" "html/template" ) func GetQaInfo(c *gin.Context) { var msg string nid := c.Param("id") id, _ := strconv.Atoi(nid) r, err := qa.GetInfoById(id) if err != nil { msg = "记录不存在" }else{ msg = r.Title } con := te...
package util import ( "bufio" "image" "os" "unsafe" "gocv.io/x/gocv" ) func ResizeImage(m gocv.Mat, w, h int) (gocv.Mat, error) { //dst := gocv.NewMatWithSize(w,h,gocv.MatTypeCV8U) dst := gocv.NewMat() gocv.Resize(m, &dst, image.Point{}, 0.5, 0.5, gocv.InterpolationDefault) return dst, nil } func WriteImag...
package fsm //----------------------------------------------------------------------------- // State represents a state activity type State interface { Activate() (State, error) } //----------------------------------------------------------------------------- // StateFunc is a function that satisfies the State int...
package main import ( "encoding/json" "fmt" "os" ) type Message struct { Version int Type int Body string } func main() { // unmarshalling example data := []byte(`{"Version":1234455, "Type":1, "Body":"Hello World!"}`) var msg Message json.Unmarshal(data, &msg) fmt.Println(msg) data2, _ := json.Mar...
package main import "fmt" type Student struct { Name string Gender string Age int Id int Score float64 } func (s *Student) say() string { str := fmt.Sprintf("Name=%v;Gender=%v;Age=%v;Id=%v;Score=%v", s.Name, s.Gender, s.Age, s.Id, s.Score) return str } func main() { stu := Student{ Name: "zcr",...
package main import "fmt" import "unicode/utf8" func main() { fmt.Println("vim-go") b := []byte("hello, 世界") for len(b) > 0 { r, size := utf8.DecodeLastRune(b) fmt.Printf("%c %v\n", r, size) b = b[:len(b)-size] } }
package main import "fmt" func main() { // map 申明 var a map[string]string a = make(map[string]string, 10) a["n.1"] = "AAA" a["n.2"] = "BBB" a["n.1"] = "CCC" // key是不可以重复的~ 如果重复的key会导致覆盖 a["n.3"] = "BBB" // value是可以重复的 //在不make初始化时候,直接用make是没法使用的,报错如下 //panic: assignment to entry in nil map fmt.Println(a) } ...
package main import ( "archive/zip" "bytes" "flag" "fmt" "io" "net/http" _ "net/http/pprof" "sync" "github.com/Taik/zing-mp3/zing" "github.com/buaazp/fasthttprouter" "github.com/oxtoacart/bpool" "github.com/valyala/fasthttp" log "gopkg.in/inconshreveable/log15.v2" ) type albumJob struct { album ...
package sockets // AddProcessor adds an event listener func (conn *Conn) AddProcessor(e string, ch chan string) { if conn.Processors == nil { conn.Processors = make(map[string][]chan string) } if _, ok := conn.Processors[e]; ok { conn.Processors[e] = append(conn.Processors[e], ch) } else { conn.Processors[e]...
package main import ( "io/ioutil" "os" "path/filepath" "strings" "github.com/reconquest/hierr-go" ) func getGitBranch() (string, error) { dir, err := os.Getwd() if err != nil { return "", hierr.Errorf( err, "unable to get current working directory", ) } for { if dir == "/" { return "", hierr...
package pg import ( "github.com/kyleconroy/sqlc/internal/sql/ast" ) type RelabelType struct { Xpr ast.Node Arg ast.Node Resulttype Oid Resulttypmod int32 Resultcollid Oid Relabelformat CoercionForm Location int } func (n *RelabelType) Pos() int { return n.Location }
package bootstrap import ( "fmt" "github.com/jinzhu/gorm" _ "github.com/jinzhu/gorm/dialects/mysql" ."go-test/config" ) var Db *gorm.DB func InitDB() { var err error Db, err = gorm.Open("mysql", fmt.Sprintf("%s:%s@tcp(%s:%s)/%s?charset=utf8&parseTime=True&loc=Local", Config.GetString("database.mysql.user"...
/* Package wsclient implements a WebSocket client. Example: ws := wsclient.NewWSClient("ws://localhost:7070/ws") ws.OnOpen(func() { fmt.Printf("connection opened") ws.SendJSON(wsclient.M{ "type": "chat", "payload": "hello world", "sender": { "name": "Bob", }, }) }) ws.OnMessage(func(data []...
// Copyright 2020 Frederik Zipp. All rights reserved. // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. // A scaling animation of a gopher image. package main import ( "bytes" _ "embed" "flag" "fmt" "image" _ "image/png" "log" "time" "github.com/fzipp/ca...
package kata import "regexp" func GetCount(str string) (count int) { vowels := regexp.MustCompile("a|e|i|o|u") amount := vowels.FindAllStringIndex(str, -1) count = len(amount) return count }
package main import ( "fmt" "net/http" "time" ) func main() { start := time.Now() servers := []string{ "http://google.com", "http://facebook.com", "http://instagram.com", } for _, server := range servers{ checkServer(server) } finish := time.Since(start) fmt.Printf("Execution time %s\n", finish) }...
package main import ( "fmt" "io/ioutil" "log" "net/http" "net/url" "time" "github.com/mmcdole/gofeed" "github.com/patrickmn/go-cache" ) // ParseFeeds allows to get feeds from a site. func ParseFeeds(siteURL, proxyURL string, news chan<- *gofeed.Feed) { // Measure the execution time of this...
package main import "fmt" type puzzle struct { name string price float64 } func (p puzzle) print() { fmt.Printf("Puzzle: %+v\n", p.name) }
package generator import ( "fmt" "strings" "github.com/getkin/kin-openapi/openapi3" ) // PathPoint represents one point in the path "chain". type PathPoint struct { Name string Level int IsParam bool Operations map[string]*openapi3.Operation // Method to OperationID Segments map[string]*PathP...
package ngomc import ( "testing" "fmt" ) type OffsetTest struct { A int64 B string C string D string E int64 } func TestPrepare_string(t *testing.T) { answer := OffsetType{{8, 64, 16, 0}, {24, 16, 32, 0}, {40, 32, 48, 0}} reply := Prepare(&OffsetTest{}) if fmt.Sprint(answer) != fmt.Sprint(reply) { t.Erro...
package lib import ( "github.com/hailongz/kk-lib/dynamic" "github.com/hailongz/kk-logic/logic" ) type RedirectLogic struct { logic.Logic } func (L *RedirectLogic) Exec(ctx logic.IContext, app logic.IApp) error { L.Logic.Exec(ctx, app) url := dynamic.StringValue(L.Get(ctx, app, "url"), "") return logic.NewRe...
package main import ( "encoding/json" "fmt" "io" "io/ioutil" "os" "github.com/axgle/mahonia" //编码转换 "gopkg.in/ini.v1" ) // var bilibiliDownloadPath = "D:/Download/Bilibili" // var destPath = "D:/Learnig/Videos" const ( bilibiliDownloadPath = "D:/Download/Bilibili" destPath = "D:/Learnig/Videos" ...
/* # -*- coding: utf-8 -*- # @Author : joker # @Time : 2021/6/4 9:13 上午 # @File : matrix.go # @Description : # @Attention : */ package v2 func updateMatrix(mat [][]int) [][]int { if len(mat) == 0 { return nil } // 多源 BFS ,0 先入队 queue := make([][]int, 0) for i := 0; i < len(mat); i++ { for j := 0; j < len(mat[...
package infrastructure import ( "os" "testing" "github.com/OopsMouse/arbitgo/models" ) func TestOrder(t *testing.T) { ex := NewBinance(os.Getenv("EXCHANGE_APIKEY"), os.Getenv("EXCHANGE_SECRET")) order := &models.Order{ Symbol: models.Symbol{Text: "ETHBTC"}, OrderType: models.TypeLimit, Side: model...
import "strings" func reverseWords(s string) string { words := strings.Split(s, " ") var reversedWords []string for _, word := range words { reversedWords = append(reversedWords, reverseWord(word)) } return strings.Join(reversedWords, " ") } func reverseWord(s string) string { var reversed []string arr := st...
package main import ( "sync" "time" "github.com/jasonlvhit/gocron" "github.com/sirupsen/logrus" ) func main() { logrus.Infof("Crawler started...") s := gocron.NewScheduler() s.Every(15).Minutes().Do(func() { logrus.Infof("Stating cron at %s", time.Now()) wg := new(sync.WaitGroup) wg.Add(2) go func() ...
package cryptutil import ( "crypto/x509" "crypto/x509/pkix" "encoding/asn1" "errors" "fmt" ) // https://tools.ietf.org/id/draft-ietf-curdle-pkix-05.html#rfc.section.3 var oidPublicKeyX25519 = asn1.ObjectIdentifier{1, 3, 101, 110} // from x509, used for ASN.1 type ( pkcs8 struct { Version int Algo ...
package main import ( "net" "strings" ) type User struct { Name string Addr string C chan string conn net.Conn server *Server } //创建一个用户的API func NewUser(conn net.Conn,server *Server) *User{ userAddr := conn.RemoteAddr().String() user := &User{ Name: userAddr, Addr: userAddr, C: make(chan string),...
package main import ( "fmt" "strings" ) func main() { var numbers [4]int fmt.Printf("%v\n", numbers) fmt.Printf("%#v\n", numbers) num := [2]int{10, 27} fmt.Printf("%#v\n", num) var a1 = [4]float64{} fmt.Printf("%#v\n", a1) var a2 = [3]int{-10, 1, 100} fmt.Printf("%#v\n", a2) a3 := [3]string{"Devin", "...
package radware import ( "github.com/zdnscloud/elb-controller/driver/radware/client" ) func (c radwareConfig) delete(cli *client.Client) error { if err := cli.VirtualServer().Delete(c.VsID); err != nil { return err } if err := cli.ServerGroup().Delete(c.VsID); err != nil { return err } for rs := range c.R...
package explain import ( "github.com/pkg/errors" apiextv1 "k8s.io/apiextensions-apiserver/pkg/apis/apiextensions/v1" "k8s.io/apimachinery/pkg/runtime" "k8s.io/apimachinery/pkg/runtime/serializer" ) func loadSchema(b []byte) (*apiextv1.JSONSchemaProps, error) { scheme := runtime.NewScheme() codecs := serializer....
package xtp_wrapper /* #include <string.h> */ import "C" import ( "fmt" "unsafe" ) func getIntValOfPtr(spiPtr C.ulonglong) uint64 { return uint64(spiPtr) } func GetInstrumentsPointer(input_arr []string) **C.char { var buf []*C.char for i, _ := range input_arr { buf = append(buf, (*C.char)(unsafe.Pointer(C.CS...
package osbuild1 import ( "encoding/json" "errors" ) // An Assembler turns a filesystem tree into a target image. type Assembler struct { Name string `json:"name"` Options AssemblerOptions `json:"options"` } // AssemblerOptions specify the operations of a given assembler-type. type AssemblerOptions ...
// This file was generated for SObject DatacloudCompany, API Version v43.0 at 2018-07-30 03:47:47.000733633 -0400 EDT m=+33.344591248 package sobjects import ( "fmt" "strings" ) type DatacloudCompany struct { BaseSObject ActiveContacts int `force:",omitempty"` AnnualRevenue string ...
package config import ( "encoding/json" "io/ioutil" ) type Config struct { Port int `json:"port"` XMLPath string `json:"xmlPath"` Token string `json:"token"` } var Conf Config func GetConfig(inputConfPath string) error { configPath := "./data.json" if inputConfPath != "" { configPath = inputConfPat...
package configman import "time" type ConfigManager interface { Get(string) interface{} GetString(string) string GetBool(string) bool GetInt(string) int GetInt64(string) int64 GetFloat64(string) float64 GetTime(string) time.Time GetDuration(string) time.Duration GetStringSlice(string) []string GetStringMap(s...
package shutdown import ( "os" "testing" "time" "github.com/stretchr/testify/assert" ) //Test the shutdown hook when an os.Interrupt signal is notified. func TestShutdown(t *testing.T) { waitShutdown := make(chan bool) hook := func() { waitShutdown <- true } go OnShutdown(hook) interruptChannel <- os....
package main import ( "fmt" "math" "reflect" ) func main() { var x float64 x = -1 // func Abs(x float64) float64 fmt.Println(math.Abs(x)) fmt.Println(math.E) fmt.Println(reflect.TypeOf(x)) }
package map_2 func Translate(str string) string { if len(str) % 3 != 0 { return "" } codons := []byte(str) var res string for i := 0; i < len(str) / 3; i ++ { name := ProteinName[string(codons[i * 3: (i + 1) * 3])] if name == "STOP" { break } res += name } return res }
package main import ( "fmt" "sync" ) var wg = sync.WaitGroup{} var m = sync.RWMutex{} func main() { ch := make(chan int) for j := 0; j < 5; j++ { wg.Add(2) go func(ch <-chan int) { i := <-ch m.Lock() fmt.Println(i) m.Unlock() wg.Done() }(ch) go func(ch chan<- int, index int) { m.Lock()...
package inc import ( "testing" ) func Test_GetSysLoadavg_1(t *testing.T) { load := GetSysLoadavg() if load >= 0 { t.Log("loadavg: ", load) } else { t.Error("loadavg: ", load) } }
package main import ( "fmt" "runtime" "sync" ) var wg sync.WaitGroup func main() { fmt.Println("Number of Goroutine 1st:", runtime.NumGoroutine()) wg.Add(5) go moo("Hello") //wg.Add(1) go moo("Football") //runtime.Gosched() go coo() fmt.Println("Number of Goroutine 2nd:", runtime.NumGoroutine()) go f...
package funcs import "fmt" func simple(a func(a int, b int) int) { fmt.Println("a(60, 7) is ", a(60, 7)) } func simpleReturnFunc() (a func(a int, b int) int) { a = func(a int, b int) int { return a + b } return } //RunHighOrderFuncAttr runs high-ordered function simple() func RunHighOrderFuncAttr() { //simpl...
/* Package euclid allows for finding the greatest common denominator between two numbers. */ package main // Function euclid finds the greates common denominator between two unsigned // If either value is 0 the result will be 0. func euclid(input1,input2 uint) (uint,int) { var remainder uint count:=0 if(input1==0...
package golog import ( "github.com/lucasew/golog/handler/default" "github.com/lucasew/golog/logger/default" "os" ) // Default Default logger already built for more out of the box experience var Default = ldefault.NewLogger( hdefault.NewHandler(os.Stderr, ""), )
package main import ( "text/template" "os" "fmt" ) func main() { f:=template.Must(template.ParseFiles("passing.gohtml","passingvar.gohtml")) err:=f.ExecuteTemplate(os.Stdout,"passing.gohtml","hey 22") if err!=nil{ fmt.Println(err) } err=f.ExecuteTemplate(os.Stdout,"passingvar.gohtml",`variable pass`) if ...
package fetch import ( "fmt" "io/ioutil" "net/http" "net/http/httptest" "strconv" "testing" "time" "github.com/gorilla/mux" "github.com/slotix/dataflowkit/splash" "github.com/spf13/viper" "github.com/stretchr/testify/assert" ) var ( IndexContent = []byte(`<!DOCTYPE html><html><body><h1>Hello World</h1></...
package service import ( "context" "github.com/teploff/otus/calendar/domain/entity" "time" ) // CalendarService encapsulate calendar domain logic type CalendarService interface { CreateEvent(ctx context.Context, event entity.Event) error UpdateEvent(ctx context.Context, event entity.Event) error DeleteEvent(ctx...
package registry // ManifestDescriptor describes a /*type ManifestDescriptor struct { Data []byte PlatformFeatures []string }*/
package main import ( "fmt" pbf "github.com/Tessen/tessProtobuf/consignment-service/proto/consignment" "github.com/micro/go-micro" "log" ) const ( port = ":50051" ) func main() { repo := &Repository{} srv := micro.NewService( micro.Name("tessen.service.consignment"), ) srv.Init() pbf.RegisterShippingSe...
package easypost import ( "context" ) // DeletePaymentMethod allows you to delete a payment method in your wallet. func (c *Client) DeletePaymentMethod(priority PaymentMethodPriority) (err error) { return c.DeletePaymentMethodWithContext(context.Background(), priority) } // DeletePaymentMethodWithContext performs ...
package models import ( "github.com/astaxie/beego" "github.com/astaxie/beego/orm" ) type User struct { Id int `orm:"column(id);pk"` //Uid int Name string `orm:"column(name);unique"` Pass string Mail string Theme string Signature string Signature_format string Created int Access int Login int Status int...
package bytearksigner import ( "crypto/md5" "encoding/base64" "errors" "fmt" URL "net/url" "sort" "strconv" "strings" "time" "github.com/pasztorpisti/qs" ) // Signer struct for Signer class. type Signer struct { AccessID string AccessSecret string DefaultAge int SkipURLEncoding bool } /...
package main import "../kvservice" import ( "fmt" ) func main() { var nodes []string nodes = []string{"52.187.214.143:2222", "52.233.32.107:2222"} c := kvservice.NewConnection(nodes) fmt.Printf("NewConnection returned: %v\n", c) for { t1, err := c.NewTX() fmt.Printf("NewTX returned: %v, %v\n", t1, err) } ...
package jobs import ( "fmt" adm "github.com/ebikode/eLearning-core/domain/admin" apset "github.com/ebikode/eLearning-core/domain/app_setting" cou "github.com/ebikode/eLearning-core/domain/course" usr "github.com/ebikode/eLearning-core/domain/user" md "github.com/ebikode/eLearning-core/model" ut "github.com/ebi...
package main import ( "errors" "fmt" "io/ioutil" "log" "os" gc "github.com/rthornton128/goncurses" ) const ( ESC_KEY gc.Key = 0x1B COLON_KEY gc.Key = 0x3A DELETE_KEY gc.Key = 0x7F CTRS_KEY gc.Key = 0x13 // for save ) type WindowMode int const ( MainWin WindowMode = iota ColmWin ModeWin ) type V...
package bgo import "fmt" // BusinessError struct type BusinessError struct { Code int Msg string } func (e *BusinessError) Error() string { return fmt.Sprintf(`{"code":%d,"msg":"%s"}`, e.Code, e.Msg) } // Throw a BusinessError with panic // Note: make sure to use this func in the call stack // w...
package x // GENERATED BY XO. DO NOT EDIT. import ( "errors" "strings" //"time" "ms/sun/shared/helper" "strconv" "github.com/jmoiron/sqlx" ) // (shortname .TableNameGo "err" "res" "sqlstr" "db" "XOLog") -}}//(schema .Schema .Table.TableName) -}}// .TableNameGo}}// CommentDeleted represents a row from 'sun.comm...
// Package shared contains shared data between the host and plugins. package shared import "github.com/hashicorp/go-plugin" // Handshake is a common handshake that is shared by plugin and host. var Handshake = plugin.HandshakeConfig{ // The ProtocolVersion is the version that must match between EG core and EG plugin...
package repository import ( "context" "github.com/muhammadisa/vanilla-microservice/model" "log" ) func (t *todoRepository) WriteTodo(ctx context.Context, todo model.Todo) error { log.Println(todo) return nil }
package powerdns import ( "context" "fmt" "strconv" ) // CryptokeysService handles communication with the cryptokeys related methods of the Client API type CryptokeysService service // Cryptokey structure with JSON API metadata type Cryptokey struct { Type *string `json:"type,omitempty"` ID *uint...
package main import "fmt" func main() { firstName := "Viktor" secondName := "Bushmin" fullName := firstName + " " + secondName arrayOfNames := []string{firstName, secondName, fullName} fmt.Printf("%q", arrayOfNames) }
package config import ( "fmt" "os" "path/filepath" "strings" corsConfig "github.com/Eldius/cors-interceptor-go/config" authConfig "github.com/eldius/jwt-auth-go/config" "github.com/mitchellh/go-homedir" "github.com/spf13/viper" ) func SetDefaults() { viper.SetDefault("app.database.url", "app.db") viper.Set...
// Copyright 2018 The eballscan Authors // This file is part of the eballscan. // // The eballscan is free software: you can redistribute it and/or modify // it under the terms of the GNU Lesser General Public License as published by // the Free Software Foundation, either version 3 of the License, or // (at your optio...
package main import ( "fmt" "github.com/bwmarrin/discordgo" "os" "os/signal" "syscall" ) /*type Config struct { storage store.Store } var config Config */ // https://media1.tenor.com/images/baf2d324d696b8e0b08daa8cff5c8f12/tenor.gif?itemid=12992329 func main() { dg, err := discordgo.New("Bot " + os.Getenv("TO...
package fourier import ( "math" "math/cmplx" ) func isPowerOfTwo(n int) bool { for n&1 == 0 && n > 1 { n >>= 1 } return (n == 1) } func RecursiveFFT(input []complex128) []complex128 { n := len(input) if !isPowerOfTwo(n) { panic("input must be padded already.") } if n == 1 { return input } halfLen...