text stringlengths 11 4.05M |
|---|
package main
import (
"fmt"
"log"
"github.com/hschain/go-sdk/hsc"
)
func main() {
hschain := hsc.NewHsc("https://testnet.hschain.io/api/lcd")
mnemonic := "drink lunch camera exhibit green spirit fiber mammal maze unable toilet hobby broken crop program physical village increase vapor jungle skirt section seed ... |
package LeetCode
import (
"fmt"
"math"
)
//love 函数 x^2 + (y-(x^2)^1/3)^2 = 1
func LoveStar() {
word := "love"
allStr := make([]string, 0)
for y := -13; y < 13; y++ {
line := make([]string, 0)
lineCon := ""
for x := -30; x < 30; x++ {
xFloat := float64(x)
yFloat := float64(y)
loc := math.Pow(mat... |
package routers
import (
"festival/app/common/middleware/auth"
"festival/app/common/router"
"festival/app/controller/module"
)
// 礼品表
// power by 7be.cn
func init() {
g2 := router.New("admin", "/admin/module", auth.Auth)
g2.GET("/goodss", true, module.ModGoodsList)
g2.GET("/goods/edit", true, module.ModGoodsEdi... |
package tool
import (
"fmt"
"strings"
"github.com/bclicn/color"
)
type TestOptions struct {
Source string
Executable string
TestsDir string
}
func TestTask(opts TestOptions) error {
Action("Compile")
err := Compile(CompileOptions{
Src: opts.Source,
Dst: opts.Executable,
Log: true,
})
FError("C... |
package subs
// milestones
/*
*/
import (
"fmt"
"github.com/alaref-codes/subs/database"
"github.com/gofiber/fiber/v2"
)
type Su struct {
Id int `json:"id"`
Email string `json:"email"`
}
func GetAllSubs(c *fiber.Ctx) error {
db := database.DBConn
var sub []Su
db.Find(&sub)
return c.JSON(sub)
}
func... |
package model
import (
"encoding/hex"
"testing"
"github.com/stretchr/testify/assert"
)
func TestPaging_Hash(t *testing.T) {
testSuites := []*struct {
in *Paging
ext []byte
expected string
}{
{
in: &Paging{Start: 3, Limit: 56},
expected: "333b3536d41d8cd98f00b204e9800998ecf8427e",
... |
package remotecache
import (
"context"
"encoding/base64"
"errors"
"syscall"
"github.com/loft-sh/devspace/pkg/devspace/config/localcache"
"github.com/loft-sh/devspace/pkg/devspace/kubectl"
"github.com/loft-sh/devspace/pkg/util/encoding"
"github.com/loft-sh/devspace/pkg/util/encryption"
"github.com/loft-sh/dev... |
package db
import (
"encoding/json"
"log"
"github.com/sauerbraten/chef/pkg/ips"
)
type Sorting struct {
Identifier string
DisplayName string
sql string
}
func (s Sorting) MarshalJSON() ([]byte, error) { return json.Marshal(s.Identifier) }
var (
ByLastSeen = Sorting{
Identifier: "last_seen",
Di... |
package main
import "fmt"
type Phone struct {
Name string
}
type Camera struct {
Name string
}
type Usb interface {
Start()
}
func (p *Phone) Start() {
fmt.Println(p.Name, "starting")
}
func (c *Camera) Start() {
fmt.Println(c.Name, "starting")
}
func main() {
var usbArr [3]Usb
usbArr[0] = &Phone{"apple... |
package ptrie
import (
"bufio"
"bytes"
"fmt"
"github.com/stretchr/testify/assert"
"github.com/viant/assertly"
"github.com/viant/toolbox"
"os"
"path"
"reflect"
"strings"
"testing"
)
func TestTrie_Get(t *testing.T) {
useCases := []struct {
description string
keywords map[string]interface{}
key ... |
package goc
import (
"strconv"
"testing"
)
func TestClockReplacement(t *testing.T) {
c := newClockCache(10)
for i := 0; i < 10; i++ {
c.set(strconv.Itoa(i), i)
}
// touch even
for _j := 0; _j <= 100; _j++ {
for i := 0; i < 10; i += 2 {
_, _ = c.get(strconv.Itoa(i))
}
}
// touch more except 1
for ... |
// Copyright 2018 The OPA Authors. All rights reserved.
// Use of this source code is governed by an Apache2
// license that can be found in the LICENSE file.
package topdown
import (
"fmt"
"testing"
)
func TestCryptoX509ParseCertificates(t *testing.T) {
rule := `
p = x {
parsed := crypto.x509.parse_certif... |
package main
var s string = """
|
package s3
type Config struct {
Endpoint string
AccessID string
AccessKey string
UseSSL bool
}
type Object struct {
Key string
LastModifiedUnix int64
}
type Objects []Object
type Service interface {
Init(cfg Config) error
Upload(bucket string, obj string, filename string) error
Download(b... |
// Copyright 2021 The gVisor 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 agree... |
package models
import "time"
type Book struct {
ModelWithId
ISBN string `json:"isbn"`
Title string `json:"title"`
Cover string `json:"cover"`
Issue int `json:"issue"`
Description *string `json:"description"`
Copies *int `json:"copies"`
Price *int... |
// Copyright (c) 2016-2019 Uber Technologies, 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... |
package handlers
import (
"code.google.com/p/go.crypto/pbkdf2"
"github.com/gaigepr/list-app/api"
"crypto/rand"
"crypto/sha512"
"encoding/base64"
"fmt"
"net/http"
)
func NewPass(password string) (string, string) {
// make user salt and hash of pass and put into database
// for salt may want to have seperate ... |
package main
import (
"database/sql"
"fmt"
"io/ioutil"
"os"
ct "github.com/mtyurt/coffeetable"
"github.com/go-yaml/yaml"
_ "github.com/mattn/go-sqlite3"
"github.com/mtyurt/coffeetable/repo"
"github.com/mtyurt/coffeetable/slackhelper"
"github.com/nlopes/slack"
)
type ServerConfig struct {
SlackToken s... |
// Copyright (C) 2017 Google 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 t... |
// Copyright (C) 2016-Present Pivotal Software, Inc. All rights reserved.
// This program and the accompanying materials are made available under the terms of the 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 Licen... |
package producer
type Producer interface {
Send(message Message) error
}
type Message struct {
CmdType CMDType
Info string
}
type CMDType int
const (
CREATE CMDType = iota
UPDATE
DELETE
)
|
package main
import (
"encoding/json"
"fmt"
"io"
"io/ioutil"
"net"
"net/http"
"net/url"
"path"
"strings"
"time"
"gopkg.in/yaml.v2"
)
func getServerByIP(ip string) (*Server, error) {
servers.Lock()
defer servers.Unlock()
for _, s := range servers.List() {
if s.metadata.Network == nil || s.metadata.Net... |
package beat
import "time"
const (
DEFAULT_PERIOD time.Duration = 10 * time.Second
DEFAULT_HOST string = "localhost"
DEFAULT_PORT int = 6379
DEFAULT_NETWORK string = "tcp"
DEFAULT_MAX_CONN int = 10
DEFAULT_AUTH_REQUIR... |
package types
type Edge struct {
Src Resource `json:"src"`
Dst Resource `json:"dst"`
ClientID string `json:"clientID,omitempty"`
ServerID string `json:"serverID,omitempty"`
Msg string `json:"noTLSReason,omitempty"`
}
type Edges []*Edge
func (e Edges) Len() int {
return len(e)
}
func (e Ed... |
package main
import "fmt"
/**
接口
*/
type Phone interface {
call() // 定义接口里的方法
}
type NokiaPhone struct {
name string
}
func (np NokiaPhone) call() {
np.name = "Nokia"
fmt.Println("I am " + np.name)
}
type IPhone struct {
}
func (ip IPhone) call() {
fmt.Println("I am iPhone")
}
type T struct {
S string
}
f... |
package fibonacci
import "testing"
func TestDyFibo10FirstTerms(t *testing.T) {
result := []int{1, 1, 2, 3, 5, 8, 13, 21, 34, 55}
for i, val := range result {
want := val
got := DyFibo(i)
if want != got {
t.Fatalf("want %v but got %v\n", want, got)
}
}
}
|
package repos
import (
"github.com/jinzhu/gorm"
"github.com/lndaquino/segmed-backend/pkg/entity"
"github.com/lndaquino/segmed-backend/pkg/errors"
)
// FileRepo struct models a file repository
type FileRepo struct {
db *gorm.DB
}
// NewFileRepo returns a FileRepo instance
func NewFileRepo(db *gorm.DB) *FileRepo {... |
package main
import (
"bufio"
"encoding/xml"
"io/ioutil"
"net/http"
"os"
"strings"
)
type RSS struct {
Channel Channel `xml:"channel"`
}
type Channel struct {
Title string `xml:"title"`
Desc string `xml:"description"`
Items []Item `xml:"item"`
}
type Item struct {
Title string `xml:"title"`
Desc ... |
package main
import (
"fmt"
delivery "github.com/informeai/challenge-go/api/delivery"
"log"
)
func main() {
//server running...
d := delivery.UserDeliveryMemory{}
fmt.Println("server running...")
log.Fatalln(d.Run(":4000"))
}
|
package disk
import (
"fmt"
"github.com/shirou/gopsutil/disk"
)
// TestDisk returns back CPU tests
func TestDisk() {
fmt.Println("====GOPSUTIL====")
x, _ := disk.Partitions(true)
y, _ := disk.Usage("/")
z, _ := disk.IOCounters()
fmt.Println("Partitions")
fmt.Println(x)
fmt.Println("Usage")
fmt.Println(y... |
package main
import (
"net/http"
"os"
"strconv"
"gopkg.in/go-playground/webhooks.v5/docker"
"gopkg.in/go-playground/webhooks.v5/github"
"gopkg.in/go-playground/webhooks.v5/gitlab"
log "github.com/sirupsen/logrus"
)
// DockerhubWebhookHandler func
func DockerhubWebhookHandler(w http.ResponseWriter, r *http.Re... |
package phpserialize_test
import (
"encoding/json"
"fmt"
"math"
"reflect"
"testing"
phpserialize "github.com/kamiaka/go-phpserialize"
"github.com/kamiaka/go-phpserialize/php"
)
func isNaN(v *php.Value) bool {
return v != nil && v.Type() == php.TypeFloat && math.IsNaN(v.Float())
}
func TestUnmarshal(t *testi... |
package main
import (
"errors"
"fmt"
"io"
"log"
"mime/multipart"
"net/http"
"os"
"strconv"
"sync"
)
const tmpFilePath = "./tmp/"
var wait sync.WaitGroup
func main() {
fileServer()
}
// 文件服务
func fileServer() {
http.HandleFunc("/chunkfile", chunkFile)
// 监听8001端口
err := http.ListenAndServe("0.0.0.0:800... |
package v1
import (
"github.com/gin-gonic/gin"
"go.rock.com/rock-platform/rock/server/clients/helm"
"go.rock.com/rock-platform/rock/server/database/api"
"go.rock.com/rock-platform/rock/server/database/models"
"go.rock.com/rock-platform/rock/server/utils"
"net/http"
)
type CreateDeploymentReq struct {
Descripti... |
package entry
import (
"shared/common"
"shared/csv/static"
"shared/utility/errors"
"shared/utility/transfer"
"sync"
)
type HeroSkill struct {
Id int32
SkillID int32
SkillLevel int32
CostItems *common.Rewards `rule:"rewards"`
Unlock *common.Conditions `rule:"conditions"`
}
type Hero struc... |
package main
import (
"archive/tar"
"fmt"
"io"
"os"
"path/filepath"
"regexp"
"strings"
"time"
"go.uber.org/zap"
gzip "github.com/klauspost/pgzip"
)
// Tar takes a source and variable writers and walks 'source' writing each file
// found to the tar writer; the purpose for accepting multiple writers is to al... |
package chance
// BoolWithChance returns any boolean value, where `true` value is returned with some likeliness.
func (chance *Chance) BoolWithChance(likeliness int) bool {
if (likeliness < 0) || (likeliness > 100) {
return false
}
f := chance.r.Float64() * 100
return float64(likeliness) <= f
}
// Bool returns ... |
package leetcode
// 2,1,3,5,4,6
func NumberOfBulbShines(bulbs []int) int {
sumBulbs := 0
shined := 0
largest := bulbs[0]
for _, b := range bulbs {
largest = larger(largest, b)
sumBulbs += b
if sumBulbs == sumOfInts(largest) {
shined++
}
}
return shined
}
func larger(a, b int) int {
if a > b {
retu... |
package cmd
import (
"fmt"
"os"
"strconv"
"strings"
"text/tabwriter"
"time"
"github.com/briandowns/spinner"
"github.com/fatih/color"
"github.com/spf13/cobra"
"k8s.io/cli-runtime/pkg/genericclioptions"
"k8s.io/client-go/kubernetes"
"k8s.io/client-go/rest"
// Required auth libraries
_ "k8s.io/client-go/p... |
//go:build integration
// +build integration
package aws_secrets_manager
import (
"os"
"testing"
"github.com/libopenstorage/secrets"
"github.com/libopenstorage/secrets/aws/utils"
"github.com/libopenstorage/secrets/test"
"github.com/pborman/uuid"
"github.com/stretchr/testify/assert"
)
func TestAll(t *testing.... |
// +build storage_boltdb storage_all !storage_pgx,!storage_fs,!storage_badger,!storage_sqlite
package boltdb
import (
pub "github.com/go-ap/activitypub"
"github.com/go-ap/errors"
"github.com/go-ap/fedbox/activitypub"
"github.com/go-ap/fedbox/internal/config"
"github.com/go-ap/handlers"
"github.com/go-ap/jsonld"... |
package gcloud
import (
"os"
"testing"
"github.com/stretchr/testify/assert"
)
func TestNew(t *testing.T) {
os.Unsetenv(GoogleKmsResourceKey)
// nil secret config
_, err := New(nil)
assert.EqualError(t, err, ErrInvalidKvdbProvided.Error(), "Unexpected error on nil secret config")
// empty secret config
secr... |
package greeting
import "time"
func IsAM() bool {
localTime := time.Now()
return localTime.Hour() <= 12
}
func IsAfternoon() bool {
localTime := time.Now()
return localTime.Hour() <=16
}
func IsEvening() bool{
localTime := time.Now()
return localTime.Hour() <= 22
} |
package main
import (
"fmt"
)
func main() {
for i := 10; i <= 100; i++ {
s:= i%4
switch s{
case 1:
fmt.Println("Muslera")
case 2:
fmt.Println("Lemina")
case s:
fmt.Println("Falcao")
}
}
}
|
package fileStore
import "io"
type Storage interface {
Save(path string, content io.Reader) error
}
|
package charts
import (
"fmt"
"regexp"
"bytes"
"strings"
"github.com/pkg/errors"
"helm.sh/helm/v3/pkg/chart/loader"
"helm.sh/helm/v3/pkg/chart"
eCharts "github.com/codefresh-io/kcfi/pkg/embeded/charts"
)
func Load(chartName string) (*chart.Chart, error){
var chartBufferedFile []*loader.BufferedFile
isArch... |
// Package png allows for loading png images and applying
// image flitering effects on them.
package png
import (
"image/color"
)
// Grayscale applies a grayscale filtering effect to the image
func (img *Image) Grayscale(last bool, start int, end int) {
bounds := img.Out.Bounds()
if start == -1 && end == -1 {
... |
// Copyright 2018 The gVisor 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 agree... |
package manager
import (
"github.com/go-redis/redis/v8"
"portal/base"
"portal/config"
sconfig "shared/utility/config"
"shared/utility/etcd"
"shared/utility/glog"
"github.com/panjf2000/ants/v2"
clientv3 "go.etcd.io/etcd/client/v3"
)
var (
Conf *config.Config
GoPool *ants.Pool
ConnPool *base... |
package ircmsg
import (
"errors"
"fmt"
"strings"
"time"
)
var CannotParseMessageError = errors.New("Message cannot be parsed; is not a valid RFC2812 IRC message")
type Message struct {
Prefix string
Nick string
Ident string
Host string
Command string
Trail string
Params []string
SentAt... |
package poolManager
type Stats struct {
Connections int
Difficulty float64
NetworkHashrate float64
StratumPorts []int
}
func NewStats() *Stats {
return &Stats{
Connections: 0,
Difficulty: 0.0,
NetworkHashrate: 0,
StratumPorts: []int{},
}
}
|
package main
import (
"fmt"
"time"
)
// 6. What is a goroutine? How do you stop it?
func routine(ch chan int, quit chan struct{}) {
defer fmt.Println("Leaving routine...")
for {
select {
case v := <-ch:
fmt.Println("Got", v)
case <-quit:
return
}
}
}
// 7. How do you check a variable type at runti... |
package cmd
import (
"fmt"
"github.com/NodeFactoryIo/vedran/internal/script"
"github.com/NodeFactoryIo/vedran/internal/ui"
log "github.com/sirupsen/logrus"
"github.com/spf13/cobra"
"net/url"
)
var (
privateKey string
totalReward string
rawLoadbalancerUrl string
feeAddress string
loa... |
package main
import (
"context"
"flag"
"fmt"
"github.com/itzg/mc-router/server"
"github.com/sirupsen/logrus"
"net"
"os"
"os/signal"
"runtime/pprof"
"strconv"
"strings"
"syscall"
)
var (
port = flag.Int("port", 25565, "The port bound to listen for Minecraft client connections")
apiBinding =... |
package main
import (
"flag"
"log"
"github.com/SND1231/dip-test/factory"
)
func main() {
flag.Parse()
args := flag.Args()
filepath := args[0]
bucketName := args[1]
objectKey := args[2]
err := Execute(filepath, bucketName, objectKey)
if err != nil {
log.Fatal(err)
}
log.Println("done")
}
func Execute(... |
package fillodb
import (
"github.com/saintfish/brave"
)
var bookTable = map[brave.BookId]string{
brave.Genesis: "Ge",
brave.Exodus: "Ex",
brave.Leviticus: "Le",
brave.Numbers: "Nu",
brave.Deuteronomy: "De",
brave.Joshua: "Jos",
brave.Judges: "Jud",
brave.Ruth: "Ru",
brave.Samuel1: "1Sa",
brave.Samuel2: "2S... |
package m2go
type AddProductPayload struct {
Product Product `json:"product"`
SaveOptions bool `json:"saveOptions"`
}
type MediaGalleryEntries struct {
ID int `json:"id"`
MediaType string `json:"media_type"`
Label string ... |
/*
Copyright 2019 The Crossplane 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, ... |
package hard
import (
"math"
)
/*
https://leetcode.com/problems/median-of-two-sorted-arrays/#/description
*/
type BSType int
const (
LESS BSType = iota
GREATER
)
type Range struct {
start int
end int
}
func findMedianSortedArrays(nums1 []int, nums2 []int) float64 {
totalCount := len(nums1) + len(nums2)
l... |
package icws
import (
"reflect"
)
type Identifiable interface {
GetID() string
}
// IDList collects the Identifiers of items
//
//
// If some of the given items are not identifiable, it panics
func IDList(identifiables interface{}) []string {
// We have to use the reflect package, because Go does not allow castin... |
package admin
import (
db "github.com/JieeiroSst/LapTRWeb/config"
)
type Author struct {
AuthId int `json:"auth_id"`
Name string `json:"name"`
Affiation string `json:"Affiation"`
Email string `json:"email"`
}
func ShowListAuthor() []Author {
db := db.DbConn()
seleDB, err := db.Query("select * f... |
package game_actions
import (
"encoding/json"
socketio "github.com/googollee/go-socket.io"
"github.com/streadway/amqp"
"log"
)
type AMQPGameAction struct {
Action GameAction
Emails []string
SentToAll bool
}
type GameAction struct {
Game Game
User User
JsonValues map[string]json.RawMessage
Template string
... |
package test
import (
"fmt"
"github.com/360EntSecGroup-Skylar/excelize"
"io/ioutil"
"strconv"
"strings"
"time"
)
type Projects struct {
name,
fileList,
urlList []string
}
//项目父级目录
var project string
var proj Projects
var f = excelize.NewFile()
const splitBackslash = "\\"
func main() {
println("正在启动....... |
// LoopIf project main.go
package main
import (
"fmt"
"time"
)
func sum(a int, b int) int {
var sum int
for i := a; i <= b; i++ {
sum += i
}
return sum
}
func definiteLoop(in *int) {
var count int
for count <= *in {
fmt.Println(count)
count++
time.Sleep(time.Second)
}
}
func infiniteLoop() {
var c... |
// 2520 is the smallest number that can be divided by each of the numbers from 1 to 10 without any remainder.
// What is the smallest positive number that is evenly divisible by all of the numbers from 1 to 20?
package main
import "fmt"
var s int = 20
func main() {
bool = true
for n := 1; bool; n++ {
a := 0
... |
package routes
import "github.com/labstack/echo"
func Send (c echo.Context) error {
return nil
}
|
package main
import (
"errors"
"flag"
"fmt"
"os"
"time"
log "github.com/sirupsen/logrus"
mgo "gopkg.in/mgo.v2"
"gopkg.in/mgo.v2/bson"
)
type Leader struct {
Name string `json:"name"`
Updated time.Time `json:"updated"`
}
var session *mgo.Session
var name string
var database string
var hostname string... |
// Copyright (c) 2016-2019 Uber Technologies, 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... |
package public
import (
"github.com/potix/gobitflyer/api/types"
"github.com/potix/gobitflyer/client"
)
const (
getMarketsPath string = "/v1/getmarkets"
)
type GetMarketsResponse []*GetMarketsMarket
type GetMarketsMarket struct {
ProductCode types.ProductCode `json:"product_code"`
Alias types.Produ... |
// Copyright (C) 2018 Google 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 t... |
package v2
import (
"github.com/gofiber/fiber/v2"
godd "github.com/pagongamedev/go-dd"
)
//==================== Interface Router ====================
// RouterGofiber struct
type RouterGofiber struct {
router *fiber.Router
framework godd.FrameWork
}
// Add func
func (router *RouterGofiber) Add(method string,... |
package main
type Person struct {
First string
Last string `json:"clan name"`
Age int
}
func main() {
//var p Person
//data := []byte(`{"First":"Tyler","Last":"Mizuyabu","Age":20}`)
//fmt.Println(string(data))
//fmt.Printf("%T\n", data)
//_ = json.Unmarshal(data, &p)
//fmt.Println(p)
ints := make([]inte... |
package main
import (
"errors"
"net/http"
"net/http/httptest"
"testing"
"github.com/hectorgabucio/genity-hector/internal/data"
"github.com/hectorgabucio/genity-hector/test/mocks"
"github.com/stretchr/testify/assert"
)
const TITLE = "title"
func TestGetData(t *testing.T) {
tests := []struct {
method ... |
/*
1. Что выведет программа? Объяснить вывод программы.
package main
import (
"fmt"
)
func main() {
a := [5]int{76, 77, 78, 79, 80}
var b []int = a[1:4]
fmt.Println(b)
}
_______________________________________________________________________________________________________________
ОТВЕТ:
ПРОГРАММА ВЫ... |
package table
type Table struct {
Name string
RowsName []string
Rows map[string]Row
Indexs map[string]Index
}
func (t *Table) Init() {
t.Rows = make(map[string]Row)
t.Indexs = make(map[string]Index)
}
func (t *Table) UpdateRowList (oth *Table) {
for _, elm := range oth.Rows{
t.RowsName = append(t.Rows... |
package application
import (
"database/sql"
"log"
"github.com/ksbeasle/GoLang/database"
)
type App struct {
DBMODEL *database.GameDB
}
/*startDB - Connect to the mysql database, return the db if successful else an error */
func StartDB() (*sql.DB, error) {
db, err := sql.Open("mysql", "web3:pass@tcp(localhost:... |
package main
import(
"fmt"
)
// the age program is to find out my date of birth
func main() {
bd := 1977
b := 1953
a := 1977
for { // for break statement
if bd > 2020 {
break
}
fmt.Println(bd)
bd++
fmt.Println("----------------")
}
switch bd { ... |
package wcompress
import (
"context"
"github.com/wenerme/letsgo/fs"
"io"
"path/filepath"
)
type Compressor struct {
Name string
Ext []string
Decompress func(ctx context.Context, reader io.Reader) (r io.Reader, err error)
Compress func(ctx context.Context, writer io.Writer) (w io.Writer, err err... |
package sync
import (
"errors"
"reflect"
"github.com/marcuswestin/fun-go/errs"
)
func expects(str string) errs.Err {
return errors.New("fun/async.Each expects " + str)
}
func Each(items interface{}, fn interface{}) (err errs.Err) {
vItems := reflect.ValueOf(items)
tItems := vItems.Type()
if tItems.Kind() != ... |
// Copyright © 2020. All rights reserved.
// Author: Ilya Stroy.
// Contacts: qioalice@gmail.com, https://github.com/qioalice
// License: https://opensource.org/licenses/MIT
package ekaerr
import (
"sync"
)
//noinspection GoSnakeCaseUsage
const (
// _ERR_CLASS_ARRAY_CACHE describes how many registered Classes wil... |
package main
import (
"strings"
"time"
"github.com/asaskevich/govalidator"
"github.com/gosimple/slug"
"github.com/kubil6y/dukkan-go/internal/data"
"github.com/kubil6y/dukkan-go/internal/validator"
)
// sanitize() trims spaces and transforms strings to lowercase
func sanitize(s string) string {
return strings.... |
package gorelic
import (
"fmt"
"time"
"github.com/courtf/go-metrics"
)
type HistogramFunc uint8
type MeterFunc uint8
type TimerFunc uint8
const (
HistogramCount HistogramFunc = iota
HistogramMax
HistogramMean
HistogramMin
HistogramPercentile
HistogramStdDev
HistogramSum
HistogramVariance
NoHistogramFunc... |
package business
import (
"fmt"
"runtime/debug"
"database/sql"
"agent_keeper/model"
"go_api_base/db"
. "go_api_base/log"
"go_api_base/constant"
"strconv"
"agent_keeper/generate"
)
type Fswap func() error
func Recovery(f Fswap) (err error) {
func() {
defer func() {
if err := recover(); err != nil {
... |
package uptime
import (
"fmt"
uptime "github.com/uptime-com/rest-api-clients/golang/uptime"
"github.com/hashicorp/terraform/helper/schema"
)
func resourceUptimeCheckNTP() *schema.Resource {
return &schema.Resource{
Create: checkCreateFunc(ntpCheck),
Read: checkReadFunc(ntpCheck),
Update: checkUpdateFunc(nt... |
package main
import (
"fmt"
"github.com/summerKK/leetcode-Go/algs4/cmd/1.3"
)
/**
1.3.5
当 N 为 50 时下面这段代码会打印什么?从较高的抽象层次描述给定正整数 N 时这段代码的行为。
Stack<Integer> stack = new Stack<Integer>();
while (N > 0)
{
stack.push(N % 2);
N = N / 2; }
for (int d : stack) StdOut.print(d);
StdOut.println();
*/
func main() {
N... |
package miner
import (
"btcnetwork/block"
"btcnetwork/common"
"btcnetwork/node"
"btcnetwork/p2p"
"btcnetwork/storage"
"btcnetwork/transaction"
"crypto/rand"
"encoding/binary"
"encoding/hex"
"errors"
"math"
"math/big"
"sync"
"time"
)
var (
ErrNonceNotFound = errors.New("nonce not found")
)
func mineMon... |
package routes
import (
"excho-job/handler"
"excho-job/hire"
"github.com/gin-gonic/gin"
)
var (
hireRepository = hire.NewRepository(DB)
hireService = hire.NewService(hireRepository, jobsRepository)
hireHandler = handler.NewHireHandler(hireService, authService)
)
func HireRoute(r *gin.Engine) {
r.GET("/... |
package main
import (
"flag"
"log"
"os"
"github.com/staffano/crazy-build/artifact"
"github.com/staffano/crazy-build/cmd"
"github.com/staffano/crazy-build/examples/example2/build/artifacts"
"github.com/staffano/crazy-build/workspace"
)
// Handling of configurations really needs two passes
// First pass to regi... |
package main
import (
"bufio"
"fmt"
"io"
"os"
)
func main() {
scanner := bufio.NewReader(os.Stdin)
alpha := make([]int, 26)
for {
sentence, err := scanner.ReadString('\n')
if err == io.EOF {
break
}
for i := 0; i < len(sentence); i++ {
if sentence[i] >= 'A' && sentence[i] <= 'Z' {
alpha[sent... |
/**
* Copyright 2020 Comcast Cable Communications Management, LLC
*
* 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 requir... |
//+build wireinject
package wire
import (
"github.com/google/wire"
"github.com/krmahadevan/di"
)
func NewServerInstance() (*di.Server, error) {
wire.Build(di.NewConfig,
di.ConnectDatabase, //Since this can return an error, we need to ensure we return back that same error
di.NewPersonRepository,
di.NewPerson... |
package domain
import (
pb "pinterest/services/user/proto"
)
func PbUserRegToUser(pbUser *pb.UserReg) User {
return User{
Username: pbUser.Username,
Password: pbUser.Password,
FirstName: pbUser.FirstName,
LastName: pbUser.LastName,
Email: pbUser.Email,
}
}
func PbUserEditinputToUser(pbUser *pb.Us... |
package libcoding
import (
"net/http"
"io/ioutil"
"github.com/bitly/go-simplejson"
"strings"
"golang.org/x/net/html"
"github.com/PuerkitoBio/goquery"
)
type Performer struct {
Name string
}
func LoadPerformers() ([]Performer, error){
url := "http://connpass.com/api/v1/event/?event_id=1... |
package ziface
type IRequest interface {
//得到当前请求的连接
GetConnection() IConnection
//得到请求的方法
GetMsg() IMessage
}
|
package main
import (
"GoMD/models"
"gopkg.in/russross/blackfriday.v2"
"strconv"
"strings"
"time"
)
/* ---------------------------------
功能: 模板函数文件
------------------------------------*/
/* 文章页面标签显示 */
func Tags(tags string) []string {
array := strings.Split(tags, ",")
return array
}
/* 分页处理 */
func Calc(x... |
package dialer
import (
"context"
"errors"
"io"
"net"
"testing"
"time"
"github.com/ooni/probe-cli/v3/internal/engine/netx/trace"
"github.com/ooni/probe-cli/v3/internal/errorsx"
"github.com/ooni/probe-cli/v3/internal/netxmocks"
)
func TestSaverDialerFailure(t *testing.T) {
expected := errors.New("mocked err... |
package main
import (
"fmt"
"github.com/gfragoso/goarea"
"github.com/gfragoso/goarea/abc"
)
func main() {
fmt.Println(goarea.Circ(4.0))
abc.Epa()
}
|
// Copyright (C) 2019-2020 Zilliz. 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 l... |
package python
import (
"context"
"github.com/quay/claircore"
"github.com/quay/claircore/libvuln/driver"
"github.com/quay/claircore/pkg/pep440"
)
var (
_ driver.Matcher = (*Matcher)(nil)
_ driver.VersionFilter = (*Matcher)(nil)
)
// Matcher attempts to correlate discovered python packages with reported
... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.