text
stringlengths
11
4.05M
/* Crie uma slice usando make que possa conter todos os estados do Brasil. Os estados: "Acre", "Alagoas", "Amapá", "Amazonas", "Bahia", "Ceará", "Espírito Santo", "Goiás", "Maranhão", "Mato Grosso", "Mato Grosso do Sul", "Minas Gerais", "Pará", "Paraíba", "Paraná", "Pernambuco", "Piauí", "Rio de Janeiro", "Rio Gran...
package bean import ( "log" "github.com/astaxie/beego/orm" "time" "fmt" pkgProto "crazyant.com/deadfat/pbd/hero" ) type ArenaLeaderboard struct { Uid uint32 `orm:"pk;column(uid)"` // 角色编号 Score uint32 `orm:"column(score)"` // 车间波次 Updated int64 `orm:"column(updated)"` //更新时间(当前时间) } func (self *Are...
package routes import ( "net/http" "github.com/gorilla/mux" "github.com/sylus/openparl/api" "github.com/sylus/openparl/auth" "github.com/urfave/negroni" ) // NewRoutes builds the routes for the api func NewRoutes(api *api.API) *mux.Router { mux := mux.NewRouter() // client static files mux.Handle("/", http...
package model import ( "github.com/ele828/higo/common" "github.com/ele828/higo/config" . "github.com/ele828/higo/error" "github.com/jinzhu/gorm" "log" "math" "strconv" "time" ) //------------------- ORM MODEL ---------------------// type Article struct { ID int Title string `sql:"size:255; ...
/* Copyright © 2020 NAME HERE <EMAIL ADDRESS> 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 writi...
package main import ( "flag" "fmt" "io/ioutil" "os" "path/filepath" "sync" "time" ) /* This application uses some of the previous concepts to calculate the size of a directory or a bunch of directories given as input. This version creates a new go routine for each call to walkDir. Since we do not know the n...
package loader import ( "encoding/csv" "io" "log" ) type ExperienceRow struct { CompanyName string `json:"company_name"` RoleTaken string `json:"role_taken"` YearStarted string `json:"year_started"` YearEnded string `json:"year_ended"` MonthStarted string `json:"month_started"` MonthEnded string `j...
package installer import ( installertypes "github.com/openshift/installer/pkg/types" vspheretypes "github.com/openshift/installer/pkg/types/vsphere" "github.com/pulumi/pulumi/sdk/v2/go/pulumi/config" ) // NewInstallConfig - create a install-config since the struct already // contains all the information we need fu...
package xhlog import ( "fmt" "testing" "time" ) func TestInit(t *testing.T) { logConf := LoggerConf{ Dir: "Z:\\Goland\\src\\gitee.com\\yongxue\\magicbox\\main\\logs", Prefix: "test", Level: "info", RotateSize: 1 * 1024 * 1024, } if err := Init(&logConf); err != nil { fmt.Println("dh lo...
package websocket type BroadcastInfo struct { userIds []int message interface{} }
package flag import ( "errors" goflag "flag" "strconv" "strings" ) // String map type stringMapValue_t map[string]string // NewStringMapValue returns a new go.Value from the specifed map. // If the specified map is nil, a new map[string]string is created func NewStringMapValue(m *map[string]string) goflag.Value ...
package utils import ( "fmt" "net/url" "strconv" "strings" "unicode" "github.com/valyala/fasthttp" ) // IsStringAbsURL checks a string can be parsed as a URL and that is IsAbs and if it can't it returns an error // describing why. func IsStringAbsURL(input string) (err error) { parsedURL, err := url.ParseRequ...
package main type JSONResponse struct { Games []JSONGameResponse `json:"games"` SummonerId uint32 } type JSONGameResponse struct { FellowPlayers []JSONPlayerResponse Stats JSONGameStatsResponse GameId uint64 CreateDate uint64 TeamId uint32 ChampionId uint32 GameMode string GameTyp...
// Copyright (c) OpenFaaS Author(s) 2018. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. package handlers import ( "net/http" "time" ) // MakeNotifierWrapper wraps a http.HandlerFunc in an interceptor to pass to HTTPNotifier func MakeNotif...
package cfg import ( "bytes" "io/ioutil" "os" "path/filepath" "testing" "github.com/stretchr/testify/assert" ) func TestNewConfig(t *testing.T) { cfg := NewConfig("test", "best-project", "docker-compose", "") assert.Equal(t, cfg.Version, "test") } func TestWriteFailed(t *testing.T) { cfg := NewConfig("test...
package cmd import ( "fmt" "strings" "gopkg.in/kyokomi/emoji.v1" "github.com/urfave/cli" ) func AddCmd() cli.Command { return cli.Command{ Name: "add", Aliases: []string{"a"}, Usage: "Add emoji commit message", Action: add, } } func add(c *cli.Context) error { e := scan("emoji", "") if len(e)...
//~7 //~-1 //~0 //~12 //~+7.000000e+000 //~-1.000000e+000 //~+7.500000e-001 //~+1.200000e+001 //~229 //~-1 //~0 //~13110 //~HelloWorld //~true package main func main() { var i1, i2 int var f1, f2 float64 var r1, r2 rune var s1, s2 string var b1, b2 bool i1, i2 = 3, 4 f1, f2 = 3.0, 4.0 r1, r2 = 'r', 's' b1,...
package main import ( "bufio" "encoding/json" "flag" "fmt" "io" "io/ioutil" "log" "os" "os/signal" "strings" "syscall" ) func main() { var debugFile string var logFile string var cmdsFile string var header Header stdFlagSet := flag.NewFlagSet(os.Args[0], flag.ExitOnError) stdFlagSet.StringVar(&debug...
package chain import ( "fmt" "os" "github.com/iotaledger/wasp/packages/hashing" "github.com/iotaledger/wasp/packages/kv/codec" "github.com/iotaledger/wasp/packages/kv/dict" "github.com/iotaledger/wasp/packages/sctransaction" "github.com/iotaledger/wasp/packages/vm/core/blob" "github.com/iotaledger/wasp/tools/...
func findMedianSortedArrays(nums1 []int, nums2 []int) float64 { l := len(nums1) + len(nums2) if l % 2 == 0{ return float64(findKth(nums1, nums2, l/2) + findKth(nums1, nums2, l/2-1)) / 2 } else { return float64(findKth(nums1, nums2, l/2)) } } func findKth(nums1 []int, nums2 []int, kth in...
package main // GeoQuadTree used for indexing GeoShapes type GeoQuadTree struct { FeatureCount int64 Root *GeoQuadTreeNode } // GeoQuadTreeNode used for holding data type GeoQuadTreeNode struct { Alpha *GeoQuadTreeNode // top right Beta *GeoQuadTreeNode // top left Gamma *GeoQuadTreeNode // bottom...
package health_check import ( "github.com/gorilla/mux" "user-event-store/app/endpoint/health_check/controller" ) func RegisterRoutes(router *mux.Router) { subRouter := router.PathPrefix("/health").Subrouter() subRouter.Methods("GET").HandlerFunc(controller.SendHeartbeat) }
package candevice import ( "encoding/json" "io/ioutil" "github.com/ghetzel/canibus/api" "github.com/ghetzel/canibus/logger" // "strconv" "time" ) const ( MAX_BUFFER = 10000 // Packets in buffer MAX_APPENDS = 1000 // Max packets returned at one time ) type Simulator struct { PacketFile string SimPacket...
// This utility decrypts the passwords that Windows EC2 instances generate. // // When starting a Windows VM on EC2, after some time an encrypted password is // written to the VM's log. The password is encrypted using the SSH public key // configured for that VM. The Amazon web interface can decrypt the password - // i...
/* # -*- coding: utf-8 -*- # @Author : joker # @Time : 2020-07-14 09:13 # @File : base.go # @Description : 链表核心知识点: 1. nil退出条件处理 2. dummy node 哑巴节点 3. 快慢指针 3.1 找到链表的中间节点 4. 链表插入 5. 链表删除 6. 反转链表 7. 合并链表 # @Attention : */ package list type ListNode struct { Val int Next *ListNode } // 给定一个排序链表,删除所有重复的元素,使...
package main import ( "github.com/joho/godotenv" "github.com/sharpvik/log-go/v2" "github.com/sharpvik/ava/configs" "github.com/sharpvik/ava/server" ) func init() { log.SetLevel(log.LevelDebug) if err := godotenv.Load(); err != nil { log.Error(err) } } func main() { config := configs.MustInit() log.Debug(...
package main import ( "fmt" "log" "os" "strings" ) func fatalln(args ...interface{}) { log.Fatalln(append([]interface{}{"ERROR:"}, args...)...) } func check(err error) { if err != nil { fatalln(err) } } func usage() string { lines := []string{ "Missing command, use one of:", fmt.Sprintf("\t%s diff ...
package kubekit import ( "time" "k8s.io/apimachinery/pkg/fields" "k8s.io/client-go/tools/cache" ) // ResyncPeriod is the delay between resync actions from the controller. This // can be overwritten at package level to define the ResyncPeriod for the // controller. var ResyncPeriod = 5 * time.Second // Watcher re...
// problem 10.5 package chapter10 import ( "container/heap" "fmt" ) func KThLargestElement(stream []int, k int) { h := make(IntHeap, 0) heap.Init(&h) for i := 0; i < k && i < len(stream); i++ { heap.Push(&h, stream[i]) fmt.Printf("kth largest after %d cycles: %d\n", i+1, h[0]) } for i := k; i < len(stream...
package trello type Board struct { Id string `json:"id"` Name string `json:"name"` Desc string `json:"desc"` DescData struct { Emoji struct { } `json:"emoji"` } `json:"descData"` Closed bool `json:"closed"` IdOrganization string `json:"idOrganization"` Invited bool `json:"i...
package validator import ( "testing" "github.com/stretchr/testify/suite" "github.com/authelia/authelia/v4/internal/configuration/schema" ) type Theme struct { suite.Suite config *schema.Configuration validator *schema.StructValidator } func (suite *Theme) SetupTest() { suite.validator = schema.NewStructV...
package uixt func (dExt *DriverExt) Drag(pathname string, toX, toY int, pressForDuration ...float64) (err error) { return dExt.DragFloat(pathname, float64(toX), float64(toY), pressForDuration...) } func (dExt *DriverExt) DragFloat(pathname string, toX, toY float64, pressForDuration ...float64) (err error) { return ...
package mocks import ( "bou.ke/monkey" "reflect" ) func InstanceMethod(target interface{}, methodName string, replacement interface{}) { monkey.PatchInstanceMethod(reflect.TypeOf(target), methodName, replacement) } func ResetMethod(target interface{}, method string) { monkey.UnpatchInstanceMethod(reflect.TypeOf(...
package odbcstream import ( "database/sql" "fmt" _"github.com/alexbrainman/odbc" ) // A pointer to an instance of the database var DBClient *sql.DB // Initializing variables for data source credentials var server, user, password, database string type Table struct { name string } // Initializes a connection to ...
func kthSmallest(matrix [][]int, k int) int { return sol1(matrix, k) } func sol1(matrix [][]int, k int) int { cursors := make([]int, len(matrix)) res := -1 for i := 0; i < k; i++ { next := 0 min := matrix[len(matrix)-1][len(matrix)-1] for j, n := range cursors { if n...
package client import ( "context" rn "roman/proto/roman" "time" ) type Repository struct { inputText string textAnalyzer *TextAnalyzer client *GrpcClient } func (r *Repository) SetInputText(inputText string) { r.inputText = inputText } func (r *Repository) GetInputText() string { return r.inputText...
package leetcode func solvePreorderTraversal(current *TreeNode, preorder []int, pos *int) { if current == nil { return } preorder[*pos] = current.Val *pos++ solvePreorderTraversal(current.Left, preorder, pos) solvePreorderTraversal(current.Right, preorder, pos) } func preorderTraversal(root *TreeNode) []int ...
package library2 import ( "github.com/lingdor/midlog" ) //var LogModule midlog.Module = "library2" //var Logger midlog.New(LogModule) var Logger midlog.Midlog = midlog.New("library2") func DumpLog(msg string) { Logger.Info("library2:", msg) } func DumpError(msg string) { Logger.Error1("library2:", msg) }
/* 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 writ...
package main import ( "encoding/json" "net/http" "strings" ) func respondWithError(w http.ResponseWriter, code int, message string) { respondWithJSON(w, code, map[string]string{"error": message}) } func respondWithJSON(w http.ResponseWriter, code int, payload interface{}) { response, _ := json.Marshal(payload) ...
package controllers import ( "app/base/database" "net/http" "github.com/gin-gonic/gin" ) func HealthHandler(c *gin.Context) { c.String(http.StatusOK, "OK") return } func HealthDBHandler(c *gin.Context) { err := database.Db.DB().Ping() if err != nil { c.String(http.StatusInternalServerError, "unable to ping...
// Copyright (c) 2020 SAP SE or an SAP affiliate company. All rights reserved. This file is licensed under the Apache Software License, v. 2 except as noted otherwise in the LICENSE file // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the Lice...
package main import ( "fmt" "os" ) func main() { if username, password := "musa", "abu"; len(os.Args) <= 1 { fmt.Println("Usage: [username] [password]") } else if os.Args[1] != username { fmt.Println("access denied for username :", os.Args[1]) } else if os.Args[2] != password { fmt.Println("access denied f...
package main import ( "fmt" "os" "bufio" "strconv" ) func main(){ //get path f,_ := os.Open("path.txt") scanner := bufio.NewScanner(f) path := make([]int,0) for scanner.Scan() { tmp := scanner.Text() num,_ := strconv.Atoi(tmp) path = append(path,num) } fmt.Println(followPath(path)) // a := []int{0...
package db import ( "log" "gopkg.in/mgo.v2" ) const ( localHostDB = "mongodb://localhost:27017" mlabHost = "mongodb://archiver:!2017Dlab@ds155737.mlab.com:55737/draglabsdev" dbName = "dsound" userC = "users" jamC = "jams" recordings = "recordings" //mongodb://marlon:4803marlon@ds035856...
package main import ( "blog/bootstrap" "blog/config" "flag" ) var configFile = flag.String("config", "./blog.yaml", "配置文件路径") func init() { flag.Parse() config.InitConfig(*configFile) } func main() { // 运行应用 app := bootstrap.Register() err := bootstrap.Run(app) if err != nil { panic(err) } }
package main import ( controllers "github.com/vlasove/proj/controllers" // new "github.com/vlasove/proj/models" // new "github.com/gin-gonic/gin" ) func main() { r := gin.Default() db := models.SetupModels() // new // Provide db variable to controllers r.Use(func(c *gin.Context) { c.Set("db"...
package model type SmProjectFileT struct { FileId int64 `xorm:"not null comment('文件ID') BIGINT(20)"` ProjectId int64 `xorm:"not null comment('项目ID') BIGINT(20)"` } /** * 将数据库查询出来的结果进行格式组装成request请求需要的json字段格式 */ func (tmProjectFileT *SmProjectFileT) ProjectFileTToRespDesc() interface{} { respInfo := map[s...
package main import "fmt" func main() { var t int fmt.Scan(&t) var inputs []int64 for i := 0; i < t; i++ { var n int64 fmt.Scan(&n) inputs = append(inputs, n) } for _, input := range inputs { out := highestPrimeFactor(input) fmt.Printf("%d\n", out) } } func highestPrimeFactor(n int64) int64 { var p...
package betypes const ( CertPath = "./certs/cert.pem" KeyPath = "./certs/cert.key" )
package relation func generate(numRows int) [][]int { tri := make([][]int, numRows) for i := 0; i < numRows; i++ { ll := i + 1 tri[i] = make([]int, ll) tri[i][0] = 1 tri[i][ll-1] = 1 for j := 1; j < ll-1; j++ { tri[i][j] = tri[i-1][j-1] + tri[i-1][j] } } return tri } func getRow0(rowIndex int) []in...
package Core type ModuleMgr struct { mgrs map[string]interface{} } var mgr *ModuleMgr func GetModuleMgr() *ModuleMgr { if mgr == nil { mgr = &ModuleMgr{mgrs: make(map[string]interface{})} } return mgr } func (mgr ModuleMgr) RegistModule(moduleName string, modulePointer interface{}) { if _, ok := mgr.mgrs[mod...
// Copyright 2020 IOTA Stiftung // SPDX-License-Identifier: Apache-2.0 package tcrypto import ( "go.dedis.ch/kyber/v3" "go.dedis.ch/kyber/v3/pairing" "go.dedis.ch/kyber/v3/util/key" ) type Suite interface { kyber.Group pairing.Suite key.Suite }
package remote import ( "sync" "time" ) var value = 0 var mockValue = 0 type Sequence interface { GetNext() int Reset() GetValue() int } type SequenceImpl struct { wait time.Duration mutex *sync.Mutex } func NewSequenceImpl() *SequenceImpl { return &SequenceImpl{100 * time.Millisecond, &sync.Mutex{}} } f...
package main import ( "encoding/json" "github.com/gorilla/mux" "log" "math/rand" "net/http" "strconv" ) // Book Struct (Model) type Book struct { ID string `json:"id"` Isbn string `json:"isbn"` Title string `json:"title"` Author *Author `json:"author"` } // Author Struct type Author struct { Fir...
// Implement binary search without using standard library. // If there are duplicate values of the key you are searching for, // return the first occurance in the slice. // If the search key is not present, SearchInts returns the index of // the first value greater than the search key. // If the key is greater than a...
package main import ( "fmt" "os" ) func main(){ s, sep := "", "" for _, arg :=range os.Args[1:] { //_ - instead of variable /*If we started from os.Args[0], 1st argument = path of compiled file C:\Users\vesel\AppData\Local\Temp\go-build013435514\b001\exe\consoleArgs2.exe */ s += sep + arg sep...
package dushengchen import "fmt" /* Submission: https://leetcode.com/submissions/detail/356983445/ */ func fourSum(nums []int, target int) [][]int { //nums = SortInt(nums) numsMap := map[int][][]int{} var res [][]int for i:=0; i<len(nums); i++ { for j:=i+1; j<len(nums); j++ { ...
package main import ( "fmt" "reflect" ) // Salah satu fungsi reflect ialah dpt melihat struktur kode kita pd saat aplikasi sedang berjalan / tercompile // Reflection sgt berguna ketika kita ingin membuat library yg general sehingga mudah digunakan type Sample struct { Name string `required:"true" max:"10"` } fu...
package graphql const ( // Operations DirectiveLocationQuery = "QUERY" DirectiveLocationMutation = "MUTATION" DirectiveLocationSubscription = "SUBSCRIPTION" DirectiveLocationField = "FIELD" DirectiveLocationFragmentDefinition = "FRAGMENT_DEFINITION" DirectiveLocationFra...
package main import ( "fmt" ) var charMorseArray =[...]string {".-","-...","-.-.","-..",".","..-.","--.","....","..",".---","-.-",".-..","--","-.","---",".--.","--.-",".-.","...","-","..-","...-",".--","-..-","-.--","--.."} func getWordNum(word string) uint64 { var result uint64 = 1 for _, tmpChar := range word[:...
package ghapp import ( "context" "encoding/json" "fmt" "net/http" "os" "github.com/dollarshaveclub/acyl/pkg/persistence" "github.com/dollarshaveclub/acyl/pkg/eventlogger" "github.com/dollarshaveclub/acyl/pkg/models" "github.com/google/go-github/github" "github.com/google/uuid" "github.com/palantir/go-gith...
package sshkeymanager import ( "fmt" "golang.org/x/crypto/ssh" kh "golang.org/x/crypto/ssh/knownhosts" "io/ioutil" "os" "path" "time" ) var ( Home string HostKeyCallback ssh.HostKeyCallback ) func defaultKeyPath() string { Home = os.Getenv("HOME") if len(Home) > 0 { return path.Join(Home, ".s...
package leetcode var last *TreeNode func doFlattern(cur *TreeNode) { if cur == nil { return } if last != nil { last.Left = cur } last = cur doFlattern(cur.Left) doFlattern(cur.Right) } func reverseTree(cur *TreeNode) { if cur == nil { return } cur.Right = cur.Left reverseTree(cur.Left) cur.Left =...
package main import ( "github.com/LukeJoeDavis/moql/discovery" "github.com/LukeJoeDavis/moql/generate" "fmt" ) func main() { tables := discover.GetTables() inserts := make([]string, 0) for _, table := range tables{ func (tempTable string){ fmt.Println(tempTable + " starting") discoveredTable := disc...
// 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 e2e import "testing" func TestE2E(t *testing.T) { RunE2ETests(t) }
package dao import ( "fmt" "github.com/xormplus/xorm" "go.uber.org/zap" "mix/test/codes" entity "mix/test/entity/core/transaction" mapper "mix/test/mapper/core/transaction" "mix/test/utils/status" ) func (p *Dao) CreateHotWithdraw(logger *zap.Logger, session *xorm.Session, item *entity.HotWithdraw) (id int64,...
package mongodb import ( "context" "errors" "testing" "github.com/brigadecore/brigade/v2/apiserver/internal/api" "github.com/brigadecore/brigade/v2/apiserver/internal/lib/mongodb" mongoTesting "github.com/brigadecore/brigade/v2/apiserver/internal/lib/mongodb/testing" // nolint: lll "github.com/brigadecore/brig...
package resource import ( "errors" "github.com/bhops/goapi/model" "github.com/bhops/goapi/storage" "github.com/manyminds/api2go" "net/http" ) // UserResource holds UserStorage type UserResource struct { UserStorage *storage.UserStorage } // FindAll to satisfy `api2go.DataSource` interface func (s UserResource)...
package third_part_pay import ( "encoding/json" "fmt" "strconv" "strings" "time" "github.com/golang/glog" "sub_account_service/finance/blockchain" "sub_account_service/finance/config" "sub_account_service/finance/db" "sub_account_service/finance/lib" "sub_account_service/finance/models" "sub_account_serv...
package heap import "fmt" type Heap struct { data []int } func CreateHeap(data []int) *Heap { heapData := []int{0} h := &Heap{ data: append(heapData, data...), } length := len(h.data) // 对所有父节点完成堆化 for i := length/2; i >= 1; i-- { h.heapify(h.data, length, i) } return h } // 堆化, 由每个叶子节点依次向下完成 func (h *...
package main import ( "fmt" "os" "github.com/kingzbauer/jsonparser" ) func main() { if len(os.Args) == 1 { fmt.Println("Expected filename") os.Exit(1) } src, err := os.ReadFile(os.Args[1]) if err != nil { fmt.Printf("Error: %s\n", err) os.Exit(1) } if err := jsonparser.Parse(src); err != nil { f...
/* * Copyright 2017 StreamSets Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed...
package main import ( "fmt" "log" "time" ) func timeZone () (loctime time.Time) { loc, err := time.LoadLocation("Australia/Sydney") if err != nil { log.Panic(err) } t := time.Now().In(loc) return t } func main(){ fmt.Println(timeZone()) }
// Copyright 2020 Authors of Cilium // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // // http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed ...
package main import ( "github.com/yuyistudio/ecs-go/entitas" "fmt" "time" "math/rand" ) type PosCom struct { x float64 y float64 } func (p *PosCom) Type() entitas.ComponentType { return ComType_pos } type RendererCom struct { screen int64 } func (p *RendererCom) Type() entitas.ComponentType { return ComTy...
package helper const workCount = 10 func work(fn func()) { }
package agent import ( "net" "testing" "github.com/golang/mock/gomock" "github.com/stretchr/testify/assert" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/utils/pointer" "github.com/openshift/installer/pkg/asset" "github.com/openshift/installer/pkg/asset/mock" "github.com/openshift/installer/pkg/ipne...
package queue import ( "errors" "fmt" ) type MyQueue struct { a []int } var q MyQueue func NewQueue() *MyQueue { return &MyQueue{a: make([]int, 0)} } func (q *MyQueue) Enqueue(val int) { q.a = append(q.a, val) } func (q *MyQueue) Dequeue() error { if len(q.a) == 0 { return errors.New("The queue is empty")...
package mainMenu import ( "github.com/myProj/scaner/new/include/config/extensions" "github.com/myProj/scaner/new/include/config/settings" "github.com/therecipe/qt/core" "github.com/therecipe/qt/gui" "github.com/therecipe/qt/widgets" ) type TabCheckBoxSettings struct { ExtcheckBoxes []*widgets.QCheckBox Setchec...
package dataconv import "fmt" // ShowConv demonstrates some type conversion func ShowConv() { // int var a = 24 // float 64 var b = 2.0 // convert the int to a float64 for this calculation c := float64(a) * b fmt.Println(c) // fmt.Sprintf is a good way to convert to strings precision := fmt.Sprintf("%.2f"...
package synapse import ( "encoding/json" "testing" "github.com/stretchr/testify/assert" ) var errorData map[string]interface{} /********** METHODS **********/ func init() { data, err := readFile("error_responses") if err != nil { panic(err) } errorData = data } /********** TESTS **********/ func Test_...
/* # -*- coding: utf-8 -*- # @Author : joker # @Time : 2021/6/4 9:33 上午 # @File : matrix_test.go.go # @Description : # @Attention : */ package v2 import ( "fmt" "testing" ) func Test_updateMatrix(t *testing.T) { fmt.Println(updateMatrix([][]int{ {0,0,0}, {0,1,0}, {0,0,0}, })) }
package repository import ( "github.com/jmoiron/sqlx" ) // entity type HotelEntity struct { ID int `json:"id" db:"id"` HotelName string `json:"hotel_name" db:"hotel_name"` Address string `json:"address" db:"address"` RoomAvailability int `json:"room_availability,omitempty" db:...
// Copyright 2020-2021 Buf Technologies, 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...
package ebby import ( "github.com/conest/ebby/game" ) // Ebby : Ebby结构定义 type Ebby struct { sceneMap game.SceneMap fn game.ExFunctions publicData interface{} } // New : 创建新的Ebby实例 func New(sceneMap game.SceneMap) *Ebby { return &Ebby{ sceneMap: sceneMap, fn: game.ExFunctions{}, } } // SetI...
package parser import ( "fmt" "os" "encoding/xml" "nighthawk/elastic" nhconfig "nighthawk/config" nhs "nighthawk/nhstruct" nhlog "nighthawk/log" nhc "nighthawk/common" ) func ParseDriverModules(caseinfo nhs.CaseInformation, auditinfo nhs.AuditType, auditfile string) { MAX_RECORD := nhconfig.BulkPostSize() ...
/* Copyright 2020 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 main // ˄ type Director struct { // ˅ // ˄ builder Builder // ˅ // ˄ } func NewDirector(builder Builder) *Director { // ˅ return &Director{builder} // ˄ } // Construct a document func (self *Director) Build() { // ˅ self.builder.CreateTitle("Greeting") ...
package main import ( "fmt" "sync" "time" ) var wg sync.WaitGroup func main() { for i := 0; i < 3; i++ { wg.Add(1) go worker(i) } wg.Wait() fmt.Println("all done") } func worker(i int) { fmt.Println(i) time.Sleep(time.Second * time.Duration(1)) wg.Done() }
package main import ( "fmt" "os" "path/filepath" "runtime" "github.com/hashicorp/errwrap" ) // returns the system path were all // timeglass related data is stored for // this machine func SystemTimeglassPath() (string, error) { if runtime.GOOS == "windows" { //@see http://blogs.msdn.com/b/patricka/archive/2...
package main import ( "bufio" "fmt" "os" ) func Readfile(filename string) (string, error) { file, err := os.Open(filename) // 1.파일열기 if err != nil { return "", err // 2. 에러 나면 에러 반환 } defer file.Close() // 3. 함수 종료 직전 파일 닫기 rd := bufio.NewReader(file) //4. 파일 내용 읽기. bufio.NewReader() 함수로 bufi...
package plumber import ( "context" "fmt" "strings" "github.com/batchcorp/plumber-schemas/build/go/protos" "github.com/batchcorp/plumber-schemas/build/go/protos/common" "github.com/batchcorp/plumber-schemas/build/go/protos/opts" "github.com/mcuadros/go-lookup" "github.com/pkg/errors" "github.com/posthog/posth...
package service import ( "strings" "tesou.io/platform/brush-parent/brush-api/common/base" "tesou.io/platform/brush-parent/brush-api/module/odds/pojo" "tesou.io/platform/brush-parent/brush-core/common/base/service/mysql" ) type AsiaTrackService struct { mysql.BaseService } func (this *AsiaTrackService) Exist(v *...
package dcrlibwallet import ( "context" "net" "strings" "sync" "github.com/decred/dcrd/addrmgr" "github.com/decred/dcrd/rpcclient" "github.com/decred/dcrwallet/chain" "github.com/decred/dcrwallet/errors" "github.com/decred/dcrwallet/p2p" "github.com/decred/dcrwallet/spv" "github.com/decred/dcrwallet/wallet...
package controller import ( "fmt" "strconv" "strings" "unicode/utf8" "walletApi/src/model" "github.com/astaxie/beego" ) type QuestionController struct { beego.Controller } // @router /Question/InitList/ [get] func (c *QuestionController) InitList() { c.TplName = "questionlist.html" } // @router /Question/I...
package main import ( "bufio" "fmt" "net" "os" ) func main() { conn, err := net.Dial("tcp", "localhost:20000") if err != nil { fmt.Println("tcpClient connect failed, err:", err) } defer conn.Close() reader := bufio.NewReader(os.Stdin) for { msg, err := reader.ReadString('\n') if err != nil { fmt....
package mockingjay import ( "encoding/json" "io/ioutil" "log" "net/http" "os" ) const debugModeOff = false type mjLogger interface { Println(...interface{}) } // Server allows you to configure a HTTP server for a slice of fake endpoints type Server struct { Endpoints []FakeEndpoint requests []Req...
package benchmark import ( "context" "database/sql" "fmt" "testing" "github.com/go-gorp/gorp" "github.com/jinzhu/gorm" "github.com/jmoiron/sqlx" "github.com/ulule/loukoum/v3" "xorm.io/xorm" "github.com/ulule/makroud" "github.com/ulule/makroud-benchmarks/mimic" ) func BenchmarkMakroud_SelectAll(b *testing...