text
stringlengths
11
4.05M
package first import ( "go/ast" ) type GenDeclVisitor struct { Context } func NewGenDeclVisitor(context Context) *GenDeclVisitor { return &GenDeclVisitor{context} } func (visitor GenDeclVisitor) Visit(node ast.Node) ast.Visitor { switch t := node.(type) { case *ast.TypeSpec: return NewTypeSpecVisitor(visitor...
package main import ( "bytes" "io/ioutil" "log" "net/http" "os" "strings" "time" "github.com/bogem/id3v2" "github.com/go-flac/flacpicture" "github.com/go-flac/flacvorbis" "github.com/go-flac/go-flac" "github.com/yoki123/ncmdump" ) func containPNGHeader(data []byte) bool { if len(data) < 8 { return fal...
package retry import ( "fmt" "testing" "time" "github.com/stretchr/testify/assert" "github.com/gruntwork-io/go-commons/logging" ) func TestDoWithRetry(t *testing.T) { t.Parallel() expectedOutput := "expected" expectedError := fmt.Errorf("expected error") actionAlwaysReturnsExpected := func() (interface{}...
package main import ( "fmt" "io/ioutil" "path" "strings" ) func compileTmpl(rootPath, outputPath, packageName, varName string) { content := `package ` + packageName + ` var ` + varName + ` = map[string]string{` content = getContentFromDir(content, fixPath(rootPath), fixPath(rootPath)) content += `}` _ = i...
package 二叉树 const INF = 100000000000 func goodNodes(root *TreeNode) int { return getCountOfGoodNode(root, -INF) } func getCountOfGoodNode(root *TreeNode, preMaxValue int) int { if root == nil { return 0 } if root.Val >= preMaxValue { return 1 + getCountOfGoodNode(root.Left, root.Val) + getCountOfGoodNode(roo...
//////////////////////////////////////////////////////////////////////////// // Program: doc-search // Purpose: Doc search // Authors: Tong Sun (c) 2021, All rights reserved //////////////////////////////////////////////////////////////////////////// package main import ( "fmt" "os" "os/exec" "github.com/blevese...
package config import ( pth "github.com/dnephin/configtf/path" "github.com/dnephin/dobi/logging" "github.com/pkg/errors" ) // Resource is an interface for each configurable type type Resource interface { Dependencies() []string Validate(pth.Path, *Config) *pth.Error Resolve(Resolver) (Resource, error) Describe...
package main import ( "fmt" ) // git 提交记录代码 var gitCommitVersion = "" func main() { fmt.Println("hello world") fmt.Println("#Git Commit: " + gitCommitVersion) }
package pgsql import ( "database/sql" "testing" ) func TestHStore(t *testing.T) { A := strptr testlist2{{ valuer: HStoreFromStringMap, scanner: HStoreToStringMap, data: []testdata{ {input: map[string]string(nil), output: map[string]string(nil)}, {input: map[string]string{}, output: map[string]string...
package main import ( "bufio" "bytes" "encoding/hex" "errors" "flag" "fmt" "go/build" "os" "os/exec" "path/filepath" "regexp" "sort" "strconv" "strings" "sync" "time" "github.com/kisielk/gotool" "launchpad.net/godeps/pkgrepo" ) var ( revFile = flag.String("u", "", "update dependencies") te...
package main import ( "encoding/json" "fmt" "io/ioutil" "math/rand" "os" "strconv" ) type PlanetarySystem struct { Name string `json:"name"` Planets []Planet `json:"planets"` } type Planet struct { Name string `json:"name"` Info string `json:"description"` } func main() { planetsyst := jsonToplaents...
package knowledge import ( "context" "fmt" "time" "github.com/clems4ever/go-graphkb/internal/history" "github.com/clems4ever/go-graphkb/internal/kbcontext" "github.com/clems4ever/go-graphkb/internal/metrics" "github.com/clems4ever/go-graphkb/internal/query" "github.com/prometheus/client_golang/prometheus" "g...
package client import ( "context" "sync" "github.com/drand/drand/log" ) // newWatchAggregator maintains state of consumers calling `Watch` so that a // single `watch` request is made to the underlying client. func newWatchAggregator(c Client, l log.Logger) *watchAggregator { return &watchAggregator{ Client: ...
package codec import ( "github.com/iotaledger/wasp/packages/coretypes" ) func DecodeAgentID(b []byte) (coretypes.AgentID, bool, error) { if b == nil { return coretypes.AgentID{}, false, nil } r, err := coretypes.NewAgentIDFromBytes(b) return r, err == nil, err } func EncodeAgentID(value coretypes.AgentID) []b...
package pgsql // PostgreSQL `timestamptz` read/write natively supported with: // `time.Time` // `string` // `[]byte` type _ native
package client type User struct { ID string `json:"id"` Email string `json:"email"` Username string `json:"username"` Active bool `json:"active"` Expiry string `json:"expiry,omitempty"` Created string `json:"created,omitempty"` }
package transdsl import ( "time" ) type Retry struct { MaxTimes int TimeLen time.Duration //ms Fragment Fragment Errs []error } func (this *Retry) Exec(transInfo *TransInfo) error { flag := false if this.MaxTimes < 0 { flag = true } var err error for i := 0; flag || i < this.MaxTimes; i++ { err ...
package httpapi import "github.com/krostar/r10k-trigger/internal/trigger-api/delivery/httpapi/handler" // Usecases defines all the usecases required by handlers. //go:generate mockery -inpkg -testonly -name Usecases type Usecases interface { handler.DeployUsecases }
package main import ( "github.com/shurcooL/vfsgen" "log" "net/http" ) func main() { err := vfsgen.Generate(http.Dir("test/sqlmap"), vfsgen.Options{ PackageName: "generator", VariableName: "SqlMap", Filename: "test/bundle/sqlmap_bundle_build.go", }) if err != nil { log.Fatalln(err) } }
/* * This file is part of impacca. Copyright (C) 2013 and above Shogun <shogun@cowtech.it>. * Licensed under the MIT license, which can be found at https://choosealicense.com/licenses/mit. */ package release import ( "fmt" "os" "sort" "github.com/Masterminds/semver" "github.com/ShogunPanda/impacca/utils" "g...
package main import ( "io" "strings" "text/template" ) // tmpl executes the given template text on data, writing the result to w. func tmpl(w io.Writer, text string, data interface{}) { t := template.New("top") t.Funcs(template.FuncMap{"trim": strings.TrimSpace}) template.Must(t.Parse(text)) if err := t.Execut...
package postgres import ( "context" "fmt" "log" "hw21/pkg/storage" pgx "github.com/jackc/pgx/v4" ) type DB struct { conn *pgx.Conn } func New(host, port, user, password, dbname string, sslmode bool) (*DB, error) { sslmodeStr := "disable" if sslmode { sslmodeStr = "enable" } connStr := fmt.Sprintf("hos...
package main import ( "net/http" "log" ) func indexRoute(res http.ResponseWriter, req *http.Request) { res.Write([]byte("Quorum index route")) } func main() { http.HandleFunc("/", indexRoute) http.HandleFunc("/getGenesisBlock", getGenesisBlock) http.HandleFunc("/joinNetwork", joinNetwork) http.HandleFunc("/n...
package sol /* Given an input string (s) and a pattern (p), implement regular expression matching with support for '.' and '*' where: '.' Matches any single character.​​​​ '*' Matches zero or more of the preceding element. The matching should cover the entire input string (not partial). Example 1: Input: s = "aa"...
/* Given 2 int arrays, a and b, return a new array length 2 containing their middle elements. */ package main import ( "fmt" "coding_bat/utils" ) func middle_way(a []int, b []int) []int { if len(a) % 2 == 0 || len(b) % 2 == 0 { return []int{} } return []int{a[len(a)/2], b[len(b)/2]} } func main(){ var status i...
package userlib /** * @file userlib.go * @author odysseyofpigs * @description This file contains the blueprint for the User structure utilized * to keep track of current user within the system. All functions that initialize * the User database of the system is handled by this file. * @functionality The library...
package push import ( "fmt" "strings" "time" "github.com/10gen/realm-cli/internal/cli" "github.com/10gen/realm-cli/internal/cli/user" "github.com/10gen/realm-cli/internal/cloud/realm" "github.com/10gen/realm-cli/internal/local" "github.com/10gen/realm-cli/internal/terminal" "github.com/10gen/realm-cli/intern...
package sql type FoodRepository struct { conn *DBConnection } func CreateFoodRepo(container DBConnectionContainer) (*FoodRepository, error) { conn, err := container.GetDBConnection() if err != nil { return nil, err } return &FoodRepository{conn}, nil } func (repo *FoodRepository) GetTextColumn() string { ret...
/* * @lc app=leetcode.cn id=143 lang=golang * * [143] 重排链表 */ // @lc code=start /** * Definition for singly-linked list. * type ListNode struct { * Val int * Next *ListNode * } */ package main import "fmt" type ListNode struct { Val int Next *ListNode } func main() { l1 := &ListNode{Val: ...
package feeds import ( "database/sql" "fmt" "time" "github.com/mmcdole/gofeed" "github.com/robfig/cron" "github.com/uber-go/zap" "gopkg.in/telegram-bot-api.v4" ) var ( FEEDS_TABLE = "feeds" ) type ( pgsqlStore struct { pool *sql.DB } feedURL struct { ID int64 URL string Ne...
package admin import ( "cwengo.com/models" "cwengo.com/utils" "github.com/astaxie/beego" "strconv" ) type HomeController struct { beego.Controller } func (this *HomeController) Prepare() { userid := this.GetSession("userid") username := this.GetSession("username") if userid == nil || username == nil { this...
package main import "os" func main() { err := os.Rename(fn.path, oo) }
package group import ( "github.com/hardstylez72/bblog/ad/pkg/util" "time" ) type Group struct { Id int `json:"id" db:"id"` Code string `json:"code" db:"code"` Description string `json:"description" db:"description"` CreatedAt time.Time `json:"created...
package gateway // FetchRequest is a request to fetch a branch. type FetchRequest struct { Remote string // name of the remote RemoteRef string // ref to fetch LocalRef string // name of the ref locally } // PushRequest is a request to push refs to a remote. type PushRequest struct { Remote string // Mapping...
/* A De Bruijn sequence is interesting: It is the shortest, cyclic sequence that contains all possible sequences of a given alphabet of a given length. For example, if we were considering the alphabet A,B,C and a length of 3, a possible output is: AAABBBCCCABCACCBBAACBCBABAC You will notice that every possible 3-char...
package main import ( "encoding/json" "fmt" ) // capitalize attributes for the marshalling to work type Person struct { Name string Addr string Phone string } func main() { p1 := Person{"Joe", "a st.", "123"} fmt.Println(p1) // {Joe a st. 123} byteArr, err := json.Marshal(p1) if err !=...
package model import ( "fmt" "gorm.io/gorm" ) const PlatformChannelUpstreamTableName = "platform_channel_upstream" type PlatformChannelUpstream struct { Id int64 `gorm:"id"` PlatformChannelId int64 `gorm:"platform_channel_id"` // 平台通道id UpstreamChannelId int64 `gorm:"upstream_channel_id"` // 上游通道...
package main import ( "fmt" "io/ioutil" "log" "os" "strconv" "strings" ) // paramMode represents the parameter mode which can be positional (the value at // the position) or immediate (the actual value). type paramMode int const ( paramModePosition paramMode = iota paramModeImmediate ) const ( opCodeAdd ...
package shapes import "math" type Circle struct { Radius float64 } type Rectangle struct { Width float64 Height float64 } type Triangle struct { Base float64 Height float64 } type Shape interface { Area() float64 Perimeter() float64 } func Perimeter(s Shape) float64 { return s.Perimeter() } func Area(...
package main import ( "encoding/base64" "flag" "fmt" "net/http" "time" "github.com/golang/glog" "github.com/liuzl/goutil/rest" "github.com/skip2/go-qrcode" ) var ( addr = flag.String("addr", ":8080", "bind address") ) func QrHandler(w http.ResponseWriter, r *http.Request) { ts := time.Now().Format(time.RF...
package main import "github.com/sonaak/vokun/app" func main() { // create a new App server, err := app.Setup() if err != nil { panic(err) } // run it forever panic(server.Run()) }
package godork import ( "strings" ) type examplesByName []*Example func (a examplesByName) Len() int { return len(a) } func (a examplesByName) Swap(i, j int) { a[i], a[j] = a[j], a[i] } func (a examplesByName) Less(i, j int) bool { return strings.Compare(a[i].Name, a[j].Name) < 0 } type functionsByN...
package service import ( "encoding/json" "fmt" "github.com/go-ocf/cloud/cloud2cloud-connector/store" "github.com/go-ocf/kit/net/grpc" ) //Config represent application configuration type Config struct { grpc.Config AuthServerAddr string `envconfig:"AUTH_SERVER_ADDRESS" default:"127.0.0.1:9100"` Resourc...
package main import ( "github.com/indidev/vocable-o/console" "github.com/indidev/vocable-o/lang" "github.com/indidev/vocable-o/util/mathutil" "github.com/indidev/vocable-o/util/stringutil" "io/ioutil" //"crypto/rand" "os" "strconv" "strings" //"time" ) const replFile = "replacements.txt" var replacements m...
// Copyright 2018 Lars Hoogestraat // Use of this source code is governed by a MIT-style // license that can be found in the LICENSE file. package models import ( "database/sql" "errors" "fmt" "net/url" "sort" "strconv" "strings" "time" "git.hoogi.eu/snafu/go-blog/httperror" "git.hoogi.eu/snafu/go-blog/set...
package fakes import "github.com/cloudfoundry-incubator/notifications/gobble" type FakeQueue struct { jobs chan gobble.Job pk int EnqueueError error } func NewFakeQueue() *FakeQueue { return &FakeQueue{ jobs: make(chan gobble.Job), } } func (fake *FakeQueue) Enqueue(job...
package storage // https://github.com/GoogleCloudPlatform/google-cloud-go/blob/master/storage/example_test.go // https://github.com/GoogleCloudPlatform/golang-samples/blob/master/storage/objects/main.go import ( "bytes" "context" "io" "io/ioutil" "strconv" "strings" "cloud.google.com/go/storage" "github.com/...
package main import ( s "gobackmessage/socket" "os" ) func main() { port := "8084" if os.Getenv("PORT") != "" { port = os.Getenv("PORT") } s.Start(port) }
package impi import ( "bufio" "errors" "fmt" "go/parser" "go/scanner" "go/token" "io" "io/ioutil" "reflect" "regexp" "sort" "strings" ) // This regex is to appear in generated code. var generatedRegex = regexp.MustCompile("// Code generated .* DO NOT EDIT\\.") type verifier struct { verifyOptions *Verif...
// Copyright 2017 PingCAP, Inc. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // // http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed to i...
package main import ( "encoding/json" "net" "net/http" "sync" "github.com/ethereum/go-ethereum/log" "github.com/ethereum/go-ethereum/p2p/discover" "github.com/ethereum/go-ethereum/p2p/simulations" "golang.org/x/net/websocket" ) type connList struct { Key string Assigned bool } type connManager struct...
package mppuma import ( "encoding/json" "testing" ) func TestGraphDefinition(t *testing.T) { desired := 5 var puma PumaPlugin graphdef := puma.GraphDefinition() if len(graphdef) != desired { t.Errorf("GraphDefinition: %d should be %d", len(graphdef), desired) } } func TestGraphDefinitionWithGC(t *testing...
package facs3 import ( "github.com/kataras/golog" facclients "github.com/wagner-aos/go-fast-aws-connections/fac_clients" "github.com/aws/aws-sdk-go/aws" "github.com/aws/aws-sdk-go/service/s3" "github.com/aws/aws-sdk-go/service/s3/s3iface" ) var ( err error s3API s3iface.S3API ) //Start - initializes S3 cli...
package api import ( "arep/controller" "github.com/gin-gonic/gin" "log" ) func StartServer(elasticController *controller.StoreController, documentDBController *controller.StoreController) { server := gin.New() apiPrefix := server.Group("api") { elasticGroup := apiPrefix.Group("elastic") { elasticGroup....
package api import ( "github.com/gin-gonic/gin" "net/http" ) func IndexApi(c *gin.Context) { c.JSON(http.StatusOK, gin.H{ "code": 0, "msg": "Hello Wolrd", "data": nil, }) }
package utils import "time" func WaitUntil(duration time.Duration) { nextTime := time.Now().Truncate(duration) nextTime = nextTime.Add(duration) time.Sleep(time.Until(nextTime)) }
package utils import "strings" func Keywords(keyword string) ([]string) { var keywords []string if (keyword == "c" || keyword == "d" || keyword == "lua" || keyword == "go") { keywords = append(keywords, " " + keyword + ".") keywords = append(keywords, ", " + keyword + " ") keywords = append(keywords, " " + k...
package features import ( "errors" "fmt" "math" "testing" "github.com/cilium/ebpf" "github.com/cilium/ebpf/asm" "github.com/cilium/ebpf/internal" "github.com/cilium/ebpf/internal/testutils" "github.com/cilium/ebpf/internal/testutils/fdtrace" ) func TestMain(m *testing.M) { fdtrace.TestMain(m) } func TestH...
package main import ( "fmt" "io/ioutil" "log" "net" "os" "strings" "golang.org/x/crypto/ssh" ) func main() { sshConfig := &ssh.ServerConfig{ PasswordCallback: func(c ssh.ConnMetadata, pass []byte) (*ssh.Permissions, error) { remoteAddr := c.RemoteAddr().String() ip := remoteAddr[0:st...
package util import ( "github.com/ActiveState/log" "github.com/ActiveState/logyard-apps/common" "github.com/ActiveState/stackato-go/server" "sync" ) var once sync.Once var nodeid string // LocalNodeId returns the node ID of the local node. func LocalNodeId() string { once.Do(func() { var err error nodeid, e...
package epf import ( "errors" "math" "time" "github.com/bearbin/go-age" ) // Different methods in calculating a rate type calculationMethod int const ( notApplicable calculationMethod = iota percentage exactAmount ) type rateCalculation struct { Minimum float64 Maximum float64 Interval ...
// Copyright 2017 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...
/** * @Author: 人从众[ckhero] * @Date: 2020/9/7 2:57 下午 * @Desc: a */ package sort func MergeSort(arr []int) []int{ if len(arr) < 2 { return arr } mid := (0 + len(arr)) >> 1 left := MergeSort(arr[0:mid]) right := MergeSort(arr[mid:]) return MergeTwoSortedArr(left, right) }
package transport type AddCommentRequest struct { VideoId string `json:"videoId"` Message string `json:"message"` ParentId int `json:"parentId"` } type EditCommentRequest struct { Message string `json:"message"` }
/* * @lc app=leetcode.cn id=33 lang=golang * * [33] 搜索旋转排序数组 */ // @lc code=start package main import "fmt" func main() { var a []int a = []int{4,5,6,7,0,1,2} fmt.Printf("%v,%d\n", a, search(a, 0)) a = []int{4,5,6,7,0,1,2} fmt.Printf("%v,%d\n", a, search(a, 3)) a = []int{5,1,2} fmt.Printf("%v,%d\n", a, ...
package problem0405 func toHex(num int) string { if num < 0 { num = 0xFFFFFFFF + num + 1 } if num == 0 { return "0" } digits := []string{"0", "1", "2", "3", "4", "5", "6", "7", "8", "9", "a", "b", "c", "d", "e", "f"} ret := "" for num != 0 { ret = digits[num%16] + ret num = num >> 4 } return ret }
package main import ( "bufio" "fmt" "io" "log" "os" "strings" ) var debug bool func check(e error) { if e != nil { fmt.Println("before fatal") log.Fatal(e) fmt.Println("after fatal") // this will never be printed //panic(e) } } func Smallestrep(line string) int { line = strings.Tri...
package leetcode func isPalindrome2(x int) bool { if x < 0 { return false } y, z := 0, x for x > 0 { y = y*10 + x%10 x = x / 10 } return y == z } func isPalindrome(x int) bool { if x < 0 || (x%10 == 0 && x != 0) { return false } y := 0 for x > y { y = y*10 + x%10 x = x / 10 } return (x == y)...
package sese import ( "encoding/xml" "github.com/thought-machine/finance-messaging/iso20022" ) type Document00400102 struct { XMLName xml.Name `xml:"urn:iso:std:iso:20022:tech:xsd:sese.004.001.02 Document"` Message *ReversalOfTransferOutConfirmationV02 `xml:"RvslOfTrfOutConfV02"` } ...
package main import ( "constants" "fmt" ) func main() { var value constants.MyInterface value = constants.MyType(5) value.MethodWithParameter(5) value.MethodWithoutParameters() fmt.Println(value.MethodwithReturnValue()) }
// +build debug package main import ( "encoding/json" "fmt" "io" "os" "github.com/juju/errors" "github.com/restic/restic" "github.com/restic/restic/backend" "github.com/restic/restic/pack" "github.com/restic/restic/repository" ) type CmdDump struct { global *GlobalOptions repo *repository.Repository } ...
// Copyright 2018 Vitali Fedulov. All rights reserved. Use of this source code // is governed by a MIT-style license that can be found in the LICENSE file. package images import ( "image" "image/gif" "image/jpeg" "image/png" "log" "os" ) // Gif saves image.RGBA to a file. func Gif(img *image.RGBA, path string)...
package regexp import ( "fmt" "unicode/utf8" ) type parser struct { in string pos int width int } func (p *parser) next() (r rune) { r, p.width = utf8.DecodeRuneInString(p.in[p.pos:]) p.pos += p.width return } func (p *parser) backup() { p.pos -= p.width p.width = 0 } func (p *parser) peek() (r rune...
/** * @Author: DollarKiller * @Description: * @Github: https://github.com/dollarkillerx * @Date: Create in 23:04 2019-09-17 */ package main import ( "MysqlMonitor/config" "MysqlMonitor/logic" "github.com/dollarkillerx/easyutils" "github.com/dollarkillerx/easyutils/clog" "github.com/robfig/cron" "io/ioutil" ...
package main import ( "os" "log" "strings" "net/http" "text/template" ) var keymap = map[string][]byte{ "randy": []byte("ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQC82w0+Q2j2hfprW2k64tRWgjw9euJiOPJw8JAD6dMj9HeLCrGtjlr+eEi51dSi7/BvGjT0LH1LvNAIgU/I/Bbn99TafcDqo0PZHQ3QqsGh4G8r7O7apcRKxmmHh2bAnMQ3lBvSqnBu5uQ0OBNpvRtmR...
package server import ( "net/http" "reflect" "strconv" "time" "github.com/ItsJimi/casa/logger" "github.com/ItsJimi/casa/utils" "github.com/labstack/echo" ) type permissionMember struct { Permission User } type memberRes struct { ID string `json:"id"` Firstname string `json:"firstname"` Lastname ...
package client import "net" type Client struct { Conn *net.Conn }
// Copyright 2020 Bjerk AS // // 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 wr...
package logic import ( "log" "net/url" "strings" "github.com/hailongz/kk-lib/dynamic" "gopkg.in/yaml.v2" ) func init() { SetGlobalIgnoreKey("contentType") } type Swagger struct { scheme string host string basePath string } func NewSwagger(baseURL string) *Swagger { v := Swagger{} u, _ := url.Pars...
package smtp import ( "net/mail" "strings" ) // SendError records send a mail error type SendError struct { Message string From *mail.Address To AddressList } func (err *SendError) Error() string { return err.Message } // SendErrors records send mails error type SendErrors struct { ...
package service import ( "context" "net/http" "github.com/go-ocf/cloud/grpc-gateway/client" "github.com/go-ocf/cloud/http-gateway/uri" kitNetGrpc "github.com/go-ocf/kit/net/grpc" "github.com/go-ocf/sdk/schema" "github.com/gorilla/mux" "github.com/gorilla/websocket" ) type DeviceResourceObservationEvent struc...
package main import ( "encoding/json" "fmt" "net/http" "github.com/gorilla/mux" "gorm.io/driver/postgres" "gorm.io/gorm" ) var DB *gorm.DB var err error var DNS = "host=localhost user=go_user password=go_pass dbname=go_db port=5432 sslmode=disable TimeZone=Asia/Shanghai" type User struct { gorm.Model Name ...
package controllers import ( m "go_cadastro/models" "log" "net/http" "strconv" "text/template" ) var temp = template.Must(template.ParseGlob("templates/*.html")) func Index(w http.ResponseWriter, r *http.Request) { todosOsProdutos := m.BuscaTodosOsProdutos() temp.ExecuteTemplate(w, "Index", todosOsProdutos) }...
package pusher import ( "encoding/json" "testing" ) func TestPrivateChannelAuthentication(t *testing.T) { ua := &UserAuthentication{"278d425bdf160c739803", "7ad3773142a6692b25b8"} authExpected := "278d425bdf160c739803:58df8b0c36d6982b82c3ecf6b4662e34fe8c25bba48f5369f135bf843651c3a4" authInfo, _ := ua.Authentica...
package game_map import ( "github.com/faiface/pixel/pixelgl" "github.com/steelx/go-rpg-cgm/animation" "github.com/steelx/go-rpg-cgm/gui" ) type TweenEvent struct { Tween animation.Tween Target gui.StackInterface ApplyFunc func(e *TweenEvent) } func TweenEventCreate(start, finish, duration float64, targe...
package dcp import "strconv" // Given a string of digits, generate all possible valid IP address combinations. // IP addresses must follow the format A.B.C.D, where A, B, C, and D are numbers between 0 and 255. Zero-prefixed numbers, such as 01 and 065, are not allowed, except for 0 itself. // For example, given "254...
package main import ( "fmt" "golangStudy/go_function/demo2/lib" ) //init函数,完成一些初始化的工作 func init() { fmt.Println("main init") } func main() { fmt.Println("main----age=", lib.Age) fmt.Println("main----name=", lib.Name) }
package ircserver import ( "testing" "github.com/robustirc/robustirc/internal/robust" "gopkg.in/sorcix/irc.v2" ) func TestPing(t *testing.T) { i, ids := stdIRCServer() mustMatchMsg(t, i.ProcessMessage(&robust.Message{Session: ids["secure"]}, irc.ParseMessage("PING")), ":robustirc.net 409 sECuRE :No origin...
package main import ( "bytes" "encoding/hex" "log" "github.com/syndtr/goleveldb/leveldb" ) // variable const ( UTXOFile = "lubit.db.utxo" ) // UTXOSet owns all the UTXOs type UTXOSet struct { lvl *leveldb.DB chain *BlockChain } func NewUTXOSet(bc *BlockChain) *UTXOSet { lvl, _ := leveldb.OpenFile(UTXOFi...
package progressbar import ( "strings" "github.com/fatih/color" ) type BlockTheme struct { filledColor *color.Color surroundColor *color.Color } func NewBlockTheme() *BlockTheme { return &BlockTheme{filledColor: color.New(color.FgHiCyan), surroundColor: color.New(color.Bold, color.FgHiWhite)} } func (t *Blo...
//Gordon Stangler //This program creates three strings, one all zeros, one all ones, one random //It puts them in three files, then compresses them. //package FordZipExample package main import( "archive/zip" "bytes" "compress/flate" "fmt" "io" "io/ioutil" "log" "os" "math/rand" ) //Write archive func FordEx...
package writer import ( "bytes" "testing" "github.com/accurics/terrascan/pkg/policy" "github.com/accurics/terrascan/pkg/results" ) // TODO: string comparision - expected and output func TestHumanReadbleWriter(t *testing.T) { type funcInput interface{} tests := []struct { name string input ...
package main import ( "github.com/button-tech/BNBTextWallet/config" "github.com/button-tech/BNBTextWallet/db" "github.com/button-tech/BNBTextWallet/handlers" "github.com/button-tech/BNBTextWallet/repositories/redisRepository" "github.com/button-tech/BNBTextWallet/services/discordClient" "github.com/bwmarrin/disc...
package models import ( "crawler/errors" "net/http" ) var testCasesGetPage = []struct { Link *Link StatusCode int URL string }{ { &Link{URL: "http://ya.ru", Hostname: "ya.ru", Error: nil}, http.StatusOK, "http://ya.ru", }, { &Link{URL: "http:/ya.ru", Hostname: "", Error: errors.INVALID_UR...
// Licensed to Elasticsearch B.V. under one or more contributor // license agreements. See the NOTICE file distributed with // this work for additional information regarding copyright // ownership. Elasticsearch B.V. licenses this file to you under // the Apache License, Version 2.0 (the "License"); you may // not use ...
package dns import ( "database/sql" "github.com/SUCHMOKUO/falcon-tun/setting" "github.com/SUCHMOKUO/falcon-tun/util" "log" "net" ) func isInWhiteList(domain string) bool { q := db.QueryRow(`SELECT COUNT(*) FROM whitelist_tmp WHERE domain = ?`, domain) count := 0 err := q.Scan(&count) if err == nil && count >...
package server import ( "bytes" "encoding/json" "errors" "io" "net/http" "testing" "github.com/bryanl/dolb/entity" "github.com/bryanl/dolb/kvs" "github.com/bryanl/dolb/pkg/app" "golang.org/x/net/context" . "github.com/smartystreets/goconvey/convey" ) func TestCreateLoadBalancer(t *testing.T) { Convey("G...
package routes import ( "joebot/rds" "joebot/tools" "strings" ) func myNotes(sender string, url string) (res string) { lowName := strings.ToLower(sender) res = "" if url == "GET" { // redis get persons team image link, err := rds.RedisGet(rds.RC, lowName) if err != nil { tools.WriteErr(err) res = "N...
package core import "sync" /* * 当前游戏世界总管理模块 */ type WorldManager struct { // AOIManager 当前世界地图的AOI 管理模块 PAoiMgr *AOIManager // 当前全部在线的 players 集合 MapPlayers map[int32]*Player // 保护 players 的集合的锁 pLock sync.RWMutex } // 提供一个对外的世界管理模块的句柄(对外唯一) var PWorldMgrObj *WorldManager //初始化方法 全局使用,故而使用 init 初始化 func ...
package response type ( appError interface { Error() string Code() uint32 Message() string } )