text
stringlengths
11
4.05M
package field import "github.com/naruta/terraform-provider-kintone/kintone" type SingleLineText struct { code kintone.FieldCode label string } func NewSingleLineText(code kintone.FieldCode, label string) *SingleLineText { return &SingleLineText{ code: code, label: label, } } func (s *SingleLineText) Type(...
// Copyright 2020 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...
// Copyright 2017 The OpenSDS 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 agre...
package main import "fmt" // Some version constants. const ( AppVendor = "hexaflex" AppName = "srv" AppVersion = "v0.0.1" ) // Version returns the version string. func Version() string { return fmt.Sprintf("%s %s %s", AppVendor, AppName, AppVersion) }
package Wallet import ( "crypto/ecdsa" "crypto/elliptic" "crypto/rand" "crypto/sha256" "fmt" "log" "github.com/mr-tron/base58" "golang.org/x/crypto/ripemd160" ) type Wallet struct { PrivateKey ecdsa.PrivateKey PublicKey []byte Token int } type Wallets struct { Wallets map[string]*Wallet } var add...
package prompt import ( "reflect" "testing" ) func TestFilter(t *testing.T) { var scenarioTable = []struct { scenario string filter Filter list []Suggest substr string ignoreCase bool expected []Suggest }{ { scenario: "Contains don't ignore case", filter: FilterContains, ...
// Copyright 2015 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 Problem0055 func canJump(nums []int) bool { for i := len(nums) - 2; i >= 0; i-- { // 找到数值为 0 的元素 if nums[i] != 0 { continue } j := i - 1 for ; j >= 0; j-- { if i-j < nums[j] { // 在 j 号位置上,可以跨过 0 元素 i = j break } } if j == -1 { // 在 0 元素之前,没有位置可以跨过 0 return false }...
package models import "time" // Job represents a single unit of work that is delivered to the worker. type Job struct { Id string // unique ID Input []byte // task payload Progress uint8 Logs []string CreatedAt time.Time DeliveredAt time.Time FinishedAt time.Time }
package goil import ( "io" "mime/multipart" "path/filepath" "sync" ) // An attachment type Attachment struct { // Filename sent to the server, optional BasePath string // File to be sent, be sure to check max length Reader io.Reader mutex *sync.Mutex } const ( MB uint = 1 << (10 *...
package data // symbolsConv defines a map of symbols and crypto currency names. type symbolsConv map[string]string // fromCurrencies updates the symbolsConv with the map of name and currency model. func (s *Service) updateSymConv() { // construct for name, curr := range s.Currencies { s.symconv[curr.Symbol] = na...
package main import "testing" func TestRedisCase(t *testing.T) { RedisCase() }
package authentication import ( "glsamaker/pkg/app/handler/authentication/auth_session" "glsamaker/pkg/app/handler/authentication/templates" "glsamaker/pkg/app/handler/authentication/utils" "glsamaker/pkg/database/connection" "glsamaker/pkg/models/users" "golang.org/x/crypto/argon2" "net/http" ) func Login(w h...
package main import ( "fmt" "log" "time" "os" "os/signal" "github.com/ddouglas/phoenix/app" _ "github.com/go-sql-driver/mysql" "github.com/gorilla/websocket" "github.com/pkg/errors" ) func main() { app, err := app.New() if err != nil { err = errors.Wrap(err, "Unable to parse env variable into struct")...
package spool import ( "time" "github.com/cloudspannerecosystem/spool/model" ) // FilterNotUsedWithin returns a function which reports whether sdb is not used within d. func FilterNotUsedWithin(d time.Duration) func(sdb *model.SpoolDatabase) bool { return func(sdb *model.SpoolDatabase) bool { return !sdb.Update...
// Copyright © 2019 Developer Network, LLC // // This file is subject to the terms and conditions defined in // file 'LICENSE', which is part of this source code package. package main import ( "fmt" "os" "go.atomizer.io/cmd" _ "go.atomizer.io/montecarlopi" ) func main() { err := cmd.Initialize("Atomizer Test A...
package strain // Implement the `keep` and `discard` operation on collections. // Given a collection and a predicate on the collection's elements, // `keep` returns a new collection containing those elements where // the predicate is true, while `discard` returns a new collection // containing those elements where the...
// Package magicbytes Some file formats are intended to be read different than text-based files because they have special // formats. In order to determine a file's format/type, magic bytes/magical numbers are used to mark files with special // signatures, located at the beginning of the file, mostly. You are assigned ...
package sensors import ( "encoding/json" "time" ) type Sensor struct { Id string Value int RecordedAt time.Time } func (sensor *Sensor) MarshalJSON() ([]byte, error) { return json.Marshal( &struct { Id string `json:"id"` Value int `json:"value"` RecordedAt int64 `json:"...
package blc //BlockChain 区块链结构 type BlockChain struct { Blocks []*Block //区块的基本机构 } //CreateBlockChainWithGenesis 初始化区块链 func CreateBlockChainWithGenesis() *BlockChain { block := CreateGenesisBlock([]byte("bc init")) return &BlockChain{[]*Block{block}} } //AddBlock 添加区块到区块链中 func (bc *BlockChain) Ad...
package craft import ( "complie/src/AST" "complie/src/tokentype" "fmt" ) type SimpleParser struct { rootNode ASTNode //script string } func NewSimpleParser() *SimpleParser { return &SimpleParser{ rootNode: nil, //script: "", } } func (this *SimpleParser) GetRoot() ASTNode { return this.rootNode } fu...
// Package deferlog implements deferpanic error logging. package deferlog import ( "fmt" "github.com/deferpanic/deferclient/deferclient" "runtime" ) // Token is your deferpanic token available in settings var Token string // Environment sets an environment tag to differentiate between separate // environments - d...
package controllers import ( "github.com/AnhNguyenQuoc/go-blog/lib" "github.com/jinzhu/gorm" "github.com/julienschmidt/httprouter" "net/http" ) var layoutService LayoutService type LayoutService struct { DB *gorm.DB } func LayoutRouter(r *httprouter.Router, db *gorm.DB) { layoutService = LayoutService{DB: db}...
package converter import ( "fmt" "regexp" "strconv" "strings" "unicode" ) var validationRegExp *regexp.Regexp var groupRegExp *regexp.Regexp func init() { validationRegExp = regexp.MustCompile(`((^|[^\\])\\([^\\\d]|$))|^\d+`) groupRegExp = regexp.MustCompile(`(\\{2}\d+)|(\\{2})|(\\\d{2,})|(\D\d+)`) } // NewS...
package crashparser import ( "bufio" ) // Reads strings from source Scanner and pass them line by line to output channel. func Read(s *bufio.Scanner, onFinish func()) (<-chan string, error) { output := make(chan string) go func() { defer close(output) defer onFinish() for s.Scan() { output <- s.Text() ...
package utils import ( "regexp" "time" ) // 获取当前时间 func NowTime() string { return time.Unix(time.Now().Unix(), 0).Format("2006-01-02 15:04:05") } // 获取当前时间戳 func NowUnix() int64 { return time.Now().Unix() } // 获取当前时间 func UnixToFormatTime(timeStamp int64) string { return time.Unix(timeStamp, 0).Format("2006-01...
package device import ( "fmt" "regexp" "strconv" "github.com/uhppoted/uhppote-core/types" "github.com/uhppoted/uhppoted-lib/locales" "github.com/uhppoted/uhppoted-lib/uhppoted" "github.com/uhppoted/uhppoted-mqtt/common" ) type Event struct { DeviceID uint32 `json:"device-id"` Index uint...
package types import ( "time" "github.com/jinzhu/gorm" // HOFSTADTER_START import // HOFSTADTER_END import ) /* Name: Post About: The blog post type */ // HOFSTADTER_START start // HOFSTADTER_END start /* Where's your docs doc?! */ type Post struct { /* ORM: server.api.databases.[name==postgres]...
package Controllers import ( "resource-api/Models" "fmt" "net/http" "github.com/gin-gonic/gin" ) //GetClients ... Get all clients func GetClients(c *gin.Context) { var client []Models.Client err := Models.GetAllClients(&client) if err != nil { c.AbortWithStatus(http.StatusNotFound) } else { c.JSON(http.St...
package pathfileops import ( "strings" "testing" ) func TestFileMgr_CopyFileToDirByLinkByIo_01(t *testing.T) { fileName := "newerFileForTest_01.txt" sourceFile := "../filesfortest/newfilesfortest/" + fileName fh := FileHelper{} absoluteSourceFile, err := fh.MakeAbsolutePath(sourceFile) if err != nil...
package article import ( "html/template" ) type Article struct { // title of article Title string // Unique identifier used internally ID uint64 // Unique identifier of the Author AuthorID uint64 // Date of release, used for sorting articles on run page // TODO change the type to time.Time Timestamp uint...
// +build integration package integration import ( "bytes" "github.com/stretchr/testify/assert" "os/exec" "testing" ) func TestMainFunction(t *testing.T) { var cmdLine []string cmdLine = append(cmdLine, "exec", "-i") cmdLine = append(cmdLine, "simple_nginx_with_curl") cmdLine = append(cmdLine, "curl", "-s"...
package heatshrink /* #cgo CFLAGS: -I./ #cgo LDFLAGS: -L./ -lheatshrink #cgo LDFLAGS: -L./ -lirzip #include "heatshrink_app.h" #include "heatshrink_common.h" #include "heatshrink_config.h" #include "heatshrink_decoder.h" #include "heatshrink_encoder.h" #include "irzip.h" #include <stdlib.h> */ import "C" import ( "en...
package main import ( "crypto/ecdsa" "crypto/rsa" "encoding/json" "fmt" "net/mail" "net/url" "os" "path/filepath" "reflect" "regexp" "strings" "time" "github.com/spf13/cobra" "github.com/spf13/pflag" "github.com/authelia/authelia/v4/internal/configuration/schema" "github.com/authelia/authelia/v4/inte...
package controller import ( "bubble/models" "github.com/gin-gonic/gin" "net/http" ) func IndexHandle(c *gin.Context) { c.HTML(http.StatusOK,"index.html",nil) } func CreateTodo(c *gin.Context) { //获取json数据 var todo models.Todo c.BindJSON(&todo) err := models.CreateOneTodo(&todo) if err !=nil { c.JSON(ht...
package sleepy type SentPacketBuffer struct { buf SequenceBuffer entries []SentPacket } func NewSentPacketBuffer(cap uint16) *SentPacketBuffer { return &SentPacketBuffer{buf: NewSequenceBuffer(cap), entries: make([]SentPacket, cap, cap)} } func (s *SentPacketBuffer) Insert(seq uint16) *SentPacket { // Packet...
package main import ( "errors" "fmt" "io" "io/ioutil" "os" "os/user" "strings" ) func main() { if len(os.Args) < 2 { terror(errors.New("missing gopath")) } gopath, err := format(os.Args[1]) if err != nil { terror(err) } shrc, err := shellrc() if err != nil { terror(err) } if err := backup(shr...
package counter import ( "testing" "time" "github.com/stretchr/testify/assert" ) func TestGaugeCounter(t *testing.T) { key := "server" g := &Group{ New: func() Counter { return NewGauge() }, } g.Add(key, 1) g.Add(key, 2) g.Add(key, 3) g.Add(key, -1) assert.Equal(t, g.Value(key), int64(5)) g.Reset(...
/** * The count-and-say sequence is the sequence of integers beginning as follows: * 1, 11, 21, 1211, 111221, ... */ func countAndSay(n int) string { if 1 == n { return "1" } s, sb := []byte{1}, make([]byte, 0) for k := 1; k < n; k++ { pre, i := s[0], byte(1) for j, count := ...
package problem0367 import "testing" func TestIsPerfectSquare(t *testing.T) { t.Log(isPerfectSquare(1)) t.Log(isPerfectSquare(100)) t.Log(isPerfectSquare(108)) }
package netqos import ( "time" "testing" ) func TestQos(t *testing.T){ q := NewServerQos() q.Stat() for i:=0;i<100;i++{ q.StatAccpetConns() go func(){ t2 := time.NewTicker(2*time.Second) for{ select { case <-t2.C: q.StatReadMsgs() } } }() } time.Sleep(time.Mi...
package main import ( "github.com/munusamy/cms" "os" ) func main() { p := &cms.Page{ Title: "Hello, world!", Content: "This is the body of our webapge", } cms.Tmpl.ExecuteTemplate(os.Stdout, "index", p) }
package main import ( "fmt" "github.com/asppj/droneDeploy/conf" http2 "github.com/asppj/droneDeploy/internal/http" "github.com/spf13/pflag" ) func main() { versionInfo := pflag.BoolP("version", "v", false, "show version info.") pflag.Parse() fmt.Printf("%s\n\n", conf.BuildVersion()) if versionInfo != nil && ...
// DRUNKWATER TEMPLATE(add description and prototypes) // Question Title and Description on leetcode.com // Function Declaration and Function Prototypes on leetcode.com //321. Create Maximum Number //Given two arrays of length m and n with digits 0-9 representing two numbers. Create the maximum number of length k <= m ...
// Copyright 2019-2023 The sakuracloud_exporter 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 appl...
package mat import ( "github.com/stretchr/testify/assert" "math" "testing" ) var rt2 = math.Sqrt(2.0) / 2.0 func TestNewLight(t *testing.T) { p := NewPoint(0, 0, 0) color := NewColor(1, 1, 1) light := NewLight(p, color) assert.True(t, TupleEquals(light.Position, p)) assert.True(t, TupleEquals(light.Intensity...
package docgen import ( "bytes" "io" "github.com/saschagrunert/go-docgen/internal/writer" "github.com/cpuguy83/go-md2man/md2man" "github.com/urfave/cli" ) // CliToMarkdown converts a given `cli.App` to a markdown string. // The function errors if either parsing or writing of the string fails. func CliToMarkdow...
package token import "fmt" type Token struct { Type Lit } type Type string type Lit []rune // Types const ( INVALID = "INVALID" EOF = "EOF" COMMA = "COMMA" COLON = "COLON" EQUAL = "EQUAL" LBRACE = "LBRACE" RBRACE = "RBRACE" LBRACKET = "LBRACKET" RBRACKET = "RBRACKET" STRING = "STRI...
package test import ( "path/filepath" "github.com/astaxie/beego" "runtime" "testing" "github.com/SungKing/blogsystem/models/dao" "github.com/SungKing/blogsystem/models/entity" "time" "fmt" "github.com/astaxie/beego/orm" "encoding/json" "os" ) func init() { _, file, _, _ := runtime.Caller(1) apppath, _ :=...
package kimono import ( "testing" "time" . "github.com/smartystreets/goconvey/convey" ) func TestGetClient(t *testing.T) { Convey("Get api client", t, func() { id := "95k55308" key := "dMes7SXhes5WG150GAdzOLfglPuDkz5o" client, err := GetClient(key, id) So(err, ShouldBeNil) So(client, ShouldNotBeNil) ...
package goub type CoubService struct { client *Client } type Web struct { Template *string Types []string Versions []string } type WebChunks struct { Template *string Types []string Versions []string Chuncks []int } type HTML5 struct { Template *string Chunks []int } type IPhone struct { URL *s...
package healthcheck import ( "reflect" "testing" "github.com/stretchr/testify/assert" ) func TestHealthCheckHandler(t *testing.T) { host := "127.0.0.1:12345" invalidhost := "invalidhost" checkers := []Checker{ ParseConn{Host: host}, FetchConn{Host: host}, RedisConn{ Network: "tcp", Host: "127.0...
package sliding_window import ( "fmt" "testing" ) func TestMinWindowSubStr(t *testing.T) { fmt.Println(MinWindowSubStr("EBBANCF", "ABC")) }
package database import ( "github.com/janwiemers/up/models" "github.com/spf13/viper" "gorm.io/driver/sqlite" "gorm.io/gorm" ) // Connect establishes a connection to the Database func connect() *gorm.DB { db, err := gorm.Open(sqlite.Open(viper.GetString("DB_PATH")), &gorm.Config{}) if err != nil { panic("fail...
// Copyright 2018 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...
// DRUNKWATER TEMPLATE(add description and prototypes) // Question Title and Description on leetcode.com // Function Declaration and Function Prototypes on leetcode.com //337. House Robber III //The thief has found himself a new place for his thievery again. There is only one entrance to this area, called the "root." B...
// Copyright 2013 The Gorilla WebSocket Authors. All rights reserved. // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. package handler import ( "chatapp/infra" "chatapp/util/logger" "context" "encoding/json" "net/http" "os" "sync" "github.com/go-redis/re...
/* * @lc app=leetcode.cn id=23 lang=golang * * [23] 合并K个升序链表 */ // @lc code=start /** * Definition for singly-linked list. * type ListNode struct { * Val int * Next *ListNode * } */ package main import "fmt" import "container/heap" type ListNode struct { Val int Next *ListNode } type heapList...
package double_pointer import ( "fmt" "testing" ) func TestRemoveDuplicates(t *testing.T) { fmt.Println(RemoveDuplicates([]int{0, 0, 1, 1, 1, 2, 3, 4, 4, 5})) fmt.Println(RemoveDuplicates([]int{0, 1, 1, 1, 1, 1, 5, 5, 11, 23, 23, 23, 44})) } func TestDeleteDuplicates(t *testing.T) { head := &Node...
package sync import ( "strings" "time" "github.com/devspace-cloud/devspace/cmd" "github.com/devspace-cloud/devspace/cmd/flags" "github.com/devspace-cloud/devspace/e2e/utils" "github.com/devspace-cloud/devspace/pkg/util/log" "github.com/pkg/errors" ) func runDownloadOnly(f *customFactory, logger log.Logger) er...
package fin import ( "path" "path/filepath" "strings" "github.com/valyala/fasthttp" ) type IRouter interface { Use(middleware ...HandlerFunc) Handle(relativePath string, method string, handlers ...HandlerFunc) ANY(relativePath string, handlers ...HandlerFunc) GET(relativePath string, handlers ...HandlerFunc...
// Package xs contains eXtended actions (xactions) except storage services // (mirror, ec) and extensions (downloader, lru). /* * Copyright (c) 2018-2020, NVIDIA CORPORATION. All rights reserved. */ package xs import ( "github.com/NVIDIA/aistore/3rdparty/glog" "github.com/NVIDIA/aistore/cluster" "github.com/NVIDI...
package routes import "net/http" func HomePageHandler(w http.ResponseWriter, r *http.Request) { w.WriteHeader(http.StatusOK) p := "./statics/indexpage.html" http.ServeFile(w, r, p) } func SignUpPageHandler(w http.ResponseWriter, r *http.Request) { w.WriteHeader(http.StatusOK) p := "./statics/signuppage.html" ht...
package telegram import ( "fmt" "net/http" "testing" "time" "github.com/metalmatze/alertmanager-bot/pkg/telegram" "gopkg.in/tucnak/telebot.v2" ) var statusWorkflows = []workflow{{ name: "Status", messages: []telebot.Update{{ Message: &telebot.Message{ Sender: admin, Chat: chatFromUser(admin), Te...
package handler import ( "encoding/json" "golang-api/model" "net/http" "net/http/httptest" "testing" ) func TestProcessStats(t *testing.T) { req, err := http.NewRequest("GET", "/stats", nil) if err != nil { t.Fatal(err) } model.Stats = model.HashRequestStats{1, 5001,5001} r := httptest.NewRecorder() han...
package main import "fmt" func main() { name := "Fah" var age int age = 19 fmt.Println(name, age) }
package main import ( "flag" "fmt" ) // MyStr 存放传进的参数与长度 type MyStr struct { v string // 存放值 l int // 存放长度 } func (m *MyStr) String() string { return string(m.v) } // Set 赋值操作 func (m *MyStr) Set(value string) error { *m = MyStr{v: value, l: len(value)} return nil } // MyStrVar 解析参数 func MyStrVar(m *MySt...
package snow import ( "fmt" "sort" "strconv" "strings" "github.com/HuiOnePos/flysnow/models" "github.com/HuiOnePos/flysnow/utils" "github.com/sirupsen/logrus" "gopkg.in/mgo.v2/bson" ) type StatReq struct { Term string Index bson.M DataQuery bson.M STime...
package kubernetes import ( "fmt" "regexp" "testing" "github.com/coredns/coredns/plugin/test" "github.com/miekg/dns" ) func TestKubernetesEndpointPodNames(t *testing.T) { var tests = []struct { test.Case TargetRegEx string AnswerCount, ExtraCount int }{ { Case: test.Case{Qname: "...
package suites import ( "crypto/tls" "fmt" "io" "net/http" "strings" "testing" "github.com/stretchr/testify/suite" "github.com/valyala/fasthttp" ) func NewRequestMethodScenario() *RequestMethodScenario { return &RequestMethodScenario{} } type RequestMethodScenario struct { suite.Suite client *http.Clien...
// // 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 tar import ( "github.com/root-gg/utils" ) // BackendConfig object type BackendConfig struct { Tar string Compress string Options string } // NewTarBackendConfig instantiate a new Backend Configuration // from config map passed as argument func NewTarBackendConfig(config map[string]interface{}) (tb ...
package git import ( "fmt" "git-get/pkg/git/test" "os" "path/filepath" "reflect" "testing" "github.com/stretchr/testify/assert" ) func TestUncommitted(t *testing.T) { tests := []struct { name string repoMaker func(*testing.T) *test.Repo want int }{ { name: "empty", repoMaker: te...
package main /** * This process creates or updates a record for each summoner ID * in the list provided as an input. Each record includes a "daily" * key that contains a bunch of records with summary stats for a * given day. * * ./join-summoners --date=2014-08-07 */ import ( gproto "code.google.com/p/goprotob...
package main import ( "fmt" "golang.org/x/tour/tree" ) // Walk walks the tree t sending all values // from the tree to the channel ch. func Walk(t *tree.Tree, ch chan int) { if t != nil { ch <- t.Value Walk(t.Left, ch) Walk(t.Right, ch) } close(ch) } // Same determines whether the trees // t1 a...
package abstract_factory type tensorFlowModel struct { } type tensorFlowPredictor struct { } type tensorFlowConverter struct { } func (model *tensorFlowModel) Name() string { return "tensorFlowModel" } func (predictor *tensorFlowPredictor) Predict() float32 { return 1.0 } func (converter *tensorFlowConverter) C...
package Problem0273 import ( "strings" ) var lessThan21 = []string{ "", "One", "Two", "Three", "Four", "Five", "Six", "Seven", "Eight", "Nine", "Ten", "Eleven", "Twelve", "Thirteen", "Fourteen", "Fifteen", "Sixteen", "Seventeen", "Eighteen", "Nineteen", "Twenty", } var ten = []string{ "", "",...
package main import "github.com/nsf/termbox-go" type Competition struct { x int y int turn Cell board *Board } func NewCompetition(first Cell) *Competition { return &Competition{ turn: first, board: NewBoard(), } } func (c *Competition) SupressCursorXY() { switch { case c.x < 0: c.x = 0 cas...
package web import ( "github.com/tdewolff/minify" minHTML "github.com/tdewolff/minify/html" minSVG "github.com/tdewolff/minify/svg" ) // DefaultMinifier is a default minifier configuration to use. func DefaultMinifier() *minify.M { m := minify.New() m.Add("text/html", minHTML.DefaultMinifier) m.Add("image/svg+x...
package repository import ( "database/sql" "kz.nitec.digidocs.pcr/internal/models" "kz.nitec.digidocs.pcr/pkg/logger" ) type BuildServiceRepository struct { db *sql.DB } func NewBuildServiceRepsoitory(db *sql.DB) *BuildServiceRepository { return &BuildServiceRepository{db} } func (brepo *BuildServiceRepository...
package main import ( "encoding/binary" "fmt" "log" "os" ) type MetaCommandResult int type PrepareResult int type StatementType int type ExecuteResult int type Statement struct { Type StatementType RowToInsert Row } type Row struct { ID uint32 UserName []byte Email []byte } // pointは書き込まれた値の最後の文字のインデ...
package Plugins import ( "../Misc" "../Parse" "fmt" "github.com/jlaffaye/ftp" "sync" "time" //"os" ) func Ftp(info Misc.HostInfo, ch chan int, wg *sync.WaitGroup) { var err error addr := fmt.Sprintf("%s:%d", info.Host, info.Port) client, err := ftp.Dial(addr, ftp.DialWithTimeout(time.Duration(info.Timeout)*...
package main import ( "errors" "example/service" "fmt" "github.com/linxlib/logs" "github.com/robfig/cron/v3" ) func main() { logs.AddFileHook("example") logs.Error(fmt.Errorf("Test Error: %+v", errors.New("error example"))) service.Init() logs.Infoln("sdasd") logs.Traceln("sjahdasd") logs.Debugln("djahsda"...
package jwt_test import ( "crypto/x509" "encoding/base64" "encoding/json" "io/ioutil" "strings" "testing" "time" "github.com/docker/licensing/lib/go-auth/identity" "github.com/docker/licensing/lib/go-auth/jwt" "github.com/stretchr/testify/require" ) func load(t *testing.T, fname string) []byte { b, err :...
package config import ( "context" _ "github.com/lib/pq" "go.mongodb.org/mongo-driver/mongo" "go.mongodb.org/mongo-driver/mongo/gridfs" "go.mongodb.org/mongo-driver/mongo/options" "log" "time" ) // database var DB *mongo.Database var UserCol *mongo.Collection var PostCol *mongo.Collection var FsFilesCol *mongo....
package functions import "math" func SoftMax(x []float64) []float64 { var max float64 = x[0] for _, n := range x { max = math.Max(max, n) } a := make([]float64, len(x)) var sum float64 = 0 for i, n := range x { a[i] -= math.Exp(n - max) sum += a[i] } for i, n := range a { a[i] = n / sum } return ...
// Copyright 2019 Google Inc. 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 applicable...
package mop import ( "fmt" "testing" od "github.com/barchart/barchart-ondemand-client-golang" ) func Test(t *testing.T) { od := od.New("FREE_API_KEY", false) od.BaseURL = "https://marketdata.websol.barchart.com/" m := NewMarket(od) fmt.Println("MM", m.Fetch()) }
package rabbitmqworker import ( "Edwardz43/tgbot/config" "Edwardz43/tgbot/err" "Edwardz43/tgbot/log" "Edwardz43/tgbot/message/from" "Edwardz43/tgbot/worker" "encoding/json" "fmt" "github.com/streadway/amqp" ) var failOnError = err.FailOnError // GetInstance returns a instance of rabbitmq worker func GetInst...
// +build !windows package runconfig import ( "fmt" "runtime" "strings" ) // IsValid indicates is an isolation level is valid func (i IsolationLevel) IsValid() bool { return i.IsDefault() } // IsPrivate indicates whether container uses it's private network stack. func (n NetworkMode) IsPrivate() bool { return ...
package main import "fmt" func maxSubArray(nums []int) int { max := -1 << 31 sum := 0 for _, n := range(nums) { sum += n if sum > max { max = sum } if sum < 0 { sum = 0 } } return max } func main() { // fmt.Printf("%v\n", parse(342...
package persistence import ( "context" "fmt" "os" "time" "github.com/majid-cj/go-docker-mongo/domain/repository" "go.mongodb.org/mongo-driver/mongo" "go.mongodb.org/mongo-driver/mongo/options" ) // Repository ... type Repository struct { Member repository.MemberRepository VerifyCode repository.Verifica...
package point2 import "fmt" type Point2 struct { X float64 Y float64 } func (p Point2) Dimensions() int { return 2 } func (p Point2) Dimension(i int) float64 { if i == 0 { return p.X } return p.Y } func (p Point2) String() string { return fmt.Sprintf("(%f,%f)", p.X, p.Y) }
package main import ( "fmt" "math/rand" "ms/sun/shared/helper" "ms/sun/servises/event_service" "ms/sun/shared/x" "time" ) func main() { //x.LogTableSqlReq.Event = false go func() { param := event_service.SubParam{ Liked_Post_Event: true, } sub := event_service.NewSub(param) for evn := range sub....
package main import "github.com/sashko/go-uinput" func touchPadExample() { touchPad, err := uinput.CreateTouchPad(0, 1919, 0, 1079) if err != nil { return } defer touchPad.Close() touchPad.MoveTo(300, 200) touchPad.RightClick() }
package Dao import ( "blog/model" "fmt" "github.com/jinzhu/gorm" ) var DB*gorm.DB func InitDB() *gorm.DB { driverName := "mysql" host := "localhost" port := "3306" username := "root" password := "512612lj" database := "gin" charset := "utf8" args := fmt.Sprintf("%s:%s@tcp(%s:%s)/%s?charset=%s&parseTime=tru...
package fetch import ( "bytes" "context" "encoding/json" "errors" "io/ioutil" "net/http" "net/url" "strings" "github.com/go-kit/kit/endpoint" httptransport "github.com/go-kit/kit/transport/http" "github.com/slotix/dataflowkit/splash" ) // NewHTTPClient returns an Fetch Service backed by an HTTP server liv...
// This file was generated by counterfeiter package propertypricehistorycomfakes import ( "sync" "github.com/DennisDenuto/property-price-collector/site" "github.com/DennisDenuto/property-price-collector/site/propertypricehistorycom" ) type FakePostcodeSuburbLookup struct { LoadStub func() error loadMutex...
package main import ( "github.com/gdamore/tcell/v2" "github.com/rivo/tview" ) func selectContext(clusters []cluster, selectedContext string) (string, error) { var userSelectedContext string app := tview.NewApplication() rootNode := tview.NewTreeNode("Clusters").SetSelectable(false) treeView := tview.NewTreeVie...
package concator import ( "context" "fmt" "io" "io/ioutil" "path/filepath" "sync" "time" "github.com/pkg/errors" "github.com/Laisky/go-fluentd/libs" "github.com/Laisky/go-fluentd/monitor" utils "github.com/Laisky/go-utils" "github.com/Laisky/go-utils/journal" "github.com/Laisky/zap" ) const ( defaultI...