text
stringlengths
11
4.05M
/* * Copyright (c) 2021. Ant Group. All rights reserved. * * SPDX-License-Identifier: Apache-2.0 */ package ttl import ( "sync" "testing" "time" "github.com/prometheus/client_golang/prometheus" dto "github.com/prometheus/client_model/go" "github.com/stretchr/testify/assert" ) func TestNewGaugeVecWithTTL(t...
package docker import ( "context" "log" "github.com/docker/docker/api/types" "github.com/docker/docker/client" ) func DeleteImage(imageName string) error { log.Println("Deleting local image:" + imageName) ctx := context.Background() cli, err := client.NewClientWithOpts(client.FromEnv) if err != nil { retur...
package main import ( "fmt" "time" ) var logColors = map[int]int{ DEBUG: 102, INFO: 28, WARN: 214, ERROR: 196, } const TIME_FORMAT = "2006/01/02 15:04:05" func colorize(c int, s string) (r string) { return fmt.Sprintf("\033[38;5;%dm%s\033[0m", c, s) } const ( DEBUG = iota INFO WARN ERROR ) ...
package dtos import "InkaTry/warehouse-storage-be/internal/pkg/stores" type GetProductDetailRequest struct { ProductId int64 } type GetProductDetailResponse struct { Product stores.Product `json:"product"` Inventories stores.Inventories `json:"inventories"` Histories stores.Histories `json:"histories...
// DRUNKWATER TEMPLATE(add description and prototypes) // Question Title and Description on leetcode.com // Function Declaration and Function Prototypes on leetcode.com //712. Minimum ASCII Delete Sum for Two Strings //Given two strings s1, s2, find the lowest ASCII sum of deleted characters to make two strings equal. ...
package md import ( "fmt" "strings" "testing" "github.com/sergi/go-diff/diffmatchpatch" ) func TestTrimpLeadingSpaces(t *testing.T) { var tests = []struct { Name string Text string Expect string }{ { Name: "trim normal text", Text: ` This is a normal paragraph this as well just with some s...
package virtual_security import "errors" var ( NilArgumentError = errors.New("nil argument error") NoDataError = errors.New("no data error") ExpiredDataError = errors.New("expired data error") NotEnoughOwnedQuantityError = errors.New("not enough owned quantity err...
package tabletmanager import ( "encoding/json" "errors" "fmt" "html/template" "testing" "time" "github.com/youtube/vitess/go/vt/health" "github.com/youtube/vitess/go/vt/mysqlctl" "github.com/youtube/vitess/go/vt/topo" "github.com/youtube/vitess/go/vt/zktopo" "golang.org/x/net/context" ) func TestHealthRec...
package main import ( "context" "log" "sync" mavlink2 "github.com/queue-b/go-mavlink2" "github.com/queue-b/go-mavlink2/ardupilotmega" "github.com/queue-b/go-mavlink2/common" "github.com/queue-b/go-mavlink2/util" ) func main() { rwc, err := util.NewUDPReadWriteCloser("0.0.0.0", 14551) if err != nil { log....
package pkg import ( "errors" "testing" "github.com/calvinmclean/automated-garden/garden-app/pkg/influxdb" "github.com/calvinmclean/automated-garden/garden-app/pkg/mqtt" "github.com/stretchr/testify/mock" ) func TestAggregateAction(t *testing.T) { garden := &Garden{ Name: "garden", } tests := []struct { ...
package main import ( "fmt" "strings" ) func main() { fmt.Println(wordCount("Hello world how many words am I wubba dubba dub dub dubdubdub?")) fmt.Println(wordCount("This is test sentence number two, wohoooo! ")) } func wordCount(s string) int { s = strings.TrimSpace(s) //removes whitespace before and after ...
package log import ( "github.com/goinbox/gomisc" "strconv" "time" ) func FormatAccessLog(traceId, point, msg []byte) []byte { return gomisc.AppendBytes( traceId, []byte("\t"), []byte("["), point, []byte("]"), []byte("\t"), msg, ) } type TraceLogArgs struct { TraceId []byte Point []byte StartTime...
package contact import ( "context" "errors" "time" "go.mongodb.org/mongo-driver/bson" "go.mongodb.org/mongo-driver/bson/primitive" "go.mongodb.org/mongo-driver/mongo" ) //CollectionName - This constant provides the collection name const ( CollectionName = "contacts" ) // ContactRepository ...
package types import ( "io" "time" ) type VolumeState string const ( VolumeStateNone = VolumeState("") VolumeStateCreated = VolumeState("created") VolumeStateDetached = VolumeState("detached") VolumeStateFaulted = VolumeState("faulted") VolumeStateHealthy = VolumeState("healthy") VolumeStateDegraded =...
package commands_test import ( "errors" "github.com/cloudfoundry/bosh-bootloader/commands" "github.com/cloudfoundry/bosh-bootloader/fakes" "github.com/cloudfoundry/bosh-bootloader/storage" . "github.com/onsi/ginkgo" . "github.com/onsi/gomega" ) var _ = Describe("CloudConfig", func() { var ( logger ...
package data import "time" import "io" import "encoding/json" type Product struct { ID int `json:"id"` Name string `json:"name"` Description string `json:"description"` Price float32 `json:"price"` SKU string `json:"sku"` CreatedOn string `json:"-"` UpdatedOn string `json:"-"` DeletedOn string `...
package models import "time" //Structure de données pour la table incident dans mySql type Incident struct { Id int `form:"-"` Cat string `form:"cat"` Title string `form:"title" valid:"MaxSize(100)"` Description string `orm:"null;type(text)" form:"description,text...
package psql import ( "testing" ) func TestVehicleDaoFindTypeById(t *testing.T) { dao := VehicleDao(db) _, err := dao.FindById(1) if err != nil { t.Error(err) } } func TestVehicleDaoFindBrandById(t *testing.T) { dao := VehicleDao(db) _, err := dao.FindBrandById(1) if err != nil { t.Error(err) } } func ...
package wordgen import ( "errors" "fmt" "math/rand" "strings" "time" ) type WordObject struct{ Word string `json:"word"` Meaning []MeaningObject `json:"meanings"` } type WordResponse struct { WordText string WordData []WordObject } type MeaningObject struct { PartOfSpeech string `json:"partOfSpeech"` Def...
package slovnik import ( "encoding/json" "fmt" "net/http" "net/url" "path" "time" ) // Client for accessing slovnik web server type Client struct { client *http.Client baseURL *url.URL } // NewClient creates new client for accessing slovnik web server func NewClient(baseURL string) (*Client, error) { clien...
/* Copyright 2021 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, sof...
package http import ( "encoding/json" "net/http" "strconv" "github.com/julienschmidt/httprouter" "github.com/smilga/analyzer/api" ) func (h *Handler) InspectWebsite(w http.ResponseWriter, r *http.Request, ps httprouter.Params) { idStr := ps.ByName("id") id, err := strconv.Atoi(idStr) if err != nil { h.resp...
package http import ( "io/ioutil" "log" Http "net/http" ) const ( CONTENT_TYPE = "Content-Type" JSON_CONTENT_TYPE = "application/json" ) type Response struct { GoResponse *Http.Response Request *Request SpiderName string ParserName string NodeName string Body string } func NewResponse(res...
/* Copyright 2021 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, so...
package leetcode import "testing" func TestCountPrimeSetBits(t *testing.T) { if countPrimeSetBits(1, 1) != 0 { t.Fatal() } if countPrimeSetBits(6, 10) != 4 { t.Fatal() } if countPrimeSetBits(10, 15) != 5 { t.Fatal() } if countPrimeSetBits(842, 888) != 23 { t.Fatal() } }
package web import ( "net/http" "sync" "github.com/gin-gonic/gin" "github.com/go-osin/session" ) var ( once sync.Once sessionKey = "gin-session" ) func SetupSessionStore(store session.Store) { session.Global.Close() session.Global = session.NewCookieManagerOptions(store, &session.CookieMngrOptions{ ...
package main import ( "archive/zip" "bytes" "compress/gzip" "encoding/base64" "encoding/gob" "fmt" "github.com/liuzl/cedar-go" "github.com/liuzl/store" "io/ioutil" "log" "os" "path/filepath" "strings" ) func main() { files, err := filepath.Glob("./data/lemmatization-*.zip") if err != nil { log.Fatal(...
package route import ( "myApis" "github.com/gin-gonic/gin" ) func InitRouter() *gin.Engine { router := gin.Default() router.GET("/", myApis.IndexApi) router.GET("/person/add", myApis.ShowHtmlPage) router.POST("/person/add", myApis.AddPersonApi) router.GET("/person/list", myApis.GetPersonsApi) router.GET...
/* Copyright The Helm 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, software di...
/* * Copyright 2018- The Pixie Authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or ag...
gitgitpackage main import "fmt" func main() { num1 := 10 // To find num1 is odd or even if num1%2 == 0 { fmt.Println("Given number is even") } else { fmt.Println("Given number is odd") } } // if we start writting else code block before the paranthesis of else block it gives us a syntax error. // So also st...
package env import ( "github.com/spf13/cobra" ) // EnvCmd is the sub-command to manage environment veriables var EnvCmd = &cobra.Command{ Use: "env [command]", Short: "Manage environment variables", }
package main import ( "time" "fmt" ) func main() { ch:=make(chan int,2) go func() { time.Sleep(99*1e9) x:=<-ch fmt.Println("receviced",x) }() fmt.Println("send 10") ch<-10 ch<-10 ch<-10 fmt.Println("sent 10") }
// +build linux package mem /* #include <unistd.h> #include <stdlib.h> #include <stdio.h> static long get_mem_available() { FILE* fp = fopen( "/proc/meminfo", "r" ); if ( fp != NULL ) { size_t bufsize = 1024 * sizeof(char); char* buf = (char*)malloc( bufsize ); long value = -1L; while ( getline( ...
package centipede import ( "context" "errors" ) var ( ErrExecutionCanceled error = errors.New("execution canceled") ) // RunWithContext accepts a context and a function that produces T // The function will be run, and so long as the context is not done, // its result will be returned. Otherwise an error will be r...
package main import ( "encoding/json" "net/http" "time" ) // Structure to hold all messages type Result struct { Timestamp int64 `json:"timestamp"` User string `json:"user"` Text string `json:"text"` } type Results []Result type ResultJson struct { Messages Results `json:"messages"` } //Structure t...
package utils import ( corev1 "k8s.io/api/core/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" ) //NewService create a new service func NewService(namespace, name, externalName string, annotations map[string]string) *corev1.Service { return &corev1.Service{ TypeMeta: metav1.TypeMeta{ Kind: "Service",...
package smpp34 import "fmt" type CMDStatus uint32 type CMDId uint32 type Header struct { Length uint32 Id CMDId Status CMDStatus Sequence uint32 } func NewPduHeader(l uint32, id CMDId, status CMDStatus, seq uint32) *Header { return &Header{l, id, status, seq} } func (s CMDId) Error() string { swit...
package gokira import ( "fmt" "github.com/sinoz/gokira/buffer" "hash/crc32" ) const polynomial = 0xEDB88320 // ReleaseManifest contains metadata about every archive in a storage. type ReleaseManifest struct { Versions []uint32 Checksums []uint32 } // ArchiveManifest contains metadata about an archive. type Ar...
package main import ( "fmt" "io" "os" "strings" //"path/filepath" ) func ReadFrom(reader io.Reader, num int) ([]byte, error) { p := make([]byte, 10) n, err := reader.Read(p) if n > 0 { return p[:n], nil } return p, err } func sampleReadFromString() { p, _ := ReadFrom(strings.NewReader("hello world~~~~")...
package remotes import ( "fmt" "github.com/davidji99/bitbucket-go/bitbucket" "github.com/deps-cloud/discovery/pkg/config" "github.com/sirupsen/logrus" ) // NewBitbucketRemote constructs a new remote implementation that speaks with Bitbucket // for repository related information. func NewBitbucketRemote(cfg *co...
package main import ( "fmt" "io/ioutil" "log" "os" "strconv" "strings" "syscall" "github.com/aQuaYi/GoKit" "github.com/PuerkitoBio/goquery" ) func buildProblemDir(s string) { var err error // 获取问题编号 problemNum := 0 if problemNum, err = strconv.Atoi(os.Args[1]); err != nil { log.Fatalln("无法获取问题编号:", e...
package gov import ( "bytes" "log" "sort" "testing" "github.com/irisnet/irishub/app/protocol" "github.com/irisnet/irishub/app/v1/asset" "github.com/stretchr/testify/require" abci "github.com/tendermint/tendermint/abci/types" "github.com/tendermint/tendermint/crypto" "fmt" "github.com/irisnet/irishub/app...
package primitives_test import ( "encoding/xml" "fmt" "github.com/plandem/xlsx/format" "github.com/plandem/xlsx/internal/ml/primitives" "github.com/stretchr/testify/require" "testing" ) func TestAlignV(t *testing.T) { type Entity struct { Attribute primitives.VAlignType `xml:"attribute,attr"` } list := ma...
package powerdns import ( "context" "fmt" "net/http" "testing" "github.com/jarcoal/httpmock" ) func registerServersMockResponder() { httpmock.RegisterResponder("GET", generateTestAPIURL()+"/servers", func(req *http.Request) (*http.Response, error) { if res := verifyAPIKey(req); res != nil { return res...
package main import ( "flag" "fmt" "io/ioutil" "log" "net/http" "os" "time" "github.com/nathan-osman/go-sunrise" "github.com/chrikoch/go-sunset-executor/config" ) func main() { var configFilename string flag.StringVar(&configFilename, "config", "", "location of config-file") flag.Parse() if len(confi...
package imageValidate import ( "fmt" "log" "os" "testing" cap "github.com/dchest/captcha" ) func Test_t222(t *testing.T) { } func Test_write_image_image_validate(t *testing.T) { for i := 0; i < 10; i++ { //bt := make([]byte, 5000) //buffer := bytes.NewBuffer(bt) d := cap.RandomDigits(cap.DefaultLen) ...
package business import "xinxin/service/model" func CreateVendor(item model.Vendor) error { } func DeleteVendor() { } func UpdateVendor() { } func GetVendor() { } func GetAllVendors() { } func SearchVendors() { }
package main import ( "context" "flag" "fmt" "io" "io/ioutil" "net/http" "strings" "time" "github.com/cybozu-go/log" "github.com/cybozu-go/well" ) const ( DataSize = 1 << 30 ) type CustomReader struct { count int } func (r *CustomReader) Read(p []byte) (int, error) { fmt.Println("CustomReader: read") ...
/* Back in 2015, Usain Bolt announced that he'll be retiring after the 2017 World Championship. Though his final season did not end gloriously, we all know that he is a true legend and we witnessed his peak during 2008 - 2013. Post retirement, Usain Bolt is still leading an adventurous life. He's exploring the unexpl...
package algutil import "testing" func AssertTrue(t *testing.T, exp bool) { if !exp { t.FailNow() } }
// Copyright 2020 Google LLC // // 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 // // https://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed to in ...
package ordered_map import ( "testing" ) type MyStruct struct { a float64 b bool } func testIntStruct() []*KVPair { var data []*KVPair = make([]*KVPair, 5) data[0] = &KVPair{0, &MyStruct{0.1, true}} data[1] = &KVPair{1, &MyStruct{1.1, true}} data[2] = &KVPair{2, &MyStruct{2.1, false}} data[3] = &KVPair{3, &M...
package main import ( "encoding/base64" "io" "log" "os" ) func main() { if len(os.Args) < 4 { log.Fatalln("参数不完整[input] [output] [output-type](1. file to base64,2. base64 to file)") } inputPath := os.Args[1] outputPath := os.Args[2] outputType := os.Args[3] var err error var inputFile *os.File inputFil...
package issummary import ( "time" "github.com/mpppk/gitany" ) type Milestone struct { ID int IID int Title string StartDate time.Time DueDate time.Time State string } func toMilestone(milestone gitany.Milestone) *Milestone { if milestone == nil { return nil } return &Milestone{ ...
package main import "fmt" func main() { fmt.Print("Enter text: ") var input string fmt.Scanln(&input) fmt.Println(input) }
/* Go Language Raspberry Pi Interface (c) Copyright David Thorpe 2016-2017 All Rights Reserved Documentation http://djthorpe.github.io/gopi/ For Licensing and Usage information, please see LICENSE.md */ package bme280 import ( "fmt" gopi "github.com/djthorpe/gopi" sensors "github.com/djthorpe/sensors" ) ...
/* * Copyright (c) 2022 VMware, Inc. or its affiliates * * 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 appl...
package event import ( "fmt" "reflect" "strings" "testing" ) type actionCall string func followCall(a1, a2 int) actionCall { return actionCall(fmt.Sprintf("Follow(%#v, %#v)", a1, a2)) } func unfollowCall(a1, a2 int) actionCall { return actionCall(fmt.Sprintf("Unfollow(%#v, %#v)", a1, a2)) } func sendMsgCall(...
package main import ( "bufio" "encoding/json" "flag" "fmt" "io/ioutil" "net/http" "os" "github.com/baldore/urlshort/urlshort" ) func main() { var ( ymlFilepath string jsonFilepath string ) flag.StringVar(&ymlFilepath, "y", "", "Yaml file to parse.") flag.StringVar(&jsonFilepath, "j", "", "Json file...
package main import ( "fmt" "github.com/PacktPublishing/Go-Programming-Cookbook-Second-Edition/chapter3/math" ) func main() { math.Examples() for i := 0; i < 10; i++ { fmt.Printf("%v ", math.Fib(i)) } fmt.Println() }
package keeper import ( sdk "github.com/cosmos/cosmos-sdk/types" sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" "github.com/irisnet/irismod/modules/nft/types" ) // HasDenomID returns whether the specified denomID exists func (k Keeper) HasDenomID(ctx sdk.Context, id string) bool { store := ctx.KVStore(k.s...
package controllers_test import ( "fmt" "net/url" "testing" "github.com/convox/rack/api/controllers" "github.com/convox/rack/api/models" "github.com/convox/rack/api/structs" "github.com/convox/rack/test" "github.com/stretchr/testify/assert" ) func init() { models.PauseNotifications = true } func TestServic...
package pattern type RegularExpr struct { matched bool // 是否匹配 pattern []rune // 正则表达式 plen int // 正则表表达式长度 } func (re *RegularExpr) Match(text []rune, tlen int) bool { re.matched = false re.rmatch(0, 0, text, tlen) return re.matched } func (re *RegularExpr) rmatch(ti, pj int, text []rune, tlen int) { ...
// Package modules contains definitions for all of the major modules of Sia, as // well as some helper functions for performing actions that are common to // multiple modules. package modules import ( "fmt" "math" "time" "gitlab.com/NebulousLabs/Sia/build" ) var ( // SafeMutexDelay is the recommended timeout fo...
package imap import ( "bufio" "crypto/tls" "fmt" "io" "strings" . "github.com/logrusorgru/aurora" ) // readStrings - read the specified number of lines // conn : reading stream // num : number of lines which should be reading // text : result of reading func readStrings(conn io.Reader, num int) (text []string)...
package paramedic import ( "io/ioutil" "net/http" "os" ) const instanceIDURL = "http://169.254.169.254/2016-09-02/meta-data/instance-id" func fetchInstanceID() (string, error) { if id := os.Getenv("AWS_SSM_INSTANCE_ID"); id != "" { return id, nil } resp, err := http.Get(instanceIDURL) if err != nil { ret...
// Copyright (c) 2020 VMware, Inc. All Rights Reserved. // SPDX-License-Identifier: Apache-2.0 package starlark import ( "context" "fmt" "github.com/pkg/errors" "github.com/vmware-tanzu/crash-diagnostics/k8s" "github.com/vmware-tanzu/crash-diagnostics/provider" "go.starlark.net/starlark" "go.starlark.net/star...
package update import ( "context" "encoding/json" "fmt" "net/http" "os" "runtime" "strings" "time" "github.com/blang/semver" "github.com/superfly/flyctl/terminal" "gopkg.in/yaml.v2" ) type Release struct { Version string `yaml:"version"` Prerelease bool `yaml:"prerelease"` DownloadURL stri...
// package main // import "fmt" // type Status int // const ( // InvalidLogin Status = iota + 1 // NotFound // ) // type StatusError struct { // Status Status // Message string // } // func (se StatusError) Error() string { // return se.Message // } // func login(uid, pwd string) error { // return nil // }...
package tcp var ( EVENT_CONNECT = TCPEvent{Name: "CONNECT", Desc: "客户端主动发起连接请求"} EVENT_CLOSE = TCPEvent{Name: "CLOSE", Desc: "主动关闭连接"} EVENT_LISTEN = TCPEvent{Name: "LISTEN", Desc: "开始监听请求"} EVENT_SYN = TCPEvent{Name: "SYN", Desc: "收到连接请求"} EVENT_ACK = TCPEvent{Name: "ACK", Desc: "收到应答"} EVENT_RST ...
package goSolution import "strings" type MapSum struct { values map[string]int } /** Initialize your data structure here. */ func ConstructorOfMapSum() MapSum { return MapSum{values: make(map[string]int)} } func (this *MapSum) Insert(key string, val int) { this.values[key] = val } func (this *MapSum) Sum(pr...
package blocks import ( bolt "go.etcd.io/bbolt" ) type BChainIterator struct { currentHash []byte db BCDB } func (i *BChainIterator) Next() *Block { var block *Block i.db.ViewChain(func(tx *bolt.Tx) error { b := tx.Bucket([]byte(bucketBlocks)) encodedBlock := b.Get(i.currentHash) block = Deseria...
package k8s_test import ( "context" "testing" "github.com/acim/lazarette/pkg/k8s" v1 "k8s.io/api/core/v1" storagev1 "k8s.io/api/storage/v1" "k8s.io/apimachinery/pkg/api/resource" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/client-go/kubernetes/fake" ) func TestStorageClasses(t *testing.T) { c, err...
package main import ( "aws-golang-terraform-colonies/functions/libs" "bytes" "context" "encoding/json" "fmt" "log" "net/http" "regexp" "github.com/aws/aws-lambda-go/lambda" ) // Colony metadata format: XXX-XXXXXXXXXX var colonyRegExp = regexp.MustCompile(`[0-9A-Z]{6}\-[0-9A-Z]{13}`) var planetRegExp = regex...
package tick import ( "github.com/astaxie/beego" "github.com/astaxie/beego/orm" "time" "tokensky_bg_admin/conf" "tokensky_bg_admin/models" "tokensky_bg_admin/utils" ) var ( //警告时间间隔 borrow_warn_time int64 = 86400 //警告系数 borrow_warn_ratio float64 = 0.1 ) func init() { if con,err := beego.AppConfig.Int64("...
package storage import "github.com/AlexBaykov/go-rest/internal/app/model" //UserRepo is an interface representing some way of storing users type UserRepo interface { Create(*model.User) error Find(id int) (*model.User, error) FindByEmail(email string) (*model.User, error) }
/* commonatlases is a package full of `atlas.Entry` definions for common types in the standard library. A frequently useful example is the standard library `time.Time` type, which is frequently serialized in some custom way: as a unix int for example, or perhaps an RFC3339 string; there are many popular choices. ...
package main import ( "bytes" "encoding/json" "fmt" "io/ioutil" "net/http" ) type GetMeT struct { Ok bool `json:"ok"` Result struct { ID int `json:"id"` IsBot bool `json:"is_bot"` FirstName string `json:"first_name"` Username ...
package main import ( "bufio" "crypto/md5" "fmt" "github.com/garyburd/redigo/redis" "math/rand" "os" "strconv" "strings" "testing" "time" ) func getredis() redis.Conn { c, err := redis.Dial("tcp", "localhost:6379") if err != nil { panic("") } /*if _, err := c.Do("AUTH", "sedsed"); err != nil { c.Clo...
package sonarqube import ( "fmt" "github.com/hashicorp/terraform-plugin-sdk/helper/schema" sonargo "github.com/labd/sonargo/sonar" ) func resourceProject() *schema.Resource { return &schema.Resource{ Create: resourceProjectCreate, Read: resourceProjectRead, Update: resourceProjectUpdate, Delete: resour...
package main import ( "net/http" ) const ( GREETING = 0 KV_INSERT = 1 KV_DELETE = 2 KV_GET = 3 KV_UPDATE = 4 KVMAN_COUNTKEY = 5 KVMAN_DUMP = 6 KVMAN_SHUTDOWN = 7 ) type Msg struct { header int key string val string w *http.ReponseWriter } func newMsg(hd int, ...
package config import ( "os" "encoding/json" ) type Env struct { RingcentralEnv string `json:"ringcentralEnv"` RedirectHost string `json:"redirectHost"` ClientId string `json:"clientId"` ClientSecret string `json:"clientSecret"` LogFile string `json:"logFile"` AccessToken string `json:"acces...
package service import ( "encoding/json" "project/app/admin/models" "project/app/admin/models/bo" "project/app/admin/models/cache" "project/app/admin/models/dto" "project/utils" "strconv" ) type Menu struct { } func (m *Menu) InsertMenu(p *dto.InsertMenuDto, flex *dto.InsertFlexMenuDto, userID int) error { i...
package solutions import "testing" func TestRemoveNthFromEnd(t *testing.T) { t.Run("Test 12345, n=2", func(t *testing.T) { head := &ListNode{ Val: 1, Next: &ListNode{ Val: 2, Next: &ListNode{ Val: 3, Next: &ListNode{ Val: 4, Next: &ListNode{ Val: 5, }, }, }...
package core import ( "fmt" "reflect" "strings" ) const ( TWOSIDES = iota + 1 ONLYTODB ONLYFROMDB ) // database column type Column struct { Name string FieldName string SQLType SQLType Length int Length2 int Nullable bool Default string Indexes ...
/* * Copyright (c) 2020, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. * * WSO2 Inc. licenses this file to you 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/li...
// +build !windows package main import ( "encoding/json" "strings" "github.com/docker/docker/pkg/integration/checker" "github.com/docker/docker/pkg/ulimit" "github.com/go-check/check" ) func (s *DockerSuite) TestBuildResourceConstraintsAreUsed(c *check.C) { testRequires(c, cpuCfsQuota) name := "testbuildreso...
package controller import ( "chirpper_backend/utils" "encoding/json" "errors" "net/http" "cloud.google.com/go/firestore" ) //Setting is an endpoints for setting func (x *EndPoints) Setting(client *firestore.Client) http.HandlerFunc { return func(res http.ResponseWriter, req *http.Request) { valid := verify...
package resolver // PackageResolver finds urls and registries from a package file type PackageResolver interface { ReadPackagesFromFile(string) error Registries() []string NumPackages() int }
package ospf type OspfRpc struct { Information struct { Overview struct { Areas []OspfAreaRpc `xml:"ospf-area-overview"` } `xml:"ospf-overview"` } `xml:"ospf-overview-information"` } type Ospf3Rpc struct { Information struct { Overview struct { Areas []OspfAreaRpc `xml:"ospf-area-overview"` } `xml:"o...
/* * Copyright (c) 2020 - present Kurtosis Technologies LLC. * All Rights Reserved. */ package datastore import ( "fmt" "github.com/kurtosis-tech/kurtosis-go/lib/services" "github.com/palantir/stacktrace" "github.com/sirupsen/logrus" "io/ioutil" "net/http" "strings" ) const ( healthcheckUrlSlug = "health"...
package service import ( "strconv" "tesou.io/platform/brush-parent/brush-core/common/utils" ) /** 获取配置信息 */ type ConfService struct { } func (this *ConfService) GetSpiderCycleTime() int64 { var result int64 temp_val := utils.GetVal("spider", "cycle_time") if len(temp_val) > 0 { result, _ = strconv.ParseInt(t...
package ackhandler import ( "time" "gx/ipfs/QmU44KWVkSHno7sNDTeUcL4FBgxgoidkFuTUyTXWJPXXFJ/quic-go/internal/congestion" "gx/ipfs/QmU44KWVkSHno7sNDTeUcL4FBgxgoidkFuTUyTXWJPXXFJ/quic-go/internal/protocol" "gx/ipfs/QmU44KWVkSHno7sNDTeUcL4FBgxgoidkFuTUyTXWJPXXFJ/quic-go/internal/utils" "gx/ipfs/QmU44KWVkSHno7sNDTeUc...
// This file was generated for SObject DocumentAttachmentMap, API Version v43.0 at 2018-07-30 03:47:46.868005293 -0400 EDT m=+33.211857928 package sobjects import ( "fmt" "strings" ) type DocumentAttachmentMap struct { BaseSObject CreatedById string `force:",omitempty"` CreatedDate string `force:",omi...
// Copyright 2021 the u-root Authors. All rights reserved // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. // Package main takes the connect function of iwl.go and reduces it // to as few lines as possible to make spotting errors in wifi bugs easier. package main ...
package problem0392 import "testing" func TestIsSubsequence(t *testing.T) { t.Log(isSubsequence("axc", "ahngdbc") == false) t.Log(isSubsequence("aaa", "ahngdbc") == false) t.Log(isSubsequence("", "ahngdbc") == true) }
// Package templates/projection includes the projection methods used by gen, // such as GroupBy and Average. package projection import ( "github.com/clipperhouse/gen/templates" ) func init() { templates.Register("projection", projectionTemplates) } var projectionTemplates = templates.TemplateSet{ "Aggregate": &t...
package main import ( "context" "fmt" micro "github.com/micro/go-micro" proto "github.com/pawinnek/GoTestPublic" //proto "github.com/micro/examples/service/proto" ) type Greeter struct{} func (g *Greeter) Hello(ctx context.Context, req *proto.Request, rsp *proto.Response) error { rsp.Greeting = ...
func twoSum(nums []int, target int) []int { numHash := make(map[int]int) for i := 0; i < len(nums); i++ { complement := target - nums[i] if val, ok := numHash[complement]; ok { indices := []int{val, i} return indices } else { numHash[nums[i]] = i } } return []int{0, 0} }