text
stringlengths
11
4.05M
package sorting type MergeSort struct { } func (sort *MergeSort) separate(a *[]int32, buf *[]int32, start int, end int) { if start >= end { return } mid := int((start + end) / 2) sort.separate(a, buf, start, mid) sort.separate(a, buf, mid + 1, end) sort.merge(a, buf, start, mid, end) } func (sort *MergeSo...
package hookexecutor import ( "os" "time" . "github.com/onsi/ginkgo" . "github.com/onsi/gomega" "k8s.io/api/core/v1" apierrors "k8s.io/apimachinery/pkg/api/errors" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/apimachinery/pkg/runtime" "k8s.io/apimachinery/pkg/watch" fakekubeclientset "k8s.io/clien...
// This file was generated for SObject SecureAgent, API Version v43.0 at 2018-07-30 03:47:25.074501777 -0400 EDT m=+11.417536634 package sobjects import ( "fmt" "strings" ) type SecureAgent struct { BaseSObject AgentKey string `force:",omitempty"` CreatedById string `force:",omitempty"` ...
package main import ( "bufio" "flag" "log" "os" "strconv" "strings" "sync" ) var ( totalProxies []string urls []string timeout int = 5 input string = "urls.txt" output string = "proxies.txt" ) func main() { flag.StringVar(&input, "input", input, "File to input urls") flag.S...
package main import "fmt" func main() { var x interface{} x = 10 switch x.(type) { case int: v := x.(int) fmt.Printf("type=%T, value=%d\n", x, x) // error //x += 10 fmt.Printf("type=%T, value=%d\n", v, v) v += 10 fmt.Printf("type=%T, value=%d\n", v, v) default: fmt.Println("don't know") } }
// Copyright 2021 PingCAP, Inc. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // // http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed to i...
package server import ( "database/sql" "encoding/json" "fmt" "github.com/golang/glog" "io/ioutil" "net/http" "strconv" "strings" ) type reqConfigFilePagesNew1 struct{ Token string CompanyName string } func ConfigFilePagesNew1(w http.ResponseWriter, req *http.Request) { if req.Method == "POST" { result...
package main import ( "fmt" "net" "os" ) var ErrorCode = 1 //监听的端口 && 地址 var ServerPort = ":1212" var LocalHost = "127.0.0.1" var op = map[string]string{ "登录": "add", "显示在线人数": "show", } func CheckError(err error) { if err != nil { fmt.Println(err) os.Exit(ErrorCode) } } f...
package main import "testing" func TestP19(t *testing.T) { v := countWeekday(1901, 2000, 0) out := 171 if v != out { t.Errorf("P19: %v\tExpected: %v", v, out) } }
package web import ( "ChangeInspector/logservice" "ChangeInspector/sorter" "encoding/json" "net/http" "net/url" "strconv" "github.com/gorilla/mux" ) /*SortHandler ...*/ type SortHandler struct { logService *logservice.LogService } func getResult(query url.Values, result sorter.GoogleChartBarResult) sorter.G...
package entities import "github.com/jinzhu/gorm" // Project entity type Project struct { gorm.Model UserID uint User User `json:"user"` Description string `json:"description"` Tasks []Task `json:"tasks"` }
/* * @lc app=leetcode.cn id=16 lang=golang * * [16] 最接近的三数之和 */ // @lc code=start package main import "fmt" import "math" func main() { var a []int var target int // a = []int{-1,2,1,-4} // target = 1 // fmt.Printf("%v, %d, %d\n", a, target, threeSumClosest(a, target)) a = []int{1,2,4,8,16,32,64,128} ...
package pipe import ( "bytes" "crypto/sha256" "errors" "fmt" "io" "math" "net" "strings" "sync/atomic" "syscall" "time" "github.com/iberryful/sproxy/pkg/log" "github.com/iberryful/sproxy/pkg/socks" ) const bufSize int = 16 * 1024 const HeaderLen int = 4 const MagicLen int = 4 const MaxLen = bufSize - He...
package handler import ( "context" "path/filepath" "testing" "github.com/jinmukeji/jiujiantang-services/service/auth" corepb "github.com/jinmukeji/proto/v3/gen/micro/idl/partner/xima/core/v1" jinmuidpb "github.com/jinmukeji/proto/v3/gen/micro/idl/partner/xima/user/v1" "github.com/stretchr/testify/assert" "git...
package game_map import ( "github.com/faiface/pixel" "github.com/faiface/pixel/pixelgl" "github.com/steelx/go-rpg-cgm/gui" "github.com/steelx/tilepix" "log" "sort" ) type ExploreState struct { Stack *gui.StateStack MapDef *tilepix.Map Map *GameMap Hero *Character win *pixe...
package models import "time" type Comment struct { CommentID int `json:"comment_id"` ArticleID int `json:"article_id"` Message string `json:"message"` CreatedAt time.Time `json:"created_at"` } type Article struct { ID int `json:"article_id"` Title string `json:"title"` ...
package veriserviceserver import ( "fmt" "io/ioutil" "log" "os" "os/signal" "strings" "syscall" "github.com/bgokden/veri/node" "github.com/bgokden/veri/state" ) func RunServer(configMap map[string]interface{}) { state.Health = true state.Ready = false services := configMap["services"].(string) log.Prin...
package inc import ( "testing" "time" ) func Test_Caller_1(t *testing.T) { // single args today := Caller("date", "+%F_%T") if today != "" { t.Log(today) } else { t.Error("Single_Args: calller return empty") return } // multi args with space temp := "/etc/passwd /etc/services" ls := Caller("/bin/ls",...
package main import "fmt" func main() { a := [5]string{"1", "2", "3", "4", "5"} slice_a := a[1:3] b := [5]string{"one", "two", "three", "four", "five"} slice_b := b[1:3] fmt.Println("Slice_a:", slice_a) fmt.Println("Slice_b:", slice_b) fmt.Println("Length of slice_a:", len(slice_a)) fmt.Println(...
package controllers import ( "encoding/json" "github.com/go-errors/errors" "github.com/revel/revel" "gopkg.in/mgo.v2/bson" "topazdev/stocks-game-api/app/models" ) type LobbyController struct { BaseController } func (c LobbyController) Index() revel.Result { var ( lobbys []models.Lobby err error ) lob...
// Copyright (c) 2020 Tailscale Inc & 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 version import "runtime" // IsMobile reports whether this is a mobile client build. func IsMobile() bool { // Good enough heuristic for n...
package shell import ( "testing" "github.com/stretchr/testify/assert" ) func TestVersionNameShouldReturnVersion(t *testing.T) { assert.Equal(t, "version", version(0).name()) } func TestVersionsDescriptionShouldNotBeEmpty(t *testing.T) { assert.NotEqual(t, "", version(0).description()) } func TestVersionUsageSh...
package controllers import "github.com/revel/revel" //questions type QuestionController struct { *revel.Controller } func(c *QuestionController) Index() revel.Result{ return c.RenderText("Hello") }
package mutexcache_test import ( "github.com/jalavosus/mutexcache-go" "testing" "time" ) var ( defaultExpiration = 30 * time.Second testKeyA = "test_key_a" testKeyB = "test_key_b" ) // Test creation and retrieval of a single *sync.Mutex func TestSingle(t *testing.T) { mutexCache := mutexcach...
package client import ( "context" "crypto/tls" "crypto/x509" "errors" "fmt" "io" "net" "net/url" "sync" "time" "github.com/dkorittki/loago/pkg/api/v1" "github.com/dkorittki/loago/pkg/instructor/config" "github.com/grpc-ecosystem/go-grpc-middleware/util/metautils" "github.com/rs/zerolog" "google.golang....
package cmd import ( "bufio" "context" "errors" "fmt" "github.com/kobtea/go-todoist/cmd/util" "github.com/kobtea/go-todoist/todoist" "github.com/spf13/cobra" "os" "strconv" "strings" ) // labelCmd represents the label command var labelCmd = &cobra.Command{ Use: "label", Short: "subcommand for label", } ...
package isEmpty import ( "testing" "github.com/sirupsen/logrus" ) func TestIsEmpty(t *testing.T) { var ( logger logrus.FieldLogger = logrus.New() str interface{} = "asdsd" integer interface{} = 1234 sliceStr interface{} = []string{"a", "b"} sliceByte interface{} =...
// Copyright 2022-present Open Networking Foundation. // // 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 applica...
package main import ( "log" "time" "strconv" "fmt" "errors" dcli "github.com/fsouza/go-dockerclient" "io" "io/ioutil" "os" "path" ) type Runner struct { ContainerId string CodeDir string Language string Code string OutStream io.Writer ErrStream io.Writer Uid int UidPool *UidP...
package main import ( "os" "github.com/kafka-async/promise" ) func main() { promise.From(nil) os.Exit(1) }
package main import "fmt" func main() { //Arrays can only store types of the same value //Arrays are fixed in length, their length has to be specified when it is initialized var array [5]int array[0] = 100 array[4] = 300 fmt.Println(array) //Explicitly defining elements in the array arr := [5]int{2, 3, 4} ...
package crawl_test import ( "testing" "github.com/l-vitaly/golang-test-task/pkg/crawl" ) func TestCrawl(t *testing.T) { c := crawl.New() result, err := c.Do("http://ya.ru") if err != nil { t.Fatalf("unexpected error: %s", err) } if want, have := "http://ya.ru", result.URL; want != have { t.Errorf("want...
package types import ( "strings" "sync" "time" "github.com/bwmarrin/discordgo" ) type ServerDataType int type PollType int type PageSwitchType int type PageSwitchGetter func(PageSwitcher) (string, int, int, error) // text, newPage, maxPages, err type Empty struct{} const ( PlayChannel = 0 VotingChannel = 1 ...
/** * Copyright (c) 2018 ZTE Corporation. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * and the Apache License 2.0 which both accompany this distribution, * and are available at http://www.eclipse.org/legal/epl-v10.html ...
package minedive import "fmt" type Cell struct { Type string `json:"type"` D0 string `json:"d0"` D1 string `json:"d1"` D2 string `json:"d2"` D3 string `json:"d3"` } func (a *Cell) String() string { return fmt.Sprintf("%v (%v %v %v %v)", a.Type, a.D0, a.D1, a.D2, a.D3) } // type p1Users struct { // Na...
package bo type SelectMenuBo struct { CreateBy int `json:"createBy"` UpdatedBy int `json:"updatedBy"` SubCount int `json:"subCount"` MenuSort int `json:"menuSort"` ID int `json:"id"` Pid int `json:"pid"` Type int `json:"t...
package common import ( "time" "gopkg.in/mgo.v2/bson" ) //////////////////////聊天房间信息<<<<<<<<<<<<<<<<<<< // 聊天房间类型 const ( CHAT_TYPE_ROOM int32 = 1 // 临时房间 CHAT_TYPE_TEAM int32 = 2 // 临时队伍 CHAT_TYPE_GROUP int32 = 3 // 群聊 CHAT_TYPE_MATCHTEAM int32 = 4 // 比赛组队 CHAT_TYPE_RADAR int3...
package main import ( "net/http" "time" "appengine/datastore" "github.com/crhym3/go-endpoints/endpoints" ) type Greeting struct { Key *datastore.Key `json:"id" datastore:"-"` Author string `json:"author"` Content string `json:"content" datastore:",noindex" endpoint:"req"` Date time.Ti...
// +build !NO_CUDA package runner import ( "testing" ) // This file contains an integration test implementation that submits a studio runner // task across an SQS queue and then validates is has completed successfully by // the go runner this test is running within func TestCUDA(t *testing.T) { logger := NewLogge...
package main import ( "fmt" "math/rand" "sort" ) type Students struct { Name string Id string Age int } type Book struct { Name string Author string } //实现sort接口 type StudentArray []Students func (p StudentArray) Len() int { return len(p) } func (p StudentArray) Swap(i, j int){ p[i], p[j] = p[j], p[i] }...
package main import "fmt" // https://leetcode-cn.com/problems/remove-nth-node-from-end-of-list/ // Definition for singly-linked list. type ListNode struct { Val int Next *ListNode } func removeNthFromEnd(head *ListNode, n int) *ListNode { if head == nil { return nil } p := head for i := 0; i < n; i++ { ...
package workqueue func (w *WriteBackerConfig) CopyFrom(other *WriteBackerConfig) { w.Batcher.MaxItems = other.Batcher.MaxItems w.Batcher.MaxWaitTime = other.Batcher.MaxWaitTime w.Batcher.BatchBufferSize = other.Batcher.BatchBufferSize w.Transactioner.DB = other.Transactioner.DB w.Transactioner.MaxTransactionSize...
package types import ( "bytes" "encoding/json" "fmt" "html" "html/template" "net/http" "strconv" "strings" "time" "github.com/GoAdminGroup/go-admin/context" "github.com/GoAdminGroup/go-admin/modules/config" "github.com/GoAdminGroup/go-admin/modules/constant" "github.com/GoAdminGroup/go-admin/modules/db" ...
/* You have an array of item codes with the following format: "[letters][digits]" Create a function that splits these strings into their alphabetic and numeric parts. */ package main import ( "fmt" "unicode" ) func main() { fmt.Println(splitcode("TEWA8392")) fmt.Println(splitcode("MMU778")) fmt.Println(split...
package jwtcontroller import ( "errors" "strings" "time" "github.com/GlitchyGlitch/typinger/config" "github.com/dgrijalva/jwt-go" ) var ( ErrInvalidHeader = errors.New("invalid authorization header") ErrInvalidToken = errors.New("invalid token") ) const prefix = "Bearer " type JWTController struct { Confi...
package cmd import ( "testing" "github.com/stretchr/testify/assert" ) func TestRootCmdShouldHaveNonEmptyUse(t *testing.T) { assert.NotEqual(t, "", rootCmd.Use) } func TestRootCmdShouldHaveNonEmptyShort(t *testing.T) { assert.NotEqual(t, "", rootCmd.Short) } func TestRootCmdShouldHaveNonEmptyLong(t *testing.T) ...
package main import "sync" type intLocker struct { m *sync.Mutex intM map[int]*sync.Mutex } func newIntLocker() *intLocker { return &intLocker{ m: &sync.Mutex{}, intM: map[int]*sync.Mutex{}, } } func (il *intLocker) get(i int) *sync.Mutex { il.m.Lock() defer il.m.Unlock() intM, ok := il.intM[i] if...
/* Slavko is learning about different numeral systems. Slavko is not the brightest when it comes to math, so he is starting out converting binary numerals to octal. The algorithm Slavko uses is this: Pad the binary numeral with zeros on the left until the number of digits is divisible by three. Group adjacen...
package ssvgc import ( "image/color" "testing" ) func TestColorFromPaintToken(t *testing.T) { var tests = []struct { in string out color.Color }{ {"red", color.RGBA{0xff, 0, 0, 0xff}}, {"#fff", color.RGBA{0xff, 0xff, 0xff, 0xff}}, {"#fe0000", color.RGBA{0xfe, 00, 00, 0xff}}, {"none", color.Transparen...
package p9p import ( "context" "io" "net" "testing" "time" ) const realPlan9 = "1.1.1.1:808" func ckHasPlan9(t *testing.T) { t.Helper() if realPlan9 == "" { t.Skip("no real plan9 defined") } result := make(chan error) ctx, fn := context.WithTimeout(context.Background(), time.Second) defer fn() go func(...
package controllers import ( "GoldenTimes-web/forms" "GoldenTimes-web/models" "GoldenTimes-web/orm" "GoldenTimes-web/request" "GoldenTimes-web/response" "encoding/json" "strconv" "github.com/astaxie/beego" ) type AlbumController struct { beego.Controller } func (c *AlbumController) URLMapping() { c.Mappin...
package binary_search_tree_to_greater_sum_tree import ( "github.com/stretchr/testify/assert" "testing" ) func Test_BstToGst(t *testing.T) { input := &TreeNode{ Val: 4, Left: &TreeNode{ Val: 1, Left: &TreeNode{ Val: 0, Left: nil, Right: nil, }, Right: &TreeNode{ Val: 2, Left:...
package handlers_test import ( "net/http" "strconv" "testing" "github.com/jchprj/GeoOrderTest/api/handlers" "github.com/jchprj/GeoOrderTest/cfg" "github.com/jchprj/GeoOrderTest/mgr" ) type request struct { start, end []string expectedCode int expectedError string } func BenchmarkPlaceHandler(b *testing...
package e2e import ( . "github.com/onsi/ginkgo" . "sigs.k8s.io/multi-tenancy/incubator/hnc/pkg" ) var _ = Describe("Demo", func() { // Test for https://docs.google.com/document/d/1tKQgtMSf0wfT3NOGQx9ExUQ-B8UkkdVZB6m4o3Zqn64 const ( nsOrg = "acme-org" nsTeamA = "team-a" nsTeamB = "team-b" nsService1 = "ser...
package cfrida func Frida_session_get_pid(obj uintptr) int { r, _, _ := frida_session_get_pid.Call(obj) return int(r) } func Frida_session_get_persist_timeout(obj uintptr) int { r, _, _ := frida_session_get_persist_timeout.Call(obj) return int(r) } func Frida_session_is_detached(obj uintptr) bool { r, _, _ := fr...
// Licensed to Elasticsearch B.V. under one or more contributor // license agreements. See the NOTICE file distributed with // this work for additional information regarding copyright // ownership. Elasticsearch B.V. licenses this file to you under // the Apache License, Version 2.0 (the "License"); you may // not use ...
package requests import ( "compress/gzip" "errors" "github.com/sirupsen/logrus" "io" "io/ioutil" "net/http" "net/http/cookiejar" "net/url" "os" "strings" ) type Requests struct { hearders map[string]string JarCks http.CookieJar //需要在init初始化设置 } var ( UnKnown = errors.New("unknown error") NetWork = e...
package example import ( "context" "log" pubsub "github.com/utilitywarehouse/go-pubsub" "github.com/utilitywarehouse/go-pubsub/sqs" ) func consumerExample() { source, err := sqs.NewMessageSource(sqs.MessageSourceConfig{ Client: getClient(), // defined in sink.go QueueURL: "https://sqs.eu-west-1.amazonaws....
package resource import ( "github.com/cisordeng/beego/xenon" bResource "kylin/business/resource" ) type Uploads struct { xenon.RestResource } func init () { xenon.RegisterResource(new(Uploads)) } func (this *Uploads) Resource() string { return "resource.uploads" } func (this *Uploads) Params() map[string][]s...
// Copyright (c) 2020 Blockwatch Data Inc. // Author: alex@blockwatch.cc package models import ( "context" "github.com/jinzhu/gorm" "tezos_index/chain" ) // BlockCrawler provides an interface to access information about the current // state of blockchain crawling. type BlockCrawler interface { // returns the bl...
// Copyright (c) 2020 Tailscale Inc & 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 derp implements DERP, the Detour Encrypted Routing Protocol. // // DERP routes packets to clients using curve25519 keys as addresses. // ...
package cmd import ( "errors" "fmt" "path/filepath" "github.com/andytom/tmpltr/template" "github.com/AlecAivazis/survey" "github.com/spf13/cobra" ) func init() { RootCmd.AddCommand(useCmd) } var useCmd = &cobra.Command{ Use: "use NAME DIR", Short: "Apply a template to a directory", Long: `Apply a templ...
package template import ( "context" "fmt" "os" "path/filepath" log "github.com/sirupsen/logrus" "github.com/spf13/cobra" "github.com/argoproj/argo/cmd/argo/commands/client" workflowtemplatepkg "github.com/argoproj/argo/pkg/apiclient/workflowtemplate" wfv1 "github.com/argoproj/argo/pkg/apis/workflow/v1alpha1...
package mapxml import ( "encoding/xml" ) type TMXWangSets struct { // <wangsets> // ~~~~~~~~~~ XMLName xml.Name `xml:"wangsets"` // Contains the list of Wang sets defined for this tileset. // Can contain any number: :ref:`tmx-wangset` } type TMXWangset struct { // <wangset> // ^^^^^^^^^ XMLName xml.Na...
package p2p import ( "time" ) // PeerMetrics is the data shared to the metrics hook type PeerMetrics struct { Hash string PeerAddress string MomentConnected time.Time PeerQuality int32 LastReceive time.Time LastSend time.Time MessagesSent uint64 BytesSen...
package db import ( "context" "github.com/go-redis/redis/v8" "os" ) func GetRedisConnection() (*redis.Client, context.Context) { dsn := os.Getenv("REDIS_DSN") ctx := context.Background() rdb := redis.NewClient(&redis.Options{ Addr: dsn, Password: "", // no password set DB: 0, // use default D...
package main import ( "github.com/streadway/amqp" "log" ) /** * Retrieves a connection from the configured AMQP host, with the given ConnectionDefinition */ func GetConnection(definition ConnectionDefinition) error { connection, err := amqp.Dial("amqp://" + definition.Username + ":" + definition.Password + "@" +...
package scache import ( "context" "errors" "math" "time" ) type builder struct { conf *Config loadFunc LoadFunc } func New(shards int, maxSize int64) *builder { return &builder{ conf: &Config{ Shards: shards, MaxSize: maxSize, Kind: KindUnknown, }, } } func FromConfig(conf *Config) *bui...
/* * Display details of a single cross-datacenter firewall policy. */ package main import ( "flag" "fmt" "os" "path" "strings" "github.com/grrtrr/clcv2/clcv2cli" "github.com/grrtrr/exit" "github.com/olekukonko/tablewriter" ) func main() { flag.Usage = func() { fmt.Fprintf(os.Stderr, "usage: %s [options]...
package add_two_numbers type ListNode struct { Val int Next *ListNode } func addTwoNumbers(l1 *ListNode, l2 *ListNode) *ListNode { newNode := &ListNode{} a, b, ab := l1, l2, newNode //进位 carry := 0 for nil != a || nil != b || carry > 0 { sum := carry if nil != a { sum += a.Val a = a.Next } if ni...
package httputils import ( "net/http" "github.com/go-chi/render" ) // HTTPError contains the error message type HTTPError struct { Message string `json:"message"` } // RespondIfError if err != nil, returns the HTTPError and code as API response // no-op if the err is nil func RespondIfError(code *int, err *error...
package main import ( "bufio" "fmt" "io" "log" "net" "runtime/debug" ) const port = "9002" const target = "" type client struct { listenChannel chan bool // Channel that the client is listening on transmitChannel chan bool // Channel that the client is writing to listener io.Writer /...
package repository import ( "fmt" "testing" "github.com/go-logr/logr" "github.com/go-test/deep" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/apimachinery/pkg/types" "k8s.io/klog/klogr" "github.com/isutton/orchid/pkg/orchid/...
package main import ( "flag" "log" "net/url" "github.com/mlmhl/gcrawler/handler" "github.com/mlmhl/gcrawler/request" "github.com/mlmhl/gcrawler/response" "github.com/mlmhl/gcrawler/spider" "github.com/mlmhl/gcrawler/types" "github.com/golang/glog" "github.com/mlmhl/gcrawler/storage" "golang.org/x/net/html...
package main import ( "bytes" "fmt" "github.com/kohirens/tmpltoapp/internal/cli" "os" "os/exec" "path/filepath" "regexp" "strings" ) // gitClone Clone a repo from a path/URL to a local directory. func gitClone(repoUri, repoDir, refName string) (string, string, error) { infof("branch to clone is %q", refName)...
//funcoes variativas: recebem parametros variaveis package main import "fmt" func media(numeros ...float64) float64 { //numeros entra como array total := 0.0 for _, num := range numeros { total += num } if total > 0.0 { return total / float64(len(numeros)) } else { return 0.0 } } func main() { fmt.P...
package agent import ( "context" "time" "github.com/MagalixCorp/magalix-agent/v3/proto" "github.com/MagalixTechnologies/uuid-go" ) type Match struct { Namespaces []string Kinds []string Labels []map[string]string } type Constraint struct { Id string TemplateId string AccountId stri...
package models type ConfigModel struct { NsqdAddr string HttpAddr string LookupdAddr string MasterTopic string TopicMaxChannel int N2n2Addr string NodeList []string }
package main import ( "fmt" "github.com/slack-go/slack" ) func main() { api := slack.New("YOUR_TOKEN_HERE") attachment := slack.Attachment{ Pretext: "some pretext", Text: "some text", // Uncomment the following part to send a field too /* Fields: []slack.AttachmentField{ slack.AttachmentField{ ...
package pie_test import ( "github.com/elliotchance/pie/v2" "github.com/stretchr/testify/assert" "testing" ) func TestStddev(t *testing.T) { assert.Equal(t, 0.0, pie.Stddev([]float64{})) assert.Equal(t, 0.0, pie.Stddev([]float64{1})) assert.Equal(t, 4.8587389053127765, pie.Stddev([]float64{10.0, 12.5, 23.3, 23.1...
package main func report() { }
/* 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 queue import ( "testing" ) func Test_IsEmpty(t *testing.T) { a := []int{1, 2, 3, 4, 5, 6, 7, 8, 9} q := New() for i := range a { q.Push(a[i]) } for !q.IsEmpty() { q.Pop() } }
package errors import ( "fmt" "testing" . "github.com/smartystreets/goconvey/convey" ) func TestIsFatal(t *testing.T) { Convey("Given a no error", t, func() { var err error Convey("When calling IsFatal", func() { f := IsFatal(err) Convey("The result should be false", func() { So(f, ShouldBeFalse) ...
package app type CSVMoveBase struct { ID string Identifier string GenerationID string TypeID string Power string PP string Accuracy string Priority string TargetID string DamageClassID ...
package util import ( "fmt" "github.com/maprost/application/generator/genmodel" "sort" ) func CalculateProfessionalSkills(application *genmodel.Application) ([]genmodel.Skill, error) { return calculateSkills(application.Profile.ProfessionalSkills, application.JobPosition.ProfessionalSkills) } func CalculateSoftS...
// Package worker_pool implements a worker pool pattern with a maximum rate // of work. Consumption from the consumer is throttled by an intermediary // which batches work and places it on a read channel at a pre-specified // interval. package worker_pool import ( "bytes" "fmt" "sync" "time" "github.com/inconshr...
// Copyright (c) 2020 by meng. All rights reserved. // Use of this source code is governed by an MIT-style // license that can be found in the LICENSE file. /** * @Author: meng * @Description: * @File: entitymgr * @Version: 1.0.0 * @Date: 2020/4/11 22:05 */ package entity import "sync" var entityMgr *Entity...
/* Copyright © 2021 Faruk AK <kakuraf@gmail.com> 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 wr...
package server import ( "encoding/json" "fmt" "net/http" "net/http/httptest" "strings" "testing" restful "github.com/emicklei/go-restful" "github.com/stretchr/testify/suite" "go-gcs/src/config" "go-gcs/src/entity" "go-gcs/src/service" "go-gcs/src/service/googlecloud/storageprovider" ) type StorageSuite s...
package main import ( "healthybank.com/healthybank/api" "healthybank.com/healthybank/financial_project" ) func main() { // client := clients.New() // if err := client.GetAccountInformation(); err != nil { // fmt.Errorf("%s", err) // } svc := financial_project.New() fpHandler := api.New(svc) fpHandler.Start...
package main import ( "flag" "fmt" "log" "net/http" "github.com/boltdb/bolt" ) var ( port = flag.Int("port", 8080, "port to run on") db = flag.String("db", "bolt.db", "bolt db file") ) func main() { flag.Parse() db, err := bolt.Open(*db, 0600, nil) if err != nil { log.Fatal(err) } defer db.Close() ...
package orm import ( "testing" "github.com/stretchr/testify/assert" "k8s.io/apimachinery/pkg/types" "k8s.io/klog/klogr" "github.com/isutton/orchid/pkg/orchid/config" "github.com/isutton/orchid/test/mocks" ) func TestORM_New(t *testing.T) { logger := klogr.New().WithName("test") config := &config.Config{User...
package parser import ( "strings" "testing" ) func TestParser(t *testing.T) { input := "//hello\n D=M;JMP//hello\n@111 // jfajfjfj j" p := New(strings.NewReader(input)) line := 0 p.Advance(&line) t.Logf("p %+v line %d", p, line) p.Advance(&line) t.Logf("p %+v line %d", p, line) p.Advance(&line) t.Logf("p %...
// Copyright (c) 2022 Target Brands, Inc. All rights reserved. // // Use of this source code is governed by the LICENSE file in this repository. package vela import ( "reflect" "testing" ) func TestVela_Bool(t *testing.T) { // setup types _bool := false want := &_bool // run test got := Bool(_bool) if !re...
package validation import "regexp" const ( usernamePattern = `^[a-z0-9._%+\-]+@[a-z0-9.\-]+\.[a-z]{2,4}$` passwordPattern = `^[a-z0-9A-Z@._\-]{8,20}$` ) // IsUsername 檢驗是否為合法用戶名,合法字符有 0-9, A-Z, a-z,合法字符長度{8,20} func IsUsername(name string) bool { changeNameType := []byte(name) usernameRegexp := regexp.MustCompil...
package sound import ( "context" "database/sql" "errors" "fmt" "log" "mime/multipart" "net/http" "os" "path" "strconv" "strings" "github.com/volatiletech/null" "github.com/ericlagergren/decimal" "github.com/gin-gonic/gin" "github.com/satori/go.uuid" "github.com/volatiletech/sqlboiler/boil" "github.c...
/**************************************************************************** * Copyright 2019, Optimizely, Inc. and contributors * * * * Licensed under the Apache License, Version 2.0 (the "License"); * * you m...
package poly2tri type AdvancingFront struct { head *Node tail *Node search_node *Node } func NewAdvancingFront(head, tail *Node) *AdvancingFront { af := &AdvancingFront{} af.Init(head, tail) return af } func (this *AdvancingFront) Init(head, tail *Node) { /** @type {Node} */ this.head = head /*...
// Scrape `sys_m_license`. package collector import ( "context" "database/sql" _ "github.com/SAP/go-hdb/driver" "go.opencensus.io/stats" "go.opencensus.io/stats/view" "go.opencensus.io/tag" "go.opencensus.io/trace" "log" ) const ( // Scrape query. licenseStatusQuery = `select hardware_key,system_id,produc...