text stringlengths 11 4.05M |
|---|
package transdsl
import (
"errors"
)
var (
ErrSucc = errors.New("trans succ")
ErrUnexpectedEvent = errors.New("unexpected event")
ErrTimeout = errors.New("timeout")
)
func isEqual(leftErr, rightErr error) bool {
return leftErr.Error() == rightErr.Error()
}
type Succ struct {
}
func (this *S... |
package main
import (
"bufio"
"flag"
"fmt"
"math/rand"
"os"
"regexp"
"strings"
"time"
)
//chosing a random word from the list
func chooserand(list []string) string {
rand.Seed(time.Now().Unix()) //needed so randomization works correctly
randomindexes := rand.Intn(len(list))
randword := list[randomindexes]
... |
/**
* Copyright (C) 2019, Xiongfa Li.
* All right reserved.
* @author xiongfa.li
* @date 2019/2/22
* @time 10:42
* @version V1.0
* Description:
*/
package test
import (
"container/list"
"fmt"
commonPool2 "github.com/xfali/gomem/commonPool2"
"testing"
"time"
)
type b int
func (f *b) Acti... |
package main
import (
"bufio"
"fmt"
"log"
"os"
"regexp"
"strconv"
)
type pattern struct {
index int
leftEdge int
topEdge int
width int
height int
}
var (
patterns []pattern
grid [1000][1000]int
)
func main() {
f, err := os.Open("../input.txt")
if err != nil {
log.Fatal(err)
}
defer ... |
package apiserver
import (
"fmt"
"github.com/gin-gonic/gin"
"log"
"net/http"
"oliujunk/server/apiserver/authentication"
"oliujunk/server/config"
"oliujunk/server/database"
"time"
)
func Start() {
log.Println("接口服务启动")
//gin.SetMode(gin.ReleaseMode)
router := gin.Default()
router.Use(cors())
router.POS... |
/*
Copyright 2022 The KubeVela Authors.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, softw... |
package compute
import (
"encoding/xml"
"fmt"
"log"
"net/http"
)
// Account represents the details for a compute account.
type Account struct {
// The XML name for the "Account" data contract
XMLName xml.Name `xml:"Account"`
// The compute API user name.
UserName string `xml:"userName"`
// The user's full ... |
// Test how big can the stack of a go routine be.
// runtime/proc.go: if 64OS maxstacksize=1GB else maxstacksize=250MB
//
// Allocate a bigger segment and move the stack:
// oldsize = gp->stack.hi - gp->stack.lo;
// newsize = oldsize * 2;
package main
func main() {
main() // will panic: runtime: goroutine stack excee... |
/*
Links
* http://arysotog.github.com/1.html
* http://arysotog.github.com/2.html
* http://arysotog.github.com/3.html
* http://arysotog.github.com/4.html
* http://arysotog.github.com/5.html
* http://arysotog.github.com/6.html
* http://arysotog.github.com/7.html
* http://arysotog.github.com/8.html
* http://arysotog.githu... |
// Copyright (C) 2019 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... |
/*
* Copyright 2018- The Pixie 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 ag... |
/*
Randall Munroe (author of XKCD) held a survey to give names to colors. The main outcome is a list of names for the 954 most common RGB monitor colors.
For ease of programming, here is the list in plain text: http://xkcd.com/color/rgb.txt. Beware, the first line is not data, but contains the license.
Write a progr... |
package nooler
import (
"database/sql"
"fmt"
"log"
"net/http"
_ "github.com/go-sql-driver/mysql"
"github.com/gorilla/mux"
"github.com/seongminnpark/nooler-server/internal/app/nooler/handler"
)
type App struct {
Router *mux.Router
DB *sql.DB
}
func (app *App) Initialize(user, password, dbName string) {
... |
package connrt
import (
"github.com/gookit/event"
"github.com/kbence/conndetect/internal/connlib"
"github.com/kbence/conndetect/internal/utils"
)
type ConnectionPrinter struct {
Node
printer utils.Printer
time utils.Time
}
func NewConnectionPrinter(eventManager event.ManagerFace) *ConnectionPrinter {
prin... |
package game
import (
"sync"
"sofa/proto"
"sofa/network"
)
type Sid2GameRoom struct {
sid2scene map[uint32]*GameRoom
umLock sync.RWMutex
}
func NewSid2GameRoom() *Sid2GameRoom {
return &Sid2GameRoom{sid2scene:make(map[uint32]*GameRoom)}
}
func (this *Sid2GameRoom) Ga... |
// Copyright 2020 Kuei-chun Chen. All rights reserved.
package mdb
import (
"context"
"go.mongodb.org/mongo-driver/bson"
"go.mongodb.org/mongo-driver/mongo"
)
// HostInfo stores build information
type HostInfo struct {
Extra struct {
KernelVersion string
}
OS struct {
Name string
Type string
Ver... |
package store
import (
"os"
"path/filepath"
"github.com/openshift/installer/pkg/asset"
)
type fileFetcher struct {
directory string
}
// FetchByName returns the file with the given name.
func (f *fileFetcher) FetchByName(name string) (*asset.File, error) {
data, err := os.ReadFile(filepath.Join(f.directory, na... |
package tools
import (
"os"
"github.com/sapk/sca/pkg"
log "github.com/sirupsen/logrus"
"github.com/spf13/cobra"
)
//TypeOrEnv parse cmd to file with env vars
func TypeOrEnv(cmd *cobra.Command, flag, envname string) string {
val, _ := cmd.Flags().GetString(flag)
if val == "" {
val = os.Getenv(envname)
}
ret... |
package rancher
import (
"github.com/docker/libcompose/config"
"github.com/docker/libcompose/project"
)
type RancherServiceFactory struct {
Context *Context
}
func (r *RancherServiceFactory) Create(project *project.Project, name string, serviceConfig *config.ServiceConfig) (project.Service, error) {
if len(r.Con... |
package extractor
import (
"testing"
)
func TestPackageComplexity(t *testing.T) {
complexity, err := PackageComplexity("github.com/freenerd/mccabe-cyclomatic/example")
if err != nil {
t.Error("expected package to open, got ", err)
}
var expected int64 = 8
if complexity != expected {
t.Errorf("expected exa... |
package main
import "fmt"
//地上有一个m行n列的方格,从坐标 [0,0] 到坐标 [m-1,n-1] 。一个机器人从坐标 [0, 0] 的格子开始移动,
//它每次可以向左、右、上、下移动一格(不能移动到方格外),也不能进入行坐标和列坐标的数位之和大于k的格子。
//例如,当k为18时,机器人能够进入方格 [35, 37] ,因为3+5+3+7=18。但它不能进入方格 [35, 38],因为3+5+3+8=19。请问该机器人能够到达多少个格子?
//示例 1:
//输入:m = 2, n = 3, k = 1
//输出:3
//示例 2:
//输入:m = 3, n = 1, k = 0
//输出... |
package main
import(
"linknodelist"
"fmt"
)
func main(){
fmt.Println("==================================================================================================")
fmt.Println("==================================================================================================")
fmt.Println("-... |
package sdutils
import (
"io"
"fmt"
"net/http"
"io/ioutil"
"bytes"
"encoding/json"
"time"
"errors"
)
type stardogClientImpl struct {
sdURL string
password string
username string
logger SdVaLogger
}
func (s *stardogClientImpl) doRequest(method, urlStr string, body io.Reader, contentType string, exp... |
package global
import (
"github.com/casbin/casbin/v2"
"github.com/go-redis/redis/v7"
"gorm.io/gorm"
)
// orm对外全局变量
var Eloquent *gorm.DB
// redis对外全局变量
var Rdb *redis.Client
//Casbin对外全局边变量
var CasbinEnforcer *casbin.SyncedEnforcer
|
// Unit tests for default configuration service.
//
// @author TSS
package service
import (
"testing"
coreservice "github.com/mashmb/1pass/1pass-core/core/service"
"github.com/mashmb/1pass/1pass-core/port/out"
"github.com/mashmb/1pass/1pass-parse/repo/file"
)
func setupConfigService() coreservice.ConfigService ... |
package sqldb
import (
"fmt"
log "github.com/sirupsen/logrus"
"upper.io/db.v3"
"upper.io/db.v3/lib/sqlbuilder"
)
type backfillClusterName struct {
clusterName string
tableName string
}
func (s backfillClusterName) String() string {
return fmt.Sprintf("backfillClusterName{%s,%s}", s.clusterName, s.tableName... |
/*
Copyright 2020 Skyscanner Limited.
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, soft... |
package oic
import (
"fmt"
"github.com/runtimeco/go-coap"
)
type Server struct {
rxer Receiver
rm ResMgr
isTcp bool
}
func NewServer(isTcp bool) Server {
s := Server{
rxer: NewReceiver(isTcp),
rm: NewResMgr(),
isTcp: isTcp,
}
return s
}
func (s *Server) AddResource(r Resource) error {
retur... |
package main
import (
"html/template"
"log"
"net/http"
"path"
"strconv"
"sync"
"github.com/pkg/errors"
)
const (
editPost = "editPost.html"
showPost = "showPost.html"
listPosts = "listPosts.html"
)
var templateFiles = []string{
editPost,
showPost,
listPosts,
}
// BlogServer struct
type BlogServer st... |
package main
import (
"container/list"
"fmt"
)
func main() {
var x list.List
x.PushBack(10)
x.PushBack(20)
x.PushBack(30)
for v := x.Front() ; v!=nil ; v = v.Next(){
fmt.Println(v.Value)
}
} |
package Problem0169
func majorityElement(nums []int) int {
// 根据题意 len[nums] > 0 且 出现次数大于 n/2 的元素存在。
x, t := nums[0], 1
for i := 1; i < len(nums); i++ {
switch {
case x == nums[i]:
t++
case t > 0:
t--
default:
// 此时 x != nums[i] 且 t == 0
// 可知 i 必定为 偶数
// 假设 nums 中出现最多的元素是 z,其出现次数为 zn > n/2
... |
package v1
import (
"blog/app/web/services"
"github.com/kataras/iris/v12"
"github.com/mlogclub/simple"
)
type SystemController struct {
Ctx iris.Context
SystemService services.SystemService
}
func NewSystemController() *SystemController {
return &SystemController{}
}
/**
* 获取系统配置
* @return json ma... |
package aoc2015
import (
"strconv"
"strings"
"time"
"github.com/golang/glog"
)
// lookAndSay looks at the string and returns a string
// containing how many times a rune has repeated itself following said rune.
// For instance:
// lookAndSay("1") returns "11" (one '1')
// lookAndSay("111221") returns "312211" (t... |
package accounts
import (
"net/http"
"os"
"testing"
"time"
uuid "github.com/satori/go.uuid"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
)
const errorValidationJSON = `
{
"error_message": "validation failure"
}
`
type MockHandler func(req *http.Request) (*http.Response, ... |
package main
import (
"bytes"
"encoding/json"
"flag"
"fmt"
"net/url"
contextio "github.com/dmlyons/contextIOTest/goContextIO"
)
func main() {
key := flag.String("key", "", "Your CIO User Key")
secret := flag.String("secret", "", "Your CIO User Secret")
flag.Parse()
c := contextio.NewContextIO(*key, *secret... |
package servers
import (
"encoding/csv"
"os"
)
// Server ...
type Server struct {
Host string
Name string
}
// GetServers ...
func GetServers() []Server {
file, err := os.Open("resources/servers.csv")
if err != nil {
panic(err)
}
defer file.Close()
reader := csv.NewReader(file)
reader.Comma = ';'
var s... |
package migrate
import (
"reflect"
"strings"
"github.com/neuronlabs/errors"
"github.com/neuronlabs/neuron-core/class"
"github.com/neuronlabs/neuron-core/mapping"
"github.com/neuronlabs/strcase"
"github.com/neuronlabs/neuron-postgres/log"
)
// Column is a postgres field kind.
type Column struct {
// Name def... |
package wx_service
import (
"errors"
"fmt"
"github.com/bitly/go-simplejson"
"github.com/freelifer/gohelper/models"
"github.com/freelifer/gohelper/pkg/cache"
"github.com/freelifer/gohelper/pkg/e"
"github.com/freelifer/gohelper/pkg/settings"
"github.com/freelifer/gohelper/pkg/utils"
"github.com/gin-gonic/gin/js... |
// Copyright 2018 Twitch Interactive, 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. A copy of the License is
// located at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// or in the "license"... |
package main
import (
"bufio"
"fmt"
"os"
"strconv"
"strings"
)
func main() {
// 標準入力
scanner := bufio.NewScanner(os.Stdin)
abc := []string{"A", "B", "C", "D", "E", "F", "G", "H", "I", "J"}
for scanner.Scan() {
strArray := strings.Fields(scanner.Text())
num := 0
i := 0
for _, str := range strArray ... |
package UserDelivery
import (
"MainApplication/internal/User/UserModel"
"MainApplication/internal/User/UserUseCase"
"MainApplication/internal/errors"
"MainApplication/internal/pkg/context"
"MainApplication/proto/FileServise"
"bytes"
"fmt"
log "github.com/sirupsen/logrus"
"io"
"net/http"
"strconv"
"time"
)... |
package nethelper
import (
"net"
"net/http"
logger "github.com/panlibin/vglog"
)
type handlerWrapper struct {
f func(w http.ResponseWriter, pReq *http.Request)
}
func (h *handlerWrapper) ServeHTTP(w http.ResponseWriter, pReq *http.Request) {
w.Header().Set("Access-Control-Allow-Origin", "*")
pReq.ParseForm()
... |
package linkedlist
type ListNode struct {
Val int
Next *ListNode
}
// 21.将两个有序链表合并为一个新的有序链表并返回。新链表是通过拼接给定的两个链表的所有节点组成的
func mergeTwoLists(l1 *ListNode, l2 *ListNode) *ListNode {
l := &ListNode{}
ret := l
for l1 != nil && l2 != nil {
if l1.Val < l2.Val {
l.Next = l1
l1 = l1.Next
} else {
l.Next = l2... |
// 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"
"fmt"
"net/url"
"strings"
"time"
"github.com/pkg/errors"
"github.com/satori/go.uuid"
"github.com/diegobernarde... |
/*
# -*- coding: utf-8 -*-
# @Author : joker
# @Time : 2021/7/13 9:11 上午
# @File : jz_31_整数中1出现的次数.go
# @Description :
# @Attention :
*/
package offer
func NumberOf1Between1AndN_Solution(n int) int {
r := 0
for i := 0; i <= n; i++ {
if i&1 >= 1 {
r++
}
}
return r
}
|
package sort
import (
)
func ShellSort(arr []string) []string {
n := len(arr)
h := chooseH(n)
for h >= 1 {
// use insertion sort
for i := h; i < n; i++ {
for j := i; j >= h && arr[j] < arr[j-h]; j -= h {
tmp := arr[j]
arr[j] = arr[j-h]
arr[j-h] = tmp
}
}
h = h / 3
}
return arr
}
func c... |
package main
import (
"fmt"
)
func main() {
fmt.Printf("Hello strings \n")
isUnique := IsUnique("abcdefghi")
fmt.Printf("IsUnique %v \n", isUnique)
isPermutation := IsPermutation("dog", "god")
fmt.Printf("IsPermutation (true) %v \n", isPermutation)
}
|
package main
import (
"path/filepath"
"sync"
bitbucket "github.com/PremiereGlobal/mkdocs-generator/bitbucket"
)
// masterFileList holds all of the files that have been processed so we don't duplicate
// Map keys should be in the formats:
// projects/<project>/repos/<repo>/raw/<filepath>
// or
// projects/<p... |
package main
import "fmt"
func main() {
//一.for循环嵌套
//外层执行一次 内层执行一周
//count:=0
//for i:= 0;i<5;i++{
// for j:=0;j<5 ;j++ {
// fmt.Println(i,j)
// count++
//
// }
//}
//fmt.Println(count)
//二.练习
//百钱百鸡
/*
中国古代数学家张丘建在他的《算经》中提出了一个著名的“百钱百鸡问题”:
一只公鸡值五钱,一只母鸡值三钱,三只小鸡值一钱,
现在要用百钱买百鸡,请问公鸡、母鸡、小鸡各多少只?
... |
package theme
import (
"encoding/xml"
"fmt"
"html"
"io/ioutil"
"os"
"path/filepath"
"regexp"
"strings"
"time"
"github.com/thoas/go-funk"
"k8s.io/klog"
)
// JcinkXML is an XML file used by jcink
type JcinkXML struct {
XMLName xml.Name `xml:"skin"`
Text string `xml:",chardata"`
ThemeName stri... |
package no_repeat_longest_str
func lengthOfLongestSubstring(s string) int {
if len(s) <= 1 {
return len(s)
}
index := make(map[byte]int)
result := 1
i := 0
j := 1
index[s[0]] = 0
for j < len(s) {
// 反向查找 str[j] 最先早出现的位置
lastPos, found := index[s[j]]
index[s[j]] = j
// i 之前的不需要管,因为存在别的字符重复了
if found... |
// Copyright 2020 Clivern. All rights reserved.
// Use of this source code is governed by the MIT
// license that can be found in the LICENSE file.
package tower
import (
"net/http"
"github.com/clivern/walrus/core/driver"
"github.com/clivern/walrus/core/model"
"github.com/gin-gonic/gin"
log "github.com/sirupse... |
package entity
import (
"time"
"github.com/fatih/structs"
)
type Balance struct {
Id int64
MerchantId int64
AddressId int64
AccountId int64
Chain string
Token string
Address string
Tag string
DepositFreeze string // 充值冻结
WithdrawFreeze string... |
package ice
import (
"testing"
"fmt"
"github.com/nkbai/log"
"github.com/nkbai/goice/stun"
)
type mockcb struct {
s serverSocker
}
/*
收到一个 stun.Message, 可能是 Bind Request/Bind Response 等等.
*/
func (m *mockcb) RecieveStunMessage(localAddr, remoteAddr string, req *stun.Message) {
if req.Type != stun.BindingRequ... |
/*
Copyright 2021 CodeNotary, 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 law or agreed to i... |
/*
Copyright 2020 The Qmgo 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, sof... |
package quotetesting
import (
"fmt"
"net/http"
"net/http/httptest"
"strconv"
"time"
)
// NewTestServer create a new httptest server that returns a response
// build on the request parameters.
// The response in an html page with a table that prints
// kew/value pairs of query parameters.
// Special parameters:
/... |
package middleware
import (
"bytes"
"dappapi/models"
"dappapi/tools"
config2 "dappapi/tools/config"
"encoding/json"
"io"
"io/ioutil"
"net/url"
"strings"
"time"
"github.com/gin-gonic/gin"
log "github.com/sirupsen/logrus"
)
type bodyLogWriter struct {
gin.ResponseWriter
body *bytes.Buffer
}
func (w body... |
package main
import (
"flag"
"fmt"
"math"
"net/http"
"sort"
"sync"
"time"
)
var (
url string // url
m string // method请求方法
c uint // 并发量
n uint // 请求总量
H string // Header
b string // Body
timeout int64 // 超时时长
)
// init all flag values
func init() {
flag.String("... |
package main
import "fmt"
func main() {
for i := 0; i < 3; i++ {
fmt.Println("before")
continue
fmt.Println("after")
}
fmt.Println("next statement")
}
|
package models
import (
"database/sql"
"log"
_ "github.com/mattn/go-sqlite3"
)
type Store interface {
AllUsers() (interface{}, error)
}
type Repo struct {
db *sql.DB
}
func NewDB(dataSourceName string) (*Repo, error) {
db, err := sql.Open("sqlite3", dataSourceName)
if err != nil {
log.Fatalf("DB open erro... |
package p9p
import "io"
func (c *Conn) Remove(fid Fid) (err error) {
defer func() { logf("Remove: %v", err) }()
m := &Msg{src: c}
if !m.writeHeader(KTremove) || !m.writebinary(fid) || !c.schedule(m) {
return m.err
}
return nil
}
func (c *Conn) Clunk(fid Fid) (err error) {
defer func() { logf("Clunk: %v", err... |
package aoc2020
import (
"sort"
"strconv"
aoc "github.com/janreggie/aoc/internal"
)
// Day09 solves the ninth day puzzle "Encoding Error"
//
// Input
//
// A file containing positive integers separated by newlines. For example:
//
// 35
// 20
// 15
// 25
// 47
// 40
// 62
// 55
// 65
// 95
// ... |
package gommon
import (
"errors"
"fmt"
)
var builtInFunc map[string]func(*Cons) (*Cons, error)
func (this *Cons) Eval() (*Cons, error) {
first := new(Cons)
last := first
p := this
for {
if t, ok := p.Car.(*Cons); ok {
if name, ok := t.Car.(AtomSymbol); ok {
if fn, ok := builtInFunc[string(name)]; ok {... |
package test
import (
"context"
"encoding/base64"
"fmt"
"io/ioutil"
"math"
"os"
"path"
"strings"
"time"
"gopkg.in/op/go-logging.v1"
"build"
"core"
"metrics"
)
var log = logging.MustGetLogger("test")
const dummyOutput = "=== RUN DummyTest\n--- PASS: DummyTest (0.00s)\nPASS\n"
const dummyCoverage = "<?x... |
package main
import (
"bytes"
"errors"
"fmt"
"mime"
"strings"
"github.com/xeipuuv/gojsonschema"
)
// ResponseExpectation is an interface to any validation
// that needs to be performed on response.
type ResponseExpectation interface {
// check does the response meet expectation
check(resp *Response) error
... |
// Package model provides an interface for all models, ensuring all models
// have validation functions of the same format
package models
import (
"reflect"
"fmt"
"errors"
)
// Model is an interface for the models of the data from incoming requests
type Model interface {
Validate() error
}
// Valida... |
package config
import (
"fmt"
"regexp"
)
// Config api/db shared config object
type Config struct {
// 'api' or 'db'
Role string
// address of db
DBAddr string
// port of db
DBPort string
// port of vr service
VRPort string
// list of vr peer urls
VRPeerURLs []string
// list of peer urls of dbs
DBP... |
package script
//Float is a floating-point number
type Float struct {
Type
}
|
package vrf
import (
"crypto/sha512"
"fmt"
cmn "github.com/HNB-ECO/HNB-Blockchain/HNB/consensus/algorand/common"
"github.com/HNB-ECO/HNB-Blockchain/HNB/consensus/algorand/types"
)
func CalcBFTGroupMembersByVRF(VRFValue []byte, candidates []*cmn.BftGroupSwitchAdvice, groupSize int) ([]*cmn.BftGroupSwitchAdvice, er... |
package msgHandler
import (
"fmt"
"github.com/HNB-ECO/HNB-Blockchain/HNB/consensus/algorand/state"
"github.com/HNB-ECO/HNB-Blockchain/HNB/consensus/algorand/types"
"github.com/HNB-ECO/HNB-Blockchain/HNB/ledger"
"time"
)
func (h *TDMMsgHandler) rollBack(begin, end uint64) error {
return ledger.RollBackLedger(beg... |
// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
// vespa document command
// author: bratseth
package cmd
import (
"fmt"
"io"
"strings"
"time"
"github.com/fatih/color"
"github.com/spf13/cobra"
"github.com/vespa-engine/vespa/client/go/util"
"github.com/... |
package main
import "fmt"
func main() {
m := map[string]string{
"nombre" : "Rodolfo",
"apellido" : "Guzmán",
}
fmt.Printf("El mapa es: %s \n", m)
fmt.Printf("\n El nombre es: %s \n", m["nombre"])
m["nickname"] = "Santo"
fmt.Printf("\n El tipo es: %T \n\n", m)
for k, v := range m{
fmt.Printf("%s \t ... |
package main
import (
"encoding/json"
"fmt"
"io/ioutil"
"log"
"sync"
"github.com/PuerkitoBio/goquery"
"github.com/parnurzeal/gorequest"
)
type Config struct {
WebhookURL string `json:"webhook_url"`
Channel string `json:"channel"`
BotName string `json:"bot_name"`
}
type Site struct {
URL string ... |
package main
import (
"net/http"
"github.com/gin-gonic/gin"
"os"
"io"
"fmt"
"strings"
"errors"
_ "net/http/pprof"
)
//gin redis nginx gorm etcd kafka es kibane
type Person struct {
Name string `json:"name"`
Age string `json:"age"`
}
//参数校验
func Middleware(out io.Writer) gin.HandlerFunc {
retu... |
//************************************************************************//
// rsc - RightScale API command line tool
//
// Generated with:
// $ praxisgen -metadata=ss/ssc/restful_doc -output=ss/ssc -pkg=ssc -target=1.0 -client=API
//
// The content of this file is auto-generated, DO NOT MODIFY
//*... |
// Copyright 2023 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 model
type Language string
const (
Javascript Language = "javascript"
Java Language = "java"
Go Language = "golang"
Cpp Language = "cpp"
)
|
package main
import (
"database/sql"
"flag"
"fmt"
"log"
"time"
_ "github.com/go-sql-driver/mysql"
)
func main() {
var (
idle = 5
open = 5
dsn = "bench:cygames0@tcp(10.9.10.223:3307)/hayao10_hayao"
)
flag.IntVar(&idle, "idle", idle, "SetMaxIdleConns")
flag.IntVar(&open, "open", open, "SetMaxOpenConn... |
package main
/*
* @lc app=leetcode id=450 lang=golang
*
* [450] Delete Node in a BST
*/
/**
* Definition for a binary tree node.
* type TreeNode struct {
* Val int
* Left *TreeNode
* Right *TreeNode
* }
*/
/*
感觉这题的解法有点取巧的意思,元素一旦重复,就不适用了
*/
func deleteNod450(root *TreeNode, k... |
package main
import (
"encoding/json"
"net/http"
"os"
"path/filepath"
"strings"
"time"
"github.com/go-chi/chi"
"github.com/go-chi/chi/middleware"
"github.com/sirupsen/logrus"
)
func startServer() {
r := chi.NewRouter()
r.Use(middleware.RequestID)
r.Use(middleware.RealIP)
r.Use(middleware.Logger)
r.Use... |
package cmd
import (
"fmt"
"strconv"
"github.com/spf13/cobra"
)
func init() {
RootCmd.AddCommand(divideCmd)
}
var divideCmd = &cobra.Command{
Use: "divide",
Short: "Calculator of division.",
Long: "Calculator to perform the division.",
Run: func(cmd *cobra.Command, args []string) {
var n1 int
var n2 ... |
package main
import "fmt"
import "regexp"
import "time"
func main() {
t := time.Now()
for i := 0; i < 100; i++ {
res, _ := regexp.MatchString("a([a-z]+)o", "afdjo")
fmt.Print(res)
}
fmt.Println("cost without regexp compiling", time.Now().Sub(t).Nanoseconds())
t = time.Now()
reg := regexp.MustCompile("a([a... |
package main
import (
"fmt"
"os"
"github.com/aymanbagabas/hknui/ui"
tea "github.com/charmbracelet/bubbletea"
"github.com/spf13/cobra"
)
var (
rootCmd = &cobra.Command{
Use: "hknui",
Short: "Hacker News TUI",
RunE: func(cmd *cobra.Command, args []string) error {
f, err := tea.LogToFile("debug.log", "... |
package masterkey
import (
"log"
"git.roosoft.com/bitcoin/hd-wallets/lib"
"github.com/tyler-smith/go-bip32"
)
var km *lib.KeyManager
var masterkey *bip32.Key
func init() {
var err error
km, err = lib.NewKeyManagerFromMnemonic(lib.Mnemonic, lib.Passphrase)
if err != nil {
log.Fatal(err)
}
masterkey, err ... |
// Copyright 2015 Simon HEGE. All rights reserved.
// Use of this source code is governed by a MIT-style
// license that can be found in the LICENSE file.
/*
Package geodesic provides direct and inverse geodesic calculations.
It is a Go wrapper around the GeographicLib geodesic C library by Charles Karney.
The origin... |
package helpers
import (
//"fmt"
"log"
"gopkg.in/mgo.v2"
"gopkg.in/mgo.v2/bson"
"time"
)
const MONGOHOST string = "localhost"
const MONGODB string = "ghdaily"
const MONGOCOLLECTION string = "repos"
func InsertRepo(repo Repo) bool {
session, err := mgo.Dial(MONGOHOST)
... |
package 数组
var morseCodes = []string{
".-", "-...", "-.-.", "-..", ".", "..-.", "--.", "....", "..", ".---",
"-.-", ".-..", "--", "-.", "---", ".--.", "--.-", ".-.", "...", "-",
"..-", "...-", ".--", "-..-", "-.--", "--..",
}
func uniqueMorseRepresentations(words []string) int {
hasMorseSequenceExisted := make(ma... |
package model
import (
"time"
"github.com/graphql-go/graphql"
)
// Team represents a F1 scuderia
type Team struct {
ID string `json:"id"`
Name string `json:"name"`
CreatedAt *time.Time `json:"createdAt"`
Seasons []TeamSeason `json:"seasons" bson:"seasons"`
}
type TeamSeason struct ... |
package dao
import (
"bytes"
"database/sql"
"fmt"
"strings"
"varconf-server/core/dao/common"
)
type ReleaseData struct {
AppId int64 `json:"appId" DB_COL:"app_id" DB_PK:"app_id" DB_TABLE:"release"`
ConfigList string `json:"configList" DB_COL:"config_list"`
ReleaseTime common.Json... |
package kafkamdm
import (
"encoding/binary"
"hash"
"hash/fnv"
"time"
"github.com/Shopify/sarama"
"github.com/raintank/fakemetrics/out"
"github.com/raintank/met"
"github.com/raintank/worldping-api/pkg/log"
"gopkg.in/raintank/schema.v1"
)
type KafkaMdm struct {
out.OutStats
topic string
brokers []strin... |
package sploit
import (
"fmt"
)
// FileFormat represents the type of file under analysis
type FileFormat uint16
// Architecture represents processor architecture
type Architecture uint16
// Endian is a integer type that represents the byte order of a binary
type Endian int
const (
// PEFile represents Microsoft ... |
package main
import (
"encoding/json"
"fmt"
"github.com/imroc/req"
"gitlab.com/buddyspencer/chameleon"
"gopkg.in/cheggaaa/pb.v1"
"gopkg.in/yaml.v2"
"io/ioutil"
"log"
"os"
"regexp"
"strings"
)
type Appimage struct {
Version int `json:"version"`
HomePageURL string `json:"home_page_url"`
FeedURL ... |
package main
import (
// "learn4/splice"
// "learn4/make"
// "learn4/exercise"
"learn4/randomPwd"
)
func main() {
// splice.Test()
// make.Test()
// exercise.Test()
randomPwd.Test()
}
|
package main
import(
"time"
"net"
"github.com/dedis/protobuf"
"fmt"
"crypto/rsa"
)
type PuzzleProposal struct{
Origin string
NodeID uint64
Timestamp time.Time
PreviousHash []byte
}
type PuzzleResponse struct{
Origin string
Destination string
CreatedBlock *Block
}
type BlockBroadcast struct{
Or... |
package main
import (
"fmt"
"github.com/quiz.algorithm-solve/go/scanner"
)
func Solve(n int) int {
return n % 21
}
func main() {
fmt.Printf("%d", Solve(scanner.ScanInt()))
}
|
package main
import (
"encoding/csv"
"fmt"
"os"
"strconv"
)
type Post struct {
Id int
Content string
Author string
}
func main() {
csvFile, err := os.Create("posts.csv")
if err != nil {
panic(err)
}
defer csvFile.Close()
allPosts := []Post{
Post{Id: 1, Content: "Go to school", Author: "Tom"},... |
package venom
import (
"context"
"encoding/json"
"fmt"
"reflect"
"strings"
"github.com/gosimple/slug"
"github.com/ovh/cds/sdk/interpolate"
"github.com/pkg/errors"
"github.com/rockbears/yaml"
)
// Executor execute a testStep.
type Executor interface {
// Run run a Test Step
Run(context.Context, TestStep) (... |
package clients
import (
"time"
"strings"
"github.com/globalsign/mgo"
"github.com/urbn/ordernumbergenerator/app"
"fmt"
)
var (
NewMongoSessionProc = NewSession
)
func NewSession(dialInfo *mgo.DialInfo) (*mgo.Session, error) { return mgo.DialWithInfo(dialInfo) }
func CreateMongoSession(mongoServers string) Mo... |
package minnow
import (
"log"
"os"
"time"
)
func Start(args []string) int {
logger := log.New(os.Stdout, "Minnow: ", 0)
if len(args) != 2 {
logger.Print("Must specify a config file")
return 1
}
config, err := ReadConfig(Path(args[1]))
if err != nil {
logger.Print(err.Error())
return 1
}
dispatch... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.