text stringlengths 11 4.05M |
|---|
// Copyright 2020 The VectorSQL Authors.
//
// Code is licensed under Apache License, Version 2.0.
package datablocks
import (
"sync"
"expressions"
"planners"
"github.com/gammazero/workerpool"
)
func (block *DataBlock) AggregateSelectionByPlan(fields []string, plan *planners.SelectionPlan) ([]expressions.IExpr... |
package pkg
// BaseConfig
type KafkaConf struct {
EnableSASL bool `json:"enable_sasl"`
Brokers []string `json:"brokers"`
User string `json:"user"`
Password string `json:"password"`
}
type NsqConf struct {
}
type MongoDBConf struct {
}
type ESConf struct {
}
// MQEvent
type MQEvent struct {... |
package zredis
import (
"bufio"
"github.com/pkg/errors"
"strconv"
)
type Resp struct {
RespType int
Val interface{}
}
func (r *Resp) String() (string) {
switch rsp := r.Val.(type) {
case string:
return rsp
case []byte:
return string(rsp)
case int:
return strconv.Itoa(rsp)
ca... |
package models
import(
"encoding/json"
)
/**
* Type definition for LockingProtocolEnum enum
*/
type LockingProtocolEnum int
/**
* Value collection for LockingProtocolEnum enum
*/
const (
LockingProtocol_KSETREADONLY LockingProtocolEnum = 1 + iota
LockingProtocol_KSETATIME
)
func (... |
package cloudformation
// AWSAppSyncDataSource_HttpConfig AWS CloudFormation Resource (AWS::AppSync::DataSource.HttpConfig)
// See: http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-appsync-datasource-httpconfig.html
type AWSAppSyncDataSource_HttpConfig struct {
// Endpoint AWS CloudFormat... |
package timecode
import (
"testing"
"github.com/stretchr/testify/assert"
)
func TestNewRate(t *testing.T) {
t.Parallel()
rate, err := NewRate(30, false)
assert.Nil(t, err)
assert.Equal(t, rate.FPS(), 30.0)
assert.Equal(t, rate.DropFrame(), false)
rate, err = NewRate(30, true)
assert.Nil(t, err)
assert.Eq... |
package fastdb
import (
"io"
"log"
"sort"
"sync"
"time"
"fastdb/index"
"fastdb/storage"
)
// DataType Define the data structure type.
type DataType = uint16
// Five different data types, support String, List, Hash, Set, Sorted Set right now.
const (
String DataType = iota
List
Hash
Set
ZSet
)
// The op... |
// Copyright 2017 The ChromiumOS Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
package example
import (
"context"
"chromiumos/tast/testing"
)
func init() {
testing.AddTest(&testing.Test{
Func: Pass,
Desc: "Always passes",
Contacts: [... |
package types
const ALL_GROUPNAME = "ALL"
const MASTER_GROUPNAME = "Master"
const ETCD_GROUPNAME = "Etcd"
const SERVICES_CHECKNAME = "Services"
const CONTAINERS_CHECKNAME = "Containers"
const CERTIFICATES_CHECKNAME = "Certificates"
const DISKUSAGE_CHECKNAME = "DiskUsage"
const KUBERNETES_CHECKNAME = "Kubernetes"
typ... |
package board
import "fmt"
type Pos struct {
Row int
Col int
}
func (p *Pos) U() *Pos {
return &Pos{
Row: p.Row + 1,
Col: p.Col,
}
}
func (p *Pos) D() *Pos {
return &Pos{
Row: p.Row - 1,
Col: p.Col,
}
}
func (p *Pos) R() *Pos {
return &Pos{
Row: p.Row,
Col: p.Col + 1,
}
}
func (p *Pos) L() *Po... |
package main
import (
"fmt"
"io/ioutil"
"log"
"net/http"
)
func main() {
//creates an http server listening on localhost:8080
http.HandleFunc("/", myFunc)
http.ListenAndServe(":8080", nil)
}
//Sends a greeting with the server's IP included
func myFunc(w http.ResponseWriter, r *http.Request) {
myIP := getMyIP... |
package main
import "sort"
//899. 有序队列
//给定一个字符串 s 和一个整数 k。你可以从 s 的前 k 个字母中选择一个,并把它加到字符串的末尾。
//
//返回 在应用上述步骤的任意数量的移动后,字典上最小的字符串。
//
//
//
//示例 1:
//
//输入:s = "cba", k = 1
//输出:"acb"
//解释:
//在第一步中,我们将第一个字符(“c”)移动到最后,获得字符串 “bac”。
//在第二步中,我们将第一个字符(“b”)移动到最后,获得最终结果 “acb”。
//示例 2:
//
//输入:s = "baaca", k = 3
//输出:"aaabc"
/... |
// Copyright 2015 Apcera Inc. All rights reserved.
package aws
import (
"errors"
"fmt"
"net/http"
"os"
"time"
"github.com/apcera/util/uuid"
"github.com/aws/aws-sdk-go/aws"
"github.com/aws/aws-sdk-go/aws/awserr"
"github.com/aws/aws-sdk-go/aws/credentials"
"github.com/aws/aws-sdk-go/aws/session"
"github.com... |
package node
import(
"fmt"
"os"
"strings"
"path/filepath"
"github.com/AmosChen35/TcpServer/server/rpc"
)
type Config struct {
Name string `toml:"-"`
NodeVersion string `toml:",omitempty"`
TCPHost string `toml:",omitempty"`
TCPPort int `toml:",omitempty"`
TCPTimeouts rpc.TCPTim... |
package app
import "golang.org/x/net/context"
type App struct {
Cfg AppConfig
Logs AppLogs
Metrics AppMetrics
Errs AppErrors
Ctx context.Context
}
func NewApp() App {
cfg := LoadConfig()
logs := NewAppLogs(cfg)
metrics := NewAppMetrics(cfg)
errs := NewAppErrors(cfg)
ctx := context.Background(... |
package iam
import (
"context"
"time"
"github.com/pegasus-cloud/iam_client/protos"
"google.golang.org/grpc"
)
func listUsers(c grpc.ClientConnInterface, input *protos.LimitOffset) (output *protos.ListUserOutput, err error) {
ctx, cancel := context.WithTimeout(context.Background(), time.Second)
defer cancel()
... |
package gobacktest
// Direction defines which direction a signal indicates
type Direction int
// different types of order directions
const (
// Buy
BOT Direction = iota // 0
// Sell
SLD
// Hold
HLD
// Exit
EXT
)
func (dir Direction) String() string {
switch dir {
case BOT:
return "BUY"
case SLD:
retur... |
package main
import (
"fmt"
"os"
"strconv"
)
func main() {
num, err := strconv.Atoi(os.Args[1])
if num <= 1 || err != nil {
fmt.Println("Please send a number greater than 1")
return
}
steps := checkSteps(num)
fmt.Printf("Number of steps: %v\n", steps)
}
func checkSteps(num int) int {
steps := 0
one := ... |
package hooks
import (
"net"
"time"
"github.com/briandowns/spinner"
"github.com/spf13/cobra"
"github.com/tatsushid/go-fastping"
"github.com/vivek-26/ipv/reporter"
)
// PreRun performs internet and dns check
func PreRun(cmd *cobra.Command, args []string) {
internetCheck()
dnsCheck()
}
// internetCheck verif... |
/**
* (C) Copyright IBM Corp. 2021.
*
* 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... |
/*
Copyright 2021 The KodeRover 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, s... |
package cache
// Cache Cache
type Cache interface{}
type cache struct{}
// New New
func New() Cache {
return &cache{}
}
|
package domain
import (
value "github.com/dev-jpnobrega/api-rest/src/domain/contract/value"
)
// ICommand infc
type ICommand interface {
GetModelValidate() interface{}
Execute(value.RequestData) (value.ResponseData, *value.ResponseError)
}
|
package utiltest
import (
"github.com/dwahyudi/go-jwt-sample/internal/jwtsample/util"
"github.com/stretchr/testify/assert"
"testing"
)
func TestSimpleSignAndValidate(t *testing.T) {
var userId = 3
var tokenString = util.JwtBuildAndSignJSON(userId)
var validatedUserId, err = util.JwtValidate(tokenString)
asser... |
package handler
import (
"net/http"
"time"
"github.com/labstack/echo"
)
// ---------
// handlers
// ---------
// HomeHandler ...
func HomeHandler(c echo.Context) error {
data := map[string]interface{}{
"title": "Hello",
"now": time.Now().Format(time.RFC3339),
}
return c.Render(http.StatusOK, "home", dat... |
package domain
type Shop struct {
Id uint64
Title string
Description string
ManagerIDs []uint64
}
type Product struct {
Id uint64
Title string
Description string
Price uint64
Availability bool
// AssemblyTime is measured in minutes
AssemblyTime uint64
PartsAmount ... |
package command
import (
"fmt"
"github.com/codegangsta/cli"
"github.com/denkhaus/irspamd/engine"
)
func (c *Commander) NewLearnCommand() {
c.Register(cli.Command{
Name: "learn",
Usage: "Learn ham or spam from given IMAP box.",
Subcommands: []cli.Command{
{
Name: "ham",
Usage: "Learn ham from l... |
package models
import (
"fmt"
"github.com/astaxie/beego/orm"
"strconv"
)
type Admin struct {
Id int64 `json:"id"`
Username string `json:"username"`
Password string `json:"password"`
Create_time int64 `json:"create_time"`
Role string `json:"role"`
Parent string `json:"parent"`
Money float64 `json:"money"`
}... |
package storage
import "net/http"
func CreatePayment(r *http.Request)string{
return ""
}
|
package main
import (
"net/http"
"os"
"github.com/gorilla/mux"
"github.com/gorilla/handlers"
"github.com/auth0/go-jwt-middleware"
"github.com/fschr/go/auth/controllers"
"github.com/fschr/go/auth/config"
jwt "github.com/dgrijalva/jwt-go"
)
func main() {
r := mux.NewRouter()
r.Handle("/user/", jwtMiddleware... |
package main
import (
"net/url"
"strings"
)
//Access policy that checks if an URL is within a domain.
//TODO: Does not accept subdomains
type checkSubDomainPolicy struct {
domainNames []string
}
func newCheckSubDomainPolicy() *checkSubDomainPolicy {
return &checkSubDomainPolicy{}
}
func initCheckSubDomainPolicy... |
package constants
import (
"fmt"
)
const (
APIVersion = "v1alpha1"
)
var (
RootPath = fmt.Sprintf("/api/%s", APIVersion)
)
const (
ParameterStart = "start"
ParameterLimit = "limit"
ParameterRequestBody = "req"
ParameterXUser = "X-User"
ParameterXTenant = "X-Tenant"
DefaultParameterStart = 0
De... |
package plugins
import (
"github.com/astaxie/beego"
_ "smartapp/plugins/test/initial"
)
func init(){
//initial.TestInit() //
beego.Debug("初始化插件信息")
} |
package main
import (
"context"
"fmt"
"github.com/zazin/test-proto-grpc/gateway"
"net/http"
)
func init() {
fmt.Println("krakend-grpc-post plugin loaded!!!")
}
var ClientRegisterer = registerer("grpc-post")
type registerer string
func (r registerer) RegisterClients(f func(
name string,
handler func(context.... |
package entry
import (
"testing"
"shared/common"
"shared/utility/errors"
)
func TestWorldItemStrengthenEXP(t *testing.T) {
target, err := CSV.WorldItem.NewWorldItem(1, 10001)
if err != nil {
t.Errorf("%+v", errors.Format(err))
}
material1, err := CSV.WorldItem.NewWorldItem(1, 10002)
if err != nil {
t.Er... |
package hub
import (
"context"
"fmt"
"testing"
"github.com/ipfs/go-datastore"
syncds "github.com/ipfs/go-datastore/sync"
)
func TestGetSettings(t *testing.T) {
d := syncds.MutexWrap(datastore.NewMapDatastore())
ns, err := GetSettings(context.Background(), "https://hub-dev.btfs.io",
"16Uiu2HAm9P1cur6Nhd542y7... |
package gore
import (
"crypto/sha1"
"fmt"
"io"
"io/ioutil"
"os"
"path"
"regexp"
"strings"
"sync"
)
// Script represents a Lua script.
type Script struct {
body string
sha string
lock sync.RWMutex
}
// NewScript returns a new Lua script
func NewScript() *Script {
return &Script{}
}
// SetBody sets scri... |
package main
import (
"TRT/usersNMethods"
"fmt"
)
var DB databaseAct.Database
func main() {
//fmt.Println(responses.AddUser())
//fmt.Println(responses.UpdateUser())
//fmt.Println(responses.DeleteUser())
//fmt.Println(responses.GetUser())
fmt.Println(usersNMethods.PercentOfMen())
}
|
/*
* @lc app=leetcode id=5 lang=golang
*
* [5] Longest Palindromic Substring
*
* https://leetcode.com/problems/longest-palindromic-substring/description/
*
* algorithms
* Medium (29.26%)
* Likes: 7334
* Dislikes: 554
* Total Accepted: 979.1K
* Total Submissions: 3.3M
* Testcase Example: '"babad"'
*... |
package utils
import (
"testing"
)
func TestStringMD5(t *testing.T) {
type args struct {
s string
}
tests := []struct {
name string
args args
want string
}{
// TODO: Add test cases.
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
if got := StringMD5(tt.args.s); got != tt.want {
... |
package gflObject
type RouteInfo struct {
id : int
Description : string
DistanceNm : int
MinAltitude : int
Remarks : string
}
/*
func (l *LogonC) Const(ref string) int {
if ret, ok := l.elements[ref]; ok {
return ret
} else {
return -1
}
}
*/
func NewRouteInfo(inId int) *RouteInfo {
lt := new(RouteInfo)... |
package main
import (
"log"
"net/http"
"github.com/gorilla/mux"
"github.com/gorilla/securecookie"
"github.com/gorilla/websocket"
"poker/database"
"poker/handlers"
"poker/models"
"poker/templates"
)
func main() {
// Connect to the database
dbUser := "postgres"
dbPassword := "postgres"
... |
package burrow
import (
"encoding/binary"
"fmt"
"github.com/cbroglie/mustache"
"log"
"strconv"
"strings"
)
func RenderTemplate(template string, vars ...interface{}) (string, error) {
return mustache.Render(template, vars...)
}
func info(format string, vals ...interface{}) {
log.Printf("Burrow info: "+format,... |
// determines the century of a given year
// 2000 is the 20th century, 1999 is the 20th century, and 2001
func getCenturyFromYear(year int) int {
if (year % 100 > 0) {
return year / 100 + 1
} else {
return year / 100
}
}
|
package build
import (
"bytes"
"context"
"errors"
"fmt"
"github.com/onsi/ginkgo/v2"
"io"
"os"
"os/exec"
"strings"
"github.com/docker/docker/api/types"
"github.com/docker/docker/api/types/container"
"github.com/loft-sh/devspace/cmd"
"github.com/loft-sh/devspace/cmd/flags"
"github.com/loft-sh/devspace/e2... |
// date: 2019-03-07
package common
import "sync"
//quote.kline.1m.btc_usdt
//quote.tick.btc_usdt
//quote.depth.btc_usdt
type SocketMap struct {
sync.Mutex
ConnMap map[string]map[string][]string
//缺少连接属性
}
var (
Smap = &SocketMap{sync.Mutex{}, make(map[string]map[string][]string)}
KlineChan = "quote.kline.... |
package ldap
// Heavily inspired by https://github.com/hashicorp/vault/blob/bc33dbd/helper/ldaputil/client.go
/// or simply copying code from there.
import (
"bytes"
"crypto/tls"
"crypto/x509"
"errors"
"fmt"
"math"
"net"
"net/http"
"net/url"
"strings"
"sync"
"text/template"
"time"
"github.com/go-ldap/l... |
// 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... |
package openstack
import "fmt"
type Image struct {
name string
id string
client imageServiceClient
}
func NewImage(name string, id string, client imageServiceClient) Image {
return Image{
name: fmt.Sprintf("%s %s", name, id),
id: id,
client: client,
}
}
func (i Image) Delete() error {
return... |
package main
import "fmt"
type Bread struct {
val string
}
type StrawberryJam struct {
opend bool
}
type SpoonOfStrawberry struct {
}
type sandwich struct {
val string
}
func GetBreads(num int) []*Bread {
breads := make([]*Bread, num)
for i := 0; i < num; i++ {
breads[i] = &Bread{val: "br... |
// status.go defines a Status struct for each node in the cluster, providing
// four attributes (CRole, DBRole, State, UpdateAt) as a way of determining each
// nodes role in the cluster, current state, and the role of the pgqsl running
// inside each (non-monitor) node.
//
// status provides methods for updating the D... |
package main
import (
"fmt"
"github.com/aws/aws-sdk-go/aws"
"github.com/aws/aws-sdk-go/aws/session"
"github.com/aws/aws-sdk-go/service/elasticsearchservice"
)
// Creating a new ElasticSearchService domain
// Not using this for now, need go through detailed
// configuration for elastic search domain
// for now wi... |
package cholesky
import (
"gonum.org/v1/gonum/mat"
)
type CTriDense struct {
Matrix *mat.CDense
Kind mat.TriKind
Len int
}
func newCTriDense(n int, kind mat.TriKind) *CTriDense {
return &CTriDense{
Matrix: mat.NewCDense(n, n, nil),
Kind: kind,
Len: n,
}
}
func (tri *CTriDense) SetTri(i, j int,... |
// Go1.11开始支持WebAssembly,
// 对应的操作系统名为js,对应的CPU类型为wasm。
// 目前还无法通过 go run 的方式直接运行输出的wasm文件,
// 因此我们需要通过 go build 的方式生成wasm目标文件,
// cd go-webassembly/hello
// GOARCH=wasm GOOS=js go build -o hello.wasm hello.go
// 然后通过Node环境执行。
// node ../lib/wasm_exec.js hello.wasm
package main
import (
"fmt"
"syscall/js"
)
func m... |
package runtime
// Program data type
type Type uint8
const (
// Empty value, nil
NilType Type = iota
// Boolean true/false
BooleanType
// Integers
IntType
// Unique symbols; variable names, function names
SymbolType
// Generic sequences
SequenceType
// Generic associations
AssocType
// Strings
StringTyp... |
package redis
import (
_ "encoding/json"
_ "fmt"
_ "github.com/go-redis/redis"
_ "github.com/tidwall/gjson"
_ "io/ioutil"
)
type config struct {
OptionsConns map[string]Options `json:"options_conns"`
Default string `json:"default"`
}
|
package fractal
import (
"image"
"image/color"
)
type Fractal struct {
LowerLeft complex128
UpperRight complex128
Scale float64
RGBA image.RGBA
}
func NewFractal(lowerLeft, upperRight complex128, scale float64) Fractal {
w := int((real(upperRight) - real(lowerLeft))*scale)
h := int((imag(upperRight) - imag(l... |
// fetch 输出从URL获取得内容
package main
import (
"bufio"
"fmt"
"io"
"io/ioutil"
"net/http"
"os"
"strings"
)
func main_() {
for _, url := range os.Args[1:]{
resp, err := http.Get(url)
if err != nil{
fmt.Fprintf(os.Stderr, "fetch: %v\n", err)
os.Exit(1)
}
b, err := ioutil.ReadAll(resp.Body)
resp.Body.... |
package main
import (
"fmt"
"reflect"
)
// 比较2个map
func mapDeepEqual() {
a := map[int]string{1: "a", 2: "b", 3: "c"}
b := map[int]string{1: "a", 2: "b", 3: "c"}
c := map[int]string{1: "a", 2: "b", 4: "c"}
fmt.Println(reflect.DeepEqual(a, b))
fmt.Println(reflect.DeepEqual(a, c))
}
// 比较切片
func sliceDeepEqual(... |
package main
//1178. 猜字谜
//外国友人仿照中国字谜设计了一个英文版猜字谜小游戏,请你来猜猜看吧。
//
//字谜的迷面puzzle 按字符串形式给出,如果一个单词word符合下面两个条件,那么它就可以算作谜底:
//
//单词word中包含谜面puzzle的第一个字母。
//单词word中的每一个字母都可以在谜面puzzle中找到。
//例如,如果字谜的谜面是 "abcdefg",那么可以作为谜底的单词有 "faced", "cabbage", 和 "baggage";而 "beefed"(不含字母 "a")以及"based"(其中的 "s" 没有出现在谜面中)。
//返回一个答案数组answer,数组中的... |
package main
// Leetcode m17.19. (hard)
func missingTwo(nums []int) []int {
n := len(nums) + 2
res := 0
for i := 1; i <= n; i++ {
res ^= i
}
for _, num := range nums {
res ^= num
}
lowbit := res & (-res)
one := 0
for i := 1; i <= n; i++ {
if i&lowbit == 0 {
one ^= i
}
}
for _, num := range nums ... |
package epazote
import (
"encoding/json"
"fmt"
"net/http"
"net/http/httptest"
"regexp"
"sync"
"testing"
)
func TestSuperviceTestOk(t *testing.T) {
var wg sync.WaitGroup
log_s := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
if r.Header.Get("User-agent") != "epazote" {
... |
package timewindow
import (
"log"
"testing"
"time"
)
// daeuihfuiseghfiusghui
func Test_timeWindow(t *testing.T) {
type args struct {
t time.Time
open time.Time
close time.Time
}
tests := []struct {
name string
args args
want bool
wantErr bool
}{
{
args: args{},
want: true,
... |
package qwertycore
import (
"io/ioutil"
)
//
type Page struct {
Filename string
Title string
Body []byte
}
// LoadPage
func LoadPage(title string) (*Page, error) {
filename := a + "/views/" + title + ".html"
body, err := ioutil.ReadFile(filename)
if err != nil {
return nil, err
}
return &Page{Filen... |
package flandmark
import "errors"
var (
ErrBadArgument = errors.New("Invalid argument.")
ErrCouldNotLoad = errors.New("Could not load file.")
ErrDataSize = errors.New("Got unexpected data size.")
ErrDetect = errors.New("Failed to detect.")
ErrNormalize = errors.New("Failed to normalize.")
ErrUnkno... |
package main
import "fmt"
type User struct {
login string
name string
surname string
birthYear int
}
func main() {
var name, surname, login string
var birthYear int
username := make(map[string]User)
loginCheck := make(map[string]bool)
for {
fmt.Println("Hello, enter the user data with space: ... |
package main
import (
"ehsan_esmaeili/config"
"ehsan_esmaeili/database"
"ehsan_esmaeili/route"
"ehsan_esmaeili/usecase"
"fmt"
"log"
"net/http"
"github.com/julienschmidt/httprouter"
)
func main() {
router := httprouter.New()
fmt.Println("Server Run On the : %s", config.Server_Url)
db, err := database.Conne... |
package master
import (
"encoding/json"
"os"
"time"
)
type JsonSnapshotWriter struct {
outDir string
}
func NewJsonSnapshotWriter(outDir string) *JsonSnapshotWriter {
return &JsonSnapshotWriter{
outDir: outDir,
}
}
type JsonSnapshotCountersRow struct {
Time string
Counters map[string]int64
}
func (w ... |
package router
import (
"github.com/gin-gonic/gin"
"hd-mall-ed/packages/admin/controller/productCategoryController"
)
func productCategoryRouter(router *gin.RouterGroup) {
category := router.Group("/product_category")
{
category.GET("/list", productCategoryController.GetList)
}
}
|
package entity
type Errors struct {
Errors []err `json:"errors"`
}
//Error ошибка
type err struct {
Error string `json:"error"` // Заголовок ошибки
Parameter string `json:"parameter"` // Параметр, на котором произошла ошибка
Code int `json:"code"` // Код ошибки
ErrorMessage... |
package People
// 获取人的信息
type PeopleGetter interface {
// 获取名字
GetName() string
// 获取年龄
GetAge() string
}
|
// Copyright 2015 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 leetcode
func twoSum1(numbers []int, target int) []int {
i, j := 0, len(numbers)-1
sums := numbers[i] + numbers[j]
for sums != target {
if sums > target {
j--
} else if sums < target {
i++
}
sums = numbers[i] + numbers[j]
}
return []int{i + 1, j + 1}
}
|
package main
import (
"fmt"
)
type myInt int
func (i myInt) init() {
fmt.Println("Init!")
i = 1
}
func main() {
var inter myInt
fmt.Println(inter)
}
|
package test
import (
"fmt"
"io/ioutil"
"testing"
"github.com/blang/semver"
"gopkg.in/yaml.v2"
"github.com/mesosphere/kubeaddons/hack/temp"
"github.com/mesosphere/kubeaddons/pkg/api/v1beta1"
"github.com/mesosphere/kubeaddons/pkg/test"
"github.com/mesosphere/kubeaddons/pkg/test/cluster/kind"
)
const default... |
package console
import (
"oh-my-posh/color"
"oh-my-posh/mock"
"oh-my-posh/platform"
"testing"
"github.com/stretchr/testify/assert"
)
func TestGetTitle(t *testing.T) {
cases := []struct {
Template string
Root bool
User string
Cwd string
PathSeparator string
ShellName... |
// Copyright 2018 The ChromiumOS Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
package network
import (
"bufio"
"context"
"os"
"strings"
"golang.org/x/sys/unix"
"chromiumos/tast/testing"
)
func init() {
testing.AddTest(&testing.Test{
Func: ... |
package main
import (
"context"
"crypto/tls"
"flag"
"github.com/jackc/pgx/v4/pgxpool"
"github.com/joho/godotenv"
"google.golang.org/grpc"
"log"
"net/http"
"os"
"snippetBox-microservice/catalog/api/grpc/protobuffs"
"snippetBox-microservice/catalog/internal/controller"
"snippetBox-microservice/catalog/intern... |
// Package writer create SSA/ASS Subtitle Script
package writer
import (
"bytes"
"fmt"
"os"
"strings"
"github.com/Alquimista/eyecandy/asstime"
"github.com/Alquimista/eyecandy/color"
"github.com/Alquimista/eyecandy/utils"
)
// silence?, noise?
const dummyVideoTemplate string = "?dummy:%.6f:%d:%d:%d:%d:%d:%d%s:... |
package http
type ErrorsResponse struct {
Errors string `json:"errors"`
}
|
// Package grpc provides a gRPC client for the Listings service.
package grpc
import (
"github.com/pkg/errors"
"golang.org/x/net/context"
"google.golang.org/grpc"
"google.golang.org/grpc/metadata"
"github.com/go-kit/kit/endpoint"
grpctransport "github.com/go-kit/kit/transport/grpc"
// This Service
pb "github... |
package apilifecycle
import godd "github.com/pagongamedev/go-dd"
// MappingStandardError Type
type MappingStandardError = func(goddErr *godd.Error) (codeOut int, responseError interface{}, goddErrOut *godd.Error)
// MappingStandardError Set
func (api *APILifeCycle) MappingStandardError(handler MappingStandardError) ... |
package stack_test
import (
"learning_golang/stack"
"testing"
)
func TestStack(t *testing.T) {
count := 1
var aStack stack.Stack
assertTrue(t,aStack.Len()==0,"expected empty Stack",count)
}
// assertTrue() calls testing.T.Error() with the given message if the
// condition is false.
func assertTrue(t *testing.T... |
package usecase_test
import (
"testing"
"github.com/go-playground/validator"
"github.com/pkg/errors"
"github.com/utahta/momoclo-channel/dao"
"github.com/utahta/momoclo-channel/entity"
"github.com/utahta/momoclo-channel/event/eventtest"
"github.com/utahta/momoclo-channel/linenotify"
"github.com/utahta/momoclo-... |
package db
import (
"context"
"fmt"
"log"
"strings"
"cloud.google.com/go/firestore"
"google.golang.org/api/iterator"
)
type Tag struct {
Name string `json:"name"`
Values map[string]int64 `json:"values"`
}
func (db *FirestoreDB) CreateTag(ctx context.Context, squadId string, tag *Tag) (err error)... |
/*
Copyright 2021 The Skaffold 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, sof... |
package access
import (
"github.com/open-kingfisher/king-utils/common/access"
"github.com/open-kingfisher/king-utils/common/log"
versionedclient "istio.io/client-go/pkg/clientset/versioned"
)
func IstioClient(clusterId string) (*versionedclient.Clientset, error) {
config, err := access.GetConfig(clusterId)
if er... |
package statistic
import (
//"github.com/astaxie/beego"
"net/http"
"strings"
"webserver/controllers"
"webserver/models"
"webserver/models/extra"
)
type ClickStatisController struct {
controllers.BaseController
}
func (c *ClickStatisController) Get() {
defer c.Recover()
c.statisticInfo()
c.WriteCommonRespon... |
// Copyright£ (c) 2020-2021 KHS Films
//
// This file is a part of mtproto package.
// See https://github.com/xelaj/mtproto/blob/master/LICENSE for details
package tl
import "fmt"
type ErrRegisteredObjectNotFound struct {
Crc uint32
Data []byte
}
func (e *ErrRegisteredObjectNotFound) Error() string {
return fmt... |
package main
import (
"fmt"
"os"
"reflect"
"strings"
)
type Config struct {
Name string `json:"server-name"`
IP string `json:"server-ip"`
URL string `json:"server-url"`
Timeout string `json:"timeout"`
}
func readConfig() *Config {
// read from xxx.json,省略
config := Config{}
typ := reflect.Type... |
package ws
import (
"encoding/json"
"log"
"net/http"
"time"
"github.com/gorilla/websocket"
m "github.com/kasiss-liu/go-webserver/models"
)
var upgrader = websocket.Upgrader{
ReadBufferSize: 1024,
WriteBufferSize: 1024,
}
func SyncServerState(w http.ResponseWriter, r *http.Request) {
conn, err := upgrader.... |
// This Source Code Form is subject to the terms of the MIT License.
// If a copy of the MIT License was not distributed with this
// file, you can obtain one at https://opensource.org/licenses/MIT.
//
// Copyright (c) DUSK NETWORK. All rights reserved.
package transactions
import (
"bytes"
"context"
"crypto/rand"... |
// 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 private
import (
"github.com/google/go-querystring/query"
"github.com/pkg/errors"
"github.com/potix/gobitflyer/api/types"
"github.com/potix/gobitflyer/client"
)
const (
getParentOrderPath string = "/v1/me/getparentorder"
)
type GetParentOrderResponse struct {
Id int64 ... |
package main
import (
"fmt"
"sync"
)
type Account struct {
Money int
Locker sync.Mutex
}
func (a *Account) SaveMoney(n int) {
a.Locker.Lock()
fmt.Println("before save,money=", a.Money)
a.Money += n
fmt.Println("after save,money=", a.Money)
a.Locker.Unlock()
}
func (a *Account) GetMoney(n int) {
a.Locker... |
package main
import "strconv"
// Leetcode 5772. (easy)
func isSumEqual(firstWord string, secondWord string, targetWord string) bool {
m := make(map[rune]int)
r := 'a'
for i := 0; i < 26; i++ {
m[r] = i
r++
}
buf := ""
for _, r := range firstWord {
buf += strconv.Itoa(m[r])
}
firstNum, _ := strconv.Atoi... |
package fmap
import (
"fmt"
"github.com/lleo/go-functional-collections/key"
)
// KeyVal is a simple struct used to transfer lists ([]KeyVal) from one
// function to another.
type KeyVal struct {
Key key.Hash
Val interface{}
}
func (kv KeyVal) String() string {
return fmt.Sprintf("{%q, %v}", kv.Key, kv.Val)
}
|
package main
import (
"github.com/stretchr/testify/assert"
"testing"
)
func TestHistory(t *testing.T) {
assert := assert.New(t)
h := &history{
Id: 123,
Name: "init",
}
assert.Equal("000123_init", h.String())
res, err := parseHistory("000123_init")
assert.Nil(err)
assert.Equal(&history{
Id: 123,
... |
package main
import (
"context"
"fmt"
"os"
"strings"
pb "github.com/aykay76/grpc-go/environment"
empty "github.com/golang/protobuf/ptypes/empty"
"github.com/prometheus/client_golang/prometheus"
"github.com/prometheus/client_golang/prometheus/promauto"
)
var (
opsProcessed = promauto.NewCounter(prometheus.C... |
package Week_03
type TreeNode struct {
Val int
Left *TreeNode
Right *TreeNode
}
func buildTree(preorder []int, inorder []int) *TreeNode {
if len(preorder) == 0 || len(inorder) == 0 {
return nil
}
skip := 0
for k, v := range inorder {
if v == preorder[0] {
skip = k
break
}
}
lTree := bui... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.