text stringlengths 11 4.05M |
|---|
/*
File describe gateway for working with track data in database.
Author: Igor Kuznetsov
Email: me@swe-notes.ru
(c) Copyright by Igor Kuznetsov.
*/
package models
import "time"
type TrackGateway interface {
GetTrackByClient(client uint32, dateStart, dateEnd time.Time) (Track, error)
}
type Track [][]float64
func... |
package main
import (
"os"
"gopkg.in/yaml.v2"
log "github.com/sirupsen/logrus"
)
// Exists reports whether the named file or directory exists.
func Exists(name string) bool {
result := false
log.Debug("We have been asked to check if this exists: ", name)
file, err := os.Stat(name)
if err == nil {
if os.IsN... |
package mocks
import (
"errors"
"github.com/ariel17/railgun/api/entities"
"github.com/ariel17/railgun/api/repositories"
"github.com/ariel17/railgun/api/services"
)
func DomainExists() {
dr := &repositories.MockDBRepository{}
services.DomainsRepository = dr
domain := entities.Domain{
ID: int64(10),
UserID:... |
package replaytutorial
import (
"context"
"testing"
"time"
"github.com/luno/jettison/jtest"
"github.com/stretchr/testify/require"
)
func TestTimestamps(t *testing.T) {
*dbRestart = true
*dbName = "tut_test"
Main(func(ctx context.Context, state State) error {
dbc := state.DBC
_, err := dbc.ExecContext(c... |
package models
// Todo is the basic type to hold a todo item
type Todo struct {
ID string `json:"ID"`
ParentID string `json:"ParentID"`
Desc string `json:"Desc"`
Complete bool `json:"Complete"`
} |
package errors
import (
"encoding/json"
"fmt"
"net/http"
"github.com/doniacld/outdoorsight/internal/endpointdef"
)
// ODSError represents the format of a returned HTTP error
type ODSError struct {
HTTPCode int `json:"HTTPCode"`
Message string `json:"message"`
}
// Error returns the message of the error
fu... |
//go:generate jsonconst -w=c -type=CodedError ./cerr
//go:generate jsonconst -w=u -type=TradeState,UserCashType,OrderState,BillboardType,VipRebateType,VpnType ./front
//go:generate mapconst -type=TradeState,UserCashType,OrderState ./front
package esecend
|
package main
import (
"flag"
"fmt"
htmlt "html/template"
"io"
"io/ioutil"
"os"
textt "text/template"
"github.com/AstromechZA/godork"
)
func OutputModeTemplate(pkg *godork.PackageDoc, w io.Writer) error {
// parse some options from the command line
fs := flag.NewFlagSet("t", flag.ExitOnError)
templateFile... |
package main
var result [][]int
func subsets(nums []int) [][]int {
result = make([][]int, 0)
solve(nums, 0, []int{})
return result
}
func solve(nums []int, idx int, tmp []int) {
result = append(result, NewSlice(tmp))
for i := idx; i < len(nums); i++ {
solve(nums, i+1, append(tmp, nums[i]))
}
}
func NewSli... |
/*
* Copyright 2018, CS Systemes d'Information, http://www.c-s.fr
*
* 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... |
package dropbox
import (
"encoding/json"
"errors"
"github.com/DennisDenuto/property-price-collector/data"
"github.com/DennisDenuto/property-price-collector/data/training/dropbox/dropboxfakes"
. "github.com/onsi/ginkgo"
. "github.com/onsi/gomega"
"io/ioutil"
)
var _ = Describe("DomaincomuaHistoryTrainingRepo", ... |
package router
import (
"github.com/gin-gonic/gin"
"nginx-manager/controllers/oauth"
"nginx-manager/controllers/process"
)
func SetupRouter() *gin.Engine {
// Disable Console Color
// gin.DisableConsoleColor()
r := gin.Default()
instance := r.Group("/process/instance")
{
instance.GET("/start", oauth.Parse... |
/*
* KSQL
*
* This is a swagger spec for ksqldb
*
* API version: 1.0.0
* Generated by: Swagger Codegen (https://github.com/swagger-api/swagger-codegen.git)
*/
package swagger
type ShowListResponse struct {
Tables []ShowListResponseTables `json:"tables,omitempty"`
Streams []ShowListResponseStreams `jso... |
package filesystem
import (
"bytes"
"io/ioutil"
"testing"
"time"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
)
func Test_readDir(t *testing.T) {
t.Parallel()
tests := []struct {
name string
body string
want []file
wantErr bool
}{
{
name: "directory",
... |
package cmd
import (
"github.com/Files-com/files-cli/lib"
"github.com/spf13/cobra"
"fmt"
"os"
files_sdk "github.com/Files-com/files-sdk-go"
"github.com/Files-com/files-sdk-go/notification"
)
var (
Notifications = &cobra.Command{
Use: "notifications [command]",
Args: cobra.ExactArgs(1),
Run: func(cmd ... |
package leetcode
import "testing"
func Test_KMP(t *testing.T) {
model := "bdaba"
t.Log(getNext(model))
t.Log(KMP(model, "abdabac"))
}
|
package db
// import (
// "errors"
// )
// // Summary contains information about the user's analysis.
// type Summary struct {
// UserID string `json:"id",sql:"type:uuid; primary key"`
// PortfolioGrowth
// }
|
package iproto
import (
"errors"
"fmt"
"testing"
cli2 "github.com/DmiAS/cube_cli/internal/app/cli"
"github.com/DmiAS/cube_cli/internal/app/connection"
"github.com/DmiAS/cube_cli/internal/app/mocks"
"github.com/DmiAS/cube_cli/internal/app/models"
)
func closeFunc(err error) mocks.ErrFn {
return func() error {... |
package mock
import (
"github.com/shharn/blog/model"
"github.com/shharn/blog/repository"
"github.com/stretchr/testify/mock"
)
type MockArticleRepository struct {
mock.Mock
}
func (mr *MockArticleRepository) Context() interface{} {
ret := mr.Called()
return ret.Get(0).(repository.Disposable)
}
func (mr *MockAr... |
package collector
import (
"context"
"fmt"
"time"
"github.com/docker/docker/api/types"
"github.com/docker/docker/api/types/filters"
"github.com/docker/docker/client"
)
func dockerCollector(ctx context.Context, name, url string, stream chan DockerMetrics, errors chan error, filters filters.Args, refreshInterval... |
package controllers
import (
"OnlineShop/models"
)
// 这里为了偷懒使用了指针类型,作为一个事件消息来说,
// 应该具备跨进程和跨机器的能力, 因为变量类型应该只能是基本类型
// 因为beego框架的限制,没有统一处理 controller的地方
// 也就是说在当前 `请求生命周期` 内,在任意地方应该可以获取当前`controller` 指针的能力,
// 如果具备了这样的能力,那么很容易在任意地方去 `make_response` (思想来源skynet框架中)。
type ShopEvent struct {
//购物事件
User *models.User
... |
// Copyright 2022 PingCAP, Inc. Licensed under Apache-2.0.
package streamhelper
import (
"context"
"github.com/google/uuid"
"github.com/pingcap/tidb/br/pkg/utils"
"github.com/pingcap/tidb/metrics"
"github.com/pingcap/tidb/owner"
clientv3 "go.etcd.io/etcd/client/v3"
)
const (
ownerPrompt = "log-backup"
owner... |
package main
import (
"context"
"fmt"
"net/http"
"time"
"go.mongodb.org/mongo-driver/mongo"
"go.mongodb.org/mongo-driver/mongo/options"
)
var client *mongo.Client
func welcomeHandler(response http.ResponseWriter, request *http.Request) {
response.Write([]byte("welcome"))
}
func main() {
clientOptions := op... |
// Copyright © 2020 Attestant 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 ... |
package openid
import (
"encoding/json"
"fmt"
"io"
"net/http"
)
const wellKnownOpenIDConfiguration = "/.well-known/openid-configuration"
type configurationGetter interface {
get(r *http.Request, url string) (configuration, error)
}
type configurationDecoder interface {
decode(io.Reader) (configuration, error)... |
/*
* @lc app=leetcode.cn id=383 lang=golang
*
* [383] 赎金信
*/
// @lc code=start
package main
// import "strings"
import "fmt"
func canConstruct(ransomNote string, magazine string) bool {
// for _, c := range ransomNote {
// cc := string(c)
// if strings.Contains(magazine, cc) {
// magazine = strings.Repl... |
// 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 core
import (
"encoding/json"
"fmt"
"io/ioutil"
"net/http"
"path"
"reflect"
"strings"
jsonpatch "github.com/evanphx/json-patch"
"github.com/gin-gonic/gin"
"github.com/textileio/go-textile/repo/config"
)
func getKeyValue(path string, object interface{}) (interface{}, error) {
keys := strings.Split(... |
package sigsci
import (
"encoding/json"
"fmt"
"log"
"os"
"reflect"
"testing"
"time"
)
type TestCreds struct {
email string
token string
corp string
site string
}
var testcreds = TestCreds{
email: os.Getenv("SIGSCI_EMAIL"),
token: os.Getenv("SIGSCI_TOKEN"),
corp: os.Getenv("SIGSCI_CORP"),
site: os.... |
// 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 pool
import (
"github.com/gocircuit/runtime/sys"
"github.com/gocircuit/runtime/sys/pipe"
"time... |
package testbed
import (
"context"
"errors"
"fmt"
"os"
"sort"
"strings"
"testing"
"github.com/favclip/testerator/v3"
_ "github.com/favclip/testerator/v3/datastore"
_ "github.com/favclip/testerator/v3/memcache"
netcontext "golang.org/x/net/context"
"google.golang.org/appengine/v2"
"google.golang.org/appe... |
// Copyright (c) 2020 Xiaozhe Yao & AICAMP.CO.,LTD
//
// This software is released under the MIT License.
// https://opensource.org/licenses/MIT
package runtime
import (
"bufio"
"encoding/json"
"fmt"
"io"
"os"
"path"
"path/filepath"
"github.com/autoai-org/aid/components/cmd/pkg/entities"
"github.com/autoai-... |
package ardupilotmega
/*
Generated using mavgen - https://github.com/ArduPilot/pymavlink/
Copyright 2020 queue-b <https://github.com/queue-b>
Permission is hereby granted, free of charge, to any person obtaining a copy
of the generated software (the "Generated Software"), to deal
in the Generated Software without re... |
package main
import (
"context"
"fmt"
"os"
"os/signal"
"redisDB"
"omokServer"
)
func main() {
ctx, done := signal.NotifyContext(context.Background(), os.Interrupt)
defer done()
conf := createHostConf()
redisC := createRedis(conf)
redisC.Start()
omokServerList := make([]*omokServer.Server, conf.maxGa... |
package main
import (
"fmt"
"github.com/rainmyy/easyDB/bootstrap"
)
/***
* easydb 服务端入库
*/
func main() {
bootstrap.GenInstance().Setup()
bootstrap.GenInstance().Start()
defer func() {
if err := recover(); err != nil {
fmt.Println(err)
}
}()
}
|
package common
import "sync"
//计数
var sum int64 = 0
// 互斥锁
var mutex sync.Mutex
//获取一个
func PassOne(hasNum int64) bool {
// 总数
//var hasNum int64
// 加锁
mutex.Lock()
defer mutex.Unlock()
// 判断是否超限
if sum < hasNum {
sum += 1
return true
}
return false
}
|
package prompt
import "strings"
const (
None = "none"
Login = "login"
Consent = "consent"
SelectAccount = "select_account"
)
type NoConsentPromptPolicy int
const (
NoConsentPromptPolicyForceConsent NoConsentPromptPolicy = iota
NoConsentPromptPolicyOmitConsentIfCan
)
type NonePromptPoli... |
package variant
import (
"fmt"
"reflect"
"strings"
"time"
"github.com/fatih/structs"
"github.com/go-playground/validator"
"github.com/markus-azer/products-service/pkg/entity"
"github.com/markus-azer/products-service/pkg/product"
"github.com/sirupsen/logrus"
)
//Service service interface
type Service struct ... |
package ztimer
import (
"log"
"testing"
"time"
)
//触发函数
func foo(args ...interface{}) {
log.Println("i am no ", args[0].(int), " function delay ", args[1].(int))
}
//手动创建调度运行时间轮 go test -v -run TestNewTimerScheduler
func TestNewTimerScheduler(t *testing.T) {
timerScheduler := NewTimerScheduler()
timerScheduler... |
//************************************************************************//
// RightScale API client
//
// Generated with:
// $ praxisgen -metadata=ss/ssm/restful_doc -output=ss/ssm -pkg=ssm -target=1.0 -client=API
//
// The content of this file is auto-generated, DO NOT MODIFY
//******************... |
package xhlog
import (
"bytes"
"encoding/json"
"fmt"
"github.com/cyongxue/magicbox/xhiris/xhid"
"github.com/kataras/iris/v12"
"reflect"
"runtime"
"strings"
)
const (
RealRemoteIP = "x-real-ip"
)
// 日志格式为:
// [INFO] [2020-06-29T22:26:59.972+0800] [logic/middleware/middlerware_handler.go:64] _request_in||uri=... |
/*
See https://app.swaggerhub.com/apis/epixode1/BYhZzCNUCkA/4.0.0
*/
package api
/* This is specific to task1. */
type GameParams struct {
NbPlayers uint32 `json:"nb_players" yaml:"nb_players"`
MapSide uint32 `json:"map_side" yaml:"map_side"`
FirstBlock string `json:"first_block"`
NbRounds uint32 `json:"... |
package model
import (
"github.com/mongodb/mongo-go-driver/bson"
"github.com/mongodb/mongo-go-driver/bson/primitive"
"github.com/mongodb/mongo-go-driver/mongo"
log "github.com/sirupsen/logrus"
)
// VerifyApplication 申请中
const VerifyApplication = "application"
// VerifyPass 通过
const VerifyPass = "pass"
// Verify... |
func minPathSum(grid [][]int) int {
min:=func(a,b int)int{if a<b{return a};return b}
y:=len(grid)
x:=len(grid[0])
dp:=make([][]int, y)
for i:=range dp{ dp[i] = make([]int,x) }
dp[0][0] = grid[0][0]
for i:=1; i<y;i++{ dp[i][0] = grid[i][0]+dp[i-1][0] }
for i:=1; i<x;i++{ dp[0][i] = grid[0... |
/*
* @lc app=leetcode id=46 lang=golang
*
* [46] Permutations
*/
func per(pr *[][]int, nums []int, depth int) {
if depth == len(nums) {
a := make([]int, len(nums))
copy(a, nums)
*pr = append(*pr, a)
}
for i := depth; i < len(nums); i++ {
nums[i], nums[depth] = nums[depth], nums[i]
per(pr, nums, depth... |
package xml
import (
"io"
"utf8"
"os"
)
// NOTE separate desc types from ?
const (
startType = iota
keyType
valueType
endType
charsType
cdataType
directiveType
commentType
eofType
)
const (
noneState = iota
startState
keyState
)
// NOTE a: Indexer
// NOTE: use bytes.Buffer instead of bytes ?
type par... |
package isis
type IsisRpc struct {
Information struct {
Adjacencies []IsisAdjacenciesRpc `xml:"isis-adjacency"`
} `xml:"isis-adjacency-information"`
}
type IsisAdjacenciesRpc struct {
InterfaceName string `xml:"interface-name"`
SystemName string `xml:"system-name"`
Level int64 `xml:"level"`
Adj... |
/**
* User: ghostwwl
* Date: 16-12-4
* Time: 上午11:17
*/
package main
import (
//"bufio"
"database/sql"
"fmt"
"io"
"io/ioutil"
"log"
"net/http"
"os/exec"
//"net"
//"strings"
"strings"
"os"
)
func main() {
//runHttpService()
runHttpService2()
}
func PathExists(fpath string) bool {
_, err := os.... |
package accrew
import (
"math"
"math/rand"
"github.com/devinmcgloin/clr/clr"
"github.com/devinmcgloin/sail/pkg/slog"
"github.com/fogleman/gg"
)
type pointColor struct {
Point gg.Point
Color clr.Color
}
//DotLines defines the type of sketch
type DotLines struct{}
//Dimensions determes the size of the sketch ... |
package main
import (
"github.com/hashicorp/memberlist"
)
// Broadcast is something that can be broadcasted via gossip to
// the memberlist cluster.
type broadcast struct {
msg []byte
notify chan<- struct{}
}
// Invalidates checks if enqueuing the current broadcast
// invalidates a previous broadcast
func (b *... |
package main
import (
"github.com/ofpiyush/automerger/automerger"
)
func main() {
automerger.Serve(automerger.ConfigureOrDie())
}
|
package orm
import (
"time"
_ "github.com/go-sql-driver/mysql" // justifying
"github.com/go-xorm/xorm"
"xorm.io/core"
"github.com/any-lyu/go.library/errors"
"github.com/any-lyu/go.library/logs"
xtime "github.com/any-lyu/go.library/time"
)
// Config database config.
type Config struct {
DSN string ... |
package main
import (
"fmt"
)
func main() {
x := []string{"Sun", "Moon", "Star", "Jupitar", "Earth", "Planet"}
fmt.Println(x)
x = append(x, "Tree", "Forest", "Land") //func append(slice []T, elements ...T) []T
fmt.Println(x)
y := []string{"Honey", "Penny", "Money", "Funny"}
x = append(x, y...) //x = append(x,... |
package server
import (
"bytes"
"io"
"golang.org/x/net/websocket"
)
type wsconn struct {
ws *websocket.Conn
backend []*bytes.Buffer
index int
}
func NewWSConn(ws *websocket.Conn) *wsconn {
conn := &wsconn{}
conn.ws = ws
conn.backend = make([]*bytes.Buffer, 2)
conn.backend[0] = bytes.NewBuffer(nil)
... |
package portsbinding
import (
"testing"
"github.com/gophercloud/gophercloud"
"github.com/gophercloud/gophercloud/acceptance/tools"
"github.com/gophercloud/gophercloud/openstack/networking/v2/extensions/portsbinding"
"github.com/gophercloud/gophercloud/openstack/networking/v2/ports"
)
// CreatePortsbinding will ... |
package log
// Logger interface taken from https://github.com/golang/go/issues/28412
type Logger interface {
// all levels + Prin
Print(v ...interface{})
Printf(format string, v ...interface{})
Println(v ...interface{})
Info(v ...interface{})
Infof(format string, v ...interface{})
Infoln(v ...interface{})
Warn... |
package gui
import (
"github.com/jesseduffield/gocui"
)
const UNKNOWN_VIEW_ERROR_MSG = "unknown view"
// getFocusLayout returns a manager function for when view gain and lose focus
func (gui *Gui) getFocusLayout() func(g *gocui.Gui) error {
var previousView *gocui.View
return func(g *gocui.Gui) error {
newView ... |
package main
import "fmt"
func main() {
// Define map
emails := make(map[string]string)
//Assign kv
emails["Bob"] = "bob@gmail.com"
emails["Sharon"] = "sharon@gmail.com"
emails["Delete"] = "to_delete@gmail.com"
fmt.Println(emails,len(emails))
delete(emails,"Delete")
fmt.Println(emails)
emailsDefinedWit... |
package help
const (
root = "https://github.com/argoproj/argo/blob/master/docs"
ArgoSever = root + "/argo-server.md"
CLI = root + "/cli.md"
WorkflowTemplates = root + "/workflow-templates.md"
WorkflowTemplatesReferencingOtherTemplates = WorkflowTemplates + "#referencing-other-... |
// Copyright 2018 Andrew Bates
//
// 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 wri... |
// 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 models
type CommitAuthor struct {
Name string
Email string
}
type Commit struct {
Sha string
Distinct bool
Message string
Author *CommitAuthor
}
|
package sql
import (
"fmt"
)
type Catalog struct {
Databases []Database
}
func (c Catalog) Database(name string) (Database, error) {
for _, db := range c.Databases {
if db.Name() == name {
return db, nil
}
}
return nil, fmt.Errorf("database not found: %s", name)
}
func (c Catalog) Table(dbName string, ... |
package gps
import "testing"
type testStruct struct {
A bool
B int
C int8
D int16
E int32
F int64
G uint
H uint8
I uint16
J uint32
K uint64
L rune // alias of int32
M byte // alias of uint8
N string
O []byte
P [16]byte
Q float32
R float64
S complex64
T complex128
/* U
V
W
X
Y
Z*/
}
// ... |
package api
import (
"errors"
"fmt"
"io/ioutil"
"net/http"
"net/http/httptest"
"reflect"
"testing"
"github.com/gorilla/mux"
commonClients "github.com/tidepool-org/go-common/clients"
"github.com/tidepool-org/go-common/clients/highwater"
"github.com/tidepool-org/go-common/clients/shoreline"
"github.com/tid... |
package frac
import "testing"
func TestFracMul(t *testing.T) {
exp := Frac{10, 21}
frac1 := Frac{2, 3}
frac2 := Frac{5, 7}
act1 := Mul(frac1, frac2)
if exp != act1 {
t.Error("Expected", exp, "got", act1)
}
act2 := Mul(frac2, frac1)
if exp != act2 {
t.Error("Expected", exp, "got", act2)
}
}
|
package common
const (
// Database operation error messages
ErrorMessageNoConnectionProvider = "Connection provider not specified"
ErrorMessageNoTransactionFunction = "Transaction function not specified"
ErrorMessageNotExist = "Not exist"
ErrorMessageAlreadyExist = "Already exist"
ErrorMessag... |
package main
import (
"github.com/andlabs/ui"
)
// The main window
var window *ui.Window
var box *ui.Box
var area *ui.Area
var mainText *ui.AttributedString
var height = 1024
var width = 1024
type areaHandler struct {
}
func (areaHandler) DragBroken(a *ui.Area) {
}
func (areaHandler) MouseCrossed(a *ui.Area, left... |
package service
type Storage interface {
ConvertFileToStruct(namePath string) ([]*Data, error)
} |
package urls
import (
"net/http"
"github.com/go-chi/chi"
)
// Register Get() and Head() methods at once
// Due to issue: https://github.com/go-chi/chi/issues/238#event-1189509880
func GetHead(r chi.Router, pattern string, h http.HandlerFunc) {
r.Get(pattern, h)
r.Head(pattern, h)
}
|
package sandbox
import (
"os"
"testing"
)
func TestIO(t *testing.T) {
r := Run("test/open", os.Stdin, os.Stdout, []string{""}, 1000, 2000)
if r.Status != IOE {
t.Fatal("IO test failed")
}
}
func TestTime(t *testing.T) {
obj := Run("/bin/sleep", os.Stdin, os.Stdout, []string{"5"}, 1000, 20000)
if obj.Status ... |
package main
import (
"go/ast"
"reflect"
gu "github.com/athlum/gorp/utils"
)
func BaseStructTypes() map[string]*ast.StructType {
m := make(map[string]*ast.StructType)
for _, i := range []interface{}{
gu.Base{},
gu.EnableBase{},
} {
m = typeToStructType(reflect.TypeOf(i), m)
}
return m
}
func typeToStr... |
package chain
import (
"github.com/ethereum/go-ethereum/common"
"github.com/sanguohot/medichain/etc"
"github.com/sanguohot/medichain/util"
"github.com/sanguohot/medichain/contracts/medi"
"math/big"
"time"
"github.com/google/uuid"
"github.com/ethereum/go-ethereum/accounts/abi/bind"
)
func GetUsersDataInstance(... |
package event
import (
"errors"
"fmt"
)
type event struct {
eType byte
expectedArgs int
}
var (
follow = event{'F', 2}
unfollow = event{'U', 2}
broadcast = event{'B', 0}
privateMsg = event{'P', 2}
statusUpdate = event{'S', 1}
payloadFormat = "%d|%1s|%d|%d\n"
)
// ErrBadFormat is ret... |
package core
import (
"github.com/bitwormhole/go-wormhole-core/io/fs"
"github.com/bitwormhole/go-wormhole-git/git/repository/config"
"github.com/bitwormhole/go-wormhole-git/git/repository/head"
"github.com/bitwormhole/go-wormhole-git/git/repository/index"
"github.com/bitwormhole/go-wormhole-git/git/repository/obj... |
package ble
import (
"crypto/rand"
"encoding/json"
"github.com/muka/go-bluetooth/hw"
"log"
"strings"
)
const SEC_APP_UUID_SUFFIX = "-0000-1000-8000-00805F9B34FB"
const APP_UUID = "0001"
const KEY_EXC_SERVICE_UUID = "0001"
const OOB_EXC_SERVICE_UUID = "0002"
const READ_CERT_1_CHAR_UUID = "00000002" // ECDSA
con... |
package e2e
import (
"context"
"fmt"
"os/exec"
"github.com/operator-framework/operator-lifecycle-manager/pkg/lib/operatorclient"
corev1 "k8s.io/api/core/v1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
)
// This module contains helper functions for copying images and creating image registries
// Use for tests... |
package handler
import (
"net/http"
"github.com/labstack/echo/v4"
"github.com/vanWezel/to-do/internal/model"
)
func (h *Handler) TaskIndex(c echo.Context) error {
page := getPageQueryParam(c.QueryParam("page"))
list, err := h.Task.Index(page)
if err != nil {
return echo.NewHTTPError(http.StatusBadRequest, ... |
package handler
import (
std "CRUD"
"os"
"io/ioutil"
"net/http"
)
func NewOrgHandler() *OrgHandler {
return &OrgHandler{Repo: std.NewStudents()}
}
// OrgHandler ..
type OrgHandler struct {
Repo *std.Repo
}
func setupResponse(w *http.ResponseWriter, req *http.Request) {
(*w).Header().Set(... |
package main
import(
"fmt"
"reflect"
)
type rectangle struct {
length float64
breadth float64
color string
}
func main() {
var rect1 = rectangle{
10,
20,
"red",
}
fmt.Println(reflect.TypeOf(rect1)) // main.rectangle
fmt.Println(reflect.ValueOf(rect1)) // {{{10 20 red}
rect2 := rectangle{
length: 1... |
package components
// A Cell is something that can be alive or dead.
// The contains some logic that lets it know if it
// should be alive or dead Next.
type Cell struct {
alive bool
}
// Calling `Cell` will create a new struct, we then return
// a pointer to that struct, rather than a copy (which would
// happen i... |
package main
import (
"fmt"
"strings"
)
type parser struct {
lexer *lexer
matched token
next token
}
// ParseError is returned if the input cannot be successfuly parsed
type ParseError struct {
// The original query
Input string
// The position where the parsing fails
Pos int
// The error message
Mes... |
package requests
import (
"encoding/json"
"testing"
"github.com/mitchellh/mapstructure"
"github.com/stretchr/testify/assert"
)
func TestDecodeAccountInfoRequest(t *testing.T) {
encoded := `{"action":"account_info","account":"abc","representative":true}`
var decoded AccountInfoRequest
json.Unmarshal([]byte(enc... |
package main
import "fmt"
func main() {
a := []int{1, 2, 3, 4, 5, 6, 7, 8, 9, 10}
for aValue := len(a); aValue > 0; aValue-- {
a = RemoveBack(a)
fmt.Println(a)
}
}
func RemoveBack(a []int) []int {
sliceLen := len(a)
b := make([]int, sliceLen)
b = a[:sliceLen-1]
return b
}
|
/*
* @lc app=leetcode.cn id=1748 lang=golang
*
* [1748] 唯一元素的和
*/
// @lc code=start
package main
func sumOfUnique(nums []int) int {
ret := 0
numCount := make(map[int]int)
for i := 0; i < len(nums); i++ {
numCount[nums[i]]++
}
for k, v := range numCount {
if v == 1 {
ret += k
}
}
return ret
}
// @... |
package client
import (
"bufio"
"context"
"fmt"
"io"
"net"
"os"
"time"
)
// TelnetClient instance of tcp-client as telnet
type TelnetClient struct {
conn net.Conn
stdinScanner *bufio.Scanner
serverScanner *bufio.Scanner
serverCh chan string
stdinCh chan string
}
// NewTelnetClient ge... |
// Usage: $0 srcdir dstdir
package main
import (
"bytes"
"fmt"
"io"
"log"
"os"
"os/exec"
"path"
"path/filepath"
"strconv"
"strings"
"time"
// "github.com/maemual/shutil"
"github.com/gosexy/exif"
shutil "github.com/termie/go-shutil"
)
func bincompare(i1, i2 io.Reader, bufsz int) int {
b1 := make([]byte,... |
package container_runtime
import (
"context"
"fmt"
"os"
"strings"
"github.com/werf/lockgate"
"github.com/werf/werf/pkg/werf"
"github.com/werf/logboek"
"github.com/werf/werf/pkg/docker"
"github.com/werf/werf/pkg/image"
)
type LegacyStageImage struct {
*legacyBaseImage
fromImage *LegacyStageI... |
// Package name
package main
// imported modules
import (
"fmt"
"os"
)
// const value
const pi = 3.14
// Simple calculator functions
func add(x int, y int) int{
return x + y
}
func diff(x int, y int) int{
return x - y
}
func multiplication(x int, y int) int{
return x * y
}
func division(x int, y int) in... |
package sim
import (
"time"
)
type Asset interface {
Account
Value() float64
Loan() Debt
Depreciate(date time.Time)
Maintain(amount float64, date time.Time)
CommissionRate() float64
PayOff(date time.Time) *Transaction
Liquidate(date time.Time) *Transaction
}
|
package blocker
// UnknownBlocker 未知Blocker
type UnknownBlocker struct {
}
// NewUnknownBlocker 创建未知Blocker
func NewUnknownBlocker() *UnknownBlocker {
b := &UnknownBlocker{}
return b
}
// IsMacBlocked zone或者mac是否被限制
func (f *UnknownBlocker) IsMacBlocked(mac, zone string) bool {
return true
}
// IgnoreIPCheck 是否忽... |
package main
import (
"fmt"
"strconv"
)
func ExampleDB_UsersTags() {
db := OpenDBInMemory()
MigrateDB(db)
alice := User{Name: "Alice"}
bob := User{Name: "Bob"}
carol := User{Name: "Carol"}
david := User{Name: "David"}
db.Create(&alice)
db.Create(&bob)
db.Create(&carol)
db.Create(&david)
frontend := Ta... |
package main
import (
"os"
"github.com/therecipe/qt/widgets"
)
func main() {
widgets.NewQApplication(len(os.Args), os.Args)
button := widgets.NewQPushButton2("check for updates", nil)
button.ConnectClicked(func(bool) { sparkle_checkUpdates() })
button.Show()
widgets.QApplication_Exec()
}
|
package main
import (
"fmt"
"io"
"unicode"
)
type jpNameTerms struct {
kanji []string
hiragana []string
katakana []string
}
func (x *jpNameTerms) dump(w io.Writer) error {
raw := "package piidata\n\n"
raw += "// JpNameKanji is Kanji name data in Japanese\n"
raw += "var JpNameKanji = []string{\n"
for _,... |
package main
import (
"compress/gzip"
"log"
"net/http"
"os"
"time"
"github.com/gosom/context-spell-correct/internal/config"
"github.com/gosom/context-spell-correct/internal/webhandlers"
"github.com/gosom/context-spell-correct/pkg/spellcorrect"
)
func main() {
cfg, err := config.New()
if err != nil {
pani... |
package defaults
import (
"github.com/openshift/installer/pkg/types"
"github.com/openshift/installer/pkg/types/ovirt"
)
func setMachinePool(p *types.MachinePool) {
if p.Platform.Ovirt == nil {
p.Platform.Ovirt = &ovirt.MachinePool{}
}
}
func setDefaultAffinityGroups(p *ovirt.Platform, mp *types.MachinePool, ag... |
package material
import (
"math"
"testing"
"github.com/calbim/ray-tracer/src/pattern"
"github.com/calbim/ray-tracer/src/tuple"
"github.com/calbim/ray-tracer/src/color"
"github.com/calbim/ray-tracer/src/light"
)
func TestMaterial(t *testing.T) {
m := New()
if !m.Color.Equals(color.New(1, 1, 1)) {
t.Errorf(... |
package debug
import (
"fmt"
"io"
"os"
"runtime"
"strings"
)
func PrintGoroutines(allFrame bool) {
FprintGoroutines(os.Stderr, allFrame)
}
func FprintGoroutines(w io.Writer, allFrame bool) {
ng := runtime.NumGoroutine()
p := make([]runtime.StackRecord, ng)
n, ok := runtime.GoroutineProfile(p)
if !ok {
pa... |
package main
import (
"flag"
"time"
"github.com/apex/log"
"github.com/apex/log/handlers/cli"
"github.com/tj/go/flag/usage"
"github.com/apex/static/docs"
)
func init() {
log.SetHandler(cli.Default)
}
func main() {
flag.Usage = usage.Output(&usage.Config{
Examples: []usage.Example{
{
Help: "Gener... |
package release
import (
"archive/zip"
"crypto/sha256"
"errors"
"fmt"
"io/ioutil"
"os"
"path/filepath"
"strings"
"github.com/ExploratoryEngineering/reto/pkg/toolbox"
)
func checksumFileName(name, version string) string {
return fmt.Sprintf("%s/%s/sha256sum_%s_%s.txt", archiveDir, version, name, version)
}
... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.