text
stringlengths
11
4.05M
package openstack import ( "os" "github.com/sirupsen/logrus" "k8s.io/apimachinery/pkg/util/validation/field" "github.com/openshift/installer/pkg/asset/installconfig/openstack/validation" "github.com/openshift/installer/pkg/types" "github.com/openshift/installer/pkg/types/openstack" openstackdefaults "github.c...
package test import ( "container/list" "fmt" "math/rand" "time" ) type Road struct { name string //每条道路都有一个名字 S2N.. vechicles list.List //道路上的车辆集合 } func (this *Road) Init(name string) { this.name = name //每隔一段时间道路上就添加一辆车 go func() { rand.Seed(time.Now().UnixNano()) for i := 1; i < 1000; i++ { ...
/* If the numbers 1 to 5 are written out in words: one, two, three, four, five, then there are 3 + 3 + 5 + 4 + 4 = 19 letters used in total. If all the numbers from 1 to 1000 (one thousand) inclusive were written out in words, how many letters would be used? NOTE: Do not count spaces or hyphens. For example, 342 (th...
package parser import ( "bufio" "bytes" "encoding/base64" "encoding/binary" "github.com/limechain/hedera-state-proof-verifier-go/internal/constants" "github.com/limechain/hedera-state-proof-verifier-go/internal/errors" "github.com/limechain/hedera-state-proof-verifier-go/internal/types" ) func ParseRecordFile(...
package main import ( "os" "image" "image/png" "image/color" ) type Pixel struct { R int G int B int A int } func rgbaToPixel(r uint32, g uint32, b uint32, a uint32) Pixel { return Pixel{ scale(r, 65535, 0, 255, 0), scale(g, 65535, 0, 255, 0), scale(b, 65535,...
package main import "fmt" func main() { //简单类型 var b byte var i int var ss string fmt.Printf(" byte: %v \n int: %v \n string: %v \n", b, i, ss) // 复杂类型 /* Types which zero values can be represented with nil The zero values of the following types can be represented with nil. Type (T) Size Of T(nil) ...
/***************************************************************** * Copyright©,2020-2022, email: 279197148@qq.com * Version: 1.0.0 * @Author: yangtxiang * @Date: 2020-08-03 10:33 * Description: *****************************************************************/ package netstream import ( "errors" "github.com/go-xe2...
package main import ( "fmt" "github.com/Horimotsu/PEGo/pe" "time" ) func main() { fmt.Println("Project Euler Problem 012") start := time.Now() fmt.Println("The answer is ", pe.Solve012()) end := time.Now() fmt.Printf("%f seconds\n", (end.Sub(start)).Seconds()) }
package main import ( "encoding/json" "errors" "github.com/BurntSushi/toml" "github.com/codegangsta/negroni" "github.com/gorilla/mux" "github.com/globalsign/mgo" // "github.com/globalsign/mgo/bson" // auth "github.com/nabeken/negroni-auth" "io" "log" "net/http" "os" // "strconv" "strings" ) type Databas...
package main import "github.com/gin-gonic/gin" type User struct { ID uint64 Name string } func main() { users := []User{{ID: 123, Name: "正经按摩的"}, {ID: 456, Name: "不长进干嘛"}} r := gin.Default() r.GET("/users", func(c *gin.Context) { c.JSON(200, users) }) r.Run(":8090") }
package commands import ( "github.com/spf13/cobra" "github.com/buildpacks/pack" "github.com/buildpacks/pack/internal/config" "github.com/buildpacks/pack/internal/style" "github.com/buildpacks/pack/logging" ) type BuildpackPullFlags struct { BuildpackRegistry string } func BuildpackPull(logger logging.Logger, ...
package lexer import "regexp" func isSpace(str string) bool { if str == "\n" || str == " " || str == "\t" { return true } return false } func isDigit(str string) bool { ok, _ := regexp.MatchString(`[0-9]+`, str) return ok } func isWord(str string) bool { ok, _ := regexp.MatchString(`[a-zA-Z]+`, str) return...
package main import ( "net/http" "net/http/cgi" ) func CgiHandler(config map[string]string) http.Handler { h := new(cgi.Handler) h.Path = mustGet(config, "path") h.Root = mustGet(config, "mount") h.Dir = tryGet(config, "dir", "") h.Args = getSlice(config, "args") h.Env = getSlice(config, "env") h.InheritEnv...
package main import "fmt" //* Definition for a binary tree node. type TreeNode struct { Val int Left *TreeNode Right *TreeNode } func constructMaximumBinaryTree(nums []int) *TreeNode { if len(nums) == 0 { return nil } left := 0 right := len(nums) - 1 return build(nums, left, right) } func build01(num...
package endpoints import ( "context" "encoding/json" "fmt" "net/http" "github.com/go-kit/kit/endpoint" kithttp "github.com/go-kit/kit/transport/http" "github.com/google/uuid" "github.com/sumelms/microservice-course/internal/matrix/domain" "github.com/sumelms/microservice-course/pkg/validator" ) type remove...
package tfrecord import ( "bytes" "os" "testing" ) func TestIO(t *testing.T) { records := []string{"Hello", "World!"} buf := &bytes.Buffer{} w := NewWriter(buf) for _, r := range records { n, err := w.Write([]byte(r)) if err != nil { t.Errorf("failed wrting %s, %v", r, err) } if n != len(r) { t....
package bukaaplikasi import ( "context" "github.com/mirzaakhena/danarisan/application/apperror" "github.com/mirzaakhena/danarisan/domain/service" "github.com/mirzaakhena/danarisan/usecase/bukaaplikasi/port" ) //go:generate mockery --dir port/ --name BukaAplikasiOutport -output mocks/ type bukaAplikasiInteractor ...
package v29 import ( "net" "github.com/giantswarm/apiextensions/pkg/clientset/versioned" "github.com/giantswarm/micrologger" "k8s.io/client-go/kubernetes" "sigs.k8s.io/cluster-api/pkg/client/clientset_generated/clientset" "github.com/giantswarm/aws-operator/client/aws" "github.com/giantswarm/aws-operator/serv...
package control import ( "encoding/json" "errors" "log" "os" "strconv" "strings" "sync" "time" "gerrit.o-ran-sc.org/r/ric-plt/sdlgo" "gerrit.o-ran-sc.org/r/ric-plt/xapp-frame/pkg/xapp" //"github.com/go-redis/redis" ) type Control struct { ranList []string //nodeB list eventCreat...
package bertymessenger import ( "context" "io" "strconv" "testing" "time" "berty.tech/berty/v2/go/internal/testutil" "berty.tech/berty/v2/go/pkg/bertyprotocol" "github.com/gogo/protobuf/proto" libp2p_mocknet "github.com/libp2p/go-libp2p/p2p/net/mock" "github.com/stretchr/testify/require" "go.uber.org/zap" ...
package x448 import ( "crypto/rand" "testing" "github.com/awnumar/memguard" "github.com/cloudflare/circl/dh/x448" "github.com/stretchr/testify/require" ) func TestX448(t *testing.T) { alicePrivate, err := memguard.NewBufferFromReader(rand.Reader, x448.Size) require.NoError(t, err) var aliceSecret x448.Key c...
package main import ( "context" "fmt" global "github.com/psinthorn/gostore/global/database" "go.mongodb.org/mongo-driver/bson" ) func main() { fmt.Println("Implement data generator") // Test connect to MongoDB database global.DB.Collection("laptop").InsertOne(context.Background(), bson.M{"name": "Dell"}) }
package e2e import ( "bytes" "context" "errors" "fmt" "net/http" "os" "os/exec" "regexp" "runtime" "strings" "syscall" "testing" "time" ) func AsyncCmdStart(cmd string, timeout time.Duration) (command *exec.Cmd, buffer *bytes.Buffer, ctx context.Context, cancel context.CancelFunc, err error) { if timeou...
/* _(underscore) in Golang is known as the Blank Identifier. Identifiers are the user-defined name of the program components used for the identification purpose. Golang has a special feature to define and use the unused variable using Blank Identifier. The real use of Blank Identifier comes when a function retur...
/* * @lc app=leetcode id=89 lang=golang * * [89] Gray Code */ func grayCode(n int) []int { if n == 0 { return []int{0} } ret := []int{0, 1} for i := 1; i < n; i++ { l := len(ret) for j := l - 1; j >= 0; j-- { ret = append(ret, ret[j]+1<<uint(i)) } } return ret }
/* Copyright 2018-2020 The Nori 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, soft...
package middleware import ( "git.dustess.com/mk-base/gin-ext/extend" "git.dustess.com/mk-training/mk-blog-svc/pkg/common" "git.dustess.com/mk-training/mk-blog-svc/pkg/user/dao" "git.dustess.com/mk-training/mk-blog-svc/pkg/user/model" "github.com/gin-gonic/gin" "strings" ) // Authorization 身份认证 func Authorizatio...
package main import ( "fmt" "strconv" ) func inputInt(msg string) (value string) { fmt.Println(msg) fmt.Scan(&value) return } func main() { var g int64 var err error for { g, err = strconv.ParseInt(inputInt("Enter integer number"), 10, 32) if err == nil{ break } } if g % 3 == 0 { fmt.Println("D...
package testdata import ( "github.com/taktakty/netlabi/models" ) var DeviceModelTestData = []models.DeviceModel{ { Name: "test name 1", Height: 1, Width: 100, Note: "test note 1", }, { Name: "test name 2", Height: 2, Width: 100, Note: "test note 2", }, { Name: "test name 3", Heig...
// DRUNKWATER TEMPLATE(add description and prototypes) // Question Title and Description on leetcode.com // Function Declaration and Function Prototypes on leetcode.com //657. Judge Route Circle //Initially, there is a Robot at position (0, 0). Given a sequence of its moves, judge if this robot makes a circle, which me...
package main import ( "context" pb "example/communication" "flag" "fmt" "log" "wtypes" "google.golang.org/grpc" ) // Define localhost address infomation const ( dstaddr = "127.0.0.1:6666" address = "127.0.0.1" defaultname = "client1" port = 8888 ) // set ip var ip = pb.IP{ Addr: address, ...
// 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...
// Copyright (c) 2020 Doc.ai and/or its affiliates. // // SPDX-License-Identifier: Apache-2.0 // // 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/LIC...
package envoy import ( "bytes" "crypto/sha256" "encoding/hex" "fmt" "hash" "io" "os" "path/filepath" "strings" "sync" "github.com/pomerium/pomerium/pkg/envoy/files" ) const ( ownerRX = os.FileMode(0o500) maxExpandedEnvoySize = 1 << 30 ) type hashReader struct { hash.Hash r io.Reader } f...
package semt import ( "encoding/xml" "github.com/thought-machine/finance-messaging/iso20022" ) type Document00300109 struct { XMLName xml.Name `xml:"urn:iso:std:iso:20022:tech:xsd:semt.003.001.09 Document"` Message *SecuritiesBalanceAccountingReportV09 `xml:"SctiesBalAcctgRpt"` } fu...
package basic import "fmt" func P1() { var a = 2 var pa = &a *pa = 3 fmt.Println(a) // 3 } func Swap(a, b int) (int, int) { b, a = a, b return b, a } func Swap2(a, b *int) { *b, *a = *a, *b }
package bitvector import ( "fmt" "math" ) // Len8 is a 8-bit vector type Len8 uint8 func (bv Len8) String() string { return fmt.Sprintf("%08b", bv) } // Clear bits from index i (included) to index j (excluded) func (bv Len8) Clear(i, j uint8) Len8 { if i > j { return bv } return (math.MaxUint8<<j | ((1 << i...
/* ###################################################################### # Author: (zfly1207@126.com) # Created Time: 2020-08-31 20:06:45 # File Name: main.go # Description: ####################################################################### */ // see: https://github.com/itbdw/ip-database/blob/master/src/IpLocati...
package api_test import ( . "cf/api" "cf/configuration" "cf/net" "encoding/base64" "fmt" . "github.com/onsi/ginkgo" . "github.com/onsi/gomega" "net/http" "net/http/httptest" testconfig "testhelpers/configuration" testnet "testhelpers/net" ) var _ = Describe("AuthenticationRepository", func() { It("TestSuc...
package main import "fmt" func main() { a := 5 func(a int) { a = 10 fmt.Println("HI") }(a) println(a) }
package main // 坐标结构体 type Node struct { x, y int } var dx []int // x变化向量 var dy []int // y变化向量 var hasBeenHandled map[int]bool // 用于 // BFS调用者 func orangesRotting(grid [][]int) int { /* 1. 确定搜索方向dx、dy */ dx = []int{0, 0, 1, -1} dy = []int{1, -1, 0, 0} hasBeenHandled = make(map[int]bool) goodOrangeCount :...
package calldiv_test import ( "testing" "github.com/b-2019-apt-test/divider/pkg/div/calldiv" "github.com/b-2019-apt-test/divider/pkg/div/divtest" ) func TestCasesCallDiv(t *testing.T) { divtest.Cases(t, calldiv.Divider) } func BenchmarkCallDiv(b *testing.B) { divtest.Benchmark(b, calldiv.Divider) } func Bench...
package pgsql import ( "database/sql" "database/sql/driver" "time" ) // TsRangeFromTimeArray2 returns a driver.Valuer that produces a PostgreSQL tsrange from the given Go [2]time.Time. func TsRangeFromTimeArray2(val [2]time.Time) driver.Valuer { return tsRangeFromTimeArray2{val: val} } // TsRangeToTimeArray2 ret...
package pg import ( "github.com/kyleconroy/sqlc/internal/sql/ast" ) type AlterOwnerStmt struct { ObjectType ObjectType Relation *RangeVar Object ast.Node Newowner *RoleSpec } func (n *AlterOwnerStmt) Pos() int { return 0 }
/** *@Author: haoxiongxiao *@Date: 2019/3/28 *@Description: CREATE GO FILE services */ package services import ( "bysj/models" "bysj/repositories" ) type FeedBackService struct { repo *repositories.FeedBackRepositories } func NewFeedBackService() *FeedBackService { return &FeedBackService{repo: repositories.New...
// Copyright 2019 Kuei-chun Chen. All rights reserved. package analytics import ( "time" "go.mongodb.org/mongo-driver/bson" ) // DocumentDoc contains db.serverStatus().document type DocumentDoc struct { Deleted int `json:"deleted" bson:"deleted"` Inserted int `json:"inserted" bson:"inserted"` Returned int `js...
package models import ( "github.com/astaxie/beego/orm" "time" ) func (a *FinancialProfit) TableName() string { return FinancialProfitTBName() } //查询的类 type FinancialProfitQueryParam struct { BaseQueryParam Name string `json:"name"` StartTime int64 `json:"startTime"` //开始时间 EndTime int64 `json:"endTim...
package efclient import ( "bytes" "encoding/json" "fmt" "log" "net/http" "sync" "time" "syreclabs.com/go/faker" "syreclabs.com/go/faker/locales" ) // User ... type User struct { ID int `json:"id"` Username string `json:"username"` Email string ...
package uuid import ( "os" uuid "github.com/nu7hatch/gouuid" "github.com/sapk/sca/pkg/model" log "github.com/sirupsen/logrus" "github.com/spf13/pflag" ) //ModuleID define the id of module const ModuleID = "UUID" var argUUID string //Module retrieve information form executing sca type Module struct { UUID str...
package main import ( "flag" "fmt" "log" "os" "os/signal" "path/filepath" "strconv" "strings" "syscall" "github.com/allan-simon/go-singleinstance" "github.com/dlasky/gotk3-layershell/layershell" "github.com/gotk3/gotk3/gdk" "github.com/gotk3/gotk3/glib" "github.com/gotk3/gotk3/gtk" ) const version = "0...
package pgsql // PostgreSQL `tsquery` read/write natively supported with: // `string` // `[]byte` type _ native
package comparisons import ( "instructions/base" "rtda" ) // IFEQ Branch if int comparison with zero succeeds /** if<cond>指令把操作数栈顶的int变量弹出,然后跟0进行比较, 满足条件则跳转。假设从栈顶弹出的变量是x,则指令执行跳转操 作的条件如下: ·ifeq : x==0 ·ifne : x!=0 ·iflt : x<0 ·ifle : x<=0·ifgt:x>0 ·ifge : x>=0 由于比较指令最终表现为跳转指令。故继承 base.BranchInstruction */ ...
// 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 applicable law or agreed to in writing...
/* Copyright 2019 Google Inc. Copyright 2019 The MayaData 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 https://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law...
package main import ( "fmt" "io/ioutil" "log" "net" ) // To run this program // Run 01_write first. It will act as server for this example // Then run this program func main() { conn, err := net.Dial("tcp", ":8080") if err != nil { log.Fatalln(err) } defer conn.Close() bs, err := ioutil.ReadAll(conn) if ...
package main import ( "fmt" "github.com/maurodelazeri/pusher-golang-wss/pusher" ) // Example Handler object type chanHandler struct{} func (o *chanHandler) HandleEvent(event pusher.Event) { fmt.Println("Handler: Got Event:", event.Channel, event.Event, event.Data) } // Example Handler function func eventHandler...
package problem0123 func maxProfit(prices []int) int { firstBuy := (int)(-10E5 - 1) firstSell := 0 secondBuy := (int)(-10E5 - 1) secondSell := 0 for _, curPrice := range prices { if firstBuy < -curPrice { firstBuy = -curPrice } if firstSell < firstBuy+curPrice { firstSell = firstBuy + curPrice } i...
package xhcrypt import ( "encoding/base64" "fmt" "testing" ) func TestAesConfig_Encrypt(t *testing.T) { plaintext := "LftuD3eBuJhRtEkAajk=" key := "uCd85n9kEOmQf11s+9SShdxzMSDnGqt7ojZPGo0w3nY=" oldKeys := make(map[string][]byte) if err := Init("=hehui", []byte(key), oldKeys); err != nil { fmt.Println(err.Er...
package ghosts type Poltergeist struct { } func (p Poltergeist) Name() string { return "Poltergeist" } func (p Poltergeist) Evidence() [3]string { return [3]string{"Orbs", "Spirit Box", "Fingerprints"} }
package main import ( "fmt" "os" "strings" ) type input []string func (r input) reverse() { strInput := strings.Join(r[:], " ") sLen := len(strInput) revStr := make([]rune, sLen) for i, v := range strInput { revStr[sLen-(i+1)] = v } fmt.Printf("%s", string(revStr)) } func main() { word := input(os.Args[...
package main import "github.com/prometheus/client_golang/prometheus" var ( AuditConnectionEventCounter = prometheus.NewCounterVec( prometheus.CounterOpts{ Namespace: "tidb", Subsystem: "audit", Name: "audit_connection_event", Help: "Counter of audit connection event", }, []string{"event"}) ...
package monster import "testing" //monster.Store()测试用例 func TestStore(t *testing.T) { monster := &Monster{ Name: "zcr", Age: 10, Skill: "kill", } err := monster.Store() if err != true { t.Fatalf("monster.Store()测试不通过") } t.Logf("monster.Store()没问题,测试通过") } //monster.ReStore测试用例 func TestReStore(t *te...
// Copyright 2021 BoCloud // // 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 wri...
package mysql import ( "github.com/ttacon/chalk" "log" "mix/core/helper" "mix/core/logger" "mix/core/storage" ) func Sync(conn, ymlPath string) (err error) { db, err := NewMySQL(conn) if err != nil { logger.Error("Connect error:", err) return } onlineTables, err := db.GetTables() if err != nil { ret...
package account type TransactionKind = byte const ( DEPOSIT TransactionKind = iota + 1 WITHDRAW ) type Transaction struct { Kind TransactionKind Amt float64 }
package actions import ( "fmt" "net/http" "strconv" "time" "github.com/gobuffalo/buffalo" "github.com/gobuffalo/envy" "github.com/gobuffalo/pop/v5" "github.com/gobuffalo/x/responder" ) type userDistanceData struct { UserID string `json:"user_id" db:"user_id"` User string `json:"user" db:"user"` Dist...
package gcp import ( "context" "net/url" "testing" "time" "github.com/stretchr/testify/suite" ) var ( mod = []byte{1, 2, 3} zip = []byte{4, 5, 6} info = []byte{7, 8, 9} ) type GcpTests struct { suite.Suite context context.Context module string version string store *Storage url *url.URL bucke...
package compress import ( "compress/flate" "io" "sync" ) type FlateWriterPool struct { level int pool *sync.Pool } func NewFlateWriterPool(level int) *FlateWriterPool { return &FlateWriterPool{level: level, pool: &sync.Pool{}} } func (wp *FlateWriterPool) Get(w io.Writer) *flate.Writer { v := wp.pool.Get() ...
package main import ( "fmt" "os" "path/filepath" "time" ) var about = "" func init() { about = "List all files in a folder." } func main() { fmt.Println(about) var files []string processfolder := "d:/DelMe100/" err := filepath.Walk(processfolder, func(path string, info os.FileInfo, err error) error { //...
package module import ( "laravel-go/app/service/demo/module" "laravel-go/pkg/libs" "strconv" "github.com/labstack/echo/v4" ) type ModuleController struct{} func NewModuleController() *ModuleController { return &ModuleController{} } func (m *ModuleController) Find(c echo.Context) error { id, _ := strconv.Ato...
/* Caryatid build script Goals: - Build single-platform binaries - Build separate binaries for each supported architecture - Assemble zipfiles for each supported architecture for release Run with "go run scripts/buildrelease.go" */ package main import ( "archive/zip" "bytes" "flag" "fmt" "io" "io/ioutil" "lo...
package ldap import ( "crypto/tls" "errors" "fmt" "log" "net/url" "strconv" "time" "github.com/go-ldap/ldap" . "github.com/wealthworks/go-debug" "github.com/liut/staffio/pkg/models" ) // Basic LDAP authentication service type ldapSource struct { Addr string // LDAP address with host and port U...
package console import ( "os" "github.com/danielchatfield/go-console/logentry" ) // Status represents the status of the task type Status int // The Status constants const ( SUCCESS Status = iota WARNING FAILURE ) var ( console = NewConsole() ) // Console is the interface that wraps the basic logging functio...
package main import "fmt" func main() { test := "abbz" //letter := 0 final := "" for _, x := range test { if (x == 90){ final += string(65) continue } if(x == 122){ final += string(97) continue } final += string(x + 1) /...
// 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...
/* * @lc app=leetcode.cn id=852 lang=golang * * [852] 山脉数组的峰顶索引 */ package main // @lc code=start func peakIndexInMountainArray(arr []int) int { for i := 1; i < len(arr); i++ { if arr[i] < arr[i-1] { return i - 1 } } return -1 } // func main() { // fmt.Println(peakIndexInMountainArray([]int{0, 1, 0})) /...
package configure /* import ( "io/ioutil" "os" "testing" "github.com/devspace-cloud/devspace/pkg/devspace/config/loader" "github.com/devspace-cloud/devspace/pkg/devspace/config/versions/latest" "github.com/devspace-cloud/devspace/pkg/util/log" "gotest.tools/assert" ) type addSyncPathTestCase struct { name s...
package models type Photo struct { BaseModel URL string `gorm:"not null" json:"url"` Path string `json:"-"` }
package widget import ( "image" "gioui.org/gesture" "gioui.org/io/pointer" "gioui.org/layout" "gioui.org/op" ) // Range is for selecting a range. type Range struct { Values []float32 dragIndex int drag gesture.Drag action rangeAction pos float32 changed bool } type rangeAction uint8 const ( ran...
package authorization import ( "regexp" "testing" "github.com/stretchr/testify/assert" ) func TestRegexpGroupStringSubjectMatcher_IsMatch(t *testing.T) { testCases := []struct { name string have *RegexpGroupStringSubjectMatcher input string subject Subject expected bool }{ { "Abc", ...
package datastore import ( "Go-Ground-Station/constants" "fmt" "rloop/Go-Ground-Station/gsgrpc" "rloop/Go-Ground-Station/gstypes" "runtime" "strings" "sync" "time" ) type DataStoreManager struct { isRunningMutex sync.RWMutex isRunning bool doRunMutex sync.RWMutex doRun ...
package main import ( "fmt" "net" "time" "github.com/mailway-app/config" "github.com/pkg/errors" ) func runPreflightChecks() error { port := config.CurrConfig.PortFrontlineSMTP if ok, _ := testPort(port); !ok { return errors.Errorf("port %d appears to be blocked", port) } return nil } func testPort(port...
package 背包问题 // ---------------------- 01背包问题 ---------------------- // 执行用时:0 ms, 在所有 Go 提交中击败了 100.00% 的用户 // 内存消耗:2.3 MB, 在所有 Go 提交中击败了 100.00% 的用户 func lastStoneWeightII(stones []int) int { canForm := getRelationOfCanForm(stones) weightOfAllStone := getSum(stones) maxOffsetWeight := 2 * getCanFormNumNearestA...
// Copyright 2019 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 in wr...
package main import ( "bufio" "fmt" "os" ) const filePath = "./input.txt" func countParens(input string) int { ct := 0 for _, c := range input { if c == '(' { ct++ } else if c == ')' { ct-- } else { //do nothing on invalid char } } return ct } func enterBasement(input string) int { ct := 0 ...
package sqlbuilder import ( "database/sql/driver" "fmt" "io" "reflect" "sort" "strings" ) const ( // Portable true/false literals. sqlTrue = "(1=1)" sqlFalse = "(1=0)" ) type expr struct { sql string args []interface{} } func Expr(sql string, args ...interface{}) expr { return expr{sql: sql, args: arg...
package day2 import ( "strconv" "strings" "github.com/littleajax/adventofcode/helpers" ) type passwordRules struct { Password string Char rune Min int Max int } func ProcessInputs() []passwordRules { values := helpers.FetchInputs("./inputs/day2.txt") inputs := []passwordRules{} for _, value...
// Copyright (C) 2015 Scaleway. All rights reserved. // Use of this source code is governed by a MIT-style // license that can be found in the LICENSE.md file. package cli import ( "fmt" "github.com/scaleway/scaleway-cli/pkg/commands" ) var cmdLogin = &Command{ Exec: runLogin, UsageLine: "login [OPTION...
package config import ( "github.com/aquinofb/location_service/controllers" "github.com/gin-gonic/gin" ) func Router() *gin.Engine { gin.SetMode(gin.ReleaseMode) router := gin.Default() router.GET("/", controllers.HomeIndex) api := router.Group("/api") { api.GET("/places", controllers.PlacesIndex) api.GE...
package main /* #cgo LDFLAGS: -lluajit-5.1 #include <stdlib.h> #include <stdio.h> #include <luajit-2.0/lua.h> #include <luajit-2.0/lualib.h> #include <luajit-2.0/lauxlib.h> int my_func() { printf("Hello from the C preamble!\n"); return 0; } */ import "C" import ( "fmt" "os" "unsafe" ) const src = ` local ff...
package schema import ( "github.com/facebook/ent/dialect" "github.com/facebook/ent" "github.com/facebook/ent/schema/field" ) // UserInfo holds the schema definition for the UserInfo entity. type UserInfo struct { ent.Schema } // Mixin of the UserInfo. func (UserInfo) Mixin() []ent.Mixin { return []ent.Mixin{} ...
package conexionBD import ( "time" "github.com/jinzhu/gorm" _ "github.com/jinzhu/gorm/dialects/postgres" "github.com/xubio-inc/sueldos-lib-framework/configuracion" ) func ConnectBD(tenant string) *gorm.DB { var db *gorm.DB var err error configuracion := configuracion.GetInstance() db, err = gorm.Open("post...
package lib import ( "fmt" "testing" ) type UrlIds struct { Url string Id int } type UrlHosts struct { Url string Host string } func TestGetArticleId(t *testing.T) { t.Log("Testing the parsing of article IDs from urls") testCases := []UrlIds{{ "http://www.freep.com/story/money/2015/09/16/uaw-fca-showdo...
package cmd import ( "context" "fmt" "path/filepath" "github.com/spf13/cobra" "github.com/superfly/flyctl/cmdctx" "github.com/superfly/flyctl/flyctl" "github.com/superfly/flyctl/internal/buildinfo" "github.com/superfly/flyctl/internal/client" "github.com/superfly/flyctl/internal/update" "github.com/superfl...
// 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 main import ( "fmt" "log" "math" "regexp" "strconv" ) func mult(nums ...int) int { prod := 1 for _, n := range nums { prod *= n } return prod } type Tile struct { dim []int id int bfield [][]bool field []string original []string sides []int permstate int } func (t ...
package main import ( "errors" "github.com/gorilla/websocket" ) type Client interface { getConn() *websocket.Conn } func ClientWriteText(client Client, data []byte) error { return client.getConn().WriteMessage(websocket.TextMessage, data) } func ClientWriteJSON(client Client, data interface{}) error { return c...
package rakuten type TravelService service
package persistence import ( "time" "github.com/steotia/go-analytics-crypto-api/marketdata" ) type MarketPairDoc struct { Hour time.Time `bson:"hour"` MarketPair string `bson:"market_pair"` Minutes map[string]marketdata.MarketData `bson:"minutes"` }
package main func main() { println(foo()) x, y := bar() println(x) println(y) } func foo() int { return 42 } func bar() (int, string) { return 43, "hello" }