text
stringlengths
11
4.05M
package main import ( "encoding/json" "fmt" "io/ioutil" "net/http" ) // RedditPost represents reddit post data type RedditPost struct { ID string `json:"id"` Thumbnail string `json:"thumbnail"` Permalink string `json:"permalink"` Title string `json:"title"` Subreddit string `json:"subreddit"` } /...
package main import ( "fmt" "io/ioutil" "strings" ) // Grid represents the seats matrix type Grid [][]rune func readInput(filename string) Grid { file, err := ioutil.ReadFile(filename) if err != nil { panic(err) } lines := strings.Split(string(file), "\n") spaces := make([][]rune, len(lines)) for i, line ...
package tccp const Outputs = ` {{define "outputs"}} DockerVolumeResourceName: Value: {{ .Guest.Outputs.Master.DockerVolume.ResourceName }} {{ if .Guest.Outputs.Route53Enabled }} HostedZoneNameServers: Value: !Join [ ',', !GetAtt 'HostedZone.NameServers' ] {{ end }} MasterImageID: Value: {{ .Guest...
package collection_test import ( "os" "strings" ) const ( SUCCESS = iota FAILURE ) const ( dictionary = "dictionary.txt" // A Tale of Two Cities, by Charles Dickens book1 = "98-0.txt" // Pride and Prejudice, by Jane Austen book2 = "1342-0.txt" // Frankenstein, by Mary Wollstonecraft (Godwin) Shelley bo...
package main import ( "encoding/json" "fmt" ) type person struct { First string Last string Age int } func main() { jsonString := `[{"First":"James","Last":"Bond","Age":32},{"First":"Miss","Last":"Moneypenny","Age":27}]` fmt.Println("JSON ::", jsonString) byteSlice := []byte(jsonStr...
package kubernetes import ( "github.com/hashicorp/terraform/helper/schema" "github.com/hashicorp/terraform/terraform" "github.com/maxmanuylov/terraform-provider-kubernetes/kubernetes/client" ) func Provider() terraform.ResourceProvider { return &schema.Provider{ Schema: map[string]*schema.Sche...
package meduza import ( "fmt" "io" "io/ioutil" "log" "net/http" "os" "os/exec" "time" ) type TestServer struct { cmd *exec.Cmd running bool port int ctlPort int } const ( // The env var for the meduza executable. If not set, we default to running "meduzad" from PATH MeduzaBinEnvvar = "MEDUZA_BIN...
/* # -*- coding: utf-8 -*- # @Author : joker # @Time : 2019-11-13 17:16 # @File : slice.go # @Description : 切片util */ package utils func ClearPointerSlice(slices ...*[]interface{}) { for _, s := range slices { *s = (*s)[0:0] } }
package core import ( "context" "time" "github.com/google/uuid" ) type DomainEvent struct { ID uuid.UUID EventID uuid.UUID Topic string CanNotPublishToEventsource bool IsPublished bool CanBuffered bool CreatedAt ...
package azure import ( corev1 "k8s.io/api/core/v1" opapi "github.com/openshift/cluster-image-registry-operator/pkg/apis/imageregistry/v1alpha1" ) type driver struct { Name string Namespace string Config *opapi.ImageRegistryConfigStorageAzure } func NewDriver(crname string, crnamespace string, c *opapi....
package main import ( "flag" "fmt" "log" "strings" "github.com/TylerReid/kask-cli/kask" "github.com/fatih/color" "github.com/jroimartin/gocui" "github.com/zyxar/image2ascii/ascii" ) var kaskApi kask.Kask var kegs []kask.KegOnTap func main() { kaskUrl := *flag.String("kaskurl", "https://ka...
package main import ( "bytes" "context" "crypto/sha256" "errors" "hash" "io" "net/http" "os" "strconv" "strings" "sync" "time" "github.com/BurntSushi/toml" _ "github.com/jackc/pgx/stdlib" "github.com/jmoiron/sqlx" "fmt" "github.com/prometheus/client_golang/prometheus" "github.com/prometheus/client...
package fsdb import ( "context" "io" ) // FSDB defines the interface for an FSDB implementation. type FSDB interface { // Read opens an entry and returns a ReadCloser. // // If the key does not exist, it should return a NoSuchKeyError. // // It should never return both nil reader and nil err. // // It's the ...
package main import "math" /** 最大子序和 给定一个整数数组 nums ,找到一个具有最大和的连续子数组(子数组最少包含一个元素),返回其最大和。 示例 1: ``` 输入: [-2,1,-3,4,-1,2,1,-5,4], 输出: 6 解释: 连续子数组 [4,-1,2,1] 的和最大,为 6。 ``` 进阶: 如果你已经实现复杂度为 O(n) 的解法,尝试使用更为精妙的分治法求解。 */ /** 今天的简单题有点不简单 */ func MaxSubArray(nums []int) int { // 之前总和 var sum int // 之前最大和 maxSum := num...
package servertoken import ( "context" "database/sql" "net/http" "github.com/gilcrest/app-client/client" "github.com/gilcrest/app-client/clientctx" "github.com/gilcrest/errors" "github.com/rs/zerolog" ) // ServerToken is a token which represents a Server type ServerToken string func (s ServerToken) String() ...
package dump import ( "encoding/json" "os" "github.com/spf13/cobra" "github.com/nordcloud/mfacli/config" "github.com/nordcloud/mfacli/pkg/vault" ) func Create(cfg *config.Config) *cobra.Command { return &cobra.Command{ Use: "dump-secrets-unencrypted", Short: "Dump secrets stored in the vault in un-enc...
// Copyright (c) 2020 Hirotsuna Mizuno. All rights reserved. // Use of this source code is governed by the MIT license that can be found in // the LICENSE file. package speedio import ( "io" "sync" "time" "github.com/tunabay/go-infounit" ) // LimiterReader implements bit rate limiting for an io.Reader object. t...
package handlers import ( "time" "github.com/assignments-fixed-ssunni12/servers/gateway/models/users" ) //TODO: define a session state struct for this web server //see the assignment description for the fields you should include //remember that other packages can only see exported fields! type SessionState struct ...
package rules import ( "bytes" "fmt" "reflect" "encoding/json" "encoding/xml" "io/ioutil" "log" "os" "path/filepath" "github.com/rogpeppe/go-charset/charset" _ "github.com/rogpeppe/go-charset/data" util "./util" ) //CheckRule : Resultado de la ejecucion de reglas type CheckRule str...
package main import ( ioboundvscpubound "github.com/masiucd/go-concurrency/src/io-bound-vs-cpu-bound" ) func main() { ioboundvscpubound.Init2() }
package utils import "fmt" // Example is a demonstration of a helper utility function func Example(input string) { fmt.Println(input) }
package app import ( "context" "fmt" v12 "github.com/rancher/wrangler-api/pkg/generated/controllers/apps/v1" corev1controller "github.com/rancher/wrangler-api/pkg/generated/controllers/core/v1" "github.com/rancher/wrangler/pkg/objectset" "github.com/weibaohui/mesh/modules/istio/controllers/app/populate" meshv1 ...
/* * Copyright 2018, CS Systemes d'Information, http://www.c-s.fr * * 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 requir...
package lib import ( "bytes" "crypto/sha1" "encoding/hex" ) func Sha1(in ...string) string { buf := new(bytes.Buffer) for idx := range in { buf.WriteString(in[idx]) } tmp := sha1.Sum(buf.Bytes()) return hex.EncodeToString(tmp[:]) }
package gcontext import ( "fmt" "github.com/go-xe2/x/type/xstring" "github.com/go-xe2/xthrift/builder" "github.com/go-xe2/xthrift/builder/comm" "github.com/go-xe2/xthrift/pdl" "sort" ) type TProcessorFunCodeWriter struct { *TWriter } var _ builder.ProcessorFunCodeWriter = (*TProcessorFunCodeWriter)(nil) func...
// 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 exoscale import ( "context" "errors" "fmt" "io/ioutil" "net/http" "strings" "github.com/exoscale/egoscale" v1 "k8s.io/api/core/v1" ) const metadataEndpoint = "http://metadata.exoscale.com/1.0/meta-data/" func (c *cloudProvider) computeInstanceByProviderID(ctx context.Context, providerID string) (*eg...
package container_runtime import ( "context" "github.com/werf/logboek" "github.com/werf/werf/pkg/image" ) type PerfCheckContainerRuntime struct { ContainerRuntime ContainerRuntime } func NewPerfCheckContainerRuntime(containerRuntime ContainerRuntime) *PerfCheckContainerRuntime { return &PerfCheckContainerRunt...
package main import ( "context" "fmt" "io/ioutil" "log" "os" "os/exec" "regexp" "strings" "sync" "time" "github.com/rafaelsq/wtc/configuration" "github.com/rjeczalik/notify" yaml "gopkg.in/yaml.v2" ) var config configuration.Config var contexts map[string]context.CancelFunc var ctxmutex sync.Mutex fun...
package testdata import ( "github.com/frk/gosql" "github.com/frk/gosql/internal/testdata/common" ) type SelectWithOffsetDirectiveQuery struct { Users []*common.User `rel:"test_user:u"` _ gosql.Offset `sql:"25"` }
package tag import ( "time" ) // Tag is an user profession. // Key's stringID is encoded "Context" key. // And the "ContextID" is an encoded "Context" key for multilang usage purpose. type Tag struct { ID string `datastore:"-"` ContextID string `datastore:"-" json:"contextID"` Created time.Time `js...
package lib import ( "os" gokitlog "github.com/go-kit/kit/log" ) func GetLogger() gokitlog.Logger { var logger gokitlog.Logger { logger = gokitlog.NewLogfmtLogger(os.Stdout) logger = gokitlog.With(logger, "TIME", gokitlog.DefaultTimestamp) logger = gokitlog.With(logger, "CALLER", gokitlog.DefaultCaller) ...
// Copyright 2023 Google LLC. 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 applica...
package hitbtc_test import ( "log" "os" "testing" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/suite" "github.com/ramezanius/crypex/exchange/hitbtc" ) type hitbtcSuite struct { suite.Suite exchange *hitbtc.HitBTC } func (suite *hitbtcSuite) SetupSuite() { suite.exchange = hitbtc.New()...
package app import ( "fmt" "testing" "time" "github.com/btnguyen2k/henge" "github.com/btnguyen2k/prom" "main/src/gvabe/bo" ) const tableNameMultitenantDynamodb = "exter_test" var setupTestDynamodbMultitenant = func(t *testing.T, testName string) { testAdc = _createAwsDynamodbConnect(t, testName) for _, tab...
package templates const NotFound = ` <html> <head> <title>DAG-nammit.</title> <link href="/static/css/style.css" rel="stylesheet" type="text/css"> </head> <body> <div class="aligner"> <div class="aligner-item">404</div> </div> </body> </html> `
package common import ( "context" "net/http" "runtime" "strings" "github.com/felixge/httpsnoop" "github.com/honeycombio/beeline-go/propagation" "github.com/honeycombio/beeline-go/timer" "github.com/honeycombio/beeline-go/trace" libhoney "github.com/honeycombio/libhoney-go" ) type ResponseWriter struct { ht...
package file import ( "bytes" "io" "testing" ) type mockCloser struct { io.Writer } func (f mockCloser) Close() error { return nil } func TestOutput(t *testing.T) { var outputMap map[string]*bytes.Buffer SetOsCreate(func(name string) (io.WriteCloser, error) { b := &bytes.Buffer{} outputMap[name] = b r...
package map3D import "github.com/MJKWoolnough/equaler" type regionYZ struct { *region x int32 y int32 z int32 } func (r *regionYZ) Extend(forward bool) { r.distance++ if !forward { r.y-- } } func (r *regionYZ) Get(theMap *Map3D, add int32, dir uint8) equaler.Equaler { if dir == 0 { return theMap.Get(r.x...
package main import ( "bytes" "fmt" "github.com/codegangsta/cli" "io/ioutil" "os" "os/exec" "time" ) type deploy struct { Config *config Logger *logger SSH *sshClient Stderr bytes.Buffer TempDir string } // build builds the binary following OS and ARCH predefined in the deploy config /...
package main import ( "errors" "fmt" "log" "sync" "time" consul "github.com/hashicorp/consul/api" "github.com/jonmorehouse/gatekeeper/gatekeeper" "github.com/jonmorehouse/gatekeeper/gatekeeper/utils" upstream_plugin "github.com/jonmorehouse/gatekeeper/plugin/upstream" ) func NewConsulUpstreams() upstream_pl...
package main import ( "database/sql" "fmt" "github.com/feng/alg/mqttpro/mqtt_blacklist" _ "github.com/go-sql-driver/mysql" "log" "net/http" ) func main() { db, err := sql.Open("mysql", "root:feng@/test?charset=utf8") if err != nil { fmt.Println(err) } defer db.Close() var num = 100 mqtt_blacklist.InitBl...
package main import ( "bufio" "client/process" "fmt" "os" _"strings" ) func main() { var loop bool = true for loop{ println("1 login the room") println("2 register new user") println("3 exit system") var key int fmt.Scanf("%d\n",&key) switch key{ case 1: var username string var password st...
package file_producer_service import ( "github.com/gin-gonic/gin" log "github.com/sirupsen/logrus" "github.com/yjagdale/siem-data-producer/models/file_producer_model" "github.com/yjagdale/siem-data-producer/utils/networkUtils" "github.com/yjagdale/siem-data-producer/utils/response" "net" "os" "strconv" ) func...
package nv7haven import ( "encoding/json" "math/rand" "net/url" "strconv" "time" "github.com/gofiber/fiber/v2" ) type idea struct { ID int CreatedOn int Yes int No int Title string HasVoted bool } type empty struct{} func (n *Nv7Haven) getIdeas(c *fiber.Ctx) error { sort := "v...
package controller import ( "heroku-backend-a-cocreate/dto" "heroku-backend-a-cocreate/helper/mc" "heroku-backend-a-cocreate/helper/response" "heroku-backend-a-cocreate/service" "net/http" "strconv" "time" "github.com/gin-gonic/gin" log "github.com/sirupsen/logrus" ) const layoutFormatDate = "2006-01-02" f...
package main import "fmt" //variadic parameter a ...int func calcSum(a ...int) int { fmt.Printf("%T type and %v values\n", a, a) return 2 } func main() { slc := []string{"1", "2", "3"} slc = append(slc, "word") slc = append(slc, "word1", "word2") slc = append(slc, "word4", "word5", "word6") fmt.Println(slc, s...
package main import ( "bufio" "fmt" "os" "sort" "strconv" "strings" ) func main() { filePath := os.Args[1] file, _ := os.Open(filePath) defer file.Close() reader := bufio.NewReader(file) scanner := bufio.NewScanner(reader) scanner.Split(bufio.ScanLines) total := 0 for scanner.Scan() { //parse o...
package main import ( "fmt" "github.com/gorilla/schema" ) type Person struct { fname string lname string email string mobile string } func main() { var decoder = schema.NewDecoder() persons := make(map[string][]string) var p = make(map[string][]*Person) persons["employees"] = []string{ "22", "eee",...
package utfstrings import ( "unicode/utf8" ) // EOS is returned when cursor reaches the end of the string. const EOS = int32(-1) // Cursor provides functions to navigate a Unicode string. type Cursor struct { Selection String string } // Selection represents the current selection in the cursor. type Selection s...
/* # -*- coding: utf-8 -*- # @Author : joker # @Time : 2020-06-18 09:46 # @File : doubly_linked_list.go # @Description : 不带头双向链表 # @Attention : */ package linked_list import "errors" type doubleListNode struct { prev *doubleListNode next *doubleListNode data interface{} } func NewDoublyListNode(data interface{}...
package messagedb import ( "encoding/json" "errors" "fmt" "runtime" ) var ( // ErrFieldsRequired is returned when a point does not any fields. ErrFieldsRequired = errors.New("fields required") // ErrFieldTypeConflict is returned when a new field already exists with a different type. ErrFieldTypeConflict = er...
package ondemand import ( "fmt" "log" "os" "testing" ) var key = os.Getenv("ONDEMAND_KEY") var od = New(key, true) func TestInit(t *testing.T) { if len(key) == 0 { log.Fatal("Set ONDEMAND_KEY env var") } // get a quote // quote, err := od.Quote([]string{"AAPL", "ESH8"}, []string{"impliedVolatility"}) ...
package models_test import ( "github.com/APTrust/exchange/models" "github.com/APTrust/exchange/util/testutil" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" "testing" ) func TestNewDeleteState(t *testing.T) { deleteState := models.NewDeleteState(testutil.MakeNsqMessage("999")) requi...
package lecimg import "image" // FilterSource is a source of filter type FilterSource struct { image image.Image filename string index int } // NewFilterSource creates an instance of FilterSource func NewFilterSource(image image.Image, filename string, index int) *FilterSource { return &FilterSource{image:...
/* Copyright 2016 The Kubernetes 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, ...
package amazonmwsapi import ( "context" "encoding/xml" "errors" ) // SubmitFeedRequest holds request data for SubmitFeed call type SubmitFeedRequest struct { amazonRequest feed *feed } type feed struct { XMLName xml.Name `xml:"AmazonEnvelope"` Xsi string `xml:"xs...
package anansi import ( "errors" "image" "io" "syscall" "github.com/jcorbin/anansi/ansi" ) // TermScreen supports attaching a ScreenDiffer to a Term's Context. type TermScreen struct { ScreenDiffer } // ScreenDiffer supports deferred screen updating by tracking desired virtual screen // state vs last known (R...
package oic import ( "fmt" log "github.com/Sirupsen/logrus" "github.com/runtimeco/go-coap" "mynewt.apache.org/newtmgr/nmxact/nmxutil" ) type ResGetFn func(uri string) (coap.COAPCode, []byte) type ResPutFn func(uri string, data []byte) coap.COAPCode type Resource struct { Uri string GetCb ResGetFn PutCb Re...
package main import ( "encoding/xml" "fmt" ) func main() { type Email struct { Where string `xml:"where,attr"` Addr string } // <Email where='work'> type TS struct { XMLName xml.Name `xml:"log4j\:event"` Logger string `xml:"logger,attr"` Timestamp string `xml:"timestamp,attr"` Epoch s...
package test import ( "testing" validator "github.com/hexbee-net/aws-validator" "github.com/stretchr/testify/assert" ) type ArnTest struct { ArnValue string `validate:"arn"` } func TestIsValidARN(t *testing.T) { cases := []struct { input string err string }{ { input: "invalid", err: "Key: 'Arn...
package utils import "strconv" func uintToString(u uint64) string { return strconv.FormatUint(u, 10) }
// Generated by go run gen.go // Do not edit. // This file must be included in .gitignore. package version const ( // Major version when you make incompatible API changes. Major = major // Minor version when you add functionality in a backwards-compatible manner. Minor = minor // Patch version when you make ba...
// Copyright 2023 Google LLC. 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 applica...
package main import ( ui "github.com/gizak/termui" DBC "github.com/influxdb/influxdb/client/v2" // tm "github.com/nsf/termbox-go" DB "github.com/vrecan/FluxDash/influx" SL "github.com/vrecan/FluxDash/sparkline" ) func main() { c := DBC.HTTPConfig{Addr: "http://127.0.0.1:8086", Username: "admin", Password: "logr...
/* Copyright (C) 2016 Red Hat, 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 in writing, softwa...
/* Copyright 2022 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, softw...
package dcp import ( "reflect" "testing" ) func Test_regularNumbers(t *testing.T) { numbers := []uint64{1, 2, 3, 4, 5, 6, 8, 9, 10, 12, 15, 16, 18, 20, 24, 25, 27, 30, 32, 36, 40, 45, 48, 50, 54, 60, 64, 72, 75, 80, 81, 90, 96, 100, 108, 120, 125, 128, 135, 144, 150, 160, 162, 180, 192, 200, 216, 225, 240, 243, 25...
package main import ( "flag" "fmt" "io" "mime/multipart" "net/http" "net/url" "os" "strconv" "strings" "time" ) const boundary = "DellvinBlackDellvinBlackDellvinBlackDellvinBlack" type Flags struct { src *string addr *string chunk *int } func main() { f := setupCLArgs() if f.addr == nil { return ...
package routes import ( "devbook-api/src/controllers" "net/http" ) var userRoutes = []Route{ { URI: "/users", Method: http.MethodPost, Handler: controllers.CreateUser, RequestAuth: false, }, { URI: "/users", Method: http.MethodGet, Handler: controllers.FindUsers, ...
/* # -*- coding: utf-8 -*- # @Author : joker # @Time : 2020-08-10 16:31 # @File : interface.go # @Description : # @Attention : */ package raft // 内存文件 type LogArray struct { } type SnapShotReq struct { } type SnapShotResp struct { } // 保存本地文件 type CommonInterface interface { GetStatus() byte SnapShort(req SnapS...
package models import ( "fmt" "github.com/freelifer/gohelper/pkg/settings" "github.com/go-xorm/xorm" "log" "os" "path" ) var ( x *xorm.Engine tables []interface{} HasEngine bool EnableSQLite3 bool ) type Model struct { Id int64 Created int64 `xorm:"created"` Updated int64 `xorm:"updated...
package db import ( "encoding/json" "github.com/fananchong/go-xserver/common" ) // AccountServer : 账号对应分配的服务资源 type AccountServer struct { NodeID common.NodeID Address string Port int32 Type common.NodeType } // Marshal : 序列化 func (accountserver *AccountServer) Marshal() (string, error) { data, err :=...
package main import ( "bufio" "fmt" "os" "strconv" ) const inputPath = "input.txt" const goal = 2020 func main() { var part1 int var part2 int input, err := readLines(inputPath) if err != nil { fmt.Println("error reading input") return } var numInput = make([]int, len(input)) for i, num := range inp...
package main import ( "flag" glad "github.com/akiross/go-glad" "github.com/go-gl/glfw/v3.2/glfw" "io/ioutil" "log" "runtime" "strconv" "strings" "time" ) var ( rows = flag.Int("rows", 20, "Number of rows in the grid") cols = flag.Int("cols", 20, "NUmber of columns in the grid") width = flag.Int("width",...
package user import ( "strings" "github.com/btnguyen2k/prom" "github.com/btnguyen2k/henge" ) // NewUserDaoMongo is helper method to create MongoDB-implementation of UserDao. func NewUserDaoMongo(mc *prom.MongoConnect, collectionName string) UserDao { txMode := strings.Index(strings.ToLower(mc.GetUrl()), "replic...
// DRUNKWATER TEMPLATE(add description and prototypes) // Question Title and Description on leetcode.com // Function Declaration and Function Prototypes on leetcode.com //788. Rotated Digits //X is a good number if after rotating each digit individually by 180 degrees, we get a valid number that is different from X. E...
package main import "fmt" //全局匿名函数 var mquan = func(a int, b int) int { return a + b } func main() { var a int = 10 var b int = 20 //匿名函数的调用方式 //第一种调用,直接在后面加括号传参即可 c := func(a int, b int) int { return a + b }(a, b) //匿名函数后加括号,即为匿名函数的即定义即调用 fmt.Println(c) //第二种调用,定义方法变量进行调用 m := func(a int, b int) int { ...
package stats_test import ( "testing" "github.com/facebookgo/ensure" "github.com/facebookgo/stats" ) func TestAverage(t *testing.T) { t.Parallel() ensure.DeepEqual(t, stats.Average([]float64{}), 0.0) ensure.DeepEqual(t, stats.Average([]float64{1}), 1.0) ensure.DeepEqual(t, stats.Average([]float64{1, 2}), 1.5)...
package model // not implement
package main import ( "fmt" "net/http" "time" "github.com/garyburd/redigo/redis" "github.com/magiconair/properties" "github.com/google/uuid" ) var pool redis.Pool var config = properties.MustLoadFile("../../conf/application.properties", properties.UTF8) func init() { pool = redis.Pool{ MaxActive: confi...
package datamodel import ( "github.com/GoAdminGroup/go-admin/context" "github.com/GoAdminGroup/go-admin/modules/db" "github.com/GoAdminGroup/go-admin/plugins/admin/modules/table" "github.com/GoAdminGroup/go-admin/template/types/form" ) func GetGoadminSuperUsersTable(ctx *context.Context) table.Table { goadminSu...
/* Given the root of a binary tree, flatten the tree into a "linked list": The "linked list" should use the same TreeNode class where the right child pointer points to the next node in the list and the left child pointer is always null. The "linked list" should be in the same order as a pre-order traversal of the bin...
package core import ( "context" "go.mongodb.org/mongo-driver/bson" "go.mongodb.org/mongo-driver/mongo" ) // DB is the core database interface type DB interface { Insert(ctx context.Context, collection string, doc interface{}) (interface{}, error) Find(ctx context.Context, collection string, filter map[string]in...
package fliters import ( "github.com/astaxie/beego" "github.com/astaxie/beego/context" "tesou.io/platform/brush-parent/brush-api/common/base" ) func init() { beego.InsertFilter("*", beego.BeforeStatic, BeforeStatic, false) beego.InsertFilter("*", beego.BeforeRouter, BeforeRouter) beego.InsertFilter("*", beego.B...
/* nighthawk.nhstruct.agentevents.go * * DataStructure for Agent Events */ package nhstruct type ItemDetail struct { Name string `xml:"name"` Value string `xml:"value"` } type AgentEventItem struct { Timestamp string `xml:"timestamp"` EventType string `xml:"eventType"` Details []ItemDetail `xml...
// ------------------------------------------------------------------- // // salter: Tool for bootstrap salt clusters in EC2 // // Copyright (c) 2013-2014 Orchestrate, Inc. All Rights Reserved. // // This file is provided to you under the Apache License, // Version 2.0 (the "License"); you may not use this file // exce...
package tsrv import ( "encoding/xml" "github.com/thought-machine/finance-messaging/iso20022" ) type Document01100101 struct { XMLName xml.Name `xml:"urn:iso:std:iso:20022:tech:xsd:tsrv.011.001.01 Document"` Message *UndertakingNonExtensionNotificationV01 `xml:"UdrtkgNonXtnsnNtfctn"...
package main import "fmt" func main() { var grades [3]float64 fmt.Println(grades) grades[0], grades[1], grades[2] = 7.8, 4.3, 9.1 fmt.Println(grades) total := 0.0 for i := 0; i < len(grades); i++ { total += grades[i] } average := total / float64(len(grades)) fmt.Printf("Average %.2f\n", average) }
// Copyright 2014 William H. St. Clair // 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 cassandraconnection import "github.com/gocql/gocql" func GetConnection() ( *gocql.Session, error){ // connect to the cluster cluster := gocql.NewCluster("10.47.2.151", "10.47.2.8", "10.47.2.1") cluster.Keyspace = "example" cluster.Consistency = gocql.Quorum session, err := cluster.CreateSession() return...
package delay import ( "strconv" "github.com/coredns/coredns/core/dnsserver" "github.com/coredns/coredns/plugin" "github.com/coredns/coredns/plugin/metrics" "github.com/caddyserver/caddy" ) // init registers this plugin. func init() { plugin.Register("delay", setup) } // setup is the function that gets called...
package model import ( "errors" "strings" validator "gopkg.in/go-playground/validator.v9" "github.com/jinzhu/gorm" "golang.org/x/crypto/bcrypt" ) // User xxx type User struct { gorm.Model Name string `validate:"required,max=50" gorm:"type:varchar(50)"` Email string `validate:"...
package functions import ( "errors" "go/ast" "go/parser" "go/token" "io" "net/http" "strings" ) func GetFunction(id string) (function struct{ Name string GoPackageName string Inputs []struct{ Name string Type string } Outputs []struct{ Name string Type string } }, err error) { filepath := id+".g...
package main import ( "fmt" "strings" ) func findWords(words []string) []string { var result []string letters := []string{"asdfghjkl", "qwertyuiop", "zxcvbnm"} for i := 0; i < len(words); i++ { for num := range letters { str := letters[num] count := 0 for index := range words[i] { temp_str := st...
package rdf import () import "testing" // Test goraptor term to string func TestTermStr(t *testing.T) { val := "some value" if val != termStr(literal(val)) { t.Fail() } if val != termStr(uri(val)) { t.Fail() } if val != termStr(blank(val)) { t.Fail() } }
/* # -*- coding: utf-8 -*- # @Author : joker # @Time : 2021/12/27 9:00 上午 # @File : lt_36_有效的数独.go # @Description : # @Attention : */ package hot100 // 关键: // 根据题意: 一行数字不可以相同,一列数字也不可以相同,斜线也不可以相同 // 一次遍历+ 子盒子的下标计算为 i/3,j/3 func isValidSudoku(board [][]byte) bool { var ( // 代表的是,9行,每行的9个元素的次数 rows [9][9]int // 代表...
package content_test import ( "bytes" "github.com/sundogrd/content-api/services/content" "github.com/sundogrd/content-api/utils/config" "github.com/sundogrd/content-api/utils/db" "context" "github.com/spf13/viper" "testing" ) func initTestDB() error { config.Init() viper.SetConfigType("json") // or viper.Set...
package main import "testing" func TestRaw(t *testing.T) { raw() }
package factoryreset import ( "os" "path/filepath" "github.com/rancher-sandbox/rancher-desktop/src/go/rdctl/pkg/autostart" "github.com/rancher-sandbox/rancher-desktop/src/go/rdctl/pkg/paths" "github.com/sirupsen/logrus" ) func DeleteData(paths paths.Paths, removeKubernetesCache bool) error { if err := autostar...