text stringlengths 11 4.05M |
|---|
package common
import "github.com/astaxie/beego/context"
const (
SUCCESS_CODE int = 200
SUCCESS_MESSAGE string = "Success"
)
type ApiResponse struct {
Code int `json:"code"`
Message string `json:"message"`
Data interface{} `json:"data"`
}
func (builder *ApiResponse) AddCode(code int) *... |
package kv
import (
"time"
"github.com/cerana/cerana/acomm"
)
func (s *KVS) TestLockKnownBad() {
tests := []struct {
name string
key string
ttl time.Duration
err string
}{
{name: "no key", err: "missing arg: key"},
{name: "no ttl", key: "foo", err: "missing arg: ttl"},
}
for _, test := range te... |
package e4
import "testing"
// TestingFatal returns a WrapFunc that calls t.Fatal if error occur
func TestingFatal(t *testing.T) WrapFunc {
t.Helper()
return func(err error) error {
if err == nil {
return nil
}
t.Helper()
t.Fatal(err)
return err
}
}
|
package handler
import (
clusterRegister "Hybrid_Cluster/clientset/clusterRegister/v1alpha1"
"log"
"github.com/aws/aws-sdk-go/aws"
"github.com/aws/aws-sdk-go/aws/session"
"github.com/aws/aws-sdk-go/service/eks"
cobrautil "Hybrid_Cluster/hybridctl/util"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
_ "k8s.i... |
// Copyright © 2020. All rights reserved.
// Author: Ilya Stroy.
// Contacts: qioalice@gmail.com, https://github.com/qioalice
// License: https://opensource.org/licenses/MIT
package ekamath
func MinI(a, b int) int {
if a < b {
return a
} else {
return b
}
}
func MinI8(a, b int8) int8 {
if a < b {
return a
... |
package npilib
import (
"encoding/xml"
"log"
c "github.com/arkaev/npilib/commands"
)
//Sender : marshal node and send bytes to socket
func startSender(nc *Conn) {
dataToSocket := make(chan []byte)
go func(in chan []byte, client *Conn) {
for data := range in {
client.send(data)
log.Printf("Sent:\n%s\n",... |
package mj
import "github.com/montanaflynn/stats"
// ---------------------------------------------------------------------
// Type definitions
// ---------------------------------------------------------------------
// LevelHistory is a list of history lines for a particular level.
type LevelHistory struct {
LevelN... |
package plugins
import (
"helm.sh/helm/pkg/kube"
"k8s.io/apimachinery/pkg/runtime"
"helm.sh/helm/pkg/release"
"WarpCloud/walm/pkg/models/k8s"
)
type RunnerType string
const (
Pre_Install RunnerType = "pre_install"
Post_Install RunnerType = "post_install"
Unknown RunnerType = "unknown"
WalmPluginConfig... |
package validation
import (
"net/url"
"reflect"
"strings"
)
type (
DataFormat map[string][]string
Options struct {
Rules DataFormat
Payload interface{}
}
Validator struct {
Options Options
}
)
var (
validationErrors url.Values
)
func New(options Options) *Validator {
return &Validator{options}
}... |
package elementary
import (
"errors"
)
// Various errors a list function can return.
var (
ErrDeleteSentinel = errors.New("cannot delete sentinel of list")
)
// NewLinkedList creates a new instance of a linked list data structure, which
// is just an arrangement of elements in a linear order. The list is doubly
//... |
package main
import (
"MercerFrame/MercerServer"
"fmt"
)
func main() {
r := MercerServer.Default()
r.Get("/test", func(context *MercerServer.Context) {
context.WriteOnWeb("hello")
name := context.DefaultQuery("name", "no one")
age := context.Query("age")
fmt.Println("name = " + name + "age = " + age)
})
... |
// Copyright 2022 The ChromiumOS Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
package audio
import (
"context"
"time"
"chromiumos/tast/ctxutil"
"chromiumos/tast/errors"
"chromiumos/tast/local/audio"
"chromiumos/tast/local/audio/crastestclient"
... |
package firiclient
import (
"crypto/hmac"
"crypto/sha256"
"encoding/hex"
"encoding/json"
"strconv"
"time"
)
func NewSigner(clientId string, apiKey string, secret []byte) *signer {
return &signer{
clientId: clientId,
apiKey: apiKey,
secretKey: secret,
validForMillis: 2000,
}
}
type ... |
package database
import (
"fmt"
"net/url"
"github.com/secmohammed/anonymous-message-board-golang/config"
log "github.com/siruspen/logrus"
"gorm.io/driver/postgres"
"gorm.io/gorm"
"gorm.io/gorm/logger"
)
type DatabaseConnection interface {
Get() *gorm.DB
}
type databaseConnection struc... |
package leetcode_0026_从排序数组中删除重复项
/*
给定一个排序数组,你需要在原地删除重复出现的元素,使得每个元素只出现一次,返回移除后数组的新长度。
不要使用额外的数组空间,你必须在原地修改输入数组并在使用 O(1) 额外空间的条件下完成。
示例 1:
给定数组 nums = [1,1,2],
函数应该返回新的长度 2, 并且原数组 nums 的前两个元素被修改为 1, 2。
你不需要考虑数组中超出新长度后面的元素。
示例 2:
给定 nums = [0,0,1,1,1,2,2,3,3,4],
函数应该返回新的长度 5, 并且原数组 nums 的前五个元素被修改为 0, 1, 2, 3, 4。
你不需要... |
package main
import (
"bufio"
"encoding/json"
"fmt"
"net"
"strconv"
"strings"
)
const separator = "#";
const endOfMessage = '\n';
func server() {
ln, err := net.Listen("tcp", ":4500")
if err != nil {
fmt.Println(err)
return
}
for {
c, err := ln.Accept()
if err != nil {
fmt.Println(err)
contin... |
package runtime_test
import (
. "github.com/d11wtq/bijou/runtime"
"github.com/d11wtq/bijou/test"
"testing"
)
func TestRunWithValidInput(t *testing.T) {
res, err := Run(
`(def head
(fn (hd & tl)
hd))
(head 42 7 23)`,
test.FakeEnv(),
)
if err != nil {
t.Fatalf(`expected err == nil, got %s`, ... |
package main
import (
"compress/gzip"
"log"
"net/http"
"net/http/httputil"
"net/url"
"time"
"github.com/NYTimes/gziphandler"
"github.com/didip/tollbooth"
"github.com/didip/tollbooth/limiter"
"github.com/rs/cors"
"github.com/sirupsen/logrus"
"github.com/thisendout/apollo"
)
func buildServeMux(rootChain ap... |
package cloudformation
// AWSAppSyncDataSource_ElasticsearchConfig AWS CloudFormation Resource (AWS::AppSync::DataSource.ElasticsearchConfig)
// See: http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-appsync-datasource-elasticsearchconfig.html
type AWSAppSyncDataSource_ElasticsearchConfig st... |
package main
import (
"database/sql"
"fmt"
_ "mysql-master"
)
type kontak struct {
ID int
Nama string
Nomor string
}
func main() {
getAllData()
}
func koneksi() (*sql.DB, error) {
db, err := sql.Open("mysql", "root:@tcp(localhost)/kontak")
if err != nil {
return nil, err
}
return db, nil
}
func ... |
// Copyright 2022 YuWenYu All rights reserved.
// Use of this source code is governed by a MIT style
// license that can be found in the LICENSE file.
package pot
import (
"github.com/gin-contrib/zap"
"github.com/gin-gonic/gin"
"github.com/spf13/cast"
"github.com/yuw-pot/pot/data"
E "github.com/yuw-pot/pot/modu... |
package postgres
import (
"context"
"database/sql"
"fmt"
"github.com/pganalyze/collector/state"
"github.com/pganalyze/collector/util"
)
const transactionIdSQLPg13 string = `
SELECT
pg_catalog.pg_current_xact_id(),
next_multixact_id
FROM pg_catalog.pg_control_checkpoint()
`
const transactionIdSQLDefault st... |
package main
import (
"bufio"
"fmt"
"flag"
"net/http"
"encoding/json"
"go/token"
"go/types"
"io/ioutil"
"os"
"strconv"
"strings"
)
type Currency struct{
Rates map[string]float32
Base string `json:"base"`
Date string `json:"date"`
}
type Contactt struct {
Name strin... |
package main
import (
"github.com/riita10069/check_interface"
"golang.org/x/tools/go/analysis/unitchecker"
)
func main() { unitchecker.Main(check_interface.Analyzer) }
|
package repository
import "github.com/lazhari/web-jwt/models"
func (pr postgresRepository) CreatePost(p *models.Post) (*models.Post, error) {
dbc := pr.db.Create(p)
if dbc.Error != nil {
return nil, dbc.Error
}
return p, nil
}
func (pr postgresRepository) GetAllPosts() ([]models.Post, error) {
var posts []m... |
package main
func main() {
println("hello world2")
}
|
package main
import (
"github.com/stretchr/testify/assert"
"testing"
)
type Test struct {
input string
expected int
}
func TestSolvePartOne(t *testing.T) {
assert := assert.New(t)
tests := []Test{
Test{input: "(())", expected: 0},
Test{input: "()()", expected: 0},
Test{input: "(((", expected: 3},
Te... |
package util
import (
"testing"
)
func TestIsStringEmpty(t *testing.T) {
if !IsStringEmpty(" ") {
t.Error("Empty string was not considered empty")
}
if IsStringEmpty(" stuff ") {
t.Error("Non-empty string considered empty")
}
}
func TestFileProcessing(t *testing.T) {
var foundLine1, f... |
package main
import (
"bytes"
"encoding/json"
"net/http"
"net/http/httptest"
"testing"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
)
func TestRenderServer(t *testing.T) {
app := &renderServer{}
ts := httptest.NewServer(app)
defer ts.Close()
formatURL := func(urlPath string)... |
package model
import (
"context"
"github.com/pkg/errors"
)
var (
ErrUnauthorizedAccessToken = errors.New("unauthorized access token")
ErrUserOrChannelNotFound = errors.New("user or channel not found")
ErrInvalidPlaylistID = errors.New("invalid playlist id")
ErrPlaylistNotFound ... |
// Copyright 2018 The Cockroach Authors.
//
// Use of this software is governed by the Business Source License
// included in the file licenses/BSL.txt.
//
// As of the Change Date specified in that file, in accordance with
// the Business Source License, use of this software will be governed
// by the Apache License, ... |
package isanagram
import "testing"
func TestIsAnagram(t *testing.T) {
if isAnagram("anagram", "nagaram") != true {
t.Errorf("Get false, Expect true")
}
if isAnagram("rat", "car") != false {
t.Errorf("Get true, Expect flase")
}
if isAnagram("anagra\u007Am", "nagaam\u007Ar") != true {
t.Errorf("Get false, ... |
//
// 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
// distribu... |
package packet
import (
"bytes"
"fmt"
"github.com/lunixbochs/struc"
"io/ioutil"
)
type ServerPacket struct {
Size uint32 `struc:"uint32,little,sizeof=Buffer"` //uint32 size
Precode [1]byte `struc:"[1]pad"` //this is an odd padding issue
OpCode uint16 `struc:"uint16,lit... |
package eventstore
import (
"context"
"github.com/caos/logging"
auth_view "github.com/caos/zitadel/internal/auth/repository/eventsourcing/view"
org_model "github.com/caos/zitadel/internal/org/model"
org_es "github.com/caos/zitadel/internal/org/repository/eventsourcing"
"github.com/caos/zitadel/internal/org/repos... |
// Package datasheet provides the operations about datasheet
package datasheet
import (
"fmt"
"github.com/apitable/apitable-sdks/apitable.go/lib/common"
athttp "github.com/apitable/apitable-sdks/apitable.go/lib/common/http"
"github.com/apitable/apitable-sdks/apitable.go/lib/common/profile"
"math"
)
const maxPage... |
package main
const (
templateUsecaseUOW = `// {{.Header}}
package usecase
import (
"sync"
{{- range $module := .Modules}}
{{clean $module.ModuleName}}usecase "{{$.GoModName}}/internal/modules/{{cleanPathModule $module.ModuleName}}/usecase"
{{- end }}
"{{.PackageName}}/codebase/factory/dependency"
)
type (
//... |
// Copyright 2019 Yunion
//
// 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 writi... |
// Copyright 2019 The Cockroach Authors.
//
// Use of this software is governed by the Business Source License
// included in the file licenses/BSL.txt.
//
// As of the Change Date specified in that file, in accordance with
// the Business Source License, use of this software will be governed
// by the Apache License, ... |
package fimp
import (
"errors"
"fmt"
"github.com/futurehomeno/fimpgo"
"github.com/futurehomeno/fimpgo/fimptype/primefimp"
"github.com/mitchellh/mapstructure"
"github.com/thingsplex/tpflow/model"
"github.com/thingsplex/tpflow/node/base"
"time"
)
type VincTriggerNode struct {
base.BaseNode
ctx ... |
package web
import (
"bytes"
"encoding/json"
"fmt"
"github.com/altwebplatform/core/storage"
"github.com/facebookgo/ensure"
"io"
"log"
"net/http"
"net/http/httptest"
"strconv"
"testing"
)
func EnsureSuccess(t *testing.T, rr *httptest.ResponseRecorder) *httptest.ResponseRecorder {
if rr.Code != 200 {
fmt.... |
package utils
import (
"bytes"
"errors"
"io"
"os"
"os/exec"
"os/user"
"path/filepath"
"runtime"
"strconv"
"strings"
)
const (
Version = "v0.2.2"
)
func CallPath(s int) string {
_, f, l, _ := runtime.Caller(s + 1)
return f + ":" + strconv.Itoa(l)
}
func PathJoin(paths ...string) string {
return filepat... |
package models
import(
"encoding/json"
)
/**
* Type definition for AuthenticationStatusEnum enum
*/
type AuthenticationStatusEnum int
/**
* Value collection for AuthenticationStatusEnum enum
*/
const (
AuthenticationStatus_KPENDING AuthenticationStatusEnum = 1 + iota
AuthenticationSta... |
package solutions
func multiply(num1 string, num2 string) string {
if num1 == "0" || num2 == "0" {
return "0"
}
result := make([]byte, len(num1) + len(num2))
for i := len(num2) - 1; i >= 0; i-- {
for j := len(num1) - 1; j >= 0; j-- {
current := (num2[i] - '0') * (num1[j] -... |
// Copyright 2020 David Norminton. All rights reserved.
// Use of this source code is governed by a MIT License
// license that can be found in the LICENSE file.
// Package episodate uses the api provided by https://www.episodate.com to
// retrieve TV Show data. The user can view show data, add shows to a list,
// and... |
package main
import (
"os"
"bufio"
"strings"
"strconv"
)
func main() {
file, _ := os.Open("file.txt")
a := bufio.NewScanner(file)
for a.Scan() {
line := strings.Split(a.Text(), " ")
var sum int
for _, item := range line {
value, _ := strconv.Atoi(item)
sum += value
}
println(sum)
}
}
|
package handle
import (
"github.com/valyala/fasthttp"
"mygo/service"
"strconv"
)
func GetGoodsById(ctx *fasthttp.RequestCtx) {
id := ctx.UserValue("id")
gid, err := strconv.ParseInt(id.(string), 10, 64)
if err != nil {
resp.Msg = "id输入错误,请确认"
CommonWriteError(ctx, resp)
return
}
resp.Data = service.Get... |
/*
* @lc app=leetcode.cn id=9 lang=golang
*
* [9] 回文数
*/
// @lc code=start
func isPalindrome(x int) bool {
}
// @lc code=end
|
package controllers
import (
"christopher/helpers"
"christopher/models"
"encoding/json"
"github.com/gin-gonic/gin"
// "log"
)
type BalancePointForm struct {
Id string
User_uid string
Blance_point string `form:"blance_point"`
}
type Mygpoint struct {
G_Point float64 `json:"g_point"`
}
type Mygpo... |
// Copyright 2022 The ChromiumOS Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
package policy
import (
"context"
"net/http"
"net/http/httptest"
"time"
"chromiumos/tast/common/fixture"
"chromiumos/tast/common/policy"
"chromiumos/tast/common/poli... |
package main
import (
"fmt"
"stress"
)
func main() {
err := stress.StressGo()
if err != nil {
fmt.Printf("stress go error:%s", err.Error())
}
} |
package db
import (
"fmt"
"testing"
)
func TestDb(t *testing.T) {
result := make(map[string]interface{})
if err := DB().Raw("select now() as a").Find(&result).Error; err != nil {
fmt.Println("查询出错.")
} else {
fmt.Println("查询结果.", result["a"])
}
//
var confs []News
if err := DB().Model(&News{}).Limit(5).F... |
func minimumFromFour() int {
var n, nmin int
for i := 1; i < 5; i++ {
fmt.Scan(&n)
if i == 1 {
nmin = n
}
if i > 1 && n < nmin {
nmin = n
}
}
return nmin
}
// Напишите функцию, находящую наименьшее из четырех введённых в этой же функции чисел.
|
package main
import (
"html/template"
"os"
"github.com/gin-contrib/static"
"github.com/gin-gonic/gin"
"github.com/yuriizinets/go-ssc"
)
func funcmap() template.FuncMap {
return ssc.Funcs()
}
func main() {
g := gin.Default()
g.GET("/", func(c *gin.Context) {
ssc.RenderPage(c.Writer, &PageIndex{})
})
g.... |
// Copyright 2020 cloudeng llc. All rights reserved.
// Use of this source code is governed by the Apache-2.0
// license that can be found in the LICENSE file.
// Package profiling provides support for enabling profiling of
// command line tools via flags.
package profiling
import (
"fmt"
"os"
"runtime/pprof"
"st... |
package global
import (
"github.com/ulricqin/goutils/filetool"
log "github.com/ulricqin/goutils/logtool"
"os"
"time"
)
const MaxCpustatHistory = 60
var CollBaseInfoInterval time.Duration
var HttpPort string
var Version string
// configuration
func initCfg() {
initHttpConfig()
initCollectBaseInfoInterval()
in... |
package main
func execSelect(input string) (string, error) {
return "TODO: Implement select executor.", nil
}
|
package main
import (
"bufio"
"fmt"
"log"
"os"
"strconv"
"strings"
"time"
)
var mapConvert = map[string]string{
"F": "0",
"B": "1",
"R": "1",
"L": "0",
}
func main() {
start := time.Now()
fmt.Printf("Result is %v \n", run())
log.Printf("Code took %s", time.Since(start))
}
func run() int64 {
var max... |
package main
import "fmt"
func main() {
nombre := interface{}("fernando")
numero := interface{}(12)
// con interfaces no podemos usar conversiones p.ej: string(numero), tenemos
// que usar assertion que se hace con nomVar.(tipo)
// fmt.Println(12 + numero) --> no nos deja sumar un int y un interface{} tenemos qu... |
package main
import (
"encoding/hex"
"fmt"
"hash/fnv"
"log"
// "math"
"reflect"
"strings"
"time"
"github.com/google/gopacket"
"github.com/google/gopacket/layers"
"github.com/google/gopacket/pcap"
)
type info struct {
id []string
vals []string
}
func (in *info) Stringify() string {
return fmt.Sprintf... |
// Package lago provides a simple way to setup logging.
package lago
// Logger ...
type Logger interface {
Errorf(format string, args ...interface{})
Infof(format string, args ...interface{})
Warnf(format string, args ...interface{})
Fatalf(format string, args ...interface{})
}
|
package tiered_cacher
type TieredCacher struct {
}
func NewTieredCacher(storage interface{}) *TieredCacher {
tieredCacher := &TieredCacher{}
return tieredCacher
}
|
package mongodb
import (
"time"
"go.mongodb.org/mongo-driver/bson"
"go.mongodb.org/mongo-driver/bson/primitive"
"golang.org/x/net/context"
)
// Commodity 商品
type Commodity struct {
ID primitive.ObjectID `bson:"_id,omitempty" json:"id"`
UserID primitive.ObjectID `bson:"user_id" json:"user_id"` // 用户ID
ShopID... |
package main
import (
"fmt"
"io/ioutil"
"log"
"net/http"
"regexp"
)
func main(){
//我的uid = 344485144
fmt.Printf("\n\n欢迎来到粉丝数获取界面 \n\n")
var mid string
var i bool
for {
fmt.Printf("请输入要获取的UP主UID:(例如我的uid =344485144)\n")
fmt.Scanln(&mid)
fmt.Printf("\n稍等片刻...")
herf2 := "https://api.bilibili.com/x... |
// Copyright 2020 The ChromiumOS Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// Package graphics contains graphics-related utility functions for local tests.
package graphics
import (
"context"
"io"
"path/filepath"
"regexp"
"sort"
"strings"
"t... |
package config
import (
"fmt"
"strings"
)
const defaultSlotName = "gulstream"
type postgres struct {
ConnectionURI string `mapstructure:"connectionURI"`
SlotName string `mapstructure:"slotName"`
}
func (p postgres) Validate() error {
if len(p.ConnectionURI) == 0 {
return fmt.Errorf("config: postgres con... |
package database
import (
"errors"
"github.com/ChristophBe/weather-data-server/data/models"
"github.com/neo4j/neo4j-go-driver/neo4j"
)
type measuringNodeRepositoryImpl struct{}
func (measuringNodeRepositoryImpl) parseMeasuringNodeFromRecord(record neo4j.Record) (interface{}, error) {
nodeData, ok := record.Get(... |
package solutions
import (
"bytes"
"fmt"
"strconv"
"strings"
)
type Codec struct {}
func Constructor() Codec {
return Codec{}
}
func (this *Codec) serialize(root *TreeNode) string {
if root == nil {
return ""
}
var buffer bytes.Buffer
queue, size := []*TreeNode{root}, 1
... |
package main
import (
"time"
mgrpc "github.com/asim/go-micro/plugins/client/grpc/v3"
mhttp "github.com/asim/go-micro/plugins/server/http/v3"
"github.com/asim/go-micro/v3"
"github.com/asim/go-micro/v3/logger"
"github.com/gin-gonic/gin"
pb "github.com/xpunch/go-micro-example/v3/event/proto"
pbh "github.com/xpun... |
package schema
import (
// "fmt"
// "img_tag/pkg/variable"
"github.com/jinzhu/gorm"
)
// User 用户模型
type User struct {
gorm.Model
UserName string `gorm:"column:user_name;size:64;index;default:'';not null;"` // 用户名
RealName string `gorm:"column:real_name;size:64;index;default:'';not null;"` // 真实姓名
Password s... |
package main
import (
"fmt"
"log"
"os"
"runtime/trace"
)
// 执行追踪器
// 跟踪器捕获各种各样的执行事件,如 goroutine 创建/阻塞/解锁,系统调用进入/退出/块,GC 相关事件,堆大小变化,处理器启动/停止等,并将它们以紧凑的形式写入 io.Writer 中
// 大多数事件都会捕获精确的纳秒精度时间戳和堆栈跟踪。跟踪可以稍后使用 'go tool trace' 命令进行分析
func main() {
// 创建trace.out文件
// 跟踪完毕后可以使用 "go tool trace testdata/trace.out" 命令分析
... |
package main
import "fmt"
func main() {
i := 1
// function call in the init part in for loop
for test(); i < 3; i++ {
fmt.Println(i)
}
// function assigment in the init part in for loop
fmt.Println("in assigment")
for i = 2; i < 5; i++ {
fmt.Println(i)
}
}
func test() {
fmt.Println("In test function")
... |
package flags
const CONTENTS_EMPTY = 0 // No contents
const CONTENTS_SOLID = 0x1 // an eye is never valid in a solid
const CONTENTS_WINDOW = 0x2 // translucent, but not watery (glass)
const CONTENTS_AUX = 0x4
const CONTENTS_GRATE = 0x8 // alpha-tested "grate" textures. Bullets/sight pass through, but solids don't
c... |
package uibutton
import (
"context"
"fmt"
apierrors "k8s.io/apimachinery/pkg/api/errors"
ctrl "sigs.k8s.io/controller-runtime"
"sigs.k8s.io/controller-runtime/pkg/builder"
ctrlclient "sigs.k8s.io/controller-runtime/pkg/client"
"sigs.k8s.io/controller-runtime/pkg/reconcile"
"github.com/tilt-dev/tilt/internal/... |
package handler
import (
"context"
"github.com/b2wdigital/openbox-go/examples/simple/internal/pkg/model/response"
"github.com/cloudevents/sdk-go"
)
func Test1(ctx context.Context, event cloudevents.Event, resp *cloudevents.EventResponse) error {
r := cloudevents.Event{
Context: cloudevents.EventContextV1{
S... |
package persistent
import (
"github.com/EventStore/EventStore-Client-Go/protos/persistent"
"github.com/EventStore/EventStore-Client-Go/protos/shared"
)
func toPersistentReadRequest(
bufferSize int32,
groupName string,
streamName []byte,
) *persistent.ReadReq {
return &persistent.ReadReq{
Content: &persistent.... |
package rootdir
type Rootdir interface {
Path() string
}
type rootdir string
func ByName(dir string) Rootdir {
d := rootdir(dir)
return &d
}
func (r *rootdir) Path() string {
return string(*r)
}
|
// Copyright 2019 Liquidata, 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... |
package cmd
import (
"github.com/spf13/cobra"
)
var verbose bool
var version bool
// rootCmd represents the base command when called without any subcommands
var rootCmd = &cobra.Command{
Use: "mp3tag",
Short: "A command line utility for manipulating the metadata in mp3 files.",
Long: `Allows viewing and manipu... |
// Copyright 2018 The gVisor 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 agree... |
package maccount
import (
"time"
"webserver/lib/jsonlib"
"webserver/models"
)
type Authenticate struct {
//RecordBase
Id int
UserId int
Type int
Value int
Info string
Image string
Extra string
Status int
CreatedAt time.Time //string
UpdatedAt time.Time //string
extra ... |
package storageoscluster
import (
"context"
"errors"
"fmt"
"sigs.k8s.io/controller-runtime/pkg/client"
storageosv1 "github.com/storageos/cluster-operator/pkg/apis/storageos/v1"
)
// ErrNoCluster is the error when there's no running StorageOS cluster found.
var ErrNoCluster = errors.New("no storageos cluster fo... |
// Copyright (c) 2013 Mathieu Turcotte
// Licensed under the MIT license.
package main
import (
"flag"
"fmt"
bc "github.com/MathieuTurcotte/go-browserchannel/browserchannel"
"log"
"net/http"
"sync"
)
var publicDir = flag.String("public_directory", "", "path to public directory")
var closureDir = flag.String("c... |
package main
import (
"database/sql"
"fmt"
"log"
"net/http"
"strconv"
_ "github.com/lib/pq"
)
var db *sql.DB
func init() {
var err error
db, err = sql.Open("postgres", "postgres://postgres@localhost?sslmode=disable")
if err != nil {
log.Fatal("Could not open database: ", err)
}
if err := db.Ping(); er... |
package sll
//ListErr : error type for the list
type ListErr struct {
s string
}
func (e *ListErr) Error() string {
return e.s
}
|
package db
import (
"database/sql"
"errors"
"fmt"
"log"
"strings"
"time"
user "github.com/bketelsen/microclass/module7/userservice/proto/account"
_ "github.com/go-sql-driver/mysql"
)
var (
Url = "root:root@tcp(127.0.0.1:3306)/user"
database string
db *sql.DB
q = map[string]string{}
accountQ... |
package main
import (
"bufio"
"fmt"
"log"
"os"
"os/exec"
)
func subjack(args []string) {
log.SetPrefix("[subjack] ")
initSubjack(args)
}
func initSubjack(args []string) {
// Fetch all hosts, for now restrict to live hosts (80/443)
var count int
row := db.QueryRow(`SELECT COUNT(*) FROM "Domains" WHERE ports... |
// Copyright 2017 The Cockroach Authors.
//
// Licensed as a CockroachDB Enterprise file under the Cockroach Community
// License (the "License"); you may not use this file except in compliance with
// the License. You may obtain a copy of the License at
//
// https://github.com/cockroachdb/cockroach/blob/master/li... |
package utils
//package main
import (
"crypto/sha1"
"fmt"
"os"
// "github.com/op/go-logging"
"io"
"log"
"math/rand"
"strconv"
"sync"
"time"
)
type LogLevel uint32
const (
NoticeLevel LogLevel = 1
FatalLevel LogLevel = 2
WarningLevel LogLevel = 3
DebugLevel LogLevel = 4
)
type LogControl struct {... |
// @APIVersion 1.0.0
// @Title beego Test API
// @Description beego has a very cool tools to autogenerate documents for your API
// @Contact astaxie@gmail.com
// @TermsOfServiceUrl http://beego.me/
// @License Apache 2.0
// @LicenseUrl http://www.apache.org/licenses/LICENSE-2.0.html
package routers
import (
"Android-... |
package stack
import (
"fmt"
"testing"
)
func init() {
}
func TestSimpleInsertSort(t *testing.T) {
var s Stack = NewArrayStack()
fmt.Println("1.", s.IsEmpty())
for i := 0; i < 10; i++ {
s.Push(i)
}
fmt.Println("2.", s.IsEmpty())
for i := 0; i < 10; i++ {
item, _ := s.Peek()
fmt.Print(item)
}
fmt.Prin... |
package csblob
import (
"crypto/x509"
"encoding/asn1"
)
// Extensions for specific types of key usage.
// These endorse a leaf certificate to create signatures with the named capability.
// https://images.apple.com/certificateauthority/pdf/Apple_WWDR_CPS_v1.22.pdf
var (
CodeSign = asn1.ObjectIdentifier{1, 2, 840, ... |
/*
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
distributed under the License... |
package main
import (
"fmt"
"github.com/silenceshell/algorithms-in-golang/utils"
)
type SortedBinaryNode struct {
left *SortedBinaryNode
right *SortedBinaryNode
data int
}
type SortedBinaryTree struct {
root *SortedBinaryNode
}
func (tree *SortedBinaryTree) insert(num int) *SortedBinaryTree {
if tree.root ... |
package ghq
import (
"encoding/json"
"io/ioutil"
"os"
)
var Config map[string]string
// loading config.json in memory.
func (r *Router) LoadConfig() (err error) {
configFile, err := os.Open("config.json")
if err != nil {
return
}
defer configFile.Close()
configBytes, err := ioutil.ReadAll(configFile)
if e... |
package controller
import (
"errors"
"fmt"
"strings"
"time"
"github.com/gin-gonic/gin"
"github.com/luxingwen/secret-game/dao"
"github.com/luxingwen/secret-game/model"
"github.com/luxingwen/secret-game/tools"
)
type TeamController struct {
}
func (ctl *TeamController) Create(c *gin.Context) {
team := new(m... |
package url
import (
"testing"
"github.com/stretchr/testify/assert"
)
func TestFnHostname(t *testing.T) {
f := &fnHostname{}
input := "https://subdomain.example.com/path?q=hello world#fragment with space"
v, err := f.Eval(input)
assert.Nil(t, err)
assert.Equal(t, "subdomain.example.com", v)
}
|
package ServerManager
import (
"golang.org/x/net/context"
"net"
"log"
"google.golang.org/grpc/reflection"
"google.golang.org/grpc"
pb "MarketServer"
"database/sql"
_ "github.com/lib/pq"
)
var s *grpc.Server
var db *sql.DB
func init() {
var err error
db, err = sql.Open("postgres", "host=localhost user=post... |
package main
import (
"bytes"
"flag"
"fmt"
"go/ast"
"go/parser"
"go/token"
"io"
"os"
"reflect"
"strings"
)
const prefix = "server_"
func pretty_print_type_expr(out io.Writer, e ast.Expr) {
ty := reflect.TypeOf(e)
switch t := e.(type) {
case *ast.StarExpr:
fmt.Fprintf(out, "*")
pretty_print_type_expr... |
package slack
import (
"github.com/shiv3/slackube/app/controller/slackcontoller"
"github.com/slack-go/slack"
"github.com/shiv3/slackube/app/usecase"
"github.com/labstack/echo/v4"
)
type (
Handler interface {
SlackEvents(c echo.Context) error
SlackActions(c echo.Context) error
}
handlerImpl struct {
s... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.