text stringlengths 11 4.05M |
|---|
package menu
import (
"errors"
"github.com/gin-gonic/gin"
"strings"
"time"
"yj-app/app/model"
menuModel "yj-app/app/model/system/menu"
userService "yj-app/app/service/system/user"
cache "yj-app/app/yjgframe/cache"
"yj-app/app/yjgframe/utils/convert"
"yj-app/app/yjgframe/utils/gconv"
"yj-app/app/yjgframe/uti... |
package quicksort
import (
"testing"
)
func TestPartition(t *testing.T) {
a := []int{1, 2, 5, 4, 3}
t.Log(partition(a, 0, len(a)-1))
}
func TestSort(t *testing.T) {
a := []int{2, 8, 7, 1, 3, 5, 6, 4}
sort(a, 0, len(a)-1)
t.Log(a)
}
func Benchmark1(b *testing.B) {
a := []int{1, 2, 3, 4, 5, 6, 7, 8}
for i :=... |
package controllers
import "github.com/astaxie/beego"
type ErrorController struct {
IndexController
}
func (c *ErrorController) Error404() {
c.Data["Path"] = c.Ctx.Request.RequestURI
c.TplName = "error/404.html"
}
func (c *ErrorController) Error500() {
c.Data["Title"] = "500 Internal Server Error"
c.Data["Info... |
package persistence
import (
"database/sql"
"encoding/json"
"fmt"
"time"
"github.com/dollarshaveclub/acyl/pkg/models"
"github.com/dollarshaveclub/metahelm/pkg/metahelm"
"github.com/google/uuid"
"github.com/lib/pq"
"github.com/pkg/errors"
)
// GetEventLogByID returns a single EventLog by id, or nil or error
... |
package query
import (
"github.com/gin-gonic/gin"
"sub_account_service/number_server/routers/query/api"
)
func InitRouter() *gin.Engine {
r := gin.New()
r.Use(gin.Logger())
r.Use(gin.Recovery())
r.GET("/orders/batch", api.BatchGetOrderList)
r.GET("/getLatestVersion", api.GetLatestVersion)
return r
}
|
package keeper
import (
"github.com/BitCannaGlobal/testnet-bcna-cosmos/x/bcna/types"
)
var _ types.QueryServer = Keeper{}
|
package solcast
import (
datatypes "github.com/Siliconrob/solcast-go/solcast/types"
"encoding/json"
"fmt"
"io/ioutil"
"log"
"math"
"net/http"
"strconv"
"time"
"github.com/jimlawless/whereami"
"github.com/google/go-querystring/query"
"github.com/pkg/errors"
"github.com/vardius/worker-pool"
"runtime"
"syn... |
package constant
const SPIDE_URL string = "go.config.url"
const SPIDE_KEYWORD string = "go.config.keyword"
const SPIDE_PAGE_SIZE string = "go.config.pageSize"
const SPIDE_SAVE_PATH string = "go.config.savePath"
func main() {
}
|
package coredb
import (
"testing"
"go.uber.org/zap/zapcore"
jarvisbase "github.com/zhs007/jarviscore/base"
)
func TestBackup06(t *testing.T) {
jarvisbase.InitLogger(zapcore.DebugLevel, true, "", "")
//------------------------------------------------------------------------
// initial CoreDB
cdb, err := New... |
package main
import (
"bufio"
"strings"
"testing"
"github.com/stretchr/testify/assert"
)
var message = `/KFM5KAIFA-METER
1-3:0.2.8(42)
0-0:1.0.0(160525205154S)
0-0:96.1.1(1234567890)
1-0:1.8.1(000001.117*kWh)
1-0:1.8.2(000004.491*kWh)
1-0:2.8.1(000000.000*kWh)
1-0:2.8.2(000000.000*kWh)
0-0:96.14.0(0002)
1-0:1.7... |
/*
Copyright 2022 The KubeVela Authors.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, softw... |
/*
Create a user defined struct with the identifier “person” the fields:
first
last
age
attach a method to type person with
the identifier “speak”
the method should have the person say their name and age
create a value of type person
call the method from the value of type person
*/
package main
import "fmt"
typ... |
package main
import (
"encoding/json"
"io/ioutil"
"net/http"
"os"
"strings"
)
type request struct {
URL string `json:"url"`
Method string `json:"method"`
Headers http.Header `json:"headers"`
Environ []string `json:"environ"`
Body []byte `json:"body"`
}
const EnvPrefix = "ECHO_"
f... |
package main
import (
fretchet "github.com/artpar/frechet/frechet"
// "fmt"
"fmt"
)
func main() {
var frechet fretchet.FrechetDistance;
var curveA, curveB [][]float64;
var dist float64;
// two curves in 3D
curveA = [][]float64{[]float64{0, -497.75619757841895}, []float64{559.4405594405595, -592.7969328517269}... |
// testadd project doc.go
/*
testadd document
*/
package main
|
package utils
import (
"fmt"
"testing"
)
func TestRandom(t *testing.T) {
}
func TestGetUniqueId(t *testing.T) {
t.Logf("id: %v", GetUniqueId())
}
func TestRandString(t *testing.T) {
for i := 1; i <= 10; i++ {
t.Logf("str: %v", RandString(32))
t.Logf("len: %v", len(RandString(32)))
}
}
func TestRemoveRep... |
package main
import "fmt"
const (
a = iota
b
c
d
)
func main() {
const e = iota
fmt.Println(a)
fmt.Println(b)
fmt.Println(c)
fmt.Println(d)
fmt.Println(e)
}
|
package gosnowth
import (
"context"
"fmt"
"path"
)
// LocateMetric returns a list of nodes owning the specified metric.
func (sc *SnowthClient) LocateMetric(uuid string, metric string,
node ...*SnowthNode,
) ([]TopologyNode, error) {
if len(node) > 0 {
return sc.LocateMetricRemote(uuid, metric, node[0])
}
t... |
package main
import (
"net/http"
"strings"
"text/template"
//"path"
//"github.com/op/go-logging"
)
var (
//log = logging.MustGetLogger("main")
)
type playHandler struct {
root string
tmpl string
}
func playServer(root, template string) http.Handler {
return &playHandler{root, template}
}
func (u *pla... |
package etw
import (
"github.com/narph/etwbeat/config"
"github.com/pkg/errors"
"github.com/elastic/beats/v7/libbeat/beat"
"github.com/elastic/beats/v7/libbeat/common"
"github.com/elastic/beats/v7/libbeat/common/fmtstr"
"github.com/elastic/beats/v7/libbeat/logp"
"github.com/elastic/beats/v7/libbeat/processors"... |
package main
import (
"encoding/json"
"fmt"
"mysql_byroad/model"
"strings"
"sync"
"time"
"github.com/Shopify/sarama"
log "github.com/Sirupsen/logrus"
"github.com/samuel/go-zookeeper/zk"
"github.com/wvanbergen/kafka/consumergroup"
)
type Entity struct {
Database string `json:"database"`
Table ... |
package main
import "fmt"
var age = test()
func test() int {
fmt.Println("test")
return 90
}
//init函数,完成一些初始化的工作
func init() {
fmt.Println("main init")
}
func main() {
fmt.Println("main----age=", age)
}
|
package main
import (
"fmt"
"html/template"
"im/app/controller"
"log"
"net/http"
)
// 注册模板
func registerView() {
//basePath, _ := os.Getwd()
tpl, err := template.ParseGlob("./app/view/*")
if err != nil {
log.Fatal(err)
}
for _, v := range tpl.Templates() {
tplName := v.Name()
fmt.Println(tplName)
ht... |
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT license.
package armhelpers
import (
"context"
"testing"
)
func TestGetLogAnalyticsWorkspaceInfo(t *testing.T) {
mc, err := NewHTTPMockClient()
if err != nil {
t.Fatalf("failed to create HttpMockClient - %s", err)
}
mc.Re... |
package localElevatorFSM
import (
"../config"
"../elevio"
)
func requestsAbove(e Elevator) bool {
for floor := e.floor + 1; floor < config.N_FLOORS; floor++ {
for button := 0; button < config.N_BUTTONS; button++ {
if e.requests[floor][button] {
return true
}
}
}
return false
}
func requestsBelow(e... |
package data
type DataClient interface {
// 将请求信息存入数据库
InsertRequestInfo(ri *RequestInfo) error
// 修改请求信息--状态
UpdateRequestInfoStatus(status int, id int64) error
// 修改请求信息--请求次数
UpdateRequestInfoTimes(id int64) error
// 修改请求信息--是否发送成功过邮件
UpdateRequestInfoSend(id int64) error
// 查找所有异常数据(状态为:2(提交失败)和4(回滚失败))
... |
package main
import (
"bufio"
"bytes"
"crypto/sha256"
"crypto/tls"
"encoding/hex"
"fmt"
"net"
"os"
"os/exec"
"strings"
"time"
"github.com/lesnuages/hershell/meterpreter"
"github.com/lesnuages/hershell/shell"
)
const (
errCouldNotDecode = 1 << iota
errHostUnreachable = iota
errBadFingerprint = iota
... |
package main
import (
"fmt"
"os"
"github.com/aleale2121/Golang-TODO-Hex-DDD/pkg/cmd"
)
func main() {
if err := cmd.RunServer(); err != nil {
_, _ = fmt.Fprintf(os.Stderr, "%v\n", err)
os.Exit(1)
}
}
|
package app
import (
"errors"
"fmt"
"github.com/domac/ats_check/log"
"github.com/domac/ats_check/util"
"math/rand"
"net"
"os"
"path/filepath"
"strings"
"sync"
"time"
)
//服务器down掉异常
var ErrServerDown = errors.New("parent server down")
//上层节点结构
type ParentServer struct {
Host string
Working bool
Mar... |
package api
import (
"octlink/mirage/src/modules/session"
"octlink/mirage/src/utils/httpresponse"
"octlink/mirage/src/utils/merrors"
"octlink/mirage/src/utils/octlog"
"octlink/mirage/src/utils/octmysql"
"github.com/gin-gonic/gin"
)
type ApiResponse struct {
Error int `json:"error"`
ErrorLog string... |
package smallpng
import (
"image"
"image/color"
"math/rand"
"runtime"
"sync"
)
// DefaultMaxKMeansIters is the default maximum number of
// iterations of the k-means algorithm for clustering.
const DefaultMaxKMeansIters = 5
// DefaultPaletteSize is the default number of colors in a
// color palette.
const Defau... |
package mesg
type Soldier struct {
Id int `json:"id"` //士兵id
Rarity int `json:"rarity"` //士兵稀有度
Unlockarena int `json:"unlockarena"` //解锁阶段
Combatpoints int `json:"combatpoints"` //战力
Name string `json:"name"` //名字
Cvc int `json:"cvc"` //cvc client version code
}
// PrintRari... |
// Copyright 2019 Drone.IO Inc. All rights reserved.
// Use of this source code is governed by the Blue Oak Model License
// that can be found in the LICENSE file.
package gc
import (
"context"
"errors"
"fmt"
"testing"
"time"
"github.com/drone/drone-gc/mocks"
"github.com/docker/docker/api/types"
"github.com... |
// 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... |
package main
import (
"time"
log "github.com/sirupsen/logrus"
"gopkg.in/mgo.v2"
"github.com/go-numb/go-bitflyer/auth"
"github.com/go-numb/go-bitflyer/v1"
"github.com/go-numb/go-bitflyer/v1/public/executions"
"github.com/go-numb/go-bitflyer/v1/types"
)
func main() {
done := make(chan struct{})
go getExec(... |
package utilities
import (
"fmt"
"strings"
)
// Mac Mac converts a byte array to a mac address
func Mac(data []byte) string {
return strings.Join(ConvertToHex(data), ":")
}
// ConvertToHex Converts a byte array to its Hex representation
func ConvertToHex(data []byte) []string {
var hexBytesArray = make([]strin... |
// 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 rc522
import (
"errors"
"github.com/zyxar/berry/bus"
"github.com/zyxar/berry/core"
)
var (
ErrNoTag = errors.New("no tag found")
ErrInvalidTag = errors.New("invalid tag")
ErrTagCRC = errors.New("tag crc error")
ErrTagCollision = errors.New("tag collision")
)
type Device struct {
dev b... |
package demo01
import "fmt"
func ArrayLiteral() {
arr1 := [3]int8{}
arr2 := [3]string{"A", "B", "C"}
arr3 := [...]bool{true, false, true}
arr4 := [...]int{0: 1, 2: 2, 1: 3, 5: 5, 7}
for i, v := range arr1 {
fmt.Printf("arr1[%d] = %d\n", i, v)
}
for i := 0; i < len(arr2); i++ {
fmt.Printf("arr2[%d] = %s\n"... |
package exchange
import (
"io"
"sync"
"github.com/daakia/utils/distribution"
)
type Node interface {
Subscribe(key []byte, id string, s io.Writer)
UnSubscribe(key []byte, id string)
Publish(key []byte, data []byte)
//Remove(key[]byte)
}
type TopicConf struct {
SingleWc byte
MultiWc byte
Sys byte
Di... |
package allmulti
import (
"context"
"crypto/tls"
)
func (ms *MultiAllStorage) IsPushCertStale(ctx context.Context, topic string, staleToken string) (bool, error) {
finalStale, finalErr := ms.stores[0].IsPushCertStale(ctx, topic, staleToken)
for n, storage := range ms.stores[1:] {
if _, err := storage.IsPushCert... |
package day02
import (
"flag"
"fmt"
"os"
)
/*
疑问:
1.为什么demo03中函数第二个参数和demo02中同名会报错: flag redefined
Note:
1.os.Args持有命令行参数
2.flag包实现命令行标记解析
1.命令行标记格式: -flag
*/
func CommandLineArgs() {
demo01()
//demo02()
demo03()
}
func demo01() {
//测试数据: name 杨一帆 age 21 gender male
fmt.Println("------方式一: os.Args-----... |
// Copyright 2014 The Sporting Exchange Limited. All rights reserved.
// Use of this source code is governed by a free license that can be
// found in the LICENSE file.
package collect
import (
"opentsp.org/contrib/collect-netscaler/nitro"
)
func init() {
registerStatFunc("protocolhttp", protocolHTTP)
}
func prot... |
// Copyright (c) 2014 James Wendel. 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 (
"bitbucket.org/kyrra/sandbox/webapi/auth"
"flag"
"fmt"
)
func main() {
listen := flag.String("listen", ":8080", "Hostname and addr... |
package fileupload
import (
"context"
"errors"
"io/ioutil"
"net/http"
"github.com/alejogs4/blog/src/post/domain/post"
"github.com/alejogs4/blog/src/shared/infraestructure/httputils"
"github.com/alejogs4/blog/src/shared/infraestructure/middleware"
)
var errCopyingFile = errors.New("File: file must be present")... |
package main
import (
"bufio"
"encoding/hex"
"fmt"
"os"
"strings"
)
func decodeBytes(src string) []byte {
h := make([]byte, hex.DecodedLen(len(src)))
_, err := hex.Decode(h, []byte(src))
if err != nil {
panic(err)
}
return h
}
func xorByVal(bs []byte, b byte) []byte {
res := make([]byte, len(bs))
for i... |
package main
import (
"fmt"
"net/http"
"log"
"encoding/json"
"strconv"
)
// 问题类型
type Question struct {
Description string `json:"description"`
ChoiceList []string `json:"choice_list"`
}
// 问题提供的接口类型
type QuestionProvider struct {
QuestionList []Question `json:"question_list"`
}
func ... |
package client
import (
"strings"
"net/http"
"io/ioutil"
)
func post(url string, data map[string]string) (map[string]interface{}, error) {
payload := strings.NewReader(makeFormData(data, "boundaryhere"))
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("content-type", "multipart/form-data; boun... |
package internal
import (
"fmt"
"io"
"os"
"time"
)
func Log(format string, args ...interface{}) {
if args != nil {
fLog(os.Stdout, format, args)
} else {
fLog(os.Stdout, format)
}
}
func LogErr(format string, args ...interface{}) {
if args != nil {
fLog(os.Stderr, "ERROR: "+format, args)
} else {
fL... |
package main
import (
rl "rules"
ac "actions"
)
type Monitor struct {
d_rules []rl.Rule
d_actions []ac.Action
}
func (m*Monitor)Init(){
m.d_actions = ac.InitAllActions()
m.d_rules = rl.InitAllRules()
}
func (m*Monitor)MparseLine(line string)string{
event,rb := ParseLine(line)
if rb ==... |
package amber
import (
"bytes"
"encoding/binary"
"errors"
"path/filepath"
"github.com/EgeBalci/amber/utils"
pe "github.com/EgeBalci/debug/pe"
)
const (
PE_DOS_STUB = "This program cannot be run in DOS mode"
)
var (
ErrUnsupportedArch = errors.New("unsupported PE file architecture")
ErrInvalidPeSpecs = e... |
package main
import (
"encoding/json"
"github.com/stretchr/testify/assert"
"testing"
)
func TestModelsCanBeConvertedToProperJson(t *testing.T) {
expected := "{\"drink\":\"beer\",\"rolled\":2}"
redisResult := &Score{
Drink: "beer",
Rolled: 2,
}
body, err := json.Marshal(redisResult)
result := string(body... |
package goracle
// Version of this driver
const Version = "v2.1.20"
|
package backend_service
import (
"2021/yunsongcailu/yunsong_server/backend/backend_dao"
"2021/yunsongcailu/yunsong_server/backend/backend_model"
)
type BackendCategoryServer interface {
// 获取所有类别
GetCategories() (categories []backend_model.BackendCategoryModel,err error)
// 添加类别
AddCategory(category backend_mod... |
package dynamic_programming
import "testing"
func Test_maxProfit(t *testing.T) {
res := maxProfit2([]int{7, 1, 5, 3, 6, 4})
if res != 5 {
t.Error(res)
}
}
|
package balancetests
import (
"bufio"
"fmt"
"os"
"sort"
"testing"
)
const Nodes = 4
var (
filePath string = "./words.txt"
nodeList = make([]string, Nodes)
)
func init() {
for n := range nodeList {
nodeList[n] = fmt.Sprintf("node-%d", n)
}
chInit()
fnv1modInit()
vaporchInit()
}
type method str... |
package main
import (
"testing"
"github.com/stretchr/testify/assert"
)
func TestStart(t *testing.T) {
a := autoAir{}
assert.NotNil(t, a)
}
|
package main
import "fmt"
func main() {
J := "z"
S := "ZZ"
answer := numJewelsInStones(J, S)
fmt.Printf("answer: %d", answer)
}
func numJewelsInStones(J string, S string) int {
js := make(map[int32]bool)
for _, c := range J {
js[c] = true
}
var cnt int
for _, c := range S {
if ok, _ := js[c]; ok {
c... |
package kafka
import metrics "github.com/rcrowley/go-metrics"
func init() {
metrics.UseNilMetrics = true
}
|
package password
import (
"crypto/rand"
"crypto/sha256"
"fmt"
"io"
"strings"
"golang.org/x/crypto/pbkdf2"
)
// SecurePassword represents a one-way encypted form of a password. It includes the hash, and
// other information that can be used to regenerate the hash and validate a password.
type SecurePassword str... |
package main
import (
"fmt"
"os"
"github.com/sendgrid/sendgrid-go"
)
func main() {
sg := sendgrid.NewSendGridClient(os.Getenv("SENDGRID_USERNAME"), os.Getenv("SENDGRID_PASSWORD"))
message := sendgrid.NewMail()
message.AddTo("eddiezane@sendgrid.com")
message.AddToName("Eddie Zaneski")
message.AddSubjec... |
/*
* Tencent is pleased to support the open source community by making Blueking Container Service available.
* Copyright (C) 2019 THL A29 Limited, a Tencent company. All rights reserved.
* Licensed under the MIT License (the "License"); you may not use this file except
* in compliance with the License. You may obta... |
package main
import (
"testing"
"github.com/stretchr/testify/assert"
)
func TestPlayfieldCap(t *testing.T) {
pf := NewPlayfield(16, 10)
r, c := pf.Cap()
assert.Equal(t, r, 16)
assert.Equal(t, c, 10)
}
func TestPlayfieldSpawn(t *testing.T) {
pf := NewPlayfield(16, 10)
err := pf.Spawn(func(l int) int { retur... |
package chain
import "testing"
func TestChain(t *testing.T) {
v1 := NewTeacher()
v2 := NewHeadermaster()
v1.SetNext(v2)
v := v1
v.Exec(1)
v.Exec(3)
v.Exec(2)
v.Exec(4)
}
|
package dns
import (
"flag"
"fmt"
"github.com/miekg/dns"
"net"
"os"
"strconv"
"strings"
"sync"
"time"
)
var IpToDNS = make(map[string]string) // key = IP, value = dnsname
var allowed_ips = make([]string, 0)
var Mutex = sync.Mutex{}
func StartDNSServer(channel chan string) {
fmt.Println("Starting DNS Server... |
package main
import (
"bytes"
"context"
"encoding/json"
"fmt"
"log"
"os"
"strconv"
"strings"
"time"
"cloud.google.com/go/firestore"
cstorage "cloud.google.com/go/storage"
gstorage "cloud.google.com/go/storage"
firebase "firebase.google.com/go"
Auth "firebase.google.com/go/auth"
"firebase.google.com/go/... |
package pg
import (
"github.com/kyleconroy/sqlc/internal/sql/ast"
)
type DefElem struct {
Defnamespace *string
Defname *string
Arg ast.Node
Defaction DefElemAction
Location int
}
func (n *DefElem) Pos() int {
return n.Location
}
|
/*
Copyright 2011 Google 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 in writing, software
di... |
package ircserver
import (
"fmt"
"os"
"strings"
"github.com/prometheus/client_golang/prometheus"
"gopkg.in/sorcix/irc.v2"
)
var (
captchaChallengesSent = prometheus.NewCounter(
prometheus.CounterOpts{
Subsystem: "captcha",
Name: "challenges_sent",
Help: "Number of CAPTCHA challenges genera... |
package api
import (
"time"
"github.com/PagerDuty/go-pagerduty"
)
var Client *PagerDutyClient
type PagerDutyClient struct {
apiClient *pagerduty.Client
}
type ScheduleInfo struct {
ID string
Name string
Location *time.Location
Start time.Time
End time.Time
FinalS... |
package main
type PatientHistory struct {
PatientId string `json:"PatientId"`
MedicalRecords []MedicalRecord `json:"MedicalRecords"`
}
|
package rest_api
import (
"bytes"
"context"
"errors"
"github.com/go-chi/chi"
"github.com/stretchr/testify/mock"
"github.com/stretchr/testify/require"
"go-friend-mgmt/cmd/internal/services/mocks"
"go-friend-mgmt/cmd/internal/services/models"
"net/http"
"net/http/httptest"
"testing"
)
func TestCreateConnecti... |
package test
import (
"testing"
)
func TestDes(t *testing.T) {
key := []byte("LKHlhb899Y09olUi")
// encryptMsg, err := encrypt(key, "Hello World")
// if err != nil {
// t.Error(err)
// } else {
// fmt.Println(encryptMsg)
// }
// msg, _ := decrypt(key, encryptMsg)
// fmt.Println(msg) // Hello World
// ... |
package main
import "fmt"
func main() {
/*
Example of If and if else
In this program we print given number is less than 5 print Hi else print Bye
*/
exampleIf()
exampleIfElse()
oddEven() // --> checks number is even or odd
}
func exampleIf() {
number := 4
if number <= 5 {
fmt.Println("Hi")
} else {
... |
package main
import (
"os"
"path/filepath"
"syscall"
"github.com/fd/forklift/util/user"
)
func user_exec() {
home, err := user.Home()
if err != nil {
return
}
path := filepath.Join(home, ".forklift", "bin", "forklift")
_, err = os.Stat(path)
if err != nil {
return
}
if os.Args[0] == path {
retur... |
/*
Broker acts as the HTTP signaling channel.
It matches clients and snowflake proxies by passing corresponding
SessionDescriptions in order to negotiate a WebRTC connection.
TODO(serene): This code is currently the absolute minimum required to
cause a successful negotiation.
It's otherwise very unsafe and problematic... |
// Copyright 2015 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... |
// Copyright 2015 Nevio Vesic
// Please check out LICENSE file for more information about what you CAN and what you CANNOT do!
// Basically in short this is a free software for you to do whatever you want to do BUT copyright must be included!
// I didn't write all of this code so you could say it's yours.
// MIT Licens... |
package main
import (
"math"
"sort"
)
func threeSumClosest(nums []int, target int) int {
sort.Ints(nums)
n := len(nums)
res := 0
mindiff := math.MaxInt32
for i := 0; i < n-2; i++ {
left := i + 1
right := n - 1
for left < right {
cur := nums[i] + nums[left] + nums[right]
curDiff := abs(cur, target)... |
package main
import (
"database/sql"
"fmt"
"strings"
"time"
"github.com/gtfierro/xboswave/ingester/types"
"github.com/immesys/wavemq/mqpb"
_ "github.com/mattn/go-sqlite3"
)
// these are addressable true/false values used internally for the RequestFilter
var _FALSE = false
var _TRUE = true
type ArchiveRequest... |
package models
import (
"time"
)
type AuthUser struct {
Id int64 `xorm:"pk autoincr"`
Password string `xorm:"varchar(128) not null"`
LastLogin time.Time `xorm:"DateTime not null"`
IsSuperuser bool `xorm:"BOOL not null"`
Username string `xorm:"varchar(64) unique not null"`
FirstN... |
package requests
import (
"github.com/sirupsen/logrus"
"gopkg.in/xmlpath.v2"
"strings"
)
type Xpath struct {
Node *xmlpath.Node
Err error
Path *xmlpath.Path
}
func (self *Xpath) New(sHtml string) {
rdHtml := strings.NewReader(sHtml)
self.Node, self.Err = xmlpath.ParseHTML(rdHtml)
}
func (self *Xpath) Parse... |
package api
import (
"encoding/json"
"log"
"net/http"
)
type messageGetRequest struct {
Chat string
}
type message struct {
Id string `json:"id"`
Chat string `json:"chat"`
Author string `json:"author"`
Text string `json:"text"`
Created_at string `json:"crea... |
// Copyright 2017 Vlad Didenko. All rights reserved.
// See the included LICENSE.md file for licensing information
package slops // import "go.didenko.com/slops"
// ExcludeAll returns a new slice where all strings from the
// rejects slice are removed from the src slice, regardless of
// how many times they occur in ... |
package main
import "fmt"
type Student struct {
Name string
Age int
}
func main() {
//创建结构体变量时候指定属性的值
stu := Student{"test", 10}
fmt.Println(stu)
var stu1 = Student{"test", 22}
fmt.Println(stu1)
//创建结构体变量时候指定属性名和属性值写在一起
stu2 := Student{
Name: "ZCR",
Age: 20,
}
fmt.Println(stu2)
var stu3 = Studen... |
package pgeo
import (
"database/sql/driver"
"errors"
"fmt"
)
// Lseg is a line segment and is represented by pairs of points that are the endpoints of the segment.
type Lseg [2]Point
// Value for the database
func (l Lseg) Value() (driver.Value, error) {
return valueLseg(l)
}
// Scan from sql query
func (l *Lse... |
package minedive
import (
"nhooyr.io/websocket"
)
type ClientOptions struct {
WSopts websocket.DialOptions
}
|
package searching
func LinearSearch(items []int, data int) bool {
for _, key := range items {
if key == data {
return true
}
}
return false
}
|
package admin
import (
"encoding/json"
admin "github.com/hxangel/bot/libs/admin"
)
type Index struct {
AdminBase
}
func (c *Index) Index() {
menu := admin.NewMenu()
views, err := json.Marshal(menu.Views)
if err == nil {
c.Assign("JsonViews", string(views))
}
menus, err := json.Marshal(menu.Menus)
if err =... |
package main
import (
"fmt"
"net/http"
"net/url"
"time"
"github.com/medhir/musicbrainz/server"
"github.com/rs/cors"
"github.com/medhir/musicbrainz/server/mbclient"
)
// BaseURL is the API Endpoint for the Musicbrainz client
const BaseURL = "https://musicbrainz.org/ws/2/"
// UserAgent provides a description ... |
package sonarqube
import (
"fmt"
"github.com/hashicorp/terraform-plugin-sdk/helper/schema"
sonargo "github.com/labd/sonargo/sonar"
)
func resourceSettingsValue() *schema.Resource {
return &schema.Resource{
Create: resourceSettingsValueCreate,
Read: resourceSettingsValueRead,
Update: resourceSettingsValue... |
package main
import (
"fmt"
"io/ioutil"
"log"
"os"
"path"
"strings"
"github.com/fogleman/nes/nes"
)
func testRom(path string) (err error) {
defer func() {
if r := recover(); r != nil {
err = r.(error)
}
}()
console, err := nes.NewConsole(path)
if err != nil {
return err
}
console.StepSeconds(3)... |
package core
import (
"encoding/json"
"er"
"fwb"
"sgs"
)
type playerSData struct {
Cereals int
Meat int
Sweater int
}
type pstData struct {
ps map[int]*playerSData
}
func pstInit(me *gameImp) *er.Err {
me.lg.Dbg("Enter Round Settlement phase")
me.pd = &pstData{
ps: make(map[int]*playerSData),
}
m... |
/*
Copyright SecureKey Technologies Inc. All Rights Reserved.
SPDX-License-Identifier: Apache-2.0
*/
package mocks
import (
fab "github.com/hyperledger/fabric-sdk-go/api/apifabclient"
"github.com/hyperledger/fabric-sdk-go/pkg/fabric-client/txn"
"github.com/pkg/errors"
)
// MockTransactor provides an implementati... |
package handler
import (
"net/http"
"github.com/agusbasari29/Skilltest-RSP-Akselerasi-2-Backend-Agus-Basari/entity"
"github.com/agusbasari29/Skilltest-RSP-Akselerasi-2-Backend-Agus-Basari/helper"
"github.com/agusbasari29/Skilltest-RSP-Akselerasi-2-Backend-Agus-Basari/request"
"github.com/agusbasari29/Skilltest-R... |
package shortestCompletingWord
import (
"testing"
"fmt"
)
func TestShortest(t *testing.T) {
cases := []struct {
plate string
words []string
output string
}{
{"1s3 PSt", []string{"step", "steps", "stripe", "stepple"}, "steps"},
{"1s3 456", []string{"looks","pest","stew","show"}, "pest"},
{"Ah71752", ... |
package generator
import (
"bytes"
"fmt"
"go/ast"
"strconv"
"strings"
"time"
"unicode"
"unicode/utf8"
)
func formatComment(comment string) string {
if comment == "" {
return ""
}
buf := bytes.NewBuffer(nil)
lines := strings.Split(comment, "\n")
for i := range lines {
// Last line contains an empty ... |
package vault
import (
"io/ioutil"
"net"
"net/rpc"
"os"
"os/signal"
"syscall"
"time"
log "github.com/sirupsen/logrus"
"github.com/nordcloud/mfacli/config"
"github.com/nordcloud/mfacli/pkg/codec"
)
const (
serverName = "VaultServer"
)
type VaultServer struct {
vault *localVault
lis net.Listener
}
fu... |
// 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... |
/*
* Copyright © 2018-2022 Software AG, Darmstadt, Germany and/or its licensors
*
* SPDX-License-Identifier: Apache-2.0
*
* 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://... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.