text stringlengths 11 4.05M |
|---|
// Pacote que contêm todas as os Tokens que podem são reconhecidos na linguagem.
package core
const (
OPERADOR_ATRIBUICAO = "OPERADOR_ATRIBUICAO"
OPERADOR_LOGICO_IGUALDADE = "OPERADOR_IGUALDADE"
OPERADOR_LOGICO_MAIOR_QUE = "OPERADOR_MAIOR_QUE"
OPERADOR_MAIOR = "OPER... |
package main
import(
"log"
"context"
"strconv"
"app/proto"
"app/models"
"github.com/gin-gonic/gin"
"google.golang.org/grpc"
)
var cl proto.BookProfilesClient
func Create(ctx *gin.Context){
var book models.Book
ctx.ShouldBindJSON(&book)
log.Println(book)
req := &proto.CreateRequest{
Book: &proto.B... |
package main
import (
jwtmiddleware "github.com/auth0/go-jwt-middleware"
"github.com/dgrijalva/jwt-go"
"golang.org/x/crypto/bcrypt"
)
type user struct {
Login string `json:"login" bson:"login"`
Password string `json:"password" bson:"password"`
Admin bool `json:"admin" bson:"admin"`
}
type article struc... |
// Copyright 2016-2023, Pulumi Corporation.
//
// 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... |
package main
import (
"flag"
"fmt"
)
// 入口函数
func main() {
filePath := flag.String("filePath", "/usr/local/Cellar/nginx/1.12.2_1/logs", "param sample:--paramName=123123")
limit := flag.String("limit", "100", "param sample:--paramName=123123")
flag.Parse()
fmt.Println(*filePath)
fmt.Println(*limit)
}
func Writ... |
package search
import (
"context"
"io/ioutil"
"log"
"strings"
"sync"
)
// Result struct
type Result struct {
Phrase string
Line string
LineNum int64
ColNum int64
}
// All ...
func All(ctx context.Context, phrase string, files []string) <-chan []Result {
ch := make(chan []Result)
wg := sync.WaitGroup{... |
// Copyright 2021 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 main
import "fmt"
var buffer = []int{65,23,897,12,43,23,78,44,213,867,21312,5,3,2,6,8,3,4,56,1111,545646,87,234,5467,867,23,46,54,6752,32342,356,345,434,234,234,23341,23,126,54,6756,}
type sortType int
const (
bubble sortType = iota
selection
insert
merge
quick
heap
)
func isSort(b []int) bool{
if le... |
package utils
import (
"runtime"
)
// 设置同时执行的cpu数量
func SetGOMAXPROCS() {
cupNum := runtime.NumCPU()
runtime.GOMAXPROCS(cupNum)
}
|
package main
import (
"net/http"
"time"
"github.com/go-kit/kit/log"
stdopentracing "github.com/opentracing/opentracing-go"
"github.com/go-kit/kit/endpoint"
"golang.org/x/net/context"
)
func EndpointTracingMiddleware(next endpoint.Endpoint) endpoint.Endpoint {
return func(ctx context.Context, request interfa... |
package findcallers
import (
"go/ast"
"go/parser"
"go/token"
"os"
"path/filepath"
"strconv"
"strings"
)
// Struct that inherits the Visit method needed by ast.Walk
// toFind is the function name to be found
// poslist is a slice of type token.Pos used to store Positions within files
type FuncVisitor struct {
... |
package typeidentifier
import (
"github.com/iLLeniumStudios/FiveMCarsMerger/pkg/dft"
xmlutils "github.com/iLLeniumStudios/FiveMCarsMerger/pkg/utils/xml"
log "github.com/sirupsen/logrus"
"io/ioutil"
"os"
)
type TypeIdentifier interface {
IdentifyDataFileType(path string) (dft.DataFileType, error)
}
type typeIde... |
package middleware
import (
"net/http"
"github.com/JacksonGariety/cetch/app/models"
"github.com/JacksonGariety/cetch/app/utils"
)
func StickyEntry(next http.Handler) http.Handler {
return http.HandlerFunc(func (w http.ResponseWriter, r *http.Request) {
data := *r.Context().Value("data").(*utils.Props)
if dat... |
/*
Write a simple program that copies itself when executed.
Your program should be some kind of executable file on Windows, Linux, etc.., should generate new executable file, which is identical to your original executable file, with random name, and quits.
Your program shouldn't involve any kind of file reading or c... |
package router
import "github.com/gin-gonic/gin"
import . "chain-web/pkg/handler"
func Init(router *gin.Engine) {
outAuthRouter(router)
}
// 不需要认证的接口
func outAuthRouter(router *gin.Engine) {
v1 := router.Group("/api/v1/")
v1.POST("/syncNt", SyncNt)
v1.POST("/createFakeChainAddr", CreateChainAddress)
}
|
// Copyright 2017 Santhosh Kumar Tekuri. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
package main
import (
"context"
"fmt"
"os"
"github.com/ory/jsonschema/v3"
_ "github.com/ory/jsonschema/v3/httploader"
)
func main() {
if len(os.... |
package mysqldb
import (
"context"
"time"
)
type SubscriptionType int32
const (
// 定制化
SubscriptionTypeCustomizedVersion = 0
// 试用版
SubscriptionTypeTrialVersion = 1
// 黄喜马把脉
SubscriptionTypeGoldenVersion = 2
// 白喜马把脉
SubscriptionTypePlatinumVersion = 3
// 钻石姆
SubscriptionTypeDiamondVersion = 4
// 礼品版
S... |
package utils
import (
"net/http"
"github.com/gorilla/mux"
"fmt"
)
type myFileHandler struct {
h http.Handler
}
func muxVariableLookup(req *http.Request, name string) string {
return mux.Vars(req)[name]
}
func IndexNameLookup(req *http.Request) string {
fmt.Println("IndexNameLookup")
return muxVariableLookup... |
package skylark
import (
"fmt"
"log"
"github.com/google/skylark"
)
func (s *skylarkVM) makeRule(thread *skylark.Thread, fn *skylark.Builtin, args skylark.Tuple, kwargs []skylark.Tuple) (skylark.Value, error) {
var impl *skylark.Function
attrs := new(skylark.Dict)
outputs := new(skylark.Dict)
err := skylark.U... |
package dfs
import "github.com/sko00o/leetcode-adventure/queue-stack/stack"
// Node defines node with neighbors.
type Node struct {
Val int
Neighbors []*Node
}
// NodeStack is stack for Nodes.
type NodeStack struct {
stack.SliceStack
}
// Push insert a Node into the stack.
func (s *NodeStack) Push(n *Node)... |
package services_test
import (
"errors"
"time"
"github.com/cloudfoundry-incubator/notifications/fakes"
"github.com/cloudfoundry-incubator/notifications/models"
"github.com/cloudfoundry-incubator/notifications/web/services"
. "github.com/onsi/ginkgo"
. "github.com/onsi/gomega"
)
var _ = D... |
//
// Copyright (c) 2014 The pblcache 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 a... |
package namecheap
import (
"bytes"
"fmt"
"github.com/hashicorp/terraform-plugin-sdk/helper/hashcode"
)
func (c *Client) AddRecord(domain string, record *Record) (*Record, error) {
allRecords, err := c.GetHosts(domain)
if err != nil {
return nil, err
}
records := RemoveParkingRecords(domain, allRecords)
rec... |
package main
func searchMatrix(matrix [][]int, target int) bool {
if len(matrix) == 0 {
return false
}
m, n := len(matrix), len(matrix[0])
l, r := 0, m*n-1
for l <= r {
mid := (l + r) / 2
if matrix[mid/n][mid%n] == target {
return true
} else {
if matrix[mid/n][mid%n] > target {
r = mid - 1
}... |
package main
import (
_ "net/http/pprof"
"testing"
)
func Test_validateSignal(t *testing.T) {
type args struct {
signal []int
}
tests := []struct {
name string
args args
want string
}{
{
name: "good signal",
args: args{
signal: []int{1, 1, 1, 1, 0, 0},
},
want: "bad",
},
{
name:... |
package main
import (
"errors"
"fmt"
"io"
"math/rand"
"strconv"
"time"
)
func init() {
rand.Seed(time.Now().Unix())
}
type Data struct {
Line string
}
type Xenia struct {
}
func (Xenia) Pull(d *Data) error {
switch i := rand.Intn(10); i {
case 1,9 :
return io.EOF
case 5:
return errors.New("Error Re... |
package test
import (
"fmt"
"gengine/engine"
"testing"
)
//测试代码框架
func nmpFramework(n, m, em int, names []string) {
type Data struct {
Count int
}
apis := make(map[string]interface{})
apis["println"] = fmt.Println
//无状态api在这里注入
pool, e := engine.NewGenginePool(2, 4, 1, n_m_model_rules, apis)
if e != nil ... |
package router_test
import (
"testing"
"github.com/golang/mock/gomock"
"github.com/redsift/go-stats/router"
"github.com/redsift/go-stats/router/rules"
"github.com/redsift/go-stats/stats"
)
func TestRouter(t *testing.T) {
ctrl := gomock.NewController(t)
defer ctrl.Finish()
c := stats.NewMockCollector(ctrl)
... |
package engine
import chess "github.com/Yoshi-Exeler/chesslib"
func u8Max(a uint8, b uint8) uint8 {
if a > b {
return a
}
return b
}
func abs(v int16) int16 {
if v < 0 {
return -v
}
return v
}
func i16min(a int16, b int16) int16 {
if a < b {
return a
}
return b
}
func i16max(a int16, b int16) int16 ... |
package testutil
import (
"bytes"
"crypto/rand"
ic "gx/ipfs/QmNiJiXwWE3kRhZrC5ej3kSjWHm337pYfhjLGSCDNKJP2s/go-libp2p-crypto"
pb "gx/ipfs/QmNiJiXwWE3kRhZrC5ej3kSjWHm337pYfhjLGSCDNKJP2s/go-libp2p-crypto/pb"
"testing"
)
func TestBogusPublicKeyGeneration(t *testing.T) {
public := RandTestBogusPublicKeyOrFatal(t)
i... |
package cuboid
import (
"github.com/go-gl/mathgl/mgl32"
"github.com/akosgarai/opengl_playground/pkg/primitives/material"
"github.com/akosgarai/opengl_playground/pkg/primitives/rectangle"
trans "github.com/akosgarai/opengl_playground/pkg/primitives/transformations"
"github.com/akosgarai/opengl_playground/pkg/vao"... |
package registry
import (
"log"
"net/http"
"sort"
"strings"
"sync"
"time"
)
// GeeRegistry is a simple register center, provide following functions.
// add a server and receive heartbeat to keep it alive.
// returns all alive servers and delete dead servers sync simultaneously.
type GeeRegistry struct {
timeou... |
package conf
import (
"encoding/json"
"log"
"os"
"path/filepath"
"reflect"
)
var confs = make(map[string]interface{})
var confDir string
func Init(dir string) {
confDir = dir
}
func All() map[string]interface{} {
return confs
}
// 载入配置文件
func Load(name string) error {
if confDir != "" {
name = filepath.J... |
//go:generate mockgen -package mock -destination firehoseiface.go github.com/aws/aws-sdk-go/service/firehose/firehoseiface FirehoseAPI
package mock
|
package primitives
import (
"encoding/xml"
"github.com/plandem/ooxml/ml"
)
//FontCharsetType is a type to encode charset of font
type FontCharsetType ml.PropertyInt
//MarshalXML marshal FontCharsetType
func (t *FontCharsetType) MarshalXML(e *xml.Encoder, start xml.StartElement) error {
return (*ml.PropertyInt)(t)... |
package reflect
import (
"reflect"
)
func GetFieldName(structure interface{}) []string {
t := reflect.TypeOf(structure)
if t.Kind() == reflect.Ptr {
t = t.Elem()
}
if t.Kind() != reflect.Struct {
panic("Check type error not Struct")
}
fieldNames := make([]string, 0)
for index := 0; index < t.NumField(); i... |
package interfaces
// Unmarshaler refers to anything that can unmarshal data into an interface{}
type Unmarshaler interface {
// Unmarshal unmarshals data from a config or other source into an interface{}
Unmarshal(interface{}) error
}
|
package app
import (
"database/sql"
"fmt"
"net/http"
"github.com/gorilla/mux"
_ "github.com/lib/pq"
)
type App struct {
DB *sql.DB
Router *mux.Router
}
func (app *App) Initialize(dbname, username, password string) error {
connectionStatement := fmt.Sprintf("user=%s dbname=%s password=%s sslmode=disable"... |
package main
import (
"fmt"
"os"
"github.com/spf13/cobra"
"github.com/openshift/installer/pkg/asset/releaseimage"
"github.com/openshift/installer/pkg/version"
)
func newVersionCmd() *cobra.Command {
return &cobra.Command{
Use: "version",
Short: "Print version information",
Long: "",
Args: cobra.Ex... |
package main
import (
"bytes"
"encoding/binary"
"errors"
"fmt"
"hash/crc32"
"io"
"io/ioutil"
"log"
"os"
tfExample "github.com/tensorflow/tensorflow/tensorflow/go/core/example/example_protos_go_proto"
"google.golang.org/protobuf/proto"
)
// https://github.com/tensorflow/tensorflow/blob/051a96f3ec4fc38b248e... |
package calc
import "math"
// Entropy calculates the average amount of information in bits of a random variable (entropy).
// See https://en.wikipedia.org/wiki/Entropy_(information_theory).
func Entropy(p []float64) float64 {
sum := 0.0
for _, v := range p {
sum += v * math.Log2(v)
}
return -1.0 * sum
}
|
package ircserver
import (
"sort"
"gopkg.in/sorcix/irc.v2"
)
func init() {
Commands["WHO"] = &ircCommand{
Func: (*IRCServer).cmdWho,
}
}
func (i *IRCServer) cmdWho(s *Session, reply *Replyctx, msg *irc.Message) {
if len(msg.Params) < 1 {
i.sendUser(s, reply, &irc.Message{
Prefix: i.ServerPrefix,
Com... |
package main
import (
"fmt"
"simpleRobot/controller"
"simpleRobot/controller/logic"
"simpleRobot/robot"
)
func main() {
robot := robot.NewRobot()
robot.SetIrSensorMode("IR-REMOTE")
//pidLogic := pid.CreatePidWorker(pid.CreatePid())
remoreLogic := new(logic.Remote)
controller := controller.CreateController(... |
package main
import (
"encoding/json"
"fmt"
"log"
"math/rand"
"os"
"os/exec"
"path"
"strings"
"time"
"github.com/square/p2/pkg/launch"
"github.com/square/p2/pkg/manifest"
"github.com/square/p2/pkg/types"
"github.com/square/p2/pkg/uri"
"github.com/square/p2/pkg/version"
"gopkg.in/alecthomas/kingpin.v2"
... |
package downloader
import (
"github.com/lf-edge/eve/pkg/pillar/types"
log "github.com/sirupsen/logrus"
)
// Handles both create and modify events
func handleDatastoreConfigModify(ctxArg interface{}, key string,
configArg interface{}) {
ctx := ctxArg.(*downloaderContext)
config := configArg.(types.DatastoreConfi... |
package logggerScan
import (
"log"
"os"
)
const panicFileName = "panicStackTraceLog.log"
/*
PanicSave log to logfile
panic stacktrace
*/
func PanicSaveTrace(stackTrace string){
f, err := os.OpenFile(panicFileName, os.O_RDWR | os.O_CREATE | os.O_APPEND, 0666)
if err != nil {
log.Println("error opening LOG file... |
package service
import (
"github.com/feng/future/go-kit/agfun/app-server/protocol/api"
)
// AppService app服务接口
type AppService interface {
CreateAccount(req api.CreateAccountReq) (api.CreateAccountResp, error)
Account(req api.AccountReq) (api.CreateAccountResp, error)
UpdateAccount(req api.UpdateAccountReq) (api.... |
// +build linux
package main
import (
"flag"
"fmt"
stdlog "log"
"os"
"path/filepath"
"sync"
"syscall"
"time"
"github.com/Cloud-Foundations/Dominator/lib/constants"
"github.com/Cloud-Foundations/Dominator/lib/flags/loadflags"
"github.com/Cloud-Foundations/Dominator/lib/fsutil"
"github.com/Cloud-Foundation... |
package test
import (
"context"
"testing"
"github.com/kohge4/go-rakutenapi/rakuten"
"github.com/stretchr/testify/assert"
)
var (
client *rakuten.Client
ctx context.Context
)
func init() {
client = NewTestClient()
ctx = context.Background()
}
func TestBooksTotalSearch(t *testing.T) {
params := &rakuten... |
package otf
import "testing"
func TestMaxPowerOf2(t *testing.T) {
type testSet struct{ in, out USHORT }
var test = []testSet{
{1, 0},
{4, 2},
{6, 2},
{0, 0},
}
for i, v := range test {
if x := maxPowerOf2(v.in); x != v.out {
t.Errorf("Test %v maxPowerOf2(`%v`) = %v, want %v", i, v.in, x, v.out)
}
... |
package jwt
import (
"fmt"
"strconv"
"time"
jwt "github.com/dgrijalva/jwt-go"
)
// JWT ...
type JWT struct {
issuer string
audience string
key []byte
expiry time.Duration
signmeth jwt.SigningMethod
}
// New ...
func New(issuer, audience, key string, expiry time.Duration) (*JWT, error) {
if issuer... |
package main
import (
"fmt"
"sync"
"time"
termbox "github.com/nsf/termbox-go"
)
var (
runFlag = false
maxRows = 21
words = []*Word{
&Word{
word: "Hello",
row: 0,
onScreen: time.Now(),
duration: time.Duration(3) * time.Second,
},
&Word{
word: "World",
row: 2,
onSc... |
/*
You are given an integer array nums and an integer k. You want to find a subsequence of nums of length k that has the largest sum.
Return any such subsequence as an integer array of length k.
A subsequence is an array that can be derived from another array by deleting some or no elements without changing the orde... |
package job_plan
import (
logs "github.com/sirupsen/logrus"
"github.com/yangqinjiang/mycrontab/worker/common"
"time"
)
//任务计划表 ,使用最小堆实现
type JobPlanArray struct {
JobPlanManager //任务计划管理
jobPlanTable map[string]*common.JobSchedulePlan //任务调度计划表内存里的任务计划表,
}
func (j *JobPlanArray)... |
package expkg
import (
"fmt"
"html"
"log"
"net/http"
)
func main() {
//---------try catch 1
defer func() {
// 获取异常信息
if err := recover(); err != nil {
// 输出异常信息
fmt.Println("error:", err)
}
}()
//---------- try catch 2
fmt.Println(" serivert ing..")
}
|
package main
import (
"errors"
"net"
"os"
"os/exec"
)
func main() {
errors.New()
// 类型已知
os.PathError
os.LinkError
os.SyscallError
exec.Error
// 类型相同
os.ErrClosed
os.ErrInvalid
os.ErrPermission
// 没有相应变量,且类型未知,只能用错误信息的字符串表示形式来做判断
os.IsExist() // 判断错误是否因为存在
os.IsNotExist() // 判断错误是否因为不存在
os... |
package main
import (
"flag"
"github.com/evil-router/isfired/config"
"github.com/evil-router/isfired/handlers"
"log"
"net/http"
)
func main() {
server := http.Server{
Addr: "127.0.0.1:8080",
}
confptr := flag.String("conf", "conf.json", "config file location")
flag.Parse()
err := config.GetConfig(*confpt... |
package api
import (
"encoding/json"
"fmt"
"io/ioutil"
"log"
"net/http"
"reflect"
"github.com/codingsince1985/geo-golang/yandex"
)
//Location struct
type (
Location struct {
Place string
// Type string
Population float64
}
)
//GetLocation returns locations from lon & len
func (api API) GetLocat... |
package basic
import (
"fmt"
"runtime"
"sync"
)
func SyncPool() {
/*
sync.Pool 的定位不是做类似连接池的东西,
它的用途仅仅是增加对象重用的几率,
减少 gc 的负担,而开销方面也不是很便宜的。
*/
p := &sync.Pool{
New: func() interface{} {
return 0
},
}
a := p.Get().(int)
p.Put(1)
b := p.Get().(int)
fmt.Println("syncpool get a=", a, ", b=", b)
b = ... |
package main
import (
"bytes"
"encoding/json"
"io/ioutil"
"testing"
"github.com/kr/pretty"
)
func TestLoadAPFromSrc(t *testing.T) {
b, err := ioutil.ReadFile("fixture/create_ap.conf")
if err != nil {
t.Fatal(err)
}
a, err := LoadAPFromConf(b)
if err != nil {
t.Fatal(err)
}
var buf bytes.Buffer
_, er... |
package log
import (
"encoding/json"
"reflect"
"testing"
"time"
)
func TestJsonFormatter_Format(t *testing.T) {
entry := &Entry{
Location: "function(file:line)",
Time: time.Date(2018, time.May, 20, 8, 20, 30, 666000000, time.UTC),
Level: InfoLevel,
TraceId: "trace_id_123456789",
Message: "mess... |
package digitalocean
import (
"os"
"testing"
"github.com/stretchr/testify/assert"
)
var (
doLiveTest bool
doAuthToken string
doDomain string
doIP string
)
func init() {
doAuthToken = os.Getenv("DO_AUTH_TOKEN")
doDomain = os.Getenv("DO_DOMAIN")
doIP = os.Getenv("DO_IP")
if len(doAuthToken) > 0 ... |
package mem_user_service
func init() {
go listen()
}
|
package parsecsv
import (
"fmt"
"github.com/IhorBondartsov/csvReader/entity"
"regexp"
"strconv"
"strings"
)
const countFieldInStruct = 4
type Parser interface {
Parse(str string) (data entity.PersonData, err error)
}
func NewParser() Parser {
return &MyCustomParser{
reqForNumber: regexp.MustCompile("[0-9]+... |
package juno
import (
"errors"
"github.com/Mintegral-official/juno/document"
"github.com/Mintegral-official/juno/index"
)
type Index struct {
invertedIndex index.InvertedIndex
storageIndex index.StorageIndex
}
func NewIndex(name string) *Index {
return &Index{
invertedIndex: index.NewSimpleInvertedIndex(),
... |
package db
import (
"database/sql"
_ "github.com/Go-SQL-Driver/MySQL"
//"time"
)
var (
db *sql.DB
err error
)
func init(){
db, err = sql.Open("mysql", "root:@/test?charset=utf8")
checkErr(err)
}
func Insert() int64{
stmt, err := db.Prepare("INSERT userinfo SET username=?,departname=?,created=?")
checkErr(... |
package tests_test
import (
"context"
"encoding/json"
"fmt"
v1 "k8s.io/api/core/v1"
kubevirtv1 "kubevirt.io/client-go/api/v1"
"time"
k8smetav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/client-go/kubernetes/scheme"
. "github.com/onsi/ginkgo"
. "github.com/onsi/gomega"
testscore "kubevirt.io/kubevirt/t... |
//go:build integration
// +build integration
package tests
import (
"context"
"log"
"os"
"strings"
"testing"
"time"
foundOS "github.com/brigadecore/brigade-foundations/os"
"github.com/brigadecore/brigade/sdk/v3"
"github.com/brigadecore/brigade/sdk/v3/meta"
"github.com/brigadecore/brigade/sdk/v3/restmachine... |
package crossregionsubnets
import (
"github.com/selectel/go-selvpcclient/selvpcclient/resell/v2/servers"
"github.com/selectel/go-selvpcclient/selvpcclient/resell/v2/subnets"
)
// CrossRegionSubnet represents a single Resell cross-region subnet.
type CrossRegionSubnet struct {
// ID is a unique id of a cross-region... |
package services
import (
"createorder/domain/order"
"createorder/utils/errors"
)
type PaymentSessionInterface interface {
CreatePaymentItem(*order.PaymentItem) *errors.RestErr
UpdatePaymentRecord(req *order.PaymentItemUpdateReq) *errors.RestErr
}
type createPaymentSessionRepo struct{}
func PaymentSessionServic... |
package client
import (
"log"
"github.com/yekhlakov/gojsonrpc/common"
)
type Transport interface {
PerformRequest(rc *common.RequestContext) error
AddPreProcessingStage(stage common.Stage)
AddPostProcessingStage(stage common.Stage)
SetLogger(l *log.Logger) error
}
type Client struct {
T Transport
logge... |
//
// Copyright 2020 The AVFS 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... |
package theme
import (
"github.com/therecipe/qt/core"
"github.com/therecipe/qt/internal/examples/showcases/wallet/theme/controller"
)
func init() { themeTemplate_QmlRegisterType2("ThemeTemplate", 1, 0, "ThemeTemplate") }
type themeTemplate struct {
core.QObject
_ func() `constructor:"init"`
_ ... |
// Copyright 2018 the u-root Authors. All rights reserved
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
package integration
import (
"testing"
)
// TestMountKExec runs an init which mounts a filesystem and kexecs a kernel.
func TestMountKExec(t *testing.T) {... |
package router
import (
"github.com/ArakiTakaki/golangWebLesson/controllers/home"
"github.com/gin-gonic/gin"
)
func homeSet(r *gin.RouterGroup) {
r.GET("/", home.Index)
r.GET("/index.html", home.Index)
}
|
package model
// empty IP
var EMPTY_VIRTUAL_IP VirtualIp = MakeVirtualIp("")
// handler protocols
const TEST_DATA_PROTOCOL = 0
const TRANSPORT_PROTOCOL = 6
const RIP_PROTOCOL = 200
// IP header
const IP_VERSION = 4
const IP_DEFAUTL_HEADER_LEN = 20
const IP_DEFAULT_TOS = 0
const IP_DEFAULT_TTL = 16
const IP_DEFAULT_I... |
package main
import (
"math/bits"
"testing"
"github.com/stretchr/testify/assert"
)
func TestIntMax(t *testing.T) {
assert.Equal(t, 5, intMax(3, 5))
assert.Equal(t, -5, intMax(-6, -5))
assert.Equal(t, 0, intMax(0, 0))
}
func TestCountBits(t *testing.T) {
assert.Equal(t, 0, bits.Len(0x0))
assert.Equal(t, 3, b... |
package service
type ZygoteService struct {
}
func NewZygoteService() *ZygoteService {
return &ZygoteService{
}
}
|
package main
import "fmt"
import "sync"
import "errors"
import "math/rand"
import "time"
type SuccessFunc func(string)
type FailureFunc func(error)
type ExecuteFunc func(int) (string, error)
type Subject struct {
success SuccessFunc
failure FailureFunc
}
func (s *Subject) Success(f SuccessFunc) *Subject {
s.succ... |
package main
import (
"fmt"
)
type S struct{}
func (s *S) M() {
fmt.Println("Hello World")
}
func main() {
s := new(S)
s.M()
}
|
/*
Copyright 2021 RadonDB.
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
distri... |
package main
import (
"testing"
"github.com/jackytck/projecteuler/tools"
)
func TestP39(t *testing.T) {
cases := []tools.TestCase{
{In: 1000, Out: 840},
}
tools.TestIntInt(t, cases, solve, "P39")
}
|
package ruffe
import (
"net/http"
)
type MuxCreator interface {
Create() Mux
}
type Mux interface {
Handle(pattern string, handler http.Handler)
HandleFunc(pattern string, handler func(http.ResponseWriter, *http.Request))
ServeHTTP(w http.ResponseWriter, r *http.Request)
}
type Router struct {
pathPrefix st... |
package internal
import (
"github.com/stretchr/testify/assert"
"os"
"testing"
)
func TestLogo(t *testing.T) {
assert.NotContains(t, GetMonochromeASCIILogo(), "\033[")
_ = os.Setenv("COLORTERM", "truecolor")
assert.Contains(t, GetASCIILogo(), "\033[38;5;209m")
_ = os.Setenv("COLORTERM", "d")
_ = os.Setenv("T... |
package main
import (
"encoding/csv"
"flag"
"fmt"
"github.com/go-kit/kit/log"
"github.com/go-kit/kit/log/level"
influx "github.com/influxdata/influxdb/client/v2"
"github.com/meixinyun/common/pkg/util/sets"
"github.com/prometheus/client_golang/prometheus"
"github.com/prometheus/common/model"
"github.com/prome... |
package cmdline
import "github.com/urfave/cli"
var (
pubkeyFileName, privKeyFileName string
keySize int
)
var flg = []cli.Flag{
&cli.StringFlag{
Name: "pub",
Value: "pubkey.pem",
Usage: "Public Key Filename",
Destination: &pubkeyFileName,
},
&cli.StringFlag{
... |
package main
import (
"fmt"
"time"
)
type Work struct {
Job string
Do func()
}
func makeWorkQ(size int) chan Work {
return make(chan Work, size)
}
func main() {
workQ := makeWorkQ(5)
// send work
go func() {
for i := 0; i < 4; i++ {
w := Work{
Job: "Print Greeting",
Do: func() {
fmt.Prin... |
package main
import (
"github.com/astaxie/beego/migration"
)
// DO NOT MODIFY
type Post_20160526_154620 struct {
migration.Migration
}
// DO NOT MODIFY
func init() {
m := &Post_20160526_154620{}
m.Created = "20160526_154620"
migration.Register("Post_20160526_154620", m)
}
// Run the migrations
func (m *Post_20... |
package states
import (
"context"
"encoding/base64"
"errors"
"time"
cloudevents "github.com/cloudevents/sdk-go/v2"
derrors "github.com/direktiv/direktiv/pkg/flow/errors"
log "github.com/direktiv/direktiv/pkg/flow/internallogger"
"github.com/direktiv/direktiv/pkg/model"
"github.com/google/uuid"
"github.com/s... |
//Gordon Stangler
//cgo example, compiled with gcc, with CFLAGS
package main
//#cgo CFLAGS: -g -Wall
//#include <stdlib.h>
//#include "FordGreet.h"
import "C"
import(
"fmt"
"unsafe"
)
func main() {
name:= C.CString("Ford team")
defer C.free(unsafe.Pointer(name))
year := C.int(2019)
ptr := C.malloc(C.sizeof_... |
package main
import (
"flag"
"fmt"
"log"
"os"
)
var name string
func main() {
// log.Println("Hello, World!")
// log.Panic("oops!")
// log.Fatalln("oops!")
prefix := fmt.Sprintf("%s: ", os.Args[0])
// infoLog := log.New(os.Stdout, prefix, log.LstdFlags)
info, err := os.Create("info.log")
if err != nil {
... |
package device
import (
"fmt"
"github.com/uhppoted/uhppote-core/types"
"github.com/uhppoted/uhppoted-lib/uhppoted"
"github.com/uhppoted/uhppoted-mqtt/common"
)
func (d *Device) GetTime(impl uhppoted.IUHPPOTED, request []byte) (interface{}, error) {
body := struct {
DeviceID *uhppoted.DeviceID `json:"device-id... |
package crypto
import (
"crypto/aes"
"crypto/cipher"
"errors"
"strconv"
)
const (
AesBlockSize = 16
)
type AesCBCCrypter struct {
blockSize int
encryptBlockMode cipher.BlockMode
decryptBlockMode cipher.BlockMode
padding PaddingInterface
}
func NewAesCBCCrypter(key []byte, iv []byte) (*AesCBCCrypter, erro... |
// Package micro provides a macro ALL in one go-micro
package micro
import (
"github.com/micro/go-micro"
_ "github.com/micro/macro"
)
// NewService returns a new macro micro.Service
func NewService(opts ...micro.Option) micro.Service {
return micro.NewService(opts...)
}
|
package models
type OrderItem struct {
ProductId int64 `json:"product_id"`
Quantity int64 `json:"quantity"`
}
|
package decorator
import (
"fmt"
"reflect"
)
func Decorator_(decoPtr, fn interface{}) (err error) {
var decoratedFunc, targetFunc reflect.Value
decoratedFunc = reflect.ValueOf(decoPtr).Elem()
targetFunc = reflect.ValueOf(fn)
v := reflect.MakeFunc(targetFunc.Type(),
func(in []reflect.Value) (out []reflect.Valu... |
package main
import (
"fmt"
"io/ioutil"
"log"
"math"
"path/filepath"
"sort"
"strings"
)
// Speech describes a file/speech text
type Speech struct {
Name string
Raw string
NumWords int
NumUniqueWords int
Tokens []string
FL FreqList
TFIDF FreqList
}
// Freq... |
package main
//给你一个由 '1'(陆地)和 '0'(水)组成的的二维网格,请你计算网格中岛屿的数量。
//
//岛屿总是被水包围,并且每座岛屿只能由水平方向和/或竖直方向上相邻的陆地连接形成。
//
//此外,你可以假设该网格的四条边均被水包围。
//
//
//
//示例 1:
//
//输入:grid = [
//["1","1","1","1","0"],
//["1","1","0","1","0"],
//["1","1","0","0","0"],
//["0","0","0","0","0"]
//]
//输出:1
//示例 2:
//
//输入:grid = [
//["1","1","0","0"... |
package kubeclient
import (
"bytes"
"encoding/json"
"fmt"
"io/ioutil"
"net/http"
"net/url"
"golang.org/x/build/kubernetes/api"
"golang.org/x/net/context"
"golang.org/x/net/context/ctxhttp"
)
const (
replicationControllersPath = apiPrefix + "/namespaces/%s/replicationcontrollers"
replicationControllerPath ... |
package main
// FeetToMeters Every function outside main.go must follow a very strict format
// where the line immediately previous to the function's signature
// is a // style comment that starts with the function's name, then some text,
// and continues for however many lines...a /* */ style comment won't do.
// Nei... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.