text
stringlengths
11
4.05M
package mysocks5 import ( "bufio" "fmt" "io" "log" "net" "os" ) const ( socks5Version = uint8(5) noAuth = uint8(0) ) var key = []byte("dengzhicong12345") // Config is used to setup and configure a Server type Config struct { // BindIP is used for bind or udp associate BindIP net.IP Logger *log.Log...
package dfs import ( "testing" "github.com/arberiii/Graph-Algorithms/graph" ) func TestDFS(t *testing.T) { g := graph.NewGraph() g = map[int][]int{ 0: {1, 2, 3}, 1: {0, 4}, 2: {0, 3, 4}, 3: {0, 2, 6, 7}, 4: {1, 2, 8}, 5: {2, 8}, 6: {3, 9, 10}, 7: {3, 10}, 8: {4, 5}, 9: {6, 10}, 10...
package main func (v *vertex) addEdge(label string, weight int) { if v.edges == nil { v.edges = make(map[string]int) } elem, ok := v.edges[label] if ok { if weight < elem { v.edges[label] = weight } } else { v.edges[label] = weight } } func (v *vertex) importEdges(u *vertex) { for key, val := range ...
/* Copyright 2022 The Skaffold Authors Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, sof...
package Happy_Number import ( "github.com/stretchr/testify/assert" "testing" ) func TestHappy(t *testing.T) { ast := assert.New(t) ast.Equal(isHappy(19), true) ast.Equal(isHappy(1), true) ast.Equal(isHappy(2), false) ast.Equal(isHappy(0), false) }
package apis import ( . "background/models" "github.com/gin-gonic/gin" "net/http" ) func IndexApi(c *gin.Context) { c.String(http.StatusOK, "It works") } // LoginApi // Path:login // Input: ID, password // OutPut(JSON): // result:boolean // (表示账户密码是否输入正确) // type:int // (表示该用户是否为学生,1为学生,0为老师) func Logi...
// Copyright 2020 The Cockroach Authors. // // Use of this software is governed by the Business Source License // included in the file licenses/BSL.txt. // // As of the Change Date specified in that file, in accordance with // the Business Source License, use of this software will be governed // by the Apache License, ...
package day8 import "fmt" type Image struct { Layers []*Layer Rows int Cols int Decoded [][]int } type Layer struct { Rows []*ImageRow } type ImageRow struct { Pixels []int } func (layer *Layer) Pixels() (res []int) { for _, row := range layer.Rows { for _, p := range row.Pixels { res = append(res, p) ...
package main import "fmt" func main() { input := [][]int{{4, 3, 1}, {3, 2, 4}, {3}, {4}, {}} resList := allPathsSourceTarget(input) fmt.Println(resList) } func allPathsSourceTarget(graph [][]int) [][]int { nodeNum := len(graph) visited := make([][]int, nodeNum) for i := 0; i < nodeNum; i++ { visited[i] = mak...
package main import ( "fmt" "sort" "sync" ) var wg sync.WaitGroup func main() { subArray := sortArray([]int{2, 7, 1, 3, 4, 5, 9, 14, 19}) sort.Ints(subArray) // built-in go method to sort array of integers fmt.Println(subArray) } func sortSubArray(arr []int) []int { sort.Ints(arr) // built-in go method to so...
package model type PeiData struct { Class string `json:"class" form:"class"` Total int `json:"total" form:"total"` } type LineData struct { Month string `json:"month" form:"month"` Total int `json:"total" form:"total"` }
package queue import ( "runtime" "testing" ) func TestRing(t *testing.T) { r := NewRing() r.Append(1) r.Append(2) assert(t, 2, r.cap) assert(t, 2, r.Len()) assert(t, 0, r.head) assert(t, 1, r.tail) r.Append(3) assert(t, 4, r.cap) assert(t, r.Len(), 3) assert(t, 0, r.head) assert(t, 2, r.tail) r.Append...
package gore import ( "fmt" "sync" "time" ) // Message is a nofitication from a subscribed channel or pchannel type Message struct { // message or pmessage Type string // The channel/pchannel the client subscribed to. For example: "test", "te*" Channel string // The channel that publisher published to. For ex...
package apply import ( "encoding/json" "os" "github.com/rancher/fleet/integrationtests/cli" "github.com/rancher/fleet/internal/cmd/cli/apply" fleet "github.com/rancher/fleet/pkg/apis/fleet.cattle.io/v1alpha1" . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" "github.com/onsi/gomega/gbytes" ) var _ = ...
package minicon // // Helper to write left-to-right, bottom-to-top within a specified bounds. // type CursorRegion struct { x, y CursorWidth } // Define a new valid region for a cursor passing starting x, starting y, and the region bounds. func (this *CursorRegion) Reset(x, y, left, top, width, height int) { this.x...
// Copyright 2019 The ChromiumOS Authors // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. package firmware import ( "context" "io/ioutil" "path/filepath" "regexp" "chromiumos/tast/common/testexec" "chromiumos/tast/shutil" "chromiumos/tast/testing" ) func...
// Copyright 2020 Comcast Cable Communications Management, 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 // // http://www.apache.org/licenses/LICENSE-2.0 // // Unless required ...
package main //Valid //Checks the Resolved type of expression to valiadte increament and decreamenet operations func f () { type num int type num2 num var a0 int var a1 num var a2 num2 a0++ a1++ a2++ }
package model type Page struct { Links []string }
package main import ( "flag" "fmt" "io" "os" "os/exec" "time" "github.com/thejerf/afibmon/heartmon" "github.com/thejerf/afibmon/heartmon/beatalyse" ) var chunkSize = flag.Int("chunksize", 512, "size of chunks to process") var analysis = flag.String("analysis", "freq_and_amp", "analysis to perform") func ma...
func isValid(s string) bool { var stack []rune stackSize := 0 for _, char := range s { switch char { case '(': fallthrough case '{': fallthrough case '[': stack = append(stack, char) stackSize++ break case ')...
package config import ( "github.com/Sirupsen/logrus" "io/ioutil" "github.com/ghodss/yaml" ) var Config []Task type Task struct { Name string `json:"name"` Src GitInfo `json:"src"` Dest GitInfo `json:"dest"` Clean bool `json:"clean"` } type GitInfo struct { Dir string `json:"dir"` } func Load(paths []string...
package main import "fmt" func main() { var a int var b int var c int fmt.Scan(&a, &b, &c) if a > c { tmp := a a = c c = tmp } if a > b { tmp := a a = b b = tmp } if b > c { tmp := b b = c c = tmp } fmt.Println(a, b, c) }
package proxy import ( "context" "fmt" "github.com/google/tcpproxy" "k8s.io/api/core/v1" "log" "strings" "sync" "time" ) func Run() { var p tcpproxy.Proxy p.AddHTTPHostRoute(":80", "foo.com", tcpproxy.To("10.0.0.1:8081")) p.AddHTTPHostRoute(":80", "bar.com", tcpproxy.To("10.0.0.2:8082")) p.AddRoute(":80",...
package templates import ( "encoding/base64" "fmt" "reflect" "testing" ) func TestBase64Encode(t *testing.T) { var tests = []struct { para interface{} expect string err string }{ { para: 1, expect: "1", }, { para: float32(3.14), expect: "3.14", }, { para: float64(3.14...
package handler import ( "github.com/caos/logging" "github.com/caos/zitadel/internal/eventstore/models" es_models "github.com/caos/zitadel/internal/eventstore/models" "github.com/caos/zitadel/internal/eventstore/spooler" "github.com/caos/zitadel/internal/org/repository/eventsourcing/model" org_model "github.com...
package outer import ( "net" "sync" "github.com/qyqx233/go-tunel/lib" "github.com/qyqx233/go-tunel/lib/file" ) var dw *file.DumpWriter func init() { dw = file.NewDumpWriter("dump.bin") } func writeLog(c net.Conn, data []byte) { dw.Write(data) } func pipeSocketWithLog(wg *sync.WaitGroup, wc, wt lib.WrapConnS...
// Copyright 2022 The ChromiumOS Authors // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. // Package cursive contains common functions used in the Cursive app. package cursive import ( "context" "chromiumos/tast/errors" "chromiumos/tast/local/chrome" "chromi...
// 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 tstest import ( "bytes" "fmt" "log" "os" "sync" "testing" "go4.org/mem" "tailscale.com/types/logger" ) type testLogWriter struct ...
package logs import ( "context" "fmt" "io" "os" "strings" kit "shylinux.com/x/toolkits" "shylinux.com/x/toolkits/conf" "shylinux.com/x/toolkits/file" ) type Any = interface{} const ( INFO = "info" WARN = "warn" ERROR = "error" DEBUG = "debug" SHOW = "show" COST = "cost" ) const LOG = "log" type ...
package main import ( "WheelhouseBE/handlers" "database/sql" "encoding/json" "flag" "fmt" "log" "net/http" "os" "time" "github.com/alexedwards/scs/v2" "github.com/go-chi/chi" "github.com/go-chi/chi/middleware" "github.com/go-chi/cors" "github.com/go-chi/docgen" "github.com/go-chi/render" _ "github.com...
package projectmanagement import ( "alauda.io/devops-apiserver/pkg/apis/devops/v1alpha1" devopsclient "alauda.io/devops-apiserver/pkg/client/clientset/versioned" "alauda.io/diablo/src/backend/api" "k8s.io/apimachinery/pkg/apis/meta/v1" ) func GetProjectManagement(client devopsclient.Interface, name string) (*v1al...
package user // This file was generated by the swagger tool. // Editing this file might prove futile when you re-run the generate command import ( "net/http" "github.com/go-swagger/go-swagger/httpkit/middleware" ) // LogoutUserHandlerFunc turns a function with the right signature into a logout user handler type L...
/* Copyright 2023 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 asset import ( "github.com/go-xiaohei/pucore/app" "github.com/go-xiaohei/pucore/core" "github.com/lunny/tango" ) const ( STATIC_PREFIX string = "/static" STATIC_DIR string = "static" ) type Module struct { } func (tm *Module) Id() string { return "ASSET" } func (tm *Module) Prepare(ctx *pucore.Mod...
package loggers import ( "time" log "github.com/sirupsen/logrus" ) // RateLogger logs messages but also accumulates the rate at which the // Log function is being called and adds that to the fields that are printed. // This is concurrent safe but may not make sense. Since it is storing global // state on the numbe...
package models import ( "github.com/jinzhu/gorm" "errors" "github.com/qowns8/sample-web/utils" "log" ) type Canvas struct { Id int `json:"id" gorm:"primary_key` Name string `json:"name"` Intro string `json:"intro"` Problem string `json: "problem"` Unique_value_propostion string `json: "unique_value_propostio...
package model type Post struct { Id string `json:"id,omitempty"` Mood string `json:"mood,omitempty"` }
package main import ( "github.com/bjatkin/golf-engine/golf" ) var g *golf.Engine func main() { g = golf.NewEngine(update, draw) g.LoadSprs(spriteSheet) g.LoadMap(mapData) g.LoadFlags(spriteFlags) initGame() g.Run() } func initGame() { // Pallet for the starting logo g.PalA(2) g.PalB(3) initEventHandle...
package vaultdb import ( "sync" ) // fanout is a fan-out notification multiplexer for channels. It receives a // notification on an input channel designated at creation time, and copies that // to all output channels added by AddReceiver. type fanout struct { input chan struct{} output []chan struct{} sync.Mute...
package odoo import ( "fmt" ) // CalendarEventType represents calendar.event.type model. type CalendarEventType struct { LastUpdate *Time `xmlrpc:"__last_update,omptempty"` CreateDate *Time `xmlrpc:"create_date,omptempty"` CreateUid *Many2One `xmlrpc:"create_uid,omptempty"` DisplayName *String `xml...
package main import ( "fmt" "log" "net/http" "time" "io/ioutil" "encoding/json" "go.mongodb.org/mongo-driver/mongo" "go.mongodb.org/mongo-driver/mongo/options" "go.mongodb.org/mongo-driver/bson" "go.mongodb.org/mongo-driver/bson/primitive" //uncomment code below for using ping //"go....
/* Copyright © 2020 Abhishek Singh Saini <abhi.taker20@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 o...
package fetcher import ( "crypto/tls" "crypto/x509" "errors" log "github.com/sirupsen/logrus" "github.com/weppos/publicsuffix-go/publicsuffix" "strconv" "time" ) type SiteCertProber interface { DaysLeft() int RefreshCertifAndGetDaysLeft() (int, error) IsSiteValid() bool Refresh() error GetConfig() Certifi...
package main import ( "encoding/json" "flag" "fmt" "io/ioutil" "log" "../NeatoBotLib" ) type configuration struct { MetaURL string `json:"URL"` EMail string `json:"eMail"` Password string `json:"password"` OAuth2Token string `json:"OAuth2Token"` } var conf configuration func main() { confFi...
package gameloop import ( "testing" ) //20 updates 5.25ms func BenchmarkLoop(b *testing.B) { l := NewLoop() for i := 1; i < 101; i++ { l.bunt.Add(uint32(i), Vector3{0, 0, 0}) } b.ResetTimer() for i := 0; i < b.N; i++ { for j := 1; j < 21; j++ { l.AddUpdate(uint32(j), Vector3{1, 1, 1}) ...
package http_message type ResponseInterface interface { GetStatusCode() WithStatus() GetReasonPhrase() }
/** 位图 1 字节的上限是 256,即 2^8 也就是同时可以表示 8 个数的二进制位 */ package bitmap type BitMap struct { bitnum int // 可存储的二进制位数 bytes []byte // 需要用到的字节 } func NewBitMap(num int) *BitMap { return &BitMap{ bitnum: num, bytes: make([]byte, num/8+1), // 这里在 8 的倍数时会多算一位,whatever } } func (bm *BitMap) Set(x int) { if x >= bm.b...
package main import ( "fmt" ) func main() { r := Rectangle{} r.NewRectangle(5, 20) fmt.Println(r.getArea()) } type Rectangle struct { weight int height int } //made mistake here //forgot pointer //func (r Rectangle) NewRectangle(w, h int) { func (r *Rectangle) NewRectangle(w, h int) { r.weight = w r.height ...
package parser import ( "encoding/csv" "fmt" "io" "os" "strings" "github.com/fedepaol/quiz/goquiz" ) // ParseFile parses a file and returns a quiz filled with questions. func ParseFile(filename string) (res quiz.Quiz, e error) { file, err := os.Open(filename) if err != nil { e = err return } return par...
package main import ( "encoding/json" "flag" "fmt" "log" "net" "net/http" "os" "strconv" "strings" "sync" "sync/atomic" "time" "github.com/gorilla/websocket" "github.com/corollari/neo-ws-pub-sub/neotx" "github.com/corollari/neo-ws-pub-sub/neotx/network" "github.com/corollari/neo-ws-pub-sub/neoutils" ...
package fakes import ( "sync" awselbv2 "github.com/aws/aws-sdk-go/service/elbv2" ) type LoadBalancersClient struct { DeleteLoadBalancerCall struct { sync.Mutex CallCount int Receives struct { DeleteLoadBalancerInput *awselbv2.DeleteLoadBalancerInput } Returns struct { DeleteLoadBalancerOutput *aw...
package rbac import ( "fmt" "time" //"errors" "encoding/json" "net/http" //"net/url" "io/ioutil" "strconv" "strings" m "cms_admin/admin/src/models" "github.com/astaxie/beego" "github.com/tealeg/xlsx" ) type OrderController struct { CommonController } type GoodsJson struct { GoodsId int64 Number ...
/* Purpose: This handles authenticating the client Written: 05.28.2013 By: Glenn Hancock <ghancock@nizex.com> URL: www.nizex.com The MIT License (MIT) Copyright (c) 2013 Nizex Inc. Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the ...
package main import ( _ "github.com/kyawmyintthein/golangRestfulAPISample/docs" "flag" "github.com/kyawmyintthein/golangRestfulAPISample/app" ) // @title App Name // @version 1.0 // @description App name documentation. // @contact.name API Support // @contact.email email address // @host localhost:3030 // @Base...
package easy func climbStairs(n int) int { res := make([]int, 2) res[0] = 1 res[1] = 2 for i := 2; i < n; i++ { res[i%2] = res[(i-1)%2] + res[(i-2)%2] } return res[(n-1)%2] }
package rest type Options map[string]string type RestResponse struct { Status int Locale Locale Error RestError Body interface{} options Options depth int } type Locale struct { Code string Name string } type RestError struct { Validation Validation Message []string } type Validation struct {...
package evaluator import ( "fmt" "strings" "../ast" "../object" "../token" ) var ( NULL = &object.Null{} TRUE = &object.Boolean{ Value: true, } FALSE = &object.Boolean{ Value: false, } ) // isError : func isError(obj object.Object) bool { if nil != obj { return object.ERROR_OBJECT == obj.Type() } ...
package client import ( "fmt" factProto "github.com/tamarakaufler/go-calculate-for-me/pb/fact/v1" "google.golang.org/grpc" ) type FactClient struct { factProto.FactServiceClient } func FactService(config Config) (*FactClient, error) { svc := fmt.Sprintf("%s:%d", config.Service, config.Port) conn, err := grpc...
// Copyright 2022 The ChromiumOS Authors // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. package arc import ( "context" "regexp" "strconv" "time" "chromiumos/tast/common/android/ui" "chromiumos/tast/common/perf" "chromiumos/tast/common/testexec" "chromi...
package flights import "time" // FlightLeg represents a single flight from an origin to a destination. // It does not represent airfare available for purchase, but a part of // such a trip, which may consist of one or more flights or other transit. type FlightLeg struct { FlightNumber string `json:"flight_number"...
package main import "fmt" func main() { var randomNumber, summ int for i := 0; i < 4; i += 1 { fmt.Println("Type the random number") fmt.Scan(&randomNumber) summ += randomNumber } fmt.Println(summ) }
// Copyright 2021 The gVisor Authors. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // // http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agree...
package main import ( "fmt" "os" apiclient "github.com/rockset/rockset-go-client" models "github.com/rockset/rockset-go-client/lib/go" ) func main() { apiKey := os.Getenv("ROCKSET_APIKEY") apiServer := os.Getenv("ROCKSET_APISERVER") // create the API client client := apiclient.Client(apiKey, apiServer) //...
// Copyright 2020 The Cockroach Authors. // // Use of this software is governed by the Business Source License // included in the file licenses/BSL.txt. // // As of the Change Date specified in that file, in accordance with // the Business Source License, use of this software will be governed // by the Apache License, ...
package main import ( "text/tabwriter" "os" "fmt" ) func t11() { w := tabwriter.NewWriter(os.Stdout, 0, 7, 11, '*', 0) defer w.Flush() fmt.Fprint(os.Stdout, "aa\tbb\n") fmt.Println("------------------") fmt.Fprint(w, "aa\tbb\n") } //aa bb //------------------ //aa***********bb func main() { t11() }
package e import ( "fmt" ) type Map map[string]interface{} type SmartError struct { Info string Cause error Args Map } func (e SmartError) Error() string { return fmt.Sprintf("%s (%s)", e.Info, e.Cause) } func (e SmartError) BottommostError() error { var err error = e for { if se, ok := err.(SmartError)...
package main import ( "fmt" ) func main() { response := "DEFAULT;SET:2,KIL:1,GET:12209,DTA:0,ORD:0,ZPR:0,QRY:0,LKS:0,LKF:0,CTN:5,DRD:89,DWT:9,NTW:4,NTR:15489,NBW:9,NBR:30986,NR0:0,NR1:0,NR2:0,NR3:0,TTW:0,TTR:0,TRB:0,TBW:0,TBR:0,TR0:0,TR1:0,TR2:0,TR3:0,TR4:0,TC0:0,TC1:0,TC2:0,TC3:0,TC4:0,ZTR:0,DFL:52,DFS:6,JFL:2,JF...
package services import ( "bytes" "crypto/tls" "fmt" "github.com/ChristophBe/weather-data-server/config" "html/template" "net" "net/mail" "net/smtp" ) type mailServiceImpl struct{} func (m mailServiceImpl) SendeTxtMail(to mail.Address, subject, messageContent string) error { headers, err := m.createHeader(t...
package main import ( "fmt" "github.com/cheekybits/genny/generic" ) // Item genseric item type Item generic.Type // BST type type BST struct { value int left *BST right *BST } // Insert insert a new bst node func (bst *BST) Insert(value int) { if value < bst.value { if bst.left == nil { newNode := BST{...
package xin import ( "strings" ) type astNode struct { isForm bool token token leaves []*astNode position } func (n astNode) String() string { if n.isForm { parts := make([]string, len(n.leaves)) for i, leaf := range n.leaves { parts[i] = leaf.String() } return "(" + strings.Join(parts, " ") + ")" ...
package v1alpha1 // Operator describes the location of a KUDO operator. type Operator struct { TypeMeta `yaml:",inline"` // Name of the operator. Name string `yaml:"name"` // GitSources are optional references to Git repositories. GitSources []GitSource `yaml:"gitSources,omitempty"` // Versions of the operato...
package pager import ( "encoding/binary" "fmt" "io" "strings" "github.com/pkg/errors" ) // DefaultPageSize is the default size for DB pages, in bytes. // // Note that was originally 1024, but was updated to 4096 in 2016: // https://www.sqlite.org/pgszchng2016.html var DefaultPageSize int64 = 4096 // SQLiteHead...
package udwRpc2 import ( "github.com/tachyon-protocol/udw/udwClose" "github.com/tachyon-protocol/udw/udwErr" "github.com/tachyon-protocol/udw/udwShm" "net" "sync" "time" ) type ClientReq struct { Addr string MaxOpenConnNum int MaxIdleTime time.Duration } type ClientHub struct { req ...
package model import ( mysqlConfig "GoPass/config/mysql" "GoPass/lib/helper" "GoPass/lib/mysql" "GoPass/lib/redis" "fmt" "github.com/jinzhu/gorm" ) var redisClient = redis.GetRedis() type Article struct { Id uint64 `json:"id"` Title string `gorm:...
package design import ( "bytes" "strings" "testing" "github.com/gregoryv/draw/types/date" "github.com/gregoryv/golden" ) func TestGanttAdjuster_At(t *testing.T) { task := NewTask("hepp") a := &GanttAdjuster{ start: date.String("20191001").Time(), // ie. diagram start task: task, } // start before start...
package Lecture01 //快速查找法 type Obj struct { intid []int } func (O *Obj) Init(N int) { for i := 0; i < N; i++ { O.intid = append(O.intid, i) } } //判断是否连通 func (O *Obj) Connect(p, q int) bool { return O.intid[p] == O.intid[q] } //连通两个节点 func (O *Obj) Union(p, q int) { pid := O.intid[p] qid := O.intid[q] for...
/* * Copyright (c) CERN 2016 * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in w...
package store import ( "context" "time" ) type Sleeper interface { // A cancelable Sleep(). Exits immediately if the context is canceled. Sleep(ctx context.Context, d time.Duration) } type sleeper struct{} func (s sleeper) Sleep(ctx context.Context, d time.Duration) { t := time.NewTimer(d) defer t.Stop() sel...
package steps import ( "errors" "fmt" survey "github.com/AlecAivazis/survey/v2" "github.com/lib/pq" s "github.com/pganalyze/collector/setup/state" "github.com/pganalyze/collector/setup/util" ) var EnsureSupportedLogLinePrefix = &s.Step{ ID: "li_ensure_supported_log_line_prefix", Kind: s.LogIn...
package accumulator import ( "testing" "time" ) func BenchmarkAtomic(b *testing.B) { c := NewInt64() for i := 0; i < b.N; i++ { c.Incr() } } func TestAtomic(t *testing.T) { c := NewInt64() for i := 0; i < 100; i++ { c.Incr() } if c.Flush() != 100 { t.Fail() } } func BenchmarkMutex(b *testing.B) { c...
// This file was generated by counterfeiter package fakes import ( "lib/marshal" "sync" ) type Marshaler struct { MarshalStub func(input interface{}) ([]byte, error) marshalMutex sync.RWMutex marshalArgsForCall []struct { input interface{} } marshalReturns struct { result1 []byte result2 err...
// Copyright (C) 2016-Present Pivotal Software, Inc. All rights reserved. // This program and the accompanying materials are made available under the terms of the 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 Licen...
package addstrings import ( "strings" "testing" ) func TestAddStrings(t *testing.T) { var num1, num2, result string num1 = "1" num2 = "23" result = addStrings(num1, num2) if strings.Compare(result, "24") != 0 { t.Errorf("Get %s, Expect 24", result) } num1 = "1" num2 = "9" result = addStrings(num1, num2...
package models //Error - HTTP Error Response type Error struct { Error string `json:"error"` Message string `json:"msg"` Code int16 `json:"code"` }
package sdf import "github.com/macroblock/sdf/pkg/event" type ( iInit interface { Init() } iCleanUp interface { CleanUp() } iUpdate interface { Update() } iRender interface { Render() } iHandleEvents interface { HandleEvent(ev event.IEvent) } // IElem - IElem interface { // Update(delta time....
package main import "fmt" func main() { fmt.Println("hello word") var mobil string = "BMW 2020" car,motor := "Honda" , "Beat" fmt.Println(car) fmt.Println(motor) fmt.Println(mobil) var newCars [4] string newCars[0] = "BMW" newCars[1] = "Toyota" newCars[2] = "Mitshubisi" newCars[3] = "Mercy" for i...
// Package ebs provides a concrete implementation of Mtest driver. package ebs import ( "fmt" "path/filepath" "github.com/Sirupsen/logrus" . "github.com/openebs/mtest/logging" ) const ( // Name of this Mtest Driver implementation // The name that this driver will be known by the outside world DRIVER_NAME = "e...
package main import ( "fmt" "login-signup/views" "net/http" // "blogapp/views" ) func main() { http.HandleFunc("/", views.IndexPage) fs := http.FileServer(http.Dir("./web/static")) http.HandleFunc("/login", views.LoginPage) http.HandleFunc("/register", views.RegisterPage) http.Handle("/static/", http.StripP...
package Router import ( controllers "Angel/Angel_Service_User/Controllers" "github.com/gin-gonic/gin" ) func Router() { // r := gin.New() r := gin.Default() r.POST("/adduser", controllers.Adduser) r.GET("/listuser", controllers.Listuser) // new r.Run(":8080") }
package db import ( "database/sql" "errors" "log" "os" "reflect" "strings" "github.com/google/uuid" ) const dbFile = "notes.db" var connections = make(map[string]*sql.DB) // Connect create a connection with the database file. // The function retuns the connection ID once properly created. ...
/* * Lean tool - hypothesis testing application * * https://github.com/MikaelLazarev/willie/ * Copyright (c) 2020. Mikhail Lazarev * */ package marketing import ( "context" "errors" "github.com/MikaelLazarev/willie/server/errors/sentry" response "github.com/MikaelLazarev/willie/server/handlers/responses" "...
package model // TableMeta 表元数据 type TableMeta struct { TableName string //表名 TableComment string //表注释 ModelName string //模型名称 ModelNameFirstLower string //模型名称首字母小写 BasePath string //路由 Fields []*FieldMeta // 所有字段 Queries ...
package recursion /* Calculate Fibonacci value iteratively n: 0 1 2 3 4 5 6 7 fib: 0 1 1 2 3 5 8 13 */ func FibonacciIterative(n int) int { if n == 0 || n == 1 { return n } n_2 := 0 n_1 := 1 var result int for i := 2; i <= n; i++ { result = n_2 + n_1 n_2 = n_1 n_1 = result } return result } func F...
package controllers import ( "net/http" "github.com/gin-gonic/gin" "github.com/mavajee/todo/models" ) type TodoController struct{} func (t TodoController) Index(c *gin.Context) { tm := models.CreateTodoManager() c.JSON(200, tm.All()) } func (t TodoController) Create(c *gin.Context) { tm := models.CreateTodo...
package tests import ( "math" "testing" ) /** * [8] String to Integer (atoi) * * Implement atoi which converts a string to an integer. * * The function first discards as many whitespace characters as necessary until the first non-whitespace character is found. Then, starting from this character, takes an optio...
package main import "fmt" import "strings" func main() { var names1 = []string{"Cello", "el", "Zhafran"} printMessage("Hola,", names1) var names2 = []string{"Qashwa", "Zhafira"} printMessage("Hello,", names2) } func printMessage(message string, arr []string) { // two parameters: message and slice arr var na...
/* Copyright 2019 Jagadish Nagarajaiah. 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 main import ( "fmt" "unsafe" ) type Args struct { num1 int num2 int } type Flag struct { num1 int16 num2 int32 } func main() { fmt.Println(unsafe.Sizeof(Args{})) fmt.Println(unsafe.Sizeof(Flag{})) fmt.Println(unsafe.Alignof(Args{})) fmt.Println(unsafe.Alignof(Flag{})) }
package main import "snmpsim-cli-manager/snmpsim/cmd" func main() { cmd.Execute() }