text stringlengths 11 4.05M |
|---|
package printer
type PrinterContext struct {
outFile string
p Printer
name string
class int // 1 = client 2 = server
}
func (self *PrinterContext) Start(g *Globals) bool {
log.Infof("[%s] %s\n", self.name, self.outFile)
bf := self.p.Run(g, self.class)
if bf == nil {
return false
}
return bf.... |
package middleware
import "net/http"
//User represents a user of the system.
type User struct {
ID int
UserName string
}
//GetAuthenticatedUser is a function that returns the
//current user given a request, or nil if the user is
//not currently authenticated. This is just for demo
//purposes: normally you wo... |
package mbr
import (
"fmt"
"os"
"os/exec"
)
func decode(file *os.File) (*Mbr, error) {
var mbr Mbr
if _, err := file.ReadAt(mbr.raw[:], 0); err != nil {
return nil, err
}
if mbr.raw[0x1FE] == 0x55 && mbr.raw[0x1FF] == 0xAA {
return &mbr, nil
}
return nil, nil
}
func read32LE(address []byte) uint64 {
re... |
package index
import (
"log"
"testing"
"github.com/stretchr/testify/assert"
)
func Test_newIndexTree_generates_an_indexTree_from_a_path(t *testing.T) {
testDir := "test_fixtures/root"
actual, err := newIndexTree(testDir)
if err != nil {
log.Println(err)
t.FailNow()
}
expected := section{
title: "Root",... |
package plumber
import (
"context"
"time"
"github.com/batchcorp/plumber-schemas/build/go/protos/encoding"
"github.com/batchcorp/plumber-schemas/build/go/protos/records"
"github.com/batchcorp/plumber/backends"
"github.com/batchcorp/plumber/validate"
"github.com/batchcorp/plumber/writer"
"github.com/pkg/errors"... |
package utils
import (
"math"
)
const _DELTA = 0.000001
func step(z, x float64) float64 {
return z - (z*z-x)/(2*z)
}
func NeotainSqrt(x float64) float64 {
z := 1.0
for newZ := step(z, x); math.Abs(newZ-z) > _DELTA; {
z = newZ
newZ = step(z, x)
}
return z
}
|
package day02
import (
"fmt"
"strconv"
"strings"
)
type passwordRule struct {
Letter string
MinOccurrences int
MaxOccurrences int
}
func (r *passwordRule) EvaluateLegacyRule(input string) bool {
actualOccurrences := strings.Count(input, r.Letter)
return actualOccurrences >= r.MinOccurrences && actual... |
// DO NOT EDIT. This file was generated by "github.com/frk/gosql".
package testdata
import (
"github.com/frk/gosql"
"github.com/frk/gosql/internal/testdata/common"
)
func (q *SelectWithJoinBlockSliceQuery) Exec(c gosql.Conn) error {
const queryString = `SELECT
u."id"
, u."email"
, u."full_name"
, u."created_a... |
// 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 types
import (
"database/sql/driver"
"fmt"
"strings"
"golang.org/x/text/language"
)
// Language represents an ISO639 language. Its SQL type could be varchar(3).
type Language struct {
base language.Base
}
// NewLanguage creates a language from language.Base
func NewLanguage(base language.Base) Language... |
package main
import (
"fmt"
"math"
"unsafe"
)
func main() {
var num int = 10
fmt.Printf("num = %v num 是 %T", num, num)
fmt.Println()
var num2 = 12
fmt.Println(unsafe.Sizeof(num2))
var a1 int16 = 10
var a2 int32 = 12
var a3 = int32(a1) + a2
fmt.Println(a3)
var n1 int16 = 130
fmt.Println(int8(n1))
fmt... |
// package main
// import (
// "fmt"
// "log"
// "net/http"
// "github.com/gorilla/mux"
// "github.com/jinzhu/gorm"
// _ "github.com/jinzhu/gorm/dialects/postgres"
// "github.com/rs/cors"
// )
// var db *gorm.DB
// var err error
// type Admindetails struct {
// gorm.Model
// Name string
// Email string
/... |
package middlewares
import (
"github.com/valyala/fasthttp"
)
// LogRequest provides trace logging for all requests.
func LogRequest(next fasthttp.RequestHandler) fasthttp.RequestHandler {
return func(ctx *fasthttp.RequestCtx) {
autheliaCtx := &AutheliaCtx{RequestCtx: ctx}
logger := NewRequestLogger(autheliaCtx)... |
// Copyright (c) 2020 TomoChain
package services
import (
"context"
"encoding/hex"
"github.com/tomochain/tomochain"
"github.com/tomochain/tomochain-rosetta-gateway/common"
tc "github.com/tomochain/tomochain-rosetta-gateway/tomochain-client"
tomochaincommon "github.com/tomochain/tomochain/common"
"math/big"
"... |
// DRUNKWATER TEMPLATE(add description and prototypes)
// Question Title and Description on leetcode.com
// Function Declaration and Function Prototypes on leetcode.com
//748. Shortest Completing Word
//Find the minimum length word from a given dictionary words, which has all the letters from the string licensePlate. S... |
package controllers
import (
"github.com/goadesign/goa"
)
var (
duplicatedEmailErr = goa.NewErrorClass("duplicated_email", 1000)
)
func unexpectedError(service *goa.Service, err error) error {
service.LogError("Unexpected error", "err", err)
return goa.ErrInternal("unexpected error")
}
|
// Copyright (c) 2013-2017 The btcsuite developers
// Copyright (c) 2016 The Decred developers
// Use of this source code is governed by an ISC
// license that can be found in the LICENSE file.
package legacyrpc
import (
"bytes"
"encoding/base64"
"encoding/hex"
"encoding/json"
"errors"
"fmt"
"sync"
"time"
"... |
package main
import (
"encoding/xml"
"fmt"
"io/ioutil"
"os"
"strings"
"util"
"github.com/tidwall/gjson"
)
type Spider struct {
Path string
Chs []chan int
UrlList, FileName []string
An util.Analysis
}
//抓取API类接口
func (s *Spider) getAPI() {
for i, v := range s.Url... |
package vips
import (
"fmt"
"github.com/sherifabdlnaby/bimg"
cfg "github.com/sherifabdlnaby/prism/pkg/config"
"github.com/sherifabdlnaby/prism/pkg/payload"
)
type rotate struct {
Raw rotateRawConfig `mapstructure:",squash"`
angle cfg.Selector
}
type rotateRawConfig struct {
Angle string
}
func (o *rotate)... |
package main
import (
"log"
"net/http"
"storage/conf"
"storage/objects"
"storage/util/heartBeat"
"strconv"
)
func main() {
conf.InitConfig()
go heartBeat.StartHeartBeat()
go heartBeat.StartLocate()
http.HandleFunc("/objects/",objects.Handler)
log.Fatal(http.ListenAndServe(":" + strconv.Itoa(conf.GetConfig... |
package main
import (
"fmt"
)
func maxSlidingWindow(nums []int, k int) []int {
if len(nums) == 0 || len(nums) < k {
return nil
}
//存储下标
window := make([]int, 0, k)
res := make([]int, 0, len(nums)-k+1)
for i, v := range nums {
for len(window) != 0 && nums[window[len(window)-1]] <= v {
window = window[0 ... |
package main
import (
"embed"
"fmt"
"text/template"
"github.com/authelia/authelia/v4/internal/templates"
)
//go:embed templates/*
var templatesFS embed.FS
var (
tmplCodeConfigurationSchemaKeys = template.Must(newTMPL("internal_configuration_schema_keys.go"))
tmplGitHubIssueTemplateBug = template.Must(new... |
/*
* Copyright (c) 2020 - present Kurtosis Technologies LLC.
* All Rights Reserved.
*/
package services
/*
The identifier used for services with the network.
*/
type ServiceID string
/*
The developer should implement their own use-case-specific interface that extends this one
*/
type Service interface {
GetServ... |
package osversion
import (
"io/ioutil"
"os"
"testing"
)
func TestVersion(t *testing.T) {
tmpFile, err := ioutil.TempFile("", "os-release")
if err != nil {
t.Fatal(err)
}
defer os.Remove(tmpFile.Name())
versionString := "CentOS release 8.8 (Final) "
_, err = tmpFile.Write([]byte(versionString))
if err != ... |
package cli
import (
"encoding/json"
"fmt"
"io"
"net/http"
"os"
"github.com/pkg/errors"
"github.com/spf13/cobra"
)
func newDumpCmd() *cobra.Command {
result := &cobra.Command{
Use: "dump",
Short: "dump internal Tilt state",
Long: `Dumps internal Tilt state to stdout.
Intended to help Tilt developers... |
package nullable
import (
"database/sql"
"testing"
)
func TestNullableString(t *testing.T) {
for _, unit := range []struct {
value *String
expected string
}{
{&String{sql.NullString{"aquas", true}}, "\"aquas\""},
{&String{sql.NullString{"aquas", false}}, "null"},
{&String{sql.NullString{"", false}}, ... |
package types
import "time"
const (
TwentySeconds = 20 * time.Second
SixtyHours = 60 * time.Hour
Day = 24 * time.Hour
TwoDays = 2 * Day
ThreeDays = 3 * Day
FiveDays = 5 * Day
Week = 7 * Day
)
|
package knot
import "testing"
func TestSimpleKnot(t *testing.T) {
expected := []int{0,1,2,3,4}
knot := New(5)
if !IntArrayEquals(knot.numbers, expected) {
t.Errorf("knot got messed up %v should have been %v", knot.numbers, expected)
}
knot = Twist(knot, 3)
expected = []int{2, 1, 0, 3, 4}
if !IntArr... |
package dao
import (
"errors"
"github.com/golang/glog"
"qipai/model"
)
var Game gameDao
type gameDao struct{
}
func (this *gameDao) GetGames(roomId uint, current int) (games []model.Game, err error) {
if Db().Where(&model.Game{RoomId: roomId, Current: current}).Find(&games).Error != nil {
err = errors.New("获取... |
package tokenizer
import (
"fmt"
"unicode/utf8"
"github.com/soundTricker/kagome/dic"
)
const (
_MAX_INT32 = 1<<31 - 1
_MAX_UNKNOWN_WORD_LENGTH = 1024
_INIT_NODE_BUFFER_SIZE = 512
)
type lattice struct {
input []byte
list [][]*Node
output []*Node
pool *NodePool
udic *dic.UserDic
}
... |
// 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 driver
import (
"context"
"fmt"
"strings"
"time"
"github.com/clivern/peanut/core/util"
"github.com/spf13/viper"
"go.etcd.io/etcd/clientv3"
)
// Etcd dri... |
package leetcode
/*Write code to remove duplicates from an unsorted linked list.*/
/**
* Definition for singly-linked list.
* type ListNode struct {
* Val int
* Next *ListNode
* }
*/
func removeDuplicateNodes(head *ListNode) *ListNode {
mapList := make(map[int]int, 0)
cur, prv := head, head
for cur !... |
package hashtable
import (
"fmt"
"hash/fnv"
"sync"
"sync/atomic"
"unsafe"
"ustr"
)
// A hashtable with a lock-free Get()
type hashtable_i interface {
Get(key interface{}) (interface{}, bool)
Set(key interface{}, val interface{}) (interface{}, bool)
Del(key interface{})
}
type elem_t struct {
key inte... |
package controller
import (
"gopetstore/src/config"
"gopetstore/src/domain"
"gopetstore/src/service"
"gopetstore/src/util"
"log"
"net/http"
"path/filepath"
)
const (
signInFormFile = "signInForm.html"
registerFormFile = "registerForm.html"
accountFieldFile = "accountField.html"
editAccountFormFi... |
// Copyright 2023 Google LLC. 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 applica... |
package session
import (
"golang.org/x/net/context"
)
type HandlerFunc func(ctx context.Context, session Session, msgByte interface{}) (error, interface{})
func (hf HandlerFunc) Handle(ctx context.Context, session Session, msgByte interface{}) (error, interface{}) {
return hf(ctx, session, msgByte)
}
... |
package ziface
//把客户端数据包装成一个requst
type IRequest interface {
//得到当前连接
GetConnection() IConnection
//得到请求数据
GetData() string
}
|
package main
import (
"flag"
"log"
"time"
"github.com/bpostlethwaite/ahipbot/asana"
)
var bot *Hipbot
var web *Webapp
func main() {
flag.Parse()
bot = NewHipbot(*configFile)
// TODO: make this a goroutine to run the bot also
go launchWebapp()
bot.loadBaseConfig()
bot.registerPlugins()
asanaClient, err... |
//Package deployment provides a top-level API to control Kyma deployment and uninstallation.
package deployment
import (
"context"
"fmt"
"strings"
"time"
"github.com/kyma-incubator/hydroform/parallel-install/pkg/components"
"github.com/kyma-incubator/hydroform/parallel-install/pkg/config"
"github.com/kyma-incu... |
// +build integration
package integration
import (
"fmt"
"io/ioutil"
"os"
"strings"
"time"
)
const (
tmpTestFilePathDefault = "/tmp/gollum_test.log"
tmpTestFilePathFoo = "/tmp/gollum_test_foo.log"
tmpTestFilePathBar = "/tmp/gollum_test_bar.log"
tmpTestFilePathGlob0 = "/tmp/gollum_test_glob0.log"
... |
package handlers
import (
"net/http"
"github.com/saravase/golang_mux_swagger/plant-api/data"
)
// swagger:route POST /plant plants addPlant
// responses:
// 200: successContent
// 422: errorValidation
// 400: errorResponse
// AddPlant used to insert the new plant data into the datastore
func (plant *Plant) Add... |
package utility
import "Perekoter/models"
func NewError(text string) {
db := models.DB()
defer db.Close()
db.Create(&models.Error{
Text: text,
Active: true,
})
}
func ConfirmError(num int) {
db := models.DB()
defer db.Close()
var targetError models.Error
db.First(&targetError, num)
targetError.Activ... |
package rpc_01
type HelloService struct {
}
// 满足go语言的RPC规则:
// 1。 方法只能有两个可序列化的参数,其中第二个参数为指针类型
// 2。 并且返回一个error类型,同时必须是公开的方法
func (p *HelloService)Hello (request string,reply *string) error {
*reply="hello:"+request
return nil
}
|
package main
import (
"database/sql"
"fmt"
//_ "github.com/mattn/go-sqlite3"
_ "github.com/go-sql-driver/mysql"
)
const (
//insertItemQuery = "insert into items ('name', 'price', 'description') values (?,?,?)"
insertItemQuery = "insert into items (name, price, description) values (?,?,?)"
insertItemQuery2 = ... |
package local
import (
"encoding/json"
"errors"
"io/ioutil"
"os"
"path/filepath"
"github.com/10gen/realm-cli/internal/cloud/realm"
)
// AppData is the Realm app data
type AppData interface {
ConfigData() ([]byte, error)
ConfigVersion() realm.AppConfigVersion
ID() string
Name() string
Location() realm.Loca... |
package ebook
import (
"bytes"
"crypto/rand"
"encoding/json"
"fmt"
"io"
"io/ioutil"
"log"
"net/url"
"os"
"path"
"path/filepath"
"regexp"
"strings"
"text/template"
"github.com/lwllvyb/gktime2book/util"
"github.com/mattn/godown"
)
func newUUID() (string, error) {
uuid := make([]byte, 16)
n, err := i... |
package repositories
import (
"database/sql"
"errors"
"fmt"
"log"
"ocg-be/database"
"ocg-be/models"
)
type CollectionRepo struct {
}
func (*CollectionRepo) Count(search string) int64 {
var rows *sql.Rows
var err error
rows, err = database.DB.Query("SELECT COUNT(*) FROM collections WHERE name LIKE ?", searc... |
package memcache
import (
"bytes"
"github.com/valyala/ybc/bindings/go/ybc"
"testing"
"time"
)
func newCachingClientServerCache(t *testing.T) (cc *CachingClient, s *Server, cache ybc.Cacher) {
c, s, cache := newClientServerCache(t)
c.Start()
cc = &CachingClient{
Client: c,
Cache: newCache(t),
}
return
}
... |
package models
import (
"github.com/jinzhu/gorm"
)
// GALLERY - ERRORS
const (
ErrAccountIDRequired modelError = "models: account ID is required"
ErrTitleRequired modelError = "models: title is required"
)
var _ GalleryDB = &galleryGorm{}
type Gallery struct {
gorm.Model
AccountID uint `gorm:"not_null;i... |
package test_matchers
import (
"fmt"
"reflect"
"github.com/onsi/gomega/format"
"github.com/onsi/gomega/types"
"github.com/prometheus/client_golang/prometheus"
dto "github.com/prometheus/client_model/go"
)
func PrometheusMetric(expected prometheus.Metric) types.GomegaMatcher {
expectedMetric := &dto.Metric{}
... |
package main
import (
"fmt"
"encoding/json"
"net"
)
type Msgdata struct{
MsgType uint32 `json:"msg_type"`
Data uint32
}
func main() {
fmt.Println("server running")
localAddr, err := net.ResolveUDPAddr("udp", "127.0.0.1:8889")
if err != nil {
fmt.Println(err)
}
l, err1 := net.ListenUDP("udp", loca... |
package middleware
import (
"net/http"
"net/http/httputil"
"strings"
"github.com/gin-gonic/gin"
)
const (
DBMongoPool = "db_mongo_pool"
DBRedisPool = "redis_pool"
)
type Middleware struct{}
func (m Middleware) HandleAuthLevel(auth int, endpoint gin.HandlerFunc) []gin.HandlerFunc {
var rtn []gin.HandlerFunc
... |
package 结构调整
// ----------------- 先标记,再删除 -----------------
const removeFlag = 1000000000000
func removeLeafNodes(root *TreeNode, target int) *TreeNode {
markRemovedLeafNodes(root, target)
return removeMarkNode(root)
}
func removeMarkNode(root *TreeNode) *TreeNode {
if root == nil || root.Val == removeFlag {
re... |
package command
import (
"fmt"
"strconv"
"strings"
"time"
"github.com/jixwanwang/jixbot/channel"
)
type uptime struct {
cp *CommandPool
lastCheck time.Time
upComm *subCommand
}
func (T *uptime) Init() {
T.upComm = &subCommand{
command: "!uptime",
numArgs: 0,
cooldown: 30 * time.Seco... |
package data
import (
"errors"
"log"
"os"
"path"
"strings"
"sync"
"sync/atomic"
"time"
"github.com/bgokden/go-cache"
"github.com/bgokden/veri/annoyindex"
pb "github.com/bgokden/veri/veriservice"
)
type DataSource interface {
StreamSearch(datumList *pb.Datum, scoredDatumStream chan<- *pb.ScoredDatum, qu... |
package main
import "fmt"
func main() {
fmt.Println(foo(1, 2))
fmt.Println(foo(1, 2, 3))
aSlice := []int{1, 2, 3, 4}
fmt.Println(foo(aSlice...))
fmt.Println(foo())
}
func foo(n ...int) int {
min := 1
for _, v := range n {
if min > v {
min = v
}
}
return min
}
|
// Copyright 2022 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... |
// See the accompanying README.
// The Go compiler is pretty cool/smart!
package main
import (
"fmt"
)
func main() {
a := 20
b := 7
c := add(a, b)
fmt.Println(c)
}
func add(x, y int) int {
return x + y
}
|
package migrations
import (
"github.com/go-pg/migrations"
log "github.com/sirupsen/logrus"
)
func init() {
migrations.Register(func(db migrations.DB) error {
log.Info("migrate 20171010114409_create-nut-plugin")
_, err := db.Exec(`
CREATE TABLE users (
id BIGSERIAL PRIMARY KEY,
name... |
// This file is subject to a 1-clause BSD license.
// Its contents can be found in the enclosed LICENSE file.
package evdev
import "unsafe"
// Relative events describe relative changes in a property.
// For example, a mouse may move to the left by a certain
// number of units, but its absolute position in space is u... |
package types
import (
"fmt"
"strings"
blk "github.com/DynamoGraph/block"
param "github.com/DynamoGraph/dygparam"
slog "github.com/DynamoGraph/syslog"
"github.com/DynamoGraph/types/internal/db"
)
const (
logid = "types: "
)
type Ty = string // type
type TyAttr = string // type:attr
type AttrTy = string
... |
package pathfileops
import (
"strings"
"testing"
)
func TestFileHelper_GetPathFromPathFileName_01(t *testing.T) {
fh := FileHelper{}
commonDir := fh.AdjustPathSlash(".\\pathfilego\\003_filehelper\\common\\xt_dirmgr_01_test.go")
expectedDir := fh.AdjustPathSlash(".\\pathfilego\\003_filehelper\\common")
... |
package hasp
import (
"fmt"
"strings"
"github.com/rmcsoft/chanim"
"github.com/sirupsen/logrus"
)
func isTransitFrameSeries(frameSeries chanim.FrameSeries) bool {
// <AnimationName>_entry - transition frames to entry the animation
if strings.HasSuffix(frameSeries.Name, "_entry") {
return true
}
// <Animati... |
package build
import (
"bytes"
"io"
"time"
)
func send(w io.Writer, msg []byte) error {
_, err := w.Write(msg)
return err
}
func respond(w io.Writer, msg string) error {
buff := &bytes.Buffer{}
buff.WriteString(time.Now().Format("2006/01/02 15:04:05.000000000 MST"))
buff.WriteString(": ")
buff.WriteStrin... |
package main
import "fmt"
type Person struct {
name string
age int
}
/**
* created: 2019/7/15 13:06
* By Will Fan
*/
func main() {
var x Person
x.age = 12
var p *Person
p = new(Person)
p.age = 12
y := Person{
"bob",
13,
}
jim := Person{
name: "Jim",
}
pjohn := &Person{
name: "John",
}
f... |
package security
import (
"testing"
)
func TestStringCamelCase(t *testing.T) {
for _, v := range [][]string{
[]string{"AppleFish", "Apple Fish"},
[]string{"A fish head", "A Fish Head"},
[]string{"A.fish-head_cat", "A Fish Head Cat"},
[]string{"AteFishToday...Fun", "Ate Fish Today Fun"},
[]string{"Address... |
package main
import "fmt"
func main() {
var i, v interface{} = "Hello", 34
fmt.Printf("%#v %#v\n", i, v)
fmt.Printf("%T %T\n", i, v)
disp(4,"Hye",true)
}
func disp(i ...interface{}) {
fmt.Println(i)
}
|
package main
import "github.com/sashko/go-uinput"
func keyboardExample() {
keyboard, err := uinput.CreateKeyboard()
if err != nil {
return
}
defer keyboard.Close()
// Press left Shift key, press G, release Shift key
keyboard.KeyDown(uinput.KeyLeftShift)
keyboard.KeyPress(uinput.KeyG)
keyboard.KeyUp(uinput.... |
package command
import (
"github.com/codegangsta/cli"
)
var Flags = []cli.Flag{
cli.StringFlag{
Name: "p, provider",
Usage: "Path to provider for fetching secrets",
},
cli.StringFlag{
Name: "e, environment",
Usage: "Specify section/environment to parse from secrets.yaml",
},
cli.StringFlag{
Name: "... |
package main
const (
UNLOCK_CODE_SHOULD_BE_SPECIFIED = "Unlock code is required"
UNLOCK_CODE_IS_INVALID = "Sorry, that code is invalid"
UNLOCK_CODE_IS_ALREADY_USED = "Sorry, that code has already been used"
UNLOCK_SUCCESSFUL = "Great! Your account is unlocked."
)
type UnlockCommand stru... |
package handler
import (
"context"
"encoding/json"
"cloud.google.com/go/pubsub"
"github.com/line/line-bot-sdk-go/linebot"
"github.com/sh0e1/translation-konjac/internal/message"
"github.com/sh0e1/translation-konjac/pkg/datastore/resources"
"github.com/sh0e1/translation-konjac/pkg/language"
"github.com/sh0e1/t... |
package main
import (
"encoding/json"
"fmt"
"io/ioutil"
"net/http"
"testing"
"github.com/eonpatapon/contrail-gremlin/neutron"
"github.com/stretchr/testify/assert"
)
func makePortRequest(tenantID string, isAdmin bool, data RequestData) *http.Response {
return makeRequest("port", ListRequest, tenantID, isAdmin... |
/**
* @Time : 2020/9/16 4:34 PM
* @Author : solacowa@gmail.com
* @File : config
* @Software: GoLand
*/
package foo
import (
"strings"
"github.com/Unknwon/goconfig"
)
const (
SectionServer = "server"
SectionRedis = "redis"
SectionMysql = "mysql"
SectionService = "service"
SectionCors = "cors"
)
... |
/*
package game
модуль start_level
отвечает за отрисовку стартового меню.
*/
package game
import (
"github.com/JoelOtter/termloop"
)
//startLevel стартовый уровень игры
type startLevel struct {
termloop.Level
startMenu *startMenu
}
//startMenu объект стартовое окно
type startMenu struct {
*termloop.Text
}
//cr... |
// FindFileString
package DaeseongLib
import (
"bufio"
"flag"
"fmt"
"io/ioutil"
"os"
"path/filepath"
"regexp"
"strings"
"sync"
)
var FileItem map[string]string
func flags() (string, string) {
spath := flag.String("path", "C:\\Go\\src\\DaeseongLib\\lib", "Search Path")
skey := flag.String("key", "Split", ... |
package main
import (
"fmt"
"sync/atomic"
)
var n uint64
func main() {
fmt.Println("vim-go")
for i := 0; i < 100; i++ {
atomic.AddUint64(&n, 10)
}
fmt.Println(n)
}
|
package hook
/*
// #include "event/hook_async.h"
*/
import "C"
import (
"log"
"time"
"encoding/json"
)
//export go_send
func go_send(s *C.char) {
str := []byte(C.GoString(s))
out := Event{}
err := json.Unmarshal(str, &out)
if err != nil {
log.Fatal("json.Unmarshal error is: ", err)
}
if out.Keychar !=... |
package test
import (
"fmt"
"sharemusic/models/tool"
"testing"
)
func TestTime(t *testing.T) {
fmt.Println(tool.GetTime(true))
}
func TestHashCode(t *testing.T) {
fmt.Println(tool.HashCode("123"))
}
func TestConvert2(t *testing.T) {
a := map[string]string{}
a["id"] = "123"
fmt.Println(a)
fmt.Println(tool.C... |
package member
type Member struct {
Id int
Name string
Phone string
Age int
Gender string
}
func NewMember(id int, name string, phone string, age int, gender string) *Member {
return &Member{Id: id, Name: name, Phone: phone, Age: age, Gender: gender}
}
|
// Copyright 2015 The Go Circuit Project
// Use of this source code is governed by the license for
// The Go Circuit Project, found in the LICENSE file.
//
// Authors:
// 2015 Petar Maymounkov <p@gocircuit.org>
package io
import (
"io"
"runtime"
"github.com/gocircuit/runtime/circuit"
"github.com/gocircuit/runt... |
package constants
type Ingredient struct {
Name string
Category string
InvX int
InvY int
InvPage int
}
const (
Fruit = "Fruit"
Mushroom = "Mushroom"
Plant = "Plant"
Meat = "Meat"
Other = "Other"
Dragon = "Dragon"
Nut = "Nut"
Fish = "Fish"
Insect ... |
package main
import (
"bytes"
"encoding/json"
"errors"
"flag"
"fmt"
"io/ioutil"
"log"
"net/http"
"os"
"time"
)
const usageStr = `The Lucifer binary makes requests to the Lucifer server.
Usage:
lucifer command [arguments]
The commands are:
invalidate Invalidate the cache for a given file
... |
package goSolution
func canSwimToTheEnd(grid [][]int, t int) bool {
n := len(grid)
m := len(grid[0])
q := [][]int{{0, 0}}
v := Initialize2DIntSlice(n, m, -1)
v[0][0] = 0
for h := 0; h < len(q); h++ {
x, y := q[h][0], q[h][1]
for d := 0; d < 4; d++ {
tx, ty := x + DX[d], y + DY[d]
if tx >= 0 && ty >= 0 ... |
/*
Copyright SecureKey Technologies Inc. All Rights Reserved.
SPDX-License-Identifier: Apache-2.0
*/
package commitment
import (
"crypto"
"testing"
"github.com/stretchr/testify/require"
"github.com/trustbloc/sidetree-core-go/pkg/canonicalizer"
"github.com/trustbloc/sidetree-core-go/pkg/jws"
)
const (
sha2_2... |
package palendrome
// Alg returns whether a given string word
// is a palendrome.
func Alg(word string) bool {
n := len(word) - 1
for i := 0; i <= len(word)/2; i++ {
if word[i] != word[n-i] {
return false
}
}
return true
}
|
package cosmos
import "context"
// Collection performs operations on a given collection.
type Collection struct {
client Client
db Database
collID string
}
// Collections struct handles all operations involving mutiple collections
type Collections struct {
client Client
db Database
}
// Document define... |
package backend_controller
import (
"2021/yunsongcailu/yunsong_server/backend/backend_service"
"2021/yunsongcailu/yunsong_server/common"
"2021/yunsongcailu/yunsong_server/param/backend_param"
"2021/yunsongcailu/yunsong_server/web/web_model"
"fmt"
"github.com/gin-gonic/gin"
"github.com/gin-gonic/gin/binding"
"m... |
package main
import (
"encoding/json"
"log"
"net/http"
"time"
"go-cqrs/db"
"go-cqrs/messaging"
"go-cqrs/model"
"go-cqrs/util"
uuid "github.com/satori/go.uuid"
)
func woofsHandler(w http.ResponseWriter, r *http.Request) {
req := model.WoofRequest{}
err := json.NewDecoder(r.Body).Decode(&req)
if err != nil... |
// 38. Offline dictionary attack on simplified SRP
package main
import (
"bufio"
"bytes"
"crypto/hmac"
"crypto/rand"
"crypto/sha256"
"encoding/hex"
"errors"
"fmt"
"log"
"math/big"
"net"
"os"
"strings"
"sync"
)
const (
file = "passwords.txt"
addr = "localhost:4000"
dhPrime = `ffffffffffffffffc9... |
package models
import (
"time"
"github.com/rabierre/scrooge/db"
)
type Record struct {
Id uint64
Time time.Time
Amount string
LabelId uint64
}
func (r *Record) LabelName() string {
obj, err := db.Dbm.Get(Label{}, r.LabelId)
if err != nil {
panic(err)
}
return obj.(*Label).Name
}
|
package main
import (
"flag"
"fmt"
"github.com/Yafimk/go-microservices/document-service/service"
"log"
"net/url"
)
const appName = "DOCUMENT_SERVICE"
func main() {
host := flag.String("host", "http://localhost:8083", "bind address <protocol://host:port>")
flag.Parse()
fmt.Printf("Starting %v on %v\n", appNam... |
package field_test
import (
"bytes"
"encoding/hex"
"io"
"testing"
"github.com/tombell/go-serato/serato/field"
)
func TestNewYearField(t *testing.T) {
data, _ := hex.DecodeString("000000170000000A00320030003100380000")
buf := bytes.NewBuffer(data)
hdr, err := field.NewHeader(buf)
if err != nil {
t.Fatalf(... |
package leetcode
//
//func smallerNumbersThanCurrent(nums []int) []int {
// ret := [100]int{}
//
// l := len(nums)
// for i :=0; i<l ; i++ {
// ret[i] = nums[i]
// }
//
// r := make([]int,l)
// for i := 0; i < 100; i++ {
//
// }i
//
//}
|
package stage
import (
"context"
"github.com/werf/werf/pkg/build/builder"
"github.com/werf/werf/pkg/config"
"github.com/werf/werf/pkg/container_runtime"
"github.com/werf/werf/pkg/util"
)
func GenerateBeforeSetupStage(ctx context.Context, imageBaseConfig *config.StapelImageBase, gitPatchStageOptions *NewGitPatch... |
package caaa
import (
"encoding/xml"
"github.com/thought-machine/finance-messaging/iso20022"
)
type Document00400103 struct {
XMLName xml.Name `xml:"urn:iso:std:iso:20022:tech:xsd:caaa.004.001.03 Document"`
Message *AcceptorCompletionAdviceResponseV03 `xml:"AccptrCmpltnAdvcRspn"`
}
f... |
package main
import (
"fmt"
"testing"
)
func Test_BoardingPass_SeatId(t *testing.T) {
expected := 70
actual := NewBoardingPass("BFFFBBFRRR").Row()
if expected != actual {
t.Errorf("Row expected %s, got %s", fmt.Sprint(expected), fmt.Sprint(actual))
}
expected = 7
actual = NewBoardingPass("BFFFBBFRRR").Co... |
package main
import (
"fmt"
)
func main() {
fmt.Println(multiply("123", "100"))
}
func multiply(num1 string, num2 string) string {
if num1 == "0" || num2 == "0" {
return "0"
}
n1, n2 := len(num1), len(num2)
res := make([]int, n1+n2)
for i := n1 - 1; i >= 0; i-- {
num1 := num1[i] - '0'
for j := n2 - 1; ... |
package main
import "flag"
// config holds settings that are set by the sysadmin running your application.
type config struct {
address string
}
func getConfig() config {
c := config{}
flag.StringVar(&c.address, "address", "localhost:8085", "The address that the server will listen on.")
flag.Parse()
return c
}
|
package models
import (
u "businessense/utils"
"fmt"
"github.com/jinzhu/gorm"
)
//PainPoint Type
type PainPoint struct {
gorm.Model
Name string `json:"name"`
}
//Create PainPoint
func (painpoint *PainPoint) Create() map[string]interface{} {
GetDB().Create(painpoint)
response := u.Message(true, "Pain Point ha... |
package cloud
import (
"encoding/json"
"fmt"
"net/http"
"strings"
)
const discoveryURI = "https://wap.tplinkcloud.com?token=%s"
type tpLinkDeviceList struct {
DeviceList []TPLinkDevice `json:"deviceList"`
}
type tpLinkGetDeviceListResponse struct {
Result tpLinkDeviceList `json:"result"`
ErrorCode int ... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.