text
stringlengths
11
4.05M
// Copyright 2020 The VectorSQL Authors. // // Code is licensed under Apache License, Version 2.0. package expressions import ( "testing" "datavalues" "github.com/stretchr/testify/assert" ) func TestExpressionFor(t *testing.T) { vals := []interface{}{ int64(1), int32(2), int16(2), byte(0x01), float64...
package types import ( "fault/ast" "fmt" "math" "strings" ) var TYPES = map[string]int{ //Convertible Types "STRING": 0, //Not convertible "BOOL": 1, "NATURAL": 2, "FLOAT": 3, "INT": 4, "UNCERTAIN": 5, } var COMPARE = map[string]bool{ ">": true, "<": true, "==": true, "!=": true, ...
// 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 session import ( "context" "github.com/godbus/dbus/v5" "chromiumos/tast/local/cryptohome" "chromiumos/tast/local/session" "chromiumos/tast/local/upstart" "ch...
package main import ( "crypto/sha512" "encoding/hex" "fmt" "net/http" "os/exec" "strconv" "strings" "time" ) var initialPassword = "hellop#firstsec" var secretKey string = "z2Xm3m4Dr:/Rm2Gv5WdpCpDLdYVrqCgpcftYqMiqSXLu3esqzwfgpwxKqyDm765UnJttuw2CtxV2bunpTwmqvLeFTfrzdkA3Q6pNNGPwvrTDCBHFN4jPyWAj7X7wPrX7feiKxRni2...
package main import ( "context" "flag" "fmt" "io" "log" "os" "strconv" "github.com/golang/protobuf/ptypes/empty" v1 "github.com/onuryartasi/scaler/pkg/api/v1" "google.golang.org/grpc" ) type container struct { *v1.Container } var ( InfoColor = "\033[1;34m%s\033[0m" NoticeColor = "\033[1;36m%s\033[0...
package services import "time" var SessionDuration time.Duration type Cache struct { values map[string]interface{} timers map[string]*time.Timer } func NewCache() Cache { var cache Cache cache.timers = make(map[string]*time.Timer) cache.values = make(map[string]interface{}) return cache } func (cache Cache) ...
package services import ( "github.com/ham357/tsundoku/api/domain/users" "github.com/ham357/tsundoku/api/utils/errors" ) // CreateUser - Service func CreateUser(user users.User) (*users.User, *errors.ApiErr) { if err := user.Save(); err != nil { return nil, err } return &user, nil }
// comma inserts commas in a non-negative decimal integer string package main import ( "fmt" ) func main() { fmt.Println(comma("1")) fmt.Println(comma("12")) fmt.Println(comma("213")) fmt.Println(comma("3451")) fmt.Println(comma("23451")) fmt.Println(comma("234543")) fmt.Println(comma("1345678")) } func comm...
package view import ( "bufio" "github.com/xiaozefeng/go-web-crawler/engine" "github.com/xiaozefeng/go-web-crawler/frontend/model" "github.com/xiaozefeng/go-web-crawler/model/zhenai" "html/template" "os" "testing" ) func TestTemplate(t *testing.T) { var item = engine.Item{ Id:"123", Url:"https://album.zhen...
// 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 camera import ( "context" "chromiumos/tast/common/media/caps" "chromiumos/tast/local/camera/cca" "chromiumos/tast/testing" ) func init() { testing.AddTest(&te...
package enums const ( //總參與人數:完成遊戲的總人數,跳出不計算 RedisFinishedGameCount = "RedisFinishedGameCount" //跳出人數:未完成遊戲的跳出人數 RedisUnfinishedGameCount = "RedisUnfinishedGameCount" //重複玩人數:同一玩家重複完整玩完的人數 RedisRepeatUserCount = "RedisRepeatUserCount" //不重複玩人數:同一玩家重複完整玩完的人數 RedisNotRepeatUserCount = "RedisNotRepeatUserC...
package gomodulesdeptwo import ( "github.com/tarekbadrshalaan/gomodulesdepone/v2/subpkg" ) // GetDatadepone : get data from depone func GetDatadepone() string { return subpkg.GetExtraData() }
package list import ( "fmt" "testing" ) func TestAppend(t *testing.T) { linkedList := NewLinkedList() linkedList.Append(1) linkedList.InsertInFront("22") if linkedList.Size != 2 { t.Error("should be 2 but it is:", linkedList.Size) } linkedList.PrintAll() fmt.Println("-------") if v := linkedList.Find("22...
package runtime import ( "github.com/juanibiapina/marco/lang" "reflect" "testing" ) func TestRunString(t *testing.T) { r := New() expr := r.Run("1") expected := lang.MakeNumber(1) if !reflect.DeepEqual(expr, expected) { t.Errorf("Wrong result, expected '%v', got '%v'", expected, expr) } }
package concurrent import ( "math/rand" "strconv" "testing" ) func TestStripedMutex_GetLock(t *testing.T) { c := NewStripedMutex(64) for i := 0; i < 100; i++ { c.GetLock(strconv.Itoa(rand.Int())) } }
package cmqapi import ( "fmt" "github.com/friendlyhank/foundation/str" ) //CmqQueue -队列 type CmqQueue struct { QueueName string //队列名 CmqClient *CmqClient Encoding bool //64位编码 } //NewCmqQueue - func NewCmqQueue(queuename string, cmqclient *CmqClient, encoding bool) *CmqQueue { return &CmqQueue{QueueName: qu...
package views import ( "io/ioutil" "path/filepath" "reflect" "testing" "github.com/jenkins-x/octant-jx/pkg/common/viewhelpers" "github.com/stretchr/testify/require" "sigs.k8s.io/yaml" "github.com/vmware-tanzu/octant/pkg/view/component" "k8s.io/apimachinery/pkg/apis/meta/v1/unstructured" ) func Test_toHealt...
package extjson const ( NamedStyleLowerCamelCase = 1001 NamedStyleUpperCamelCase = 1002 NamedStyleUnderScoreCase = 1003 )
package Tieba import ( "github.com/PuerkitoBio/goquery" ) type Article struct { url string totalPage int author string lastUpdate int } func (article Article) NewArticle(url string) (article *Article){ doc, _ := goquery.NewDocument(url) &article.totalPage = doc.Find(".l_reply_num .red").Eq(1).Text() return a...
package main import ( "fmt" "testing" ) func TestFindMove(t *testing.T) { board := new(Board) board.NewGame() game := new(Game) game.board = board blackPlayer := &Player{BLACK} redPlayer := &Player{RED} game.DoMove(&Square{2, 1}, &Square{3, 2}, blackPlayer) game.DoMove(&Square{5, 0}, &Square{4, 1}, redPl...
package moxings type Yinpinwenjians struct { Id int Xuliehao string `gorm:"not null;DEFAULT:0"` Lujing string `gorm:"not null;DEFAULT:0"` Leixing string `gorm:"not null;DEFAULT:0"` Mima string `gorm:"not null;DEFAULT:0"` Md5mima string `gorm:"not null;DEFAULT:0"` } func (Yinpinwenjians) TableName(...
package sphinx import "github.com/decred/slog" // sphxLog is a logger that is initialized with no output filters. This // means the package will not perform any logging by default until the caller // requests it. // The default amount of logging is none. var sphxLog = slog.Disabled // UseLogger uses a specified Lo...
package client_generator import ( "fmt" "github.com/go-openapi/spec" "github.com/morlay/gin-swagger/codegen" "sort" ) func getFieldsFromSchema(schema spec.Schema) (fields []string, deps []string) { var propNames = []string{} for name := range schema.Properties { propNames = append(propNames, name) } sort....
package main import ( "github.com/p4vlowVl4d/purchase-tracker_gui/gui" "log" ) func main() { log.Println("Starting") win := gui.NewWindow(640, 480, "example") win.Show() }
package processor import ( "context" "fmt" ) type TileInternalPipeline struct { Context context.Context Error chan error RPCAddress string APIAddress string } func NewTileInternalPipeline(ctx context.Context, apiAddr string, rpcAddr string, errChan chan error) *TileInternalPipeline { return &TileInter...
package service import ( "github.com/talesmud/talesmud/pkg/db" "github.com/talesmud/talesmud/pkg/repository" "github.com/talesmud/talesmud/pkg/scripts" ) //Facade ... type Facade interface { CharactersService() CharactersService PartiesService() PartiesService UsersService() UsersService RoomsService() RoomsSe...
package main import ( "github.com/astaxie/beego" _ "github.com/go-sql-driver/mysql" _ "my_blog/routers" ) func main() { //beego.AutoRender beego.Run() }
package crybsy import ( "crypto/sha256" "errors" "fmt" "log" "os" "os/user" "path/filepath" "regexp" "sync" "time" ) type scanner struct { Root *Root Files chan File Errors chan error WaitGroup *sync.WaitGroup Filter []*regexp.Regexp } // NewRoot creates a new CryBSy Root func NewRoot(p...
/* * Copyright 2021 Vitali Baumtrok. * Distributed under the Boost Software License, Version 1.0. * (See accompanying file LICENSE or copy at * http://www.boost.org/LICENSE_1_0.txt) */ package displays import ( "strconv" "testing" ) func TestAll(t *testing.T) { displays := All() if len(...
package main import "fmt" /* https://www.hackerearth.com/practice/data-structures/arrays/1-d/tutorial/ */ func gsg5() { var n int fmt.Scanf("%d", &n) nums := make([]int, n) for i := 0; i < n; i++ { fmt.Scanf("%d", &nums[i]) } for i := len(nums) - 1; i >= 0; i-- { fmt.Println(nums[i]) } }
/* Copyright 2020 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 main import ( "context" "fmt" ) func t21() { ctx := context.WithValue(context.Background(), "key", "value2222") fmt.Println(ctx.Value("key").(string)) } func main() { t21() }
package renderings type HistoryItem struct { Time string `json:"time"` Rate float32 `json:"rate"` } type HistoryResponse struct { Message string `json:"message"` Code int `json:"code"` Payload []HistoryItem `json:"payload"` }
package top import ( . "github.com/trapped/gomaild2/pop3/structs" ) // Arguments: // a message-number (required) which may NOT refer to to a // message marked as deleted, and a non-negative number // of lines (required) // Restrictions: // may only be given in the TRANSACTION state func Process(c *Client, cmd Comman...
package main import "fmt" func main() { greeting := func() { fmt.Println("Hello, world") } greeting() //assign a func to a variable //only way to assign a function within a function }
package dal import ( "bytes" "fmt" "io" "io/ioutil" "os" "os/user" "github.com/anurakhan/go-mongo-lb-driver/models" "github.com/anurakhan/go-mongo-lb-driver/server" "gopkg.in/mgo.v2/bson" "encoding/hex" ) type PhotosRepository struct { Server *server.Server DbInteractor *MongoInteractor } func (re...
/* * Created on Fri Feb 01 2019 9:10:2 * Author: WuLC * EMail: liangchaowu5@gmail.com */ // dp, O(n) time, O(n) space func mincostTickets(days []int, costs []int) int { dp := []int{0} for i := 0; i < len(days); i++ { dp = append(dp, dp[i] + costs[0]) for j := i-1; j >= 0 && j >= i - 30; j-- { if days[j] ...
// Copyright 2020 The Tekton 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 server import ( "encoding/json" "fmt" "github.com/loft-sh/devspace/pkg/devspace/dependency/registry" "github.com/loft-sh/devspace/pkg/devspace/pipeline/types" "net/http" ) func (h *handler) ping(w http.ResponseWriter, req *http.Request) { decoder := json.NewDecoder(req.Body) var t registry.PingPayload ...
package requests import ( "encoding/json" "fmt" "io/ioutil" "net/url" "strings" "github.com/atomicjolt/canvasapi" "github.com/atomicjolt/canvasapi/models" ) // GetUploadedMediaFolderForUserCourses Returns the details for a designated upload folder that the user has rights to // upload to, and creates it if it...
// Copyright 2018, Irfan Sharif. // // 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 w...
package odoo import ( "fmt" ) // ResPartner represents res.partner model. type ResPartner struct { LastUpdate *Time `xmlrpc:"__last_update,omptempty"` Active *Bool `xmlrpc:"active,omptempty"` ActivityDateDeadline *Time `xmlrpc:"activity_date_deadli...
package main /* #cgo CFLAGS: -I. #cgo LDFLAGS: -L. -ldemo #include "demo.h" */ import "C" import "fmt" func main() { fmt.Println(C.sum(1,2)) fmt.Println("111111") }
package jumphelper import ( "fmt" "io/ioutil" "log" "net/http" "strings" ) import ( "github.com/bwesterb/go-pow" ) // Client is a HTTP client that makes jumphelper requests type Client struct { host string port string verbose bool client *http.Client } // Log wraps Println to control verbosity. fun...
package security import ( "bytes" "testing" ) func TestPKCS5Padding(t *testing.T) { actual, _ := PKCS5Padding([]byte{'1', '2', '3', '4', '5'}, 8) expect := []byte{'1', '2', '3', '4', '5', '3', '3', '3'} if !bytes.Equal(actual, expect) { t.Errorf("TestPKCS5Padding: expect->%q, actual->%q", expect, actual) } a...
package atTheCrossroads func knapsackLight(value1 int, weight1 int, value2 int, weight2 int, maxW int) int { //if all <= maxW if weight1+weight2 <= maxW { return value1+value2 } //if all > maxW if weight1>maxW && weight2>maxW { return 0 } if weight1<=maxW && weight2<=maxW { if value1>value2 { retur...
// In the early 60's G.M. Adelson-Velsky and E.M. Landis // invented the first self-balancing binary search tree // data structure, calling it AVL Tree. // // An AVL tree is a binary search tree between the height // of the left and right subtrees cannot be no more than one. // // The AVL balance condition, known also ...
package configuration import ( "database/sql" "fmt" "log" "testing" _ "github.com/lib/pq" ) type failure struct { Prefix string Expected interface{} Actual interface{} } func SetupDB() *sql.DB { db, err := sql.Open("postgres", "user=tenable password=insecure dbname=apitest") if err != nil { log.Fata...
package cloudid // import "yunion.io/x/onecloud/pkg/apis/cloudid"
package services import ( "github.com/johnnyeven/chain/blockchain" "github.com/johnnyeven/chain/messages" "github.com/johnnyeven/chain/global" "github.com/johnnyeven/terra/dht" "github.com/johnnyeven/chain/network" "github.com/sirupsen/logrus" "github.com/boltdb/bolt" "bytes" "encoding/gob" "errors" "fmt" )...
// Copyright 2021 The ChromiumOS Authors // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. package scanapp import ( "context" "path/filepath" "time" "chromiumos/tast/ctxutil" "chromiumos/tast/local/bundles/cros/scanapp/scanning" "chromiumos/tast/local/chrom...
// Copyright (C) 2017 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 t...
package virus_handler import ( "decept-defense/controllers/comm" "decept-defense/models" "decept-defense/pkg/app" "decept-defense/pkg/util" "github.com/gin-gonic/gin" "net/http" ) func CreateVirusRecord(c *gin.Context) { appG := app.Gin{C: c} var record models.VirusRecord err := c.ShouldBindJSON(&record) if...
package logr import ( "testing" "github.com/go-logr/logr" ) func TestLogger(t *testing.T) { var logger interface{} = New(nil) if _, ok := logger.(logr.Logger); !ok { t.Error("Logger does not implement the logr.Logger interface") } }
package eval import ( "bytes" "context" "io" "io/ioutil" "net/http" "net/url" "os" "sort" "strconv" "github.com/hashicorp/hcl/v2" "github.com/hashicorp/hcl/v2/hclsyntax" "github.com/zclconf/go-cty/cty" "github.com/zclconf/go-cty/cty/function" "github.com/zclconf/go-cty/cty/function/stdlib" ac "github....
package entry import ( "shared/common" "shared/utility/errors" "shared/utility/transfer" "sync" ) type PatchCfg struct { Channel string `json:"channel"` AppVersion string `json:"app_version"` ResourceUrl []string `json:"resource_url"` ResourceVersion string `json:"resource_version"` } ...
package utils import ( "bufio" "encoding/json" "fmt" "io/ioutil" "os" "path/filepath" "strconv" "time" ) // GetExecutablePath gets the path of the current executable. func GetExecutablePath() (string, error) { ex, err := os.Executable() if err != nil { return "", err } return filepath.Dir(ex), nil } ...
package employee type position int const ( Developer position = iota Manager Boss ) func NewEmployee(position position) *employee { switch position { case Developer: return &employee{position: "developer", annualIncome: 60000} case Manager: return &employee{position: "manager", annualIncome: 80000} case B...
package main import ( "encoding/json" "github.com/prometheus/client_golang/prometheus" log "github.com/sirupsen/logrus" "io/ioutil" "net/http" "time" ) type terminationCollector struct { metadataEndpoint string terminationIndicator *prometheus.Desc terminationTime *prometheus.Desc } type InstanceAc...
package oci8 /* #include "oci8.go.h" #cgo !noPkgConfig pkg-config: oci8 */ import "C" import ( "bytes" "database/sql/driver" "errors" "fmt" "unsafe" ) // noPkgConfig is a Go tag for disabling using pkg-config and using environmental settings like CGO_CFLAGS and CGO_LDFLAGS instead func freeBo...
package snowflake import ( "context" "errors" "fmt" "sync" "sync/atomic" "time" "github.com/derry6/gleafd/pkg/log" ) type Service struct { md Metadata stor Storage fs chan Factory // 使用chan 代替使用锁 logger log.Logger wg sync.WaitGroup closed int32 // 退出标记 closeC chan stru...
package structs import ( "sync" ) // Item is an interface for the nodes to be stored in a queue type Item interface { DeepCopy() Item Equals(Item) bool Priority() int } type node struct { item Item prev *node next *node } func newNode(item Item) *node { return &node{item: item.DeepCopy()} } // CompareFunc...
package main import ( "encoding/json" "fmt" "io" "github.com/bloveless/tweetgo" ) func statusesUpdate(c config, status string) { tc := getTwitterClient(c) input := tweetgo.StatusesUpdateInput{ Status: tweetgo.String(status), } output, err := tc.StatusesUpdatePost(input) if err != nil { panic(err) } ...
package main import ( "context" "errors" "fmt" "github.com/afex/hystrix-go/hystrix" "github.com/gin-gonic/gin" "github.com/micro/go-micro/v2" "github.com/micro/go-micro/v2/registry" "github.com/micro/go-micro/v2/web" "github.com/micro/go-plugins/registry/consul/v2" proto "go-mic...
package parser import ( "github.com/stephens2424/php/ast" "github.com/stephens2424/php/lexer" "github.com/stephens2424/php/token" ) func (p *Parser) parseFunctionStmt(inMethod bool) *ast.FunctionStmt { stmt := &ast.FunctionStmt{} stmt.FunctionDefinition = p.parseFunctionDefinition() if !inMethod { p.namespace...
// Unless explicitly stated otherwise all files in this repository are licensed // under the Apache License Version 2.0. // This product includes software developed at Datadog (https://www.datadoghq.com/). // Copyright 2016-present Datadog, Inc. package orchestratorexplorer import ( "fmt" "strconv" "github.com/Da...
package leetcode import ( "testing" "github.com/stretchr/testify/assert" ) /** 139. Word Break Given a string s and a dictionary of strings wordDict, return true if s can be segmented into a space-separated sequence of one or more dictionary words. Note that the same word in the dictionary may be reused m...
package main import ( "github.com/nsf/termbox-go" "time" ) func draw() { termbox.Clear(termbox.ColorDefault, termbox.ColorDefault) w, h := termbox.Size() bWidth := w * 15 / 100 bHeight := h / 3 offY := (h - bHeight) / 2 spacing := w * 1 / 10 hourTen := spacing hourOne := bWidth + spacing colonSpace := bWid...
package models import ( "time" //"github.com/jinzhu/gorm" //"github.com/spf13/viper" ) type Assignment struct { EmployeeNumber uint `gorm:"column:emp_no"` DepartmentNumber string `gorm:"column:dept_no"` StartDate time.Time `gorm:"column:from_date"` EndDate time.Time `gorm:"column:to_d...
package commands import ( "fmt" "image" "path/filepath" "strings" "github.com/spf13/cobra" "gocv.io/x/gocv" ) var ( cropCmd = &cobra.Command{ Use: "crop", Short: "Crop a photo file", Long: "Crop a photo file", Run: cropCommand, } ) func init() { cropCmd.PersistentFlags().StringVarP(&cascadeFil...
package kinesumer import ( "context" "os" "sync" "time" "github.com/daangn/kinesumer/pkg/xrand" "github.com/aws/aws-sdk-go/aws" "github.com/aws/aws-sdk-go/aws/credentials/stscreds" "github.com/aws/aws-sdk-go/aws/session" "github.com/aws/aws-sdk-go/service/kinesis" "github.com/pkg/errors" "github.com/rs/ze...
package ontap import ( "bytes" "encoding/xml" "fmt" "github.com/go-xmlfmt/xmlfmt" "net/http" "regexp" "strconv" "strings" ) type AggrInfo struct { Name string SizeTotal string SizeUsed string SizeAvailable string SizeUsedPercent string State string Cluster st...
package cmd import ( "context" "testing" "github.com/stretchr/testify/require" "github.com/tharsis/token/app" ) // TODO fix invalid mnemonic test case // Error: DeployToken err: " --- at github.com/tharsis/ethermint/app/ante/eth.go:217 (EthNonceVerificationDecorator.AnteHandle) ---\nCaused by: invalid nonce; got...
package auth import ( "log" "net/http" "net/http/httptest" "os" "testing" "github.com/spatiumsocialis/infra/pkg/common" "github.com/stretchr/testify/assert" ) func TestMain(m *testing.M) { if err := common.LoadEnv(); err != nil { log.Fatalln(err) } os.Exit(m.Run()) } func addTokenToRequest(r *http.Reque...
package main import ( "fmt" "os" s "strings" "unicode" ) func main() { var f = fmt.Printf f("to upper %s\n", s.ToUpper("Hello world")) f("to lower %s\n", s.ToLower("Hello world")) f("%s\n", s.Title("hello world")) f("%v\n", s.EqualFold("hello World", "HELLO WORld")) f("%v\n", s.EqualFold("hello World", "H...
package circular import ( "fmt" ) type CircularlyLinkedList struct { head *Node tail *Node length int } type Node struct { data interface{} next *Node previous *Node } func (cl *CircularlyLinkedList) InsertFront(nodeData interface{}) { fmt.Printf("inserting %v to front of list...\n", nodeData) ...
package main import ( "github.com/robfig/cron" "go-admin-starter/models" "log" "time" ) func main() { log.Println("Starting...") c := cron.New() var tag models.Tag c.AddFunc("* * * * * *", func() { log.Println("Run tag.CleanAll...") tag.CleanAll() }) var article models.Article c.AddFunc("* * * * * *"...
package snailframe //去除两端的字符串 func Strip(s_ string, chars_ string) string { s , chars := []rune(s_) , []rune(chars_) length := len(s) max := len(s) - 1 l, r := true, true //标记当左端或者右端找到正常字符后就停止继续寻找 start, end := 0, max tmpEnd := 0 charset := make(map[rune]bool) //创建字符集,也就是唯一的字符,方便后面判断是否存在 for i := 0; i < len(ch...
package main import "fmt" type RPCError struct { Code int64 Message string } func (e *RPCError) Error() string { return fmt.Sprintf("%s,code=%d", e.Message, e.Code) } func NewRpcError(code int64, msg string) error { return &RPCError{ Code: code, Message: msg, } } //类型检查 var _ error = (*RPCError)(nil...
package bungo import ( "errors" "fmt" ) type InventoryBucketLocation string func InventoryBucketLocations(key int) InventoryBucketLocation { out, _ := InventoryBucketLocationsE(key) return out } func InventoryBucketLocationsE(key int) (InventoryBucketLocation, error) { switch key { case 1: return "Inventory...
// Copyright 2020 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...
/* Copyright The containerd 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...
package testutil import ( config_v2 "github.com/cyberark/secretless-broker/pkg/secretless/config/v2" ) // GenerateConfigurations returns a Secretless Config along with a comprehensive // list of LiveConfigurations for use in tests. // TODO: consider parametrising ConnectPort generator func GenerateConfigurations() (...
// Copyright 2019 The ChromiumOS Authors // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. package video import ( "context" "time" "chromiumos/tast/local/bundles/cros/video/playback" "chromiumos/tast/local/chrome" "chromiumos/tast/local/chrome/ash" "chromiu...
package acl import ( "encoding/json" "errors" "fmt" "github.com/xuperchain/xupercore/kernel/permission/acl/base" actx "github.com/xuperchain/xupercore/kernel/permission/acl/context" "github.com/xuperchain/xupercore/kernel/permission/acl/utils" pb "github.com/xuperchain/xupercore/protos" ) // Manager manages a...
package twoDimensionalSliceUnwinder import ( "fmt" "math/rand" "strconv" ) func Unwind(args []string) []int { var unwind []int matrix := composeTwoDimensionalSlice(args) _, unwind = unwindTwoDimensionalSlice(matrix, unwind) return unwind } func unwindTwoDimensionalSlice(twoDimensional [][]int, unwind []int) ...
package emitter import ( "github.com/olebedev/emitter" ) var e = &emitter.Emitter{} type ( Event = emitter.Event Group = emitter.Group ) func New(capacity uint) *emitter.Emitter { e = emitter.New(capacity) return e } // Use registers middlewares for the pattern. func Use(pattern string, middlewares ...func(*E...
package commander import ( "errors" "fmt" "net/http" "strings" "github.com/gempir/gempbot/internal/config" "github.com/gempir/gempbot/internal/dto" "github.com/gempir/gempbot/internal/helixclient" "github.com/gempir/gempbot/internal/humanize" "github.com/gempir/gempbot/internal/log" "github.com/gempir/gempb...
package main import ( "bytes" "flag" "goout" "net" ) var addr string func handleTCP(tcp *net.TCPConn) { var ioBuffer bytes.Buffer var tcpWithTarget *net.TCPConn for { req, ok := goout.ParseHttpRequest(tcp, &ioBuffer) if !ok { tcp.Close() if tcpWithTarget != nil { tcpWithTarget.Close() } re...
package levenshteinsearch import "testing" func TestSearch(t *testing.T) { dict := CreateDictionary() dict.Put("banana") dict.Put("orange") dict.Put("monkey") result := dict.SearchAll("banana", 1) for word := range result { if word != "banana" { t.Error("Expected to find 'banana' with a distance of 1") ...
package indexer import ( "fmt" "sort" log "github.com/sirupsen/logrus" ) type MultipleDefinitionLoader []DefinitionLoader func defaultMultiLoader() *MultipleDefinitionLoader { return &MultipleDefinitionLoader{ defaultFsLoader(), embeddedLoader(), // escLoader{http.Dir("")}, } } func contains(s []string,...
package main import "errors" const ( EmptyMode = "" FilterMode = "filter" AllMode = "all" //action SubscribeAction = "subscribe" UnsubscribeAction = "unsubscribe" ) var ( SpecificHeight = Condition{ Key: "tx.height", Operation: "Equal", Value: 5, } SpecificHash = Condition{ Key: "t...
package main import ( "sort" "strings" "testing" ) func TestHierarchy(t *testing.T) { for k, v := range map[string]string{ "ab | ae | bc": "a [b [c], e]", "ab | bc | cd | ae | cx | xz": "a [b [c [d, x [z]]], e]"} { if r := hierarchy(k); r != v { t.Errorf("failed: hierarchy %s is %s, got %s...
// // Copyright (c) SAS Institute 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 agre...
// 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 gio contains functions and structs used for testing the gaming input overlay. package gio import ( "context" "os" "path/filepath" "strconv" "strings" "time"...
/* Copyright 2018 The Doctl Authors 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 applicable law or agreed to ...
package main import ( "net/http" "path/filepath" "strconv" "github.com/sirupsen/logrus" "gopkg.in/alecthomas/kingpin.v2" "net" "os" "strings" ) var ( app = kingpin.New("serve", "Serve is a simple utility to serve a directory via HTTP") port = app.Flag("port", "The port of the HTTP server.").Defa...
package Week_01 import "sort" // 先合并再排序 func merge(nums1 []int, m int, nums2 []int, n int) { nums1 = append(nums1[:m], nums2[:n]...) sort.Ints(nums1) } // 双指针,从后向前插入;最后的数最大 func merge2(nums1 []int, m int, nums2 []int, n int) { for m > 0 && n > 0 { //当nums1和nums2都有数据时,从最大下标处开始比较。大的放到nums1的最右方 if nums1[m-1] > num...
package fs import ( "github.com/fsnotify/fsnotify" "os" ) type Enriched struct { InstanceID string Event *fsnotify.Event FullPath string IsDirectory bool Directory string } func (e *Enriched) Read() chan *Frame { return readSlowly(e.InstanceID, e.FullPath) } func StartEnrich(instanceID, director...
package store import ( "testing" "github.com/skoltai/limithandling/domain" "github.com/stretchr/testify/assert" ) func TestAppCollection(t *testing.T) { c := newAppCollection() app := App{ OwnerID: 1, SubscriptionID: 2, App: domain.App{Name: "testapp"}, } app.ID = c.create(app) got, ...