text
stringlengths
11
4.05M
/* * Copyright 2017 StreamSets 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...
package scheduler import ( "encoding/json" "time" ) const SignalFormat = "20060102150405" type IProvider interface { Init() error GetName() string CheckInterval(time.Time) bool Run(time.Time) String() string } type Provider struct { Name string `toml:"name" json:"name"` TimeRule string `toml:"int...
package main import ( "go_interview/advanced_go_programming/chapter04/rpc_hello_02/rpc_hello" "log" "net" "net/rpc" ) func main() { err := rpc_hello.RegisterHelloService(new(rpc_hello.HelloService)) if err != nil { log.Fatal("register HelloService err:", err) } listener, err := net.Listen("tcp", ":1234") ...
package authentication import ( "glsamaker/pkg/database/connection" "glsamaker/pkg/logger" "glsamaker/pkg/models" "net/http" ) func Logout(w http.ResponseWriter, r *http.Request) { sessionID, err := r.Cookie("session") if err != nil || sessionID == nil { // TODO Error } session := &models.Session{Id: ses...
package myhttp import "flag" // ParseCLI parse command line args func ParseCLI() (int, []string) { limit := flag.Int("limit", 10, "int that indicates the limit of concurrent request possible") flag.Parse() urls := flag.Args() return *limit, urls }
package routers import ( "github.com/francescoforesti/appointments/be/model" "github.com/gin-gonic/gin" "log" "net/http" "sort" "strconv" ) import service "github.com/francescoforesti/appointments/be/service" type AppointmentAPI struct { AppointmentService service.AppointmentService } func CreateAPI(p service...
package gcp // Metadata contains GCP metadata (e.g. for uninstalling the cluster). type Metadata struct { Region string `json:"region"` ProjectID string `json:"projectID"` NetworkProjectID string `json:"networkProjectID,omitempty"` PrivateZoneDomain string `json:"privateZoneDomain,omitempty"` }...
package atomix import "testing" func TestFloat64(t *testing.T) { a := NewFloat64(10.5) mustEqual(t, a.String(), "10.5") mustEqual(t, a.Load(), float64(10.5)) mustEqual(t, a.Add(0.3), float64(10.8)) mustEqual(t, a.Sub(0.5), float64(10.3)) mustEqual(t, a.CAS(10.3, 0.5), true) mustEqual(t, a.Load(), float64(0....
/* There are n students in a school class, the rating of the i-th student on Codehorses is ai. You have to form a team consisting of k students (1≤k≤n) such that the ratings of all team members are distinct. If it is impossible to form a suitable team, print "NO" (without quotes). Otherwise print "YES", and then prin...
// Copyright 2022 PingCAP, Inc. Licensed under Apache-2.0. package glue import ( "context" "fmt" "io" "os" "time" "github.com/fatih/color" "github.com/pingcap/tidb/br/pkg/utils" "github.com/vbauerster/mpb/v7" "github.com/vbauerster/mpb/v7/decor" "golang.org/x/term" ) const OnlyOneTask int = -1 var spinne...
package futures import ( "testing" "github.com/stretchr/testify/suite" ) type openInterestServiceTestSuite struct { baseTestSuite } func TestGetOpenInterestService(t *testing.T) { suite.Run(t, new(openInterestServiceTestSuite)) } func (s *openInterestServiceTestSuite) TestGetOpenInterest() { data := []byte(`{...
package main import ( "github.com/gin-gonic/gin" "net/http" "fmt" "strconv" ) func main() { router := gin.Default() router.Static("/static", "./assets") router.GET("/api/image", func(context *gin.Context) { resp, err := http.Get("https://ss1.baidu.com/6ONXsjip0QIZ8tyhnq/it/u=3811938961,201576138&fm=173&app...
// Package ibmcloud extracts IBM Cloud metadata from install configurations. package ibmcloud import ( "context" icibmcloud "github.com/openshift/installer/pkg/asset/installconfig/ibmcloud" "github.com/openshift/installer/pkg/types" "github.com/openshift/installer/pkg/types/ibmcloud" ) // Metadata converts an in...
package atomix import ( "testing" ) func TestInt32(t *testing.T) { a := NewInt32(10) mustEqual(t, a.String(), "10") mustEqual(t, a.Load(), int32(10)) mustEqual(t, a.Add(5), int32(15)) mustEqual(t, a.Sub(3), int32(12)) mustEqual(t, a.Inc(), int32(13)) mustEqual(t, a.Dec(), int32(12)) mustEqual(t, a.CAS(12...
// GENERATED BY THE COMMAND ABOVE; DO NOT EDIT // This file was generated by swaggo/swag at // 2019-07-23 16:13:30.86042 -0700 PDT m=+0.239072254 package docs import ( "bytes" "encoding/json" "github.com/alecthomas/template" "github.com/swaggo/swag" ) var doc = `{ "schemes": {{ marshal .Schemes }}, "swa...
// Copyright (c) 2017, 0qdk4o. All rights reserved. // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. // +build ignore package main import ( "fmt" "os" "github.com/abegin/domain" ) func main() { r := domain.NewRegistrar("Us2Demo") if r == nil { fmt.Print...
package main import ( "fmt" "net/http" ) // 处理请求方法 func hander(write http.ResponseWriter, request *http.Request) { fmt.Fprintf(write, "hello world, %s!", request.URL.Path[0:]) } func main() { // 设置路由处理方法 http.HandleFunc("/", hander) // 设置监听端口 http.ListenAndServe(":8000", nil) }
package main import ( "log" "os" "regexp" "net/http" "crypto/tls" "github.com/hashicorp/terraform/helper/schema" ) // ApiProvider returns a terraform.ResourceProvider. func ApiProvider() *schema.Provider { apiDiscoveryUrl := getApiDiscoveryUrl() d := &ProviderFactory{ Name: getProviderName(), ...
package main /* #include <stdlib.h> #include "type.h" const size_t FILE_SIZE = sizeof(struct File); const size_t IDENT_SIZE = sizeof(struct Ident); const size_t COBJECT_SIZE = sizeof(struct CObject); const size_t GENDECL_SIZE = sizeof(struct GenDecl); const size_t FUNCDECL_SIZE = sizeof(struct FuncDecl); const size_t ...
package setting import ( "os" "time" "github.com/unknwon/com" ) var ( RunMode string HTTPPort int ReadTimeout time.Duration WriteTimeout time.Duration PageSize int JwtSecret string ) func init() { LoadBase() LoadServer() LoadApp() } func LoadBase() { RunMode = os.Getenv("RUN_MODE") } func Loa...
package redux // This file exists to setup the binary for tests and to cleanup. // Please don't create any test files that sort lower than z // and don't add more tests to this file. import ( "io/ioutil" "os" "os/exec" "path/filepath" "strings" "testing" ) var binDir string // build the binary, just for testi...
package auth import ( "golang.org/x/net/context" "golang_practice/core/auth" "net" "fmt" "google.golang.org/grpc" "github.com/grpc-ecosystem/grpc-gateway/runtime" "flag" "net/http" "golang_practice/util/protoutil" ) type AuthServer struct { db *DBModel authModel AuthModel } func NewAuthServer() (s ...
package eap import ( "encoding/hex" "testing" ) func TestDecode(t *testing.T) { data, _ := hex.DecodeString("029900980d800000008e160301008901000085030155ce6793b60f8a0539772c75fcffa8e9de21ce25ecb525d5953581266f8229d000004a00ffc024c023c00ac009c008c028c027c014c013c012c026c025c005c004c003c02ac029c00fc00ec00d006b006700...
package kafka100 //协议版本定义 const ( KAFKA_PROTO_VERSION_001 = 0x01000001 //v1.0.0版本协议 ) //卡夫卡数据类型 const ( KAFKA_DT_DEVICE_ONLINE = 1 //设备状态上线 KAFKA_DT_DEVICE_OFFLINE = 2 //设备状态下线 KAFKA_DT_ALARM = 3 //报警 KAFKA_DT_DISALARM = 4 //消警 KAFKA_DT_LIFT_MV_STATUS ...
// web cliant package main import ( "flag" "fmt" "io/ioutil" "log" "net/http" "time" ) var addr = flag.String("addr", "http://localhost:6060", "") //var scheme = flag.String("scheme", "http:", "") //var host = flag.String("host", "//localhost:6060", "") func init(){ flag.Parse() } func main() { fmt.Printl...
package main import ( "fmt" "image/color" "os" "github.com/soh335/truecolor" ) func main() { for h := 0; h < 360; h++ { tc := truecolor.New() tc.Add(truecolor.NewBackgrond(hsv(float64(h) / float64(360)))) tc.Fprint(os.Stdout, " ") if h%60 == 59 { fmt.Print("\n") } } } // https://ja.wikipedia.org...
package main import ( "fmt" "math/rand" ) /** * author: will fan * created: 2019/5/3 7:17 * description: */ const ( win = 100 gamesPerSeries = 10 ) type score struct { player, opponent, thisTurn int } type action func(current score) (result score, turnIsOver bool) func roll(s score) (score, bool) { outc...
package gcp import ( "context" "fmt" "sort" "strings" "time" "github.com/AlecAivazis/survey/v2" "github.com/AlecAivazis/survey/v2/core" "github.com/pkg/errors" "github.com/openshift/installer/pkg/types/gcp" gcpValidation "github.com/openshift/installer/pkg/types/gcp/validation" ) // Platform collects GCP-...
package v1 import ( "context" "github.com/mee6aas/zeep/pkg/activity" "google.golang.org/grpc/codes" "google.golang.org/grpc/status" ) // ListRequested is invoked when the invoker requests to list the activities. func (h Handle) ListRequested( _ context.Context, _ string, ) (out []activity.Activity, e error) { ...
package main import "fmt" func main() { for i := 0; i < 10; i++ { if i == 3 { fmt.Println("continue") continue } if i > 5 { fmt.Println("break") break } fmt.Println(i) } sum := 1 for sum < 10 { sum += sum fmt.Println(sum) } fmt.Println(sum, "sum") arr := []string{"python", "go", "rea...
package demo // SayHi :: Return result func SayHi() string { return "Say hi from demo" }
package cluster import ( "bufio" "bytes" "fmt" "io" "os" "os/exec" "path" "sort" "strings" "text/template" "time" "github.com/iotaledger/goshimmer/client/wallet/packages/seed" "github.com/iotaledger/goshimmer/dapps/valuetransfers/packages/address" "github.com/iotaledger/goshimmer/dapps/valuetransfers/pa...
package main import "fmt" //接口的"实例化" 接口不能创建实例! 但可以指向实现了该接口方法的对象, 即将man赋值给接口 type MyInterface interface { //接口内部不得有变量! Say() Eat() } type Man struct { Name string } //Man结构体实现了 接口方法 func (m Man) Say() { fmt.Println("hello world") } func (m Man) Eat() { fmt.Println("chichichi") } func main() { var man Man //...
package horizon // EffectsPageResponse contains page of effects returned by Horizon type EffectsPageResponse struct { Embedded struct { Records []EffectResponse } `json:"_embedded"` } // EffectResponse contains effect data returned by Horizon type EffectResponse struct { Type string `json:"type"` Amount strin...
package charneoapo import "testing" func TestSimple(t *testing.T) { c := NewNeoapo() err := c.Do("characters", "16222") if err != nil { t.Fatal(err) } if c.Name() != "本田未央" { t.Errorf("Unexpected Neoapo.Name: %s", c.Name()) } if c.Kana() != "ほんだみお" { t.Errorf("Unexpected Neoapo.Kana: %s", c.Kana()) ...
package main import ( "fmt" "log" ) func PanicOnError(err error) { if err != nil { panic(err) } } func LogOnError(err error) { if err != nil { fmt.Println(err.Error()) } } func handleError(err error, event string) { dcounts.Incr(event + " total") if err == nil { dcounts.Incr(event + " success") retu...
package pathrename import "log" func isHidden(path string) bool { log.Fatal("Not implemented yet") return false } func prenamingHidden(name string) string { return name } func postnamingHidden(name string) string { return name }
package calculate import "time" import "encoding/json" type Response struct { Product int } func Calculate(a, b int) string { valueA := make(chan int, 0) valueB := make(chan int, 0) go func() { time.Sleep(time.Second * 5) valueA <- calculateFactorial(a) }() go func() { time.Sleep(time.Second * 5) va...
package format import ( "github.com/plandem/xlsx/internal/ml/primitives" ) //List of all possible values for ConditionValueType const ( _ primitives.ConditionValueType = iota ConditionValueTypeNum ConditionValueTypePercent ConditionValueTypeMax ConditionValueTypeMin ConditionValueTypeFormula ConditionValueTyp...
package metadata import ( "fmt" "testing" "github.com/stretchr/testify/require" "github.com/root-gg/plik/server/common" ) func TestBackend_CreateToken(t *testing.T) { b := newTestMetadataBackend() defer shutdownTestMetadataBackend(b) user := common.NewUser(common.ProviderLocal, "user") createUser(t, b, use...
package api import ( "html/template" "io/ioutil" "log" "os" ) const basePath = "template" func populateTemplates() map[string]*template.Template { result := make(map[string]*template.Template) funcMap := template.FuncMap{ // The name "inc" is what the function will be called in the template text. "even": ...
package command type CommandFile struct { Commands []Command `yaml:"commands" json:"commands"` } type Command struct { Name string `yaml:"name" json:"name"` Description string `yaml:"description" json:"description"` Options []CommandOption `yaml:"options,omitempty" json:"options,omite...
/* * Licensed to the OpenSkywalking under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file ...
package main import ( "sync" "github.com/mattermost/mattermost-server/v6/plugin" "github.com/mattermost/mattermost-server/v6/model" ) // Plugin implements the interface expected by the Mattermost server to communicate between the server and plugin processes. type Plugin struct { plugin.MattermostPlugin // conf...
package main import "fmt" func main() { x := 10 if x > 5 { a, x := 20, 5 fmt.Println(a, x) } fmt.Println(x) }
package domain import ( "time" "github.com/angryronald/guestlist/internal/guest/infrastructure/repository" "github.com/angryronald/guestlist/internal/guest/public" "github.com/angryronald/guestlist/lib/encoding" "github.com/google/uuid" ) type Guest struct { ID uuid.UUID `json:"id"` Nam...
package main //整型的使用 import ( "fmt" "unsafe" ) func main() { var i int = 1 fmt.Println("i=", i) //var j int8 = -129 //var j int8 = -128 //var j int8 = 128 var j int8 = 127 fmt.Println("j=", j) //var k uint8 = 256 //var k uint8 = -1 var k uint8 = 0 fmt.Println("k=", k) var a int = 8900 fmt.Println("a=...
package actions import ( "errors" "strings" "github.com/barrydev/api-3h-shop/src/common/connect" "github.com/barrydev/api-3h-shop/src/factories" "github.com/barrydev/api-3h-shop/src/model" ) func UpdateProduct(productId int64, body *model.BodyProduct) (*model.Product, error) { queryString := "" var args []int...
package attributes import ( "net/http" httplib "gitlab.com/semestr-6/projekt-grupowy/backend/go-libs/http-lib" ) func GetRoutes() (routes httplib.Routes) { routes = httplib.Routes{ httplib.Route{ HttpMethod: http.MethodPost, Route: "/add-factor-attribute", HandlerFunc: addFactorAttribute, }, ...
package util_test import ( "github.com/APTrust/exchange/constants" "github.com/APTrust/exchange/util" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" "testing" ) func TestOwnerOf(t *testing.T) { if util.OwnerOf("aptrust.receiving.unc.edu") != "unc.edu" { t.Error("OwnerOf misidentifi...
// Copyright (C) 2018 Storj Labs, Inc. // See LICENSE for copying information. package routes import ( "encoding/json" "fmt" "net/http" "strings" "github.com/julienschmidt/httprouter" "go.uber.org/zap" "storj.io/storj/storage/boltdb" ) // NetStateRoutes maintains access to a boltdb client and zap logger typ...
package pkg type Version string type Person struct { Name string Email string Web string //URL? } type People []Person type Bugs struct { Name string Web string } type License struct { Type string Web string //url? } type Repository struct { Type string URL string //URL? } type Repositories []Repositor...
package binary_search func BinarySearch(arr []int, num int) bool
package logging import ( "math/rand" "testing" "time" "github.com/apache/arrow/go/v8/arrow" "github.com/apache/arrow/go/v8/arrow/array" "github.com/apache/arrow/go/v8/arrow/memory" "github.com/stretchr/testify/assert" "google.golang.org/protobuf/types/known/timestamppb" "github.com/feast-dev/feast/go/protos...
// SPDX-License-Identifier: Apache-2.0 // Copyright (c) 2020 Intel Corporation package daemon import ( "context" "fmt" "os" "sort" "path/filepath" "github.com/go-logr/logr" . "github.com/onsi/ginkgo" . "github.com/onsi/gomega" sriovv1 "github.com/open-ness/openshift-operator/sriov-fec/api/v1" corev1 "k8s....
package service import ( "context" "encoding/json" "flag" "fmt" "log" "os" "sample/gen-go/Sample" ) func Usage() { fmt.Fprint(os.Stderr, "Usage of ", os.Args[0], ":\n") flag.PrintDefaults() fmt.Fprint(os.Stderr, "\n") } //定义服务 type Greeter struct { } func NewGreeterHandle() *Greeter ...
package postgres import ( "context" "go.uber.org/zap" "gorm.io/gorm" "github.com/silverspase/todo/internal/modules/todo" "github.com/silverspase/todo/internal/modules/todo/model" ) const pageSize = 2 type postgres struct { conn *gorm.DB logger *zap.Logger } func NewRepository(conn *gorm.DB, logger *zap.L...
package domain import "github.com/tokopedia/tdk/go/log" // Message type type Message struct { ID int `json:"id"` Timestamp int64 `json:"timestamp"` Sender string `json:"sender"` MessageType string `json:"message_type"` Receiver string `json:"receiver"` Text string `json:"text"` } ...
package DMST // MessageArgs is invoked by leader to replicate log entries; also used as // heartbeat. // Term - leader’s term // leaderId - so follower can redirect clients type MessageArgs struct { FromID int Type string NodeLevel int NodeState string NodeFragment int EdgeWeight int...
package smtcp import ( "testing" "github.com/stretchr/testify/assert" ) func TestNewParams(t *testing.T) { p := NewParams() assert.NotNil(t, p) data := p.Get("chave") assert.Equal(t, "", data) p.Set("chave", "raw data") data = p.Get("chave") assert.Equal(t, "raw data", data) }
package main import "fmt" func test(n1 int) { n1 = n1 + 1 fmt.Println("test() n1 = ", n1) } func getSum(n1 int, n2 int) int { sum := n1 + n2 fmt.Println("getSum() sum = ", sum) return sum } func main() { n1 := 10 test(n1) fmt.Println("main() n1 = ", n1) sum := getSum(10, 20) fmt.Println("main() sum = ", ...
package server func (s *server) routes() { s.Router.HandleFunc("/", s.handleIndex()) s.Router.HandleFunc("/dist/", s.handleStaticAssets()) s.Router.HandleFunc("/api/search", s.handleSearch()) s.Router.HandleFunc("/api/album/", s.handleGetAlbumInfo()) }
package queue import "context" // ReaderFactory is an interface for any component that can furnish an // implementation of the Reader interface capable of reading messages from a // specific queue (or similar channel) of some (presumably asynchronous) // messaging system. type ReaderFactory interface { // NewReader ...
// Copyright Amazon.com Inc. or its affiliates. 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. A copy of the // License is located at // // http://aws.amazon.com/apache2.0/ // // or in the "license" file ...
package qpx import "encoding/json" import "fmt" func ParseResponse(res []byte) Response { var r Response err := json.Unmarshal(res, &r) if err != nil { panic(err) } return r } func (r Response) PrettyPrint() string { output := "Flight Plans:\n" for i, e := range r.Trips.TripOption { output += fmt.Sprintf(...
package main import ( "encoding/csv" "flag" "fmt" "io" "log" "os" "github.com/tealeg/xlsx" ) // https://gist.github.com/jmoiron/e9f72720cef51862b967 // https://play.golang.org/p/FqKzq_1ICs type Options struct { OutputFile string SheetIndex int SheetName string HeaderLine int StartLine int EndLine i...
/* Seeing as there have been an awful lot of normal Fibonacci challenges, I decided that it might be interesting to calculate the Reciprocal Fibonacci constant - namely, the sum of the reciprocals of the Fibonacci sequence. The challenge is to calculate the Reciprocal Fibonacci constant with the number of Fibonacci s...
package database_Celica import ( "Celica/checkError_Celica" "strconv" ) func (this *CelicaSql) RecordGet(nowGet *RecordOpe) int { if this == nil || this.db == nil { return 1 } if nowGet.tableName == "" || nowGet.Field == "" || nowGet.keyName == "" { return 2 } commad := "select " + nowGet.Field + " from "...
package main import ( "sort" "github.com/urfave/cli" ) var ( imageSubCommands = []cli.Command{ historyCommand, imageExistsCommand, inspectCommand, lsImagesCommand, pruneImagesCommand, pullCommand, rmImageCommand, tagCommand, } imageDescription = "Manage images" imageCommand = cli.Command{ ...
//nolint package types import ( sdk "github.com/irisnet/irishub/types" ) // Rand errors reserve 100 ~ 199. const ( DefaultCodespace sdk.CodespaceType = "htlc" CodeInvalidAddress sdk.CodeType = 100 CodeInvalidAmount sdk.CodeType = 101 CodeInvalidHashLock sdk.CodeType = 102 CodeHashLockAlrea...
package types import ( "testing" "github.com/stretchr/testify/require" sdk "github.com/irisnet/irishub/types" ) // test ValidateBasic for MsgSwapOrder func TestMsgSwapOrder(t *testing.T) { tests := []struct { name string msg MsgSwapOrder expectPass bool }{ {"no input coin", NewMsgSwapOrder...
package models type ErrorResult struct { Msg string Code int } type Result struct { Msg string Code int JumpUrl string } type AwadResult struct { Msg string Awd int } type Data struct { Id string `json:"id"` } type UploadResult struct { //{"status":true,"data":{"id":"431cbf5cfe3e45c4abcea878723d7b89"},"me...
package coupons import ( "context" "database/sql" "strconv" "time" "cinemo.com/shoping-cart/internal/errorcode" "cinemo.com/shoping-cart/internal/orm" "github.com/volatiletech/sqlboiler/v4/boil" "github.com/volatiletech/sqlboiler/v4/queries/qm" ) const orangeDiscountName = "30% coupon discount on oranges" co...
package request import ( "bytes" "fmt" ) // Request is a representation of request - sequence of two english letters type Request [2]byte // String returns the r converted to string func (r Request) String() string { return string(r.Bytes()) } // Bytes returns the r converted to []byte func (r Request) Bytes() [...
package quenet import "sync" type ItemQueue struct { items []*Request lock *sync.RWMutex } func QueueNew() *ItemQueue { return &ItemQueue{ items: make([]*Request, 0), lock: &sync.RWMutex{}, } } func (s *ItemQueue) New() *ItemQueue { s.items = make([]*Request, 0) s.lock = &sync.RWMutex{} return s } // ...
package cmd import ( "log" "os" "os/exec" "path" "syscall" "github.com/sam-blackfly/dabba/internal/paths" "github.com/spf13/cobra" ) var RunCmd = &cobra.Command{ Use: "run", Short: "Execute command inside a container", Args: cobra.MinimumNArgs(1), Run: func(cmd *cobra.Command, args []string) { run(ar...
package upstream import ( "github.com/hashicorp/go-plugin" "github.com/jonmorehouse/gatekeeper/gatekeeper" "github.com/jonmorehouse/gatekeeper/internal" ) // Plugin is the interface which a plugin will implement and pass to `RunPlugin` type Plugin interface { // internal.Plugin exposes the following methods, per:...
package models import ( "fmt" "time" "github.com/jinzhu/gorm" ) // ===== BEGIN of all query sets // ===== BEGIN of query set UserQuerySet // UserQuerySet is an queryset type for User type UserQuerySet struct { db *gorm.DB } // NewUserQuerySet constructs new UserQuerySet func NewUserQuerySet(db *gorm.DB) UserQ...
package config import ( "testing" "github.com/stretchr/testify/assert" "k8s.io/utils/pointer" ) func TestArtifactRepository_IsArchiveLogs(t *testing.T) { assert.False(t, (&ArtifactRepository{}).IsArchiveLogs()) assert.False(t, (&ArtifactRepository{ArchiveLogs: pointer.BoolPtr(false)}).IsArchiveLogs()) assert.T...
package xml import "io" // Writer is used to write the XML elements. type Writer struct { w io.Writer indent string } // NewWriter creates a new XML writer. func NewWriter(w io.Writer) *Writer { return &Writer{w, ""} } // Write writes the parsed element. func (w *Writer) Write(e Element) error { return wri...
package report import ( "fmt" "sort" "github.com/naggie/dsnet" "golang.zx2c4.com/wireguard/wgctrl" ) var wg *wgctrl.Client type TimeSeriesType struct { TX []*DataPoint RX []*DataPoint } type Report struct { Report *dsnet.DsnetReport TimeSeries *TimeSeriesType } func getReport() Report { timeSeriesLoc...
package mwgrs type RegionType string const ( TypeFace RegionType = "Face" TypePet RegionType = "Pet" TypeFocus RegionType = "Focus" TypeBarCode RegionType = "BarCode" ) type FocusUsage string const ( EvaluatedUsed FocusUsage = "EvaluatedUsed" EvaluatedNotUsed FocusUsage = "EvaluatedNotUsed" NotEvalu...
package config import ( "bufio" "fmt" "html/template" "os" "strings" "github.com/antonioalfa22/go-utils/collections" "github.com/antonioalfa22/go-utils/command" "github.com/antonioalfa22/go-utils/io" ) func AddHostGroup(group string, hostslist []string, connection string) { groups := io.ReadFile("/etc/egida...
package main import ( "fmt" basc "github.com/hyperorchidlab/BAS/client" "github.com/hyperorchidlab/BAS/crypto" "github.com/hyperorchidlab/BAS/dbSrv" "github.com/hyperorchidlab/go-miner/node" "github.com/spf13/cobra" ) var BasCmd = &cobra.Command{ Use: "bas", Short: "register self to block chain service", L...
package view import ( "fmt" tgbotapi "github.com/go-telegram-bot-api/telegram-bot-api" view2 "projja_telegram/command/execute/view" "projja_telegram/command/projects/view" rootc "projja_telegram/command/root/controller" "projja_telegram/command/root/menu" "projja_telegram/command/util" "strings" ) func Listen...
package hot100 // 关键: // 看到这种题,直接回溯(dfs+裁剪) // 需要注意点的是,需要有一个bool数组标识是否已经使用 // 同时也需要注意的是,append 数据的时候要使用拷贝 func permute(nums []int) [][]int { ret := make([][]int, 0) used := make([]bool, len(nums)) var dfs func(index int) cur := make([]int, 0) dfs = func(count int) { if count == len(nums) { ret = append(ret, ...
/* * This file is part of the MultiCallC distribution Copyright (c) 2015 Jimmy * Aguilar Mena. * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, version 3. * * This program is distribute...
package main import ( "fmt" "io" "math/rand" "net/http" "os" "time" ) func init() { rand.Seed(time.Now().UnixNano()) } func main() { start := time.Now() ch := make(chan string) url := os.Args[1] //for _, url := range os.Args[1:] { go func() { fetch(url, ch) fmt.Println("1 done") //wg.Done() }() g...
package manager import ( "fmt" "github.com/zcong1993/telnetor/internal" ) // Manager is telnetor manager type Manager struct { workers map[string]*internal.Telenter errorCallback func(errMsg string) error } // NewManager is constructor of Manager func NewManager(errorCallback func(errMsg string) error) *Ma...
package collectors_test import ( "net/http" . "github.com/onsi/ginkgo" . "github.com/onsi/gomega" "github.com/onsi/gomega/ghttp" "github.com/cloudfoundry-community/go-cfclient" "github.com/prometheus/client_golang/prometheus" "github.com/prometheus/common/log" . "github.com/bosh-prometheus/cf_exporter/colle...
package redislogger import ( "bytes" "fmt" "html/template" "net/http" "os" "strconv" "time" "github.com/labstack/echo" "gopkg.in/redis.v5" ) const KeyLogList string = "kb:custom:log:list" const MaxListSize = 20000 var redisClient *redis.Client // type RedisLoggerConf struct { // Host string // Po...
package mail import ( "app-auth/config" "crypto/tls" "fmt" "log" "net/smtp" "strings" ) type Mail struct { senderId string toIds []string subject string body string } type SmtpServer struct { host string port string } func (s *SmtpServer) ServerName() string { return s.host + ":" + s.port } f...
package api import ( "github.com/idena-network/idena-indexer/core/holder/online" ) type Api struct { onlineIdentities online.CurrentOnlineIdentitiesHolder } func NewApi(onlineIdentities online.CurrentOnlineIdentitiesHolder) *Api { return &Api{ onlineIdentities: onlineIdentities, } } func (a *Api) GetOnlineIde...
package fakes import "github.com/cloudfoundry-incubator/notifications/models" type FakeRegistrar struct { RegisterArguments []interface{} RegisterError error PruneArguments []interface{} PruneError error } func NewFakeRegistrar() *FakeRegistrar { return &FakeRegistrar{} } func (fak...
package epsp import ( "encoding/json" "os" "strings" "time" ) type keyFile struct { PeerID string SecKey string PubKey string Expire time.Time KeySig string Global bool PeerCountByRegion PeerCounts Peers []string } // SaveKey は...
package main import ( "github.com/zhiruchen/archi/pb" ) func main() { }
package spa import ( "bufio" "fmt" "io/ioutil" "net/http" "net/url" "os/exec" "regexp" "strings" "github.com/gin-gonic/gin" "github.com/koding/websocketproxy" ) type spa struct { config Config isDevServerStarted bool url *url.URL } func (s *spa) startDevServer() { cmd := exe...
package ionic import ( "bytes" "encoding/json" "fmt" "github.com/ion-channel/ionic/pagination" "net/url" "github.com/ion-channel/ionic/deliveries" ) // GetDeliveryDestinations takes a team ID, and token. It returns list of deliveres and // an error if it receives a bad response from the API or fails to unmarsh...
package util import ( "os/exec" "strconv" "strings" ) //脚本执行工具 //直接执行命令脚本 func ShellRun(script string) error { return exec.Command("sh", "-c", script).Run() } //直接执行命令脚本,返回 []byte. func Output(script string) ([]byte, error) { return exec.Command("sh", "-c", script).Output() } //直接执行命令脚本,返回 string. func String...
// Copyright 2022 PingCAP, Inc. Licensed under Apache-2.0. package stream import ( "bytes" "testing" "github.com/pingcap/tidb/meta" "github.com/pingcap/tidb/tablecodec" "github.com/pingcap/tidb/util/codec" "github.com/stretchr/testify/require" ) func encodeTxnMetaKey(key []byte, field []byte, ts uint64) []byt...