text stringlengths 11 4.05M |
|---|
package _51_N_Queens
import "testing"
func TestSolveNQueens(t *testing.T) {
var ret [][]string
ret = solveNQueens(1)
t.Log(ret)
ret = solveNQueens(4)
t.Log(ret)
}
|
package design
import (
. "github.com/goadesign/goa/design"
. "github.com/goadesign/goa/design/apidsl"
)
var UserPayload = Type("UserPayload", func() {
Attribute("name", func() {
MinLength(2)
Example("James Brown")
})
Attribute("email", func() {
Format("email")
})
Attribute("password", func() {
MinLeng... |
package main
import (
"coolGame/lib"
"fmt"
"time"
)
func main() {
player := lib.NewPlayer("jack")
fmt.Println(player)
boss := lib.NewBoss()
battle := lib.NewBattle(boss, player)
fmt.Println(battle.Boss)
// battleDone := make(chan bool)
t := time.Tick(1 * time.Second)
i := 0
for now := range t {
fmt.Pri... |
package bosh
import (
"reflect"
"testing"
"time"
"github.com/skriptble/nine/element"
"github.com/skriptble/nine/namespace"
)
func TestBodyTransformElement(t *testing.T) {
t.Parallel()
// Adds proper attributes
body1 := Body{
To: "foo@bar",
From: "baz@quux",
Lang: "en-gb",
Ve... |
package image
import (
"bufio"
"bytes"
_ "golang.org/x/image/webp"
"image"
_ "image/gif"
_ "image/jpeg"
_ "image/png"
"os"
"github.com/disintegration/imaging"
)
func DecodeFile(file *os.File) (image.Image, error) {
img, _, err := image.Decode(bufio.NewReader(file))
if err != nil {
return nil, err
}
re... |
package UI
import (
"fmt"
"io/ioutil"
"strings"
"log"
"encoding/json"
"github.com/veandco/go-sdl2/sdl"
"github.com/veandco/go-sdl2/ttf"
"github.com/cuu/gogame/display"
"github.com/cuu/gogame/surface"
"github.com/cuu/gogame/draw"
"github.com/cuu/gogame/color"
"github.com/cuu/gogame/rect"
"github.com/cuu... |
package main
import (
"math/rand"
"time"
)
type Row [14]int
type Board struct {
Black Row
White Row
}
type Game struct {
WhiteStones int
BlackStones int
Board Board
Pot int
}
func New() *Game {
rand.Seed(time.Now().UnixNano())
return &Game{
WhiteStones: 7,
BlackStones: 7,
Pot: ... |
package linter
import (
"context"
"os"
"github.com/openllb/hlb/checker"
"github.com/openllb/hlb/codegen"
"github.com/openllb/hlb/diagnostic"
"github.com/openllb/hlb/errdefs"
"github.com/openllb/hlb/parser"
)
type Linter struct {
Recursive bool
errs []error
}
type LintOption func(*Linter)
func WithRec... |
package main
import (
"log"
"net/http"
"github.com/Bobochka/thumbnail_service/lib/service"
)
func main() {
cfg, err := ReadConfig()
if err != nil {
log.Fatal(err)
}
svc := service.New(cfg)
app := &App{service: svc}
http.HandleFunc("/thumbnail", app.thumbnail)
log.Fatal(http.ListenAndServe(bindPort(),... |
package lbfactory
import (
"errors"
"testing"
"github.com/bryanl/dolb/entity"
"github.com/bryanl/dolb/kvs"
"github.com/bryanl/dolb/pkg/app"
. "github.com/smartystreets/goconvey/convey"
)
func TestLoadBalancerFactoryBuild(t *testing.T) {
Convey("Given a LoadBalancerFactory", t, func() {
mockEntityManager :=... |
package migrations
import (
"database/sql"
"os"
"path"
_ "github.com/mutecomm/go-sqlcipher"
)
type Minor002 struct{}
func (Minor002) Up(repoPath string, pinCode string, testnet bool) error {
var dbPath string
if testnet {
dbPath = path.Join(repoPath, "datastore", "testnet.db")
} else {
dbPath = path.Join... |
// Package main defines a command line interface for the sqlboiler package
package main
import (
"fmt"
"os"
"path/filepath"
"strings"
"github.com/friendsofgo/errors"
"github.com/spf13/cobra"
"github.com/spf13/viper"
"github.com/volatiletech/sqlboiler/v4/boilingcore"
"github.com/volatiletech/sqlboiler/v4/dri... |
// DRUNKWATER TEMPLATE(add description and prototypes)
// Question Title and Description on leetcode.com
// Function Declaration and Function Prototypes on leetcode.com
//327. Count of Range Sum
//Given an integer array nums, return the number of range sums that lie in [lower, upper] inclusive.
//Range sum S(i, j) is d... |
package main
import (
log "github.com/mailgun/vulcand/Godeps/_workspace/src/github.com/mailgun/gotools-log"
"os"
)
var vulcanUrl string
func main() {
log.Init([]*log.LogConfig{&log.LogConfig{Name: "console"}})
cmd := NewCommand()
err := cmd.Run(os.Args)
if err != nil {
log.Errorf("Error: %s\n", err)
}
}
|
package gogo
import (
"io/ioutil"
"net/http"
"net/http/httptest"
"net/http/httputil"
"strconv"
"strings"
"testing"
"github.com/golib/assert"
)
func Test_NewAppRoute(t *testing.T) {
prefix := "/prefix"
server := newMockServer()
assertion := assert.New(t)
route := NewAppRoute(prefix, server)
assertion.Em... |
/*
Copyright 2021 Digitalis.IO.
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, software
d... |
// Copyright 2015 Walter Schulze
//
// 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... |
package regexpx_test
import (
"regexp"
"testing"
rx "github.com/yargevad/regexpx"
)
var testMatch = rx.RegexpSet{
regexp.MustCompile(`^abc+$`),
regexp.MustCompile(`^abc+d$`),
}
type MatchTest struct {
Input string
Match bool
Index int
}
func TestMatch(t *testing.T) {
for _, test := range []MatchTest{
{"... |
package releasetarsrepo
import (
"fmt"
"strings"
bhs3 "github.com/bosh-io/web/s3"
)
type ReleaseTarballRec struct {
urlFactory bhs3.URLFactory
source string
versionRaw string
BlobID string
SHA1 string
}
func (r ReleaseTarballRec) ActualDownloadURL() (string, error) {
path := "/" + r.BlobID
fileNa... |
package leetcode
import (
"reflect"
"testing"
)
func TestFourSum(t *testing.T) {
tests := []struct {
nums []int
target int
solutions [][]int
}{
{
nums: []int{1, 0, -1, 0, -2, 2},
target: 0,
solutions: [][]int{
{-2, -1, 1, 2},
{-2, 0, 0, 2},
{-1, 0, 0, 1},
},
},
{
n... |
package oku
import (
"fmt"
"io"
"github.com/qiniu/iconv"
"github.com/saintfish/chardet"
)
// validEncodings is the intersection of types supported by chardet and iconv (ISO-8859-8-I is the only format not recognised by iconv)
var validEncodings = []string{
"Big5",
"EUC-JP", "EUC-KR",
"ISO-2022-JP", "ISO-2022-... |
/*
This module consist of cache implementation of cache
and has global variable that will be require to access
the access the cache of Routing server.
*/
package servercac
import "github.com/sirupsen/logrus"
// This function permit us to initialize various cache related
// variable at the start of the go subroutine... |
package main
import (
"fmt"
"github.com/pkg/profile"
)
func main() {
defer profile.Start(profile.MemProfile, profile.ProfilePath(".")).Stop()
fmt.Println("start")
new()
add()
remove()
fmt.Println("end")
}
func exec() {
new()
add()
remove()
}
var m map[int64]struct{}
func new() {
m = make(map[int64]st... |
package model
type Payload struct {
Payload string `json:"payload"`
}
|
package equinix
import (
"context"
"fmt"
"github.com/equinix/ne-go"
"github.com/hashicorp/go-cty/cty"
"github.com/hashicorp/terraform-plugin-sdk/v2/diag"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/validation"
)
var networkSSHUserSchemaName... |
package types
import (
"fmt"
"strings"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
configv1 "github.com/openshift/api/config/v1"
"github.com/openshift/installer/pkg/ipnet"
"github.com/openshift/installer/pkg/types/alibabacloud"
"github.com/openshift/installer/pkg/types/aws"
"github.com/openshift/installer/... |
package DeviceAPI
import b64 "encoding/base64"
type JPush struct {
Authorization string
Device
Push//用于推送
}
func NewJPush(appKey, masterSecrect string) (*JPush) {
authorization := "Basic " + b64.StdEncoding.EncodeToString([]byte(appKey+":"+masterSecrect))
return &JPush{
Authorization: authorization,
Device:... |
package log
import "fmt"
func Log(s string) {
fmt.Println(s)
}
|
package main
import (
"database/sql"
"fmt"
_ "github.com/mattn/go-sqlite3"
"log"
"os"
"strconv"
)
type DbFunc func(Db *sql.DB)
//TODO add indexes
func main() {
BackendDbSchema := []DbFunc{
func(Db *sql.DB) {
Db.Exec(`CREATE TABLE GPSRecords (
ID INTEGER PRIMARY KEY AUTOINCREMENT,
Message TEXT... |
package foo
import (
"context"
"net/http"
"strings"
kithttp "github.com/go-kit/kit/transport/http"
"github.com/pkg/errors"
)
type ResStatus string
var ResponseMessage = map[ResStatus]int{
Invalid: 400,
}
const (
Invalid ResStatus = "invalid"
)
func (c ResStatus) String() string {
return string(c)
}
func ... |
package ws
import (
"fmt"
"net/http"
"github.com/gorilla/websocket"
)
const wsReadBufferSize = 1024
const wsWriteBufferSize = 1024
type Client struct {
conn *websocket.Conn
}
func UpgradeConnection(w http.ResponseWriter, req *http.Request, responseHeader http.Header) (*Client, error) {
conn, err := websocket.... |
package typeInfo
import (
"github.com/graphql-go/graphql/language/ast"
)
// TypeInfoI defines the interface for TypeInfo Implementation
type TypeInfoI interface {
Enter(node ast.Node)
Leave(node ast.Node)
}
|
// 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 in writing... |
// Copyright 2021 Clivern. All rights reserved.
// Use of this source code is governed by the MIT
// license that can be found in the LICENSE file.
package cmd
import (
"fmt"
"os"
"github.com/spf13/cobra"
)
var config string
var rootCmd = &cobra.Command{
Use: "peanut",
Short: `🐺 Deploy Databases and Services... |
package main
import (
"fmt"
)
type TreeNode struct {
Val int
Left *TreeNode
Right *TreeNode
}
// 想法:
// 其实就是一个先序遍历
func tree2str(t *TreeNode) string {
st := []*TreeNode{}
st = append(st, t)
nums := []int{}
for len(st) > 0 {
len := len(st)
cur := st[len-1]
nums = append(nums, cur.Val)
st = st[:le... |
package defaults
import (
"testing"
"github.com/stretchr/testify/assert"
"github.com/openshift/installer/pkg/types/ovirt"
)
func defaultPlatform() *ovirt.Platform {
return &ovirt.Platform{
NetworkName: DefaultNetworkName,
AffinityGroups: []ovirt.AffinityGroup{
defaultComputeAffinityGroup(),
defaultCon... |
package state
import "fmt"
const (
SMALL = "small"
SUPER = "super"
FIRE = "fire"
DIE = "die"
)
// Mario is the game role
type Mario interface {
State() string
MeetMushroom(*MarioContext)
MeetFireFlower(*MarioContext)
MeetMonster(*MarioContext)
}
type defaultMario struct{}
func (*defaultMario) State() st... |
package main
import "fmt"
import "log"
import "net/http"
import "io/ioutil"
import "golang.org/x/net/html"
func main() {
resp, err := http.Get("http://www.zhihu.com/")
if err != nil {
log.Fatal(err)
}
defer resp.Body.Close()
body, err := ioutil.ReadAll(resp.Body)
fmt.Printf("%q", body)
z := html.NewTokenizer... |
package user
import (
"bytes"
"database/sql"
"encoding/json"
"fmt"
"strings"
// Postgresql Driver
_ "github.com/lib/pq"
)
// User is a modle of record.
type User struct {
ID int `json:"id"`
Username string `json:"username"`
Loginid string `... |
package main
import (
"fmt"
"github.com/glassechidna/trackiam/generator"
"os"
)
func main() {
if len(os.Args) == 1 {
usage()
}
switch os.Args[2] {
case "generate":
generator.Generate()
case "publish":
generator.Publish()
default:
usage()
}
}
func usage() {
fmt.Printf("usage: %s generate|publish\n... |
package main
import (
"math/rand"
)
type Generator struct {
minID uint64
maxID uint64
checksumLength int
src rand.Source
rand *rand.Rand
indices []int
pos int
}
type Batch struct {
IDs []uint64
Checksums map[uint64][]byte
}
func newGenerator(minID, maxID uint64, checksumLeng... |
package handler
import (
"fmt"
"memoapp/internal/database"
"memoapp/model"
"log"
"github.com/labstack/echo/v4"
)
type (
// MemoHandler メモ用ハンドラー
MemoHandler struct {
HasCache bool
Client database.Client
echo *echo.Echo
}
EndPointHandler func(c echo.Context) ([]byte, error)
)
var (
pkgName = ... |
package controller
import (
"net/http"
"github.com/gin-gonic/gin"
)
func Home(c *gin.Context) {
c.JSON(http.StatusOK, gin.H{
"code": 0,
"msg": "service running",
})
}
|
package server
import (
"bytes"
"context"
"testing"
"github.com/danielkvist/botio/proto"
"github.com/golang/protobuf/ptypes/empty"
)
func TestAddCommand(t *testing.T) {
tt := []struct {
name string
command *proto.BotCommand
expectedToFail bool
}{
{
name: "without command",
},
... |
package main
import "fmt"
func fib(n int) int {
thesum := 0
a := 1
b := 1
for a < n {
if a%2 == 0 {
thesum = thesum + a
}
a, b = b, a+b
}
return thesum
}
func main() {
fmt.Println(fib(4000000))
} |
package main
import (
"net/http"
"net/http/httptest"
"testing"
"time"
)
/*
Wraping up
* select
* Helps you wait on multiple channels.
* Sometimes you'll want to include time.
After in one of your cases to prevent your system blocking forever.
* httptest
* A convenient way of creating test servers... |
package main
import (
"os"
"bufio"
"errors"
"fmt"
)
func writeFile(filename string) {
file,err := os.Create(filename)
if err!=nil {
panic(err)
}
defer file.Close()
writer := bufio.NewWriter(file)
defer writer.Flush()
}
// 入口函数
func main() {
fmt.Println("who are u...");
errors.New("this is customer er... |
package test_string
import (
"fmt"
"github.com/golang/example/stringutil"
)
func ExampleReverse() {
fmt.Println(stringutil.Reverse("HOLA"))
// Output: ALOH!
} |
package microsvc
import (
"sync"
"github.com/go-kit/kit/log"
"github.com/hashicorp/consul/api"
"errors"
"github.com/hathbanger/microsvc-base/pkg/microsvc/models"
)
const (
// ServiceName - name of the service
ServiceName = "microsvc-base"
)
var (
// ErrMarshal - error for UnMarshalling
ErrMarshal = error... |
package main
import "fmt"
//example function 1
func func1(a int, b int) int {
return a * b
}
//example function 2
func func2(a, b int) int {
return a * b
}
//example function 3
func func3(a, b int) (int, int) {
sum := a + b
mul := a * b
return sum, mul
}
//example function 4
func func4(a, b int) (sum, mul int... |
package main
import (
"bufio"
"bytes"
"encoding/json"
"flag"
"fmt"
"io/ioutil"
"log"
"math"
"math/rand"
"net/http"
"os"
"sort"
"strings"
"sync"
"time"
)
var (
numUser = flag.Int("numuser", 1, "number of users hitting simultaneously")
numSec = flag.Float64("numsec", 10, "number nu... |
package main
import "fmt"
import "time"
func main() {
var c1 = make(chan string)
var c2 = make(chan string)
go func() {
for {
c1 <- "from 1"
time.Sleep(time.Second * 3)
}
}()
go func() {
for {
c2 <- "from 2"
time.Sleep(time.Second * 2)
}
}()
go func() {
i := 0
for {
select {
ca... |
package main
import (
"bytes"
"flag"
"fmt"
"io/ioutil"
"log"
"net/http"
"os"
"strconv"
"time"
"github.com/garyburd/redigo/redis"
)
func getRedisConnect(redisURL string) redis.Conn {
var c, e = redis.DialURL(redisURL)
if e != nil {
log.Fatal(e)
return nil
}
return c
}
func doGetClientCount(c redi... |
package main
import (
"fmt"
"math/rand"
"time"
)
func main() {
v, error := searchTimeout("test", time.Second*8)
if error != nil {
fmt.Println("time out")
}
fmt.Println(v)
}
func searchTimeout(kw string, t time.Duration) (string, error) {
select {
case v := <-mongo(kw):
return v, nil
case v := <-elec(kw... |
package cmd
import (
"fmt"
"strconv"
"amru.in/cli/db"
"github.com/spf13/cobra"
)
// doCmd represents the do command
var doCmd = &cobra.Command{
Use: "do",
Short: "Marks the to-do tasks as complete",
Run: func(cmd *cobra.Command, args []string) {
var idx []int
for _, val := range args {
id, err := s... |
package main
import (
"fmt"
"sort"
)
// 40. 组合总和 II
// 给定一个数组 candidates 和一个目标数 target ,找出 candidates 中所有可以使数字和为 target 的组合。
// candidates 中的每个数字在每个组合中只能使用一次。
// 说明:
// 所有数字(包括目标数)都是正整数。
// 解集不能包含重复的组合。
// https://leetcode-cn.com/problems/combination-sum-ii/
func main() {
fmt.Println(combinationSum2([]int{... |
package repository
import "github.com/majid-cj/go-docker-mongo/domain/entity"
// MemberRepository ...
type MemberRepository interface {
CreateMember(*entity.Member) (*entity.Member, error)
DeleteMember(string) error
GetMembers() ([]entity.Member, error)
GetMember(string) (*entity.Member, error)
GetMembersByType(... |
/*
Description
We'll call the consecutive distance rating of an integer sequence the sum of the distances between consecutive integers.
Consider the sequence 1 7 2 11 8 34 3. 1 and 2 are consecutive integers, but their distance apart in the sequence is 2.
2 and 3 are consecutive integers, and their distance is 4. The... |
package main
import (
"io/ioutil"
"os"
"strings"
smartling "github.com/Smartling/api-sdk-go"
"github.com/reconquest/hierr-go"
)
func readFilesFromStdin() ([]smartling.File, error) {
lines, err := ioutil.ReadAll(os.Stdin)
if err != nil {
return nil, hierr.Errorf(
err,
"unable to read stdin",
)
}
v... |
/**
* Hastie - Static Site Generator
* https://github.com/mkaz/hastie
*/
package main
import (
"bytes"
"flag"
"fmt"
"io/ioutil"
"os"
"os/exec"
"path/filepath"
"strings"
"text/template"
"time"
"github.com/mkaz/hastie/pkg/logger"
"github.com/mkaz/hastie/pkg/utils"
)
var log logger.Logger
var config Con... |
package queue
type Queue interface {
EnQueue(interface{})
DeQueue()interface{}
} |
package rsvc
import (
"fmt"
"sort"
)
type SvmServices struct {
services map[uint8]*ServiceOrder
}
func NewSvmServices() *SvmServices {
svs := new(SvmServices)
svs.services = map[uint8]*ServiceOrder{}
return svs
}
func (svs *SvmServices) AddService(service InidService) {
if _, so := svs.services[service.GetSe... |
// I'm sure programs already exist to do this, but this is my implementation of a hash-based integrity checker for downloaded binaries, to encourage me to double check more often. - vkraven
// Version 0.2 - SmartChkk implemented
// SmartChkk allows the checksums to be generated only when required. This makes chkk per... |
package info
// generated from http://mervine.net/json2struct
type CollectionNameAndSize struct {
Name string `json:"name"`
TotalStorageSize float64 `json:"totalStorageSize"`
}
type WorkspaceInfo struct {
ApiHalted interface{} `json:"apiHalted"`
Collections []CollectionNameAndSize `json:"collections... |
// Copyright 2021 Clivern. All rights reserved.
// Use of this source code is governed by the MIT
// license that can be found in the LICENSE file.
package definition
import (
"fmt"
"strings"
"testing"
"github.com/franela/goblin"
)
// TestUnitMemcached test cases
func TestUnitMemcached(t *testing.T) {
g := gob... |
package grpc
import (
"context"
"log"
"net"
"github.com/BENSARI-Fathi/cni/v1/pb"
"google.golang.org/grpc"
)
var socketFile = "/tmp/my-ipam.sock"
func UnixConnect(context.Context, string) (net.Conn, error) {
unixAddress, _ := net.ResolveUnixAddr("unix", socketFile)
conn, err := net.DialUnix("unix", nil, unixA... |
package docker
import (
"context"
"encoding/json"
"io/ioutil"
"os"
"path/filepath"
"testing"
"github.com/devspace-cloud/devspace/pkg/util/fsutil"
"github.com/docker/docker/api/types"
"github.com/docker/docker/api/types/registry"
dockerclient "github.com/docker/docker/client"
"gopkg.in/yaml.v2"
"gotest.to... |
package methods
import (
"fmt"
"testing"
)
func TestPointString(t *testing.T) {
p := Point{X: 300, Y: 60}
got := fmt.Sprintf("%v", p)
want := "point: x=300, y=60"
if got != want {
t.Fatalf("got %q, expected %q", got, want)
}
}
func TestPointGetX(t *testing.T) {
p := Point{X: 100, Y: 200}
got := p.GetX()
... |
package main
import (
"fmt"
"strconv"
)
func StartApp11() {
fmt.Println("==============StartApp11==============")
//test1101()
test1102()
}
func test1101() {
number, _ := strconv.Atoi("21")
fmt.Println(number)
str := strconv.Itoa(12)
fmt.Printf("%T, %s\n", str, str)
parseBool, _ := strconv.ParseBool("tr... |
package gin
//GetInitHandle ..
func GetInitHandle() HandlerFunc {
return func(c *Context) {
//init the Context
// c.Context = context.Background()
}
}
|
package handlers
import (
"encoding/json"
"fmt"
"net/http"
"time"
"github.com/esrever001/toyserver/db"
"github.com/julienschmidt/httprouter"
)
type EventsAddRequest struct {
User string
Type string
Time *time.Time
Notes string
Image string
}
type EventsAddHandler struct {
Database *db.Database
}
fun... |
package main
import (
"log"
"github.com/royaloaklabs/super-genki-db/db"
"github.com/royaloaklabs/super-genki-db/freq"
"github.com/royaloaklabs/super-genki-db/jmdict"
)
func main() {
freq.BuildFrequencyData()
err := jmdict.Parse()
if err != nil {
log.Fatal(err)
}
databaseEntries := make([]*db.SGEntry, 0)... |
package owm
import (
"bufio"
"encoding/csv"
"fmt"
"io"
"os"
"path/filepath"
"strconv"
"github.com/tada3/triton/config"
)
const (
csvFilePath = "weather/owm/csv/weather_condition.csv"
unknown = "不明"
)
var (
wcMap = map[int64]string{}
)
func init() {
homeDir := config.GetHomeDir()
fp := filepath.Joi... |
package convert
import (
Model "MainApplication/internal/Letter/LetterModel"
pb "MainApplication/proto/MailService"
)
func ModelToProto(letter Model.Letter) *pb.Letter {
pbLetter := pb.Letter{
Sender: letter.Sender,
Receiver: letter.Receiver,
Lid: letter.Id,
DateTime: uint64(letter.DateTime),
... |
package fs
// INode node interface of filesystem
type INode interface {
Print(string)
Clone() INode
}
|
package resource
import (
"os"
"github.com/chronojam/aws-pricing-api/types/schema"
"github.com/olekukonko/tablewriter"
)
func GetManageBlockChain() {
mgmtblockchain := &schema.AmazonManagedBlockchain{}
err := mgmtblockchain.Refresh()
if err != nil {
panic(err)
}
table := tablewriter.NewWriter(os.Stdout)
... |
/*
Go functions may be closures. A closure is a function value that references variables from outside its body
*/
package main
import "fmt"
func adder() func(int) int {
sum := 0
return func(x int) int {
sum += x
return sum
}
}
func muller() func(i int) int {
x := 2
return func(a int) int {
x *= a
return... |
package main
import (
"strings"
"github.com/corymurphy/adventofcode/shared"
)
type Instruction int
const (
Noop Instruction = 0
Addx Instruction = 1
Unknown Instruction = -1
)
func (i Instruction) String() string {
switch i {
case Noop:
return "noop"
case Addx:
return "addx"
default:
return "U... |
// This file was generated for SObject LightningUsageByPageMetrics, API Version v43.0 at 2018-07-30 03:47:17.340680714 -0400 EDT m=+3.683425364
package sobjects
import (
"fmt"
"strings"
)
type LightningUsageByPageMetrics struct {
BaseSObject
Id string `force:",omitempty"`
MetricsDate string `forc... |
package main
import (
"math"
"time"
cases "github.com/envoyproxy/protoc-gen-validate/tests/harness/cases/go"
other_package "github.com/envoyproxy/protoc-gen-validate/tests/harness/cases/other_package/go"
sort "github.com/envoyproxy/protoc-gen-validate/tests/harness/cases/sort/go"
yet_another_package "github.com... |
package main
import (
"errors"
"net/http"
"os"
"regexp"
"strconv"
"github.com/naelyn/go-docker-registry/Godeps/_workspace/src/github.com/golang/glog"
"github.com/naelyn/go-docker-registry/Godeps/_workspace/src/github.com/gorilla/mux"
"github.com/naelyn/go-docker-registry/auth"
"github.com/naelyn/go-docker-re... |
package stackdriver
import (
"context"
"encoding/json"
"fmt"
"reflect"
"strings"
"time"
"google.golang.org/api/option"
"cloud.google.com/go/logging"
"cloud.google.com/go/logging/logadmin"
"github.com/egnyte/ax/pkg/backend/common"
"google.golang.org/api/iterator"
)
const QueryLogTimeout = 20 * time.Second... |
package flowcontrol
import (
"time"
. "github.com/onsi/ginkgo"
. "github.com/onsi/gomega"
"gx/ipfs/QmU44KWVkSHno7sNDTeUcL4FBgxgoidkFuTUyTXWJPXXFJ/quic-go/internal/congestion"
"gx/ipfs/QmU44KWVkSHno7sNDTeUcL4FBgxgoidkFuTUyTXWJPXXFJ/quic-go/internal/protocol"
"gx/ipfs/QmU44KWVkSHno7sNDTeUcL4FBgxgoidkFuTUyTXWJPXXF... |
package main
import(
"log"
"net"
"context"
"app/utils"
"app/proto"
"app/models"
"google.golang.org/grpc"
)
type server struct{
proto.UnimplementedBookProfilesServer
}
func (*server) Create(c context.Context, req *proto.CreateRequest)(*proto.MainResponse, error){
db, err := utils.DBConnection()
if err !... |
// Manual
// https://developer.github.com/apps/building-oauth-apps/authorizing-oauth-apps/
package oauth_github
import (
"fmt"
"net/http"
"strings"
"github.com/a1div0/oauth"
"net/url"
"io/ioutil"
"encoding/json"
"time"
)
type OAuthGitHub struct {
ClientId string
ClientSecret s... |
// Copyright (c) 2020 Siemens AG
//
// Permission is hereby granted, free of charge, to any person obtaining a copy of
// this software and associated documentation files (the "Software"), to deal in
// the Software without restriction, including without limitation the rights to
// use, copy, modify, merge, publish, di... |
package main
import (
"bufio"
"encoding/gob"
"fmt"
"io/ioutil"
"net"
"os"
"os/exec"
"time"
hyperclient "github.com/Cloud-Foundations/Dominator/hypervisor/client"
imgclient "github.com/Cloud-Foundations/Dominator/imageserver/client"
"github.com/Cloud-Foundations/Dominator/lib/constants"
"github.com/Cloud-F... |
package main
import "strings"
func wordsTyping(sentence []string, rows, cols int) int {
joinedSentence := strings.Join(sentence, " ")
sentenceNo, rowsUsed := computeParagraph(joinedSentence, rows, cols)
completeParagraphSentences := (rows / rowsUsed) * sentenceNo
var remainingSentences int
remainingSentences, r... |
package main
const cardsInDeck = 52
var cardSuits []string = []string{"spades", "diamonds", "clubs", "hearts"}
var cardValues []string = []string{"ace", "king", "queen", "jack", "10", "9", "8", "7", "6", "5", "4", "3", "2"}
var hands []string = []string{"royalFlush", "straightFlush", "fourOfAkind", "fullHouse", "flus... |
package models
import (
"github.com/alehano/gobootstrap/sys/cmd"
"github.com/alehano/gobootstrap/sys/db"
"github.com/spf13/cobra"
)
func init() {
cmd.RootCmd.AddCommand(&cobra.Command{
Use: "init_db",
Short: "Init all DB",
Long: "Init all DB tables with DBInitter interface being registered in sys/db",
R... |
package store
import (
"context"
"time"
"github.com/ankurs/Feed/Feed/service/store/cassandra"
"github.com/ankurs/Feed/Feed/service/store/db"
"github.com/ankurs/Feed/Feed/service/store/redis"
)
type RegisterRequest interface {
GetLastName() string
GetFirstName() string
GetUserName() string
GetPassword() stri... |
package confformat
import "fmt"
const (
exampleTOML = `name="Example1"
age=99
`
exampleJSON = `{"name":"Example2","age":98}`
exampleYAML = `name: Example3
age: 97
`
)
// UnmarshalAll takes data in various formats
// and converts them into structs
func UnmarshalAll() error {
t := TOMLData{}
j := JS... |
package admin
import (
"blog/app/models"
"blog/app/web/responses"
)
type SystemConfigResponse struct {
}
func (r SystemConfigResponse) List(models []*models.SysConfig) (list responses.Results) {
for _, model := range models {
list = append(list, r.Item(model))
}
return list
}
func (r SystemConfigResponse) It... |
package models
import (
"fmt"
"github.com/astaxie/beego/orm"
"strings"
"time"
"tokensky_bg_admin/common"
"tokensky_bg_admin/conf"
"tokensky_bg_admin/utils"
)
//查询的类
type BorrowLimitingQueryParam struct {
BaseQueryParam
StartTime int64 `json:"startTime"` //开始时间
EndTime int64 `json:"endTime"` //截止时间... |
package recv
import (
"github.com/scottshotgg/proximity/pkg/listener"
)
type (
// Recv ...
Recv interface {
Open() error
Close() error
Attach(lis listener.Listener) error
}
)
|
package usecases
import (
"fmt"
"time"
"github.com/michaldziurowski/tech-challenge-time/server/timetracking/domain"
)
type Service interface {
StartSession(userId string, name string, startedAt time.Time) (int64, error)
StopSession(userId string, sessionId int64, stoppedAt time.Time) error
ResumeSession(userId... |
/*
# -*- coding: utf-8 -*-
# @Author : joker
# @Time : 2021/10/25 9:07 上午
# @File : lt_146_lru.go
# @Description :
# @Attention :
*/
package offer
type node struct {
prev *node
next *node
value int
}
type DoubleLinkedList struct {
head *node
tail *node
}
type LRUCache struct {
// key value
dataM map[int]*no... |
package main
import (
"fmt"
)
func main() {
s := "Olá, mundo! 坔"
sb := []byte(s)
fmt.Printf("%v\n%T\n", s, s)
fmt.Printf("%v\n%T\n", sb, sb)
// por caracter
for _, v := range s {
fmt.Printf("%b - %v - %T - %#U - %#x\n", v, v, v, v, v)
}
fmt.Println("")
// por byte
for i := 0; i < len(s); i++ {
fmt.... |
package main
import (
"fmt"
"log"
"os"
"github.com/urfave/cli/v2"
)
const version = "0.1.0"
var revision = "HEAD"
func main() {
if err := newApp().Run(os.Args); err != nil {
exitCode := 1
if excoder, ok := err.(cli.ExitCoder); ok {
exitCode = excoder.ExitCode()
}
log.Fatal("error", err.Error())
o... |
package omg
import (
"net/http"
"github.com/gorilla/mux"
)
func router() *mux.Router {
router := mux.NewRouter().StrictSlash(true)
router.HandleFunc("/api/v1/privatestorage/file", uploadLocalFile).Methods(http.MethodPut)
router.HandleFunc("/api/v1/privatestorage/file", getFileInfo).Methods(http.MethodGet)
rout... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.