text
stringlengths
11
4.05M
package main import ( "testing" "github.com/stretchr/testify/assert" "time" "github.com/aws/aws-sdk-go/service/sqs/sqsiface" "github.com/aws/aws-sdk-go/service/sqs" ) type mockedDeleteMsgs struct { sqsiface.SQSAPI } func (m mockedDeleteMsgs) DeleteMessage(in *sqs.DeleteMessageInput) (*sqs.DeleteMessageOutput, ...
// ------------------------------------------------------------ // Copyright (c) Microsoft Corporation. // Licensed under the MIT License. // ------------------------------------------------------------ package cloudkms import ( "context" "fmt" cloudkms "cloud.google.com/go/kms/apiv1" "github.com/dapr/components...
package parser import ( "fmt" "reflect" "strings" ) // A Visitor's Visit method is invoked for each node encountered by Walk. // If the result visitor w is not nil, Walk visits each of the children // of node with the visitor w, followed by a call of w.Visit(nil). type Visitor interface { // Visit visits the curr...
package main /* #cgo pkg-config: libmodbus */ import "C"
package ehttp import "testing" func TestResponse_ToSwaggerResponse(t *testing.T) { type LoginInfo struct { ID string `json:"id" xml:"id"` } resp := &Response{ Description: "return a book", Model: &LoginInfo{}, Headers: map[string]ValueInfo{ "X-Rate-Limit": ValueInfo{Type: "int32", Desc: "calls ...
package entity type ProductDec struct { ID int `json:"id"` ProductID int `json:"product_id"` Quantity int `json:"quantity"` InvoiceID int `json:"invoice_id"` }
package main import ( "bufio" "fmt" "log" "os" "strconv" ) func main() { lines := parseLines("day1/input.txt") fmt.Println(partOne(lines)) fmt.Println(partTwo(lines)) } func partOne(input []string) int { frequency := 0 for _, line := range input { parsedInt, _ := strconv.Atoi(line) frequency += parsed...
package cache import ( "fmt" "os" "sync" "github.com/pilillo/igovium/utils" "github.com/xitongsys/parquet-go/parquet" "github.com/xitongsys/parquet-go/writer" ) var parquetFormatterOnce sync.Once var parquetFormatterInstance *parquetFormatter type parquetFormatter struct{} // NewParquetFormatter ... constru...
package engine type ( factory struct { sf StorageFactory } )
package main import ( "testing" ) func Test(t *testing.T) { var test = struct { edges map[int][]int edgesRev map[int][]int vertices map[int]*vertex want []int }{ map[int][]int{ 1: []int{2}, 2: []int{3}, 3: []int{1, 4}, 5: []int{4}, 6: []int{4, 7}, 7: []int{8}, 8: []int{6}, }...
package rpool import ( "sync" "github.com/moisespsena-go/io-common" ) // PoolReader is a wrapper around iocommon.ReadSeekCloser to modify the the behavior of // iocommon.ReadSeekCloser's Close() method. type PoolReader struct { iocommon.ReadSeekCloser mu sync.RWMutex c *channelPool unusable bool }...
package wxcontext import "github.com/astaxie/beego/cache" // Config for user type Config struct { AppID string AppSecret string Token string EncodingAESKey string Cache cache.Cache // 商户平台参数 MchID string MchAPIKey string // 商户平台APIKEY SslCertFilePath string //...
package sms import ( "VideoSync/com" "encoding/json" "fmt" "time" "strings" "crypto/sha256" "math/rand" "strconv" "github.com/astaxie/beego" "VideoSync/data" ) type TencentSms struct { Url string; AppId string; Secret string } // SMSTel 国家码,手机号 type SMSTel struct { NationCode string `json:"nationcod...
package main func main() { } /* 1.并发指goroutine相互独立运行 2.使用关键字go创建goroutine运行函数 3.goroutine在(GO运行时)逻辑处理器上执行, 逻辑处理器有独立的系统线程和运行队列 ~ GO运行时逻辑处理器和系统线程绑定 4.竞争状态指>=2个goroutine同时访问同一共享资源 5.消除竞争状态 1.原子函数: 原子操作 2.互斥锁: 临界区 6.通道提供了在两个goroutine间共享数据的便捷方法 1.无缓冲通道保证同时交互数据, 有缓冲通道不保证 */
package main import ( "net/http" "github.com/gorilla/mux" ) func newRouter() *mux.Router { router := mux.NewRouter().StrictSlash(true) router.HandleFunc("/status", status).Methods("GET") return router } func status(w http.ResponseWriter, r *http.Request) { w.WriteHeader(http.StatusOK) }
package events import ( "strings" "time" "github.com/bonjourmalware/melody/internal/events/helpers" "github.com/bonjourmalware/melody/internal/logdata" "github.com/bonjourmalware/melody/internal/config" "github.com/bonjourmalware/melody/internal/sessions" "github.com/google/gopacket" "github.com/google/gop...
package keeper import ( "testing" "github.com/irisnet/irishub/app/v1/rand/internal/types" "github.com/irisnet/irishub/codec" "github.com/irisnet/irishub/store" sdk "github.com/irisnet/irishub/types" "github.com/stretchr/testify/require" abci "github.com/tendermint/tendermint/abci/types" "github.com/tendermint...
package leetcode import "strconv" func freqAlphabets(s string) string { ls := len(s) out := make([]rune, 0, ls) p := ls - 1 for p >= 0 { if s[p] == '#' { ch, _ := strconv.Atoi(s[p-2 : p]) out = append(out, rune(ch-1+'a')) p -= 3 } else { ch := s[p] out = append(out, rune(ch-'0'-1+'a')) p-- ...
package main func translateNode2Louds(root *Node) { }
package main import ( "log" "net/http" proto "github.com/sk-develop/grpc-sample/hello-api/hello-proto" echo "github.com/labstack/echo/v4" grpc "google.golang.org/grpc" ) const ( address = "localhost:9090" ) func main() { e := echo.New() conn, err := grpc.Dial( address, grpc.WithInsecure()...
/* Copyright 2020, 2021 The Flux 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, s...
package main import ( "strconv" "strings" ) func isAdditiveNumber(num string) bool { // [0,i-1] 表示第一个数字 // [i,t]表示第二个数字 for i := 1; i < len(num); i++ { for t := i; t < len(num); t++ { if isAdditiveNumberExec(num[t+1:], num[:i], num[i:t+1]) == true { return true } } } return false } // 没有优化的递归搜索 ...
package databox import ( "errors" _ "fmt" "os" "reflect" "testing" "time" ) var originalPostRequest = postRequest var originalGetRequest = getRequest func getToken() (pushToken string) { pushToken = "adxg1kq5a4g04k0wk0s4wkssow8osw84" envPushToken := "" + os.Getenv("DATABOX_PUSH_TOKEN") if envPushToken != ""...
// x := uint16(123) // y := uint16(456) // d := x & y // e := x | y // f := x << 2 // g := y >> 2 // h := ^x // i := ^y // fmt.Printf("d: %v\ne: %v\nf: %v\ng: %v\nh: %v\ni: %v\nx: %v\ny: %v\n", d, e, f, g, h, i, x, y) package main import ( "bufio" "fmt" "log" "os" "strconv" "strings" ) var varMap = make(map[s...
package config type TransparentProxyConfig struct { DryRun bool Verbose bool RedirectPortOutBound string RedirectInBound bool RedirectPortInBound string RedirectPortInBoundV6 string ExcludeInboundPorts string ExcludeOutboundPorts string UID s...
package sql import ( "reflect" "strings" "time" ) //DataType .. type DataType string //TimeType .. type TimeType int64 //TimeReflectType .. var TimeReflectType = reflect.TypeOf(time.Time{}) const ( //UnixSecond .. UnixSecond TimeType = 1 //UnixMillisecond .. UnixMillisecond TimeType = 2 //UnixNanosecond .....
/* * @lc app=leetcode.cn id=28 lang=golang * * [28] 实现 strStr() */ // @lc code=start package main import "fmt" func strStr(haystack string, needle string) int { if needle == "" { return 0 } // if haystack == "" || needle == "" { // return -1 // } size := len(haystack) size2 := len(needle) for i :=...
package meetup import ( "beer/internal/domain/model" "beer/internal/tools/customerror" "context" "math" "time" ) const unitOfBeer = 6 type WeatherRepository interface { GetWeather(ctx context.Context, latitude float64, longitude float64, date time.Time) (*model.Weather, error) } type Service struct { Weather...
// Unless explicitly stated otherwise all files in this repository are licensed under the MIT License. // // This product includes software developed at Datadog (https://www.datadoghq.com/). Copyright 2021 Datadog, Inc. package temporalite import ( "go.temporal.io/server/common/log" "github.com/DataDog/temporalite...
package webhook import ( "encoding/json" "fmt" "testing" jsonpatch "github.com/evanphx/json-patch" corev1 "k8s.io/api/core/v1" "sigs.k8s.io/yaml" ) var testyaml = ` apiVersion: apps/v1 kind: Deployment metadata: labels: app: nginx-test name: nginx-test namespace: test1 spec: replicas: 1 selector:...
package topology import ( "fmt" "net" "os" "path/filepath" "sort" "github.com/Cloud-Foundations/Dominator/lib/fsutil" "github.com/Cloud-Foundations/Dominator/lib/json" "github.com/Cloud-Foundations/Dominator/lib/log" "github.com/Cloud-Foundations/Dominator/lib/log/nulllogger" "github.com/Cloud-Foundations/D...
package main import "fmt" func main() { age := 44 fmt.Println("1. main func: ") fmt.Println(age) fmt.Println(&age) changeMe(&age) fmt.Println("2. main func: ") fmt.Println(age) fmt.Println(&age) } func changeMe(z *int) { fmt.Println("1. changeMe func: ") fmt.Println(z) fmt.Println(*z) *z = 24 fmt....
// 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 btree import ( "math" "math/rand" "testing" ) func TestNewNode(t *testing.T) { if NewNode(1).Value != 1 { t.Fatal("NewNode fails to create nodes") } } func TestNode_Insert(t *testing.T) { root := NewNode(2) root.Insert(3) root.Insert(1) if root.Right.Value != 3 { t.Fatal("Insert Right didn't wo...
package Problem0202 func isHappy(n int) bool { slow, fast := n, trans(n) for slow != fast { slow = trans(slow) fast = trans(trans(fast)) } if slow == 1 { return true } return false } func trans(n int) int { res := 0 for n != 0 { res += (n % 10) * (n % 10) n /= 10 } return res }
// Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. package azurestack import ( "fmt" "reflect" ) // DeepCopy dst and src should be the same type in different API version // dst should be pointer type func DeepCopy(dst, src interface{}) (err error) { defer func() { if ...
package label var ( RedisAddr string JobName string )
package cmd import ( "fmt" "github.com/balaji-dongare/gophercises/CLI/task/dbrepository" "github.com/spf13/cobra" ) var listallTask = dbrepository.ReadTodosTaskFromDB //ListTask Show todo task list var ListTask = &cobra.Command{ Use: "list", Short: "list is a CLI command to show todo task list ", Run: func...
package process import ( "encoding/binary" "encoding/json" "fmt" "go-basic/hsp/chart/common" "go-basic/hsp/chart/client/utils" "net" ) // 客户端这边用于维护客户信息的(比如列表) var onlineUserMap map[int]*common.User = make(map[int]*common.User, 10) var UserId int // 输出当前在线用户信息列表 func outputUserOnLine() { fmt.Println("在线用户列表如下...
package leetcode import "testing" func TestSearchInsert(t *testing.T) { tests := []struct { input []int target int output int }{ { input: []int{}, target: 0, output: 0, }, { input: []int{1, 3, 5, 6}, target: 5, output: 2, }, { input: []int{1, 3, 5, 6}, target: 2, outpu...
// Copyright 2015 Google Inc. 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...
package fleabug import ( "io" "log" "os" "runtime" ) var defaultDumper = newDumper() var defaultOut = os.Stdout // Dump prints given arguments with newline. func Dump(a ...interface{}) (n int, err error) { totalSize := 0 n, _ = defaultDumper.blocker() totalSize += n n, err = defaultDumper.dumpData(a...) if ...
package shmallocator import ( "unsafe" "github.com/Beyond-simplechain/foundation/allocator" ) type Allocator struct { availableHeaps []DefaultMemory actualHeapSize uint32 activeHeap uint32 activeFreeHeap uint32 initialized bool grow func() []byte } func New(initialHeap func() []byte, growHe...
package server import "code.game.com/api" var apiSevice *api.APIClient func GetAPIInstance() *api.APIClient { if apiSevice == nil { apiSevice = api.NewAPIClient("proxy") } return apiSevice }
package main import ( "flag" "fmt" "github.com/drsoares/go-linux/pkg/proc" "os" "runtime" ) var pattern string func main() { goos := runtime.GOOS if goos != "linux" { fmt.Println("only linux distros are supported") os.Exit(1) } flag.StringVar(&pattern, "pattern", "", "filter processes by pattern") fla...
// Copyright (c) 2017-2018 Zededa, Inc. // SPDX-License-Identifier: Apache-2.0 package zedmanager import ( "github.com/lf-edge/eve/pkg/pillar/types" uuid "github.com/satori/go.uuid" log "github.com/sirupsen/logrus" ) // The /persist/img directory does not include ImageIDs and we don't want to add // it in order t...
package main import ( "database/sql" "flag" "fmt" "io/ioutil" "log" "os" "strings" _ "github.com/go-sql-driver/mysql" "github.com/zlowram/gsd" "golang.org/x/net/proxy" ) const ( TOP_100 = "7,9,13,21-23,25-26,37,53,79-81,88,106,110-111,113,119,135," + "139,143-144,179,199,389,427,443-445,465,513-515,543-...
package main import ( "flag" "fmt" "os" "os/exec" ) func main() { flag.Parse() args := flag.Args() target := "" if len(args) > 0 { target = args[0] } switch target { case "build": build() case "clean": clean() case "test": test() case "test-short": testshort() case "generate": generate() ...
/* Take the number 192 and multiply it by each of 1, 2, and 3: 192 × 1 = 192 192 × 2 = 384 192 × 3 = 576 By concatenating each product we get the 1 to 9 pandigital, 192384576. We will call 192384576 the concatenated product of 192 and (1,2,3) The same can be achieved by starting with 9 and multiplying by 1,...
package model import ( "errors" "github.com/mongodb/mongo-go-driver/bson" "github.com/mongodb/mongo-go-driver/bson/primitive" ) // PermissionRole ... type PermissionRole struct { Model `bson:",inline"` PermissionID primitive.ObjectID `bson:"permission_id"` RoleID primitive.ObjectID `bson:"role_id"`...
package modules // CircleSetController operations for CircleSet type CircleSetController struct { BaseUserController } func (c *CircleSetController) Prepare() { c.RequestCreateItem = &CreateCircleSet{} c.RequestUpdateItem = &UpdateCircleSet{} c.ModelItem = &CircleSet{} c.ModelItems = &[]CircleSet{} c.ResponseI...
package flow import "testing" func TestTruncateLogsMsg(t *testing.T) { root := "root" // TODO: Linter Dupword lsout := "total 12\ndrwxr-x--- 3 " + root + " " + root + "4096 Apr 17 11:34 .\ndrwxrwxrwx 3" + root + " " + root + " 4096 Apr 17 11:34 ..\ndrwxr-xr-x 5 " + root + " " + root + " 4096 Apr 17 11:34 out" in :...
package main import ( "fmt" "os" "os/exec" "path/filepath" "strconv" "time" "github.com/google/uuid" tap "github.com/mndrix/tap-go" "github.com/opencontainers/runtime-tools/validation/util" ) func main() { t := tap.New() t.Header(0) tempDir, err := os.MkdirTemp("", "oci-pid") if err != nil { util.Fat...
package read import ( "os" "log" "bufio" "fmt" "io" ) var filePath = "src/lesson/myLesson/readAndWrite/read/readStdin.go" func TestReadFromFile() { inputFile,err := os.Open(filePath) if err!=nil { log.Fatal(err) } defer inputFile.Close() inputReader := bufio.NewReader(inputFile) for { inputString,err ...
package parser import ( "github.com/stretchr/testify/assert" "testing" ) func Test_AttributeStartsWith(t *testing.T) { var tests = []struct { name string source string checkAttribute string checkValue string expectedResult bool }{ { name: "bucket name starts with bucket", s...
package login import ( "auth0/app" "auth0/auth" "crypto/rand" "encoding/base64" "log" "net/http" ) func LoginHandler(w http.ResponseWriter, r *http.Request) { log.Printf("LOGIN HANDLER") //generate random state bytes := make([]byte, 32) _, err := rand.Read(bytes) if err != nil { http.Error(w, err.Error()...
package pubpub import ( "fmt" "os" "github.com/spf13/cobra" ) var ( // VERSION set during build VERSION string ) var cfgFile string var home = os.Getenv("HOME") // RootCmd represents the base command when called without any subcommands var RootCmd = &cobra.Command{ Use: "pubpub", Short: "Publisher", Lon...
package main import ( "encoding/json" "fmt" ) type detail struct { Name string ZIP int } func main() { var decoded [2]detail str:=`[{"Name":"Delhi","ZIP":110078},{"Name":"Noida","ZIP":201301}]` err:=json.Unmarshal([]byte(str),&decoded) if err!=nil{ fmt.Println(err) return } fmt.Println(...
package main import "github.com/tsaikd/go-demo-unused/lib" func main() { lib.Do() }
package gotest import ( "github.com/ainsleyclark/go-test/interfaces" ) type MyStruct struct { Shape interfaces.Shape } func (m *MyStruct) GetArea() (float64, error) { a, err := m.Shape.Area() if err != nil { return 0, err } return a, nil }
package main import ( "bytes" "log" "testing" "git.sr.ht/~sircmpwn/go-bare" ) type UserRole uint const ( Admin UserRole = 0 Normal = 1 Guest = 2 ) type Session struct { Token []byte Expires uint } type User struct { ID uint Name string Email string Role UserRole Se...
package replact import "testing" func TestStudentReflact(t *testing.T) { StudentReflact() } func TestReflactStruct(t*testing.T){ ReflactStruct() } func TestReflectVaule(t*testing.T){ ReflectVaule() }
package main import ( "context" "fmt" "github.com/aws/aws-lambda-go/events" "github.com/aws/aws-lambda-go/lambda" "github.com/aws/aws-sdk-go/service/dynamodb" "github.com/aws/aws-sdk-go/service/dynamodb/expression" . "github.com/pobo380/network-games/card-game/server/websocket/handler" ) func Debug(ctx context...
package backend import ( "context" "os" "github.com/dragonflyoss/image-service/contrib/nydusify/pkg/remote" ocispec "github.com/opencontainers/image-spec/specs-go/v1" "github.com/pkg/errors" ) type Registry struct { remote *remote.Remote } func (r *Registry) Upload( ctx context.Context, blobID, blobPath stri...
package cockroachdb import "github.com/jmoiron/sqlx" // Link is used to insert and update in mysql type Link struct{} // InitDB create db if not exists func (link *Link) InitDB(exec sqlx.Execer, dbName string) (errExec error) { _, errExec = exec.Exec(`CREATE DATABASE IF NOT EXISTS ` + dbName) if errExec != nil { ...
package main import ( "log" _ "github.com/go-sql-driver/mysql" "main/route" ) func main() { log.Println("Server started on: localhost:8080") router := route.Init() router.Logger.Fatal(router.Start(":8080")) }
// Copyright 2020 Adam Chalkley // // https://github.com/atc0005/go-lockss // // Licensed under the MIT License. See LICENSE file in the project root for // full license information. // Package lockss assists with LOCKSS related configuration settings. // // The plan is to export this package at some point for externa...
package api var curses = []string{ "fuck", "shit", "dick", "bitch", "ass", "cunt", "penis", "vagina", "tits", "cock", "nigga", "nigger", "fag", "faggot", "pussy", }
package service import ( "context" "fmt" "net/http" "net/http/httputil" "strconv" "strings" "time" "github.com/go-ocf/cloud/grpc-gateway/client" "github.com/google/uuid" "github.com/go-ocf/cloud/http-gateway/uri" "github.com/go-ocf/kit/log" kitNetGrpc "github.com/go-ocf/kit/net/grpc" kitHttp "github.com...
package main import ( "fmt" "time" ) func main() { fmt.Println("one...") time.Sleep(400 * time.Millisecond) fmt.Println("two...") time.Sleep(400 * time.Millisecond) fmt.Println("three!") }
package control import ( "net/http" "GoVideo/com/db" "strings" "GoVideo/com" "fmt" ) type Statics struct { CPort int; VPort int; Url string //http://209.58.163.29:50080/RfpLoad } type ChannelServer struct { Id int64; HttpPort string; Ip string; Type string Dataversion int; IsAutoRelay int;...
package l1184 /* 环形公交路线上有 n 个站,按次序从 0 到 n - 1 进行编号。我们已知每一对相邻公交站之间的距离,distance[i] 表示编号为 i 的车站和编号为 (i + 1) % n 的车站之间的距离。 环线上的公交车都可以按顺时针和逆时针的方向行驶。 返回乘客从出发点 start 到目的地 destination 之间的最短距离。 Tips: > > - 1 <= n <= 10^4 > - distance.length == n > - 0 <= start, destination < n > - 0 <= distance[i] <= 10^4 来源:力扣(LeetCode) 链...
package main import ( "bytes" "encoding/json" "flag" "fmt" "os/exec" ) type deps struct { Deps []string `json:"Deps"` } type imports struct { Imports []string `json:"Imports"` } var b = flag.String("p", "ex104", "Please specify a package to show the dependency.") ////////////////////////////////////////////...
package constants const ( NotFound = 404 DBConnect = "user=admin dbname=subd password=admin host=localhost port=5432 sslmode=disable pool_max_conns=50" )
package main import ( "flag" "fmt" "log" "strconv" "strings" "time" "github.com/y4v8/errors" "github.com/y4v8/train" ) func main() { args, err := getArgs() if err != nil { fmt.Println("Usage:") flag.PrintDefaults() return } monitor(args.fromName, args.toName, args.trainNumber, args.wagonTypeID, arg...
package main import ( "bufio" "fmt" "net" "os" ) func checkError(err error) { if err != nil { fmt.Fprintf(os.Stderr, "Fatal error: %s", err.Error()) } } func main() { if len(os.Args) != 2 { fmt.Fprintf(os.Stderr, "Usage: %s host:port", os.Args[0]) os.Exit(1) } service := os.Args[1] fmt.Println(servi...
package sort /* Notes: 简述,每轮遍历未排序区间,取最小值,交换到未排区间头部,缩小未排序区间。 优化做法:每次遍历,找出最大值和最小值,并移到正确的位置。 不稳定排序。 */ func selectSort(nums []int) { for i := 0; i < len(nums); i++ { minIdx := i for j := i + 1; j < len(nums); j++ { if nums[j] < nums[minIdx] { minIdx = j } } if minIdx != i { nums[i], nums[minIdx] = ...
// Package dbg provided methods to write debug message to standard logger, // which can be disabled at runtime and build time. // +build release package dbg import "log" // Enabled reports whether debug output is enabled. const Enabled = false func init() { log.SetFlags(log.Ltime | log.Lshortfile) } // SetPrefix...
package agent import ( "crypto/tls" "fmt" api "github.com/nodamu/prof-log/api/v1" "github.com/nodamu/prof-log/internal/auth" "github.com/nodamu/prof-log/internal/discovery" "github.com/nodamu/prof-log/internal/log" "github.com/nodamu/prof-log/internal/server" "go.uber.org/zap" "google.golang.org/grpc" "googl...
package orm import "time" type DBConfig struct { Name string // 数据库链接名称 IsMater bool // 主数据库 Driver string Dsn string MaxLifetime time.Duration MaxOpenConns int //最大链接数量 } type KConfig struct { DBConfig []DBConfig }
// 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 commands_test import ( "errors" "io/ioutil" "os" "github.com/cloudfoundry/bosh-bootloader/application" "github.com/cloudfoundry/bosh-bootloader/commands" "github.com/cloudfoundry/bosh-bootloader/fakes" "github.com/cloudfoundry/bosh-bootloader/storage" "github.com/cloudfoundry/bosh-bootloader/terraform...
package golib // LogServerConf 日志配置 type LogServerConf struct { Level string Prefix string Syslog int IP string Port int } // mysql conf type MysqlConf struct { IP string Port int DB string User string Password string MaxIdle int MaxActive int } // BaseConf APP通用配置 typ...
/* Copyright 2018 Gravitational, 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, soft...
package db import ( log2 "Open_IM/pkg/common/log" "github.com/garyburd/redigo/redis" ) const ( userIncrSeq = "REDIS_USER_INCR_SEQ:" // user incr seq appleDeviceToken = "DEVICE_TOKEN" lastGetSeq = "LAST_GET_SEQ" userMinSeq = "REDIS_USER_MIN_SEQ:" ) func (d *DataBases) Exec(cmd string, key inter...
package byutil import ( "bylib/bylog" "time" ) //打印二进制数据 func HexDump(msg string, data []byte){ bylog.Debug("%s % X",msg,data) } type TickInfo struct{ start int64 count int } var tickMap map[string]*TickInfo func init(){ tickMap=make(map[string]*TickInfo) } func FreqPrintf(name string){ if _,ok:=tickMap[name]...
package main import ( "net/http" "github.com/ivpusic/golog" ) var ( logger = golog.GetLogger("main") ) func main() { http.Handle("/", http.FileServer(http.Dir("dist"))) host := ":8000" logger.Infof("Starting a webserver on %s", host) logger.Panic(http.ListenAndServe(host, nil)) }
// DBDeployer - The MySQL Sandbox // Copyright © 2006-2019 Giuseppe Maxia // // 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...
package server import ( "time" "os" "bytes" "github.com/att/deadline/common" "github.com/att/deadline/config" "github.com/att/deadline/schedule" "encoding/json" "encoding/xml" "errors" "net/http" ) var M *schedule.ScheduleManager type DeadlineServer struct { server *http.Server } func NewDeadlineServer...
package net import ( "net" ) // ValidateMAC validates a address is hardware address func ValidateMAC(mac string) bool { addr, err := net.ParseMAC(mac) if err != nil { return false } isBroadcast := (addr[0] >> 0 & 1) == 1 if isBroadcast { return false } // Check if all zero: 00:00:00:00:00:00 for _, b :...
package main import ( "fmt" "net" "time" "github.com/ICKelin/article/books/code/arq/gbn" ) func main() { // raddr, _ := net.ResolveUDPAddr("udp", "18.220.204.29:5012") raddr, _ := net.ResolveUDPAddr("udp", "127.0.0.1:5012") client, err := net.DialUDP("udp", nil, raddr) if err != nil { return } swc := gb...
package repository import ( "github.com/nicolascancino/web-service-go/models" "golang.org/x/crypto/bcrypt" ) func Login(email, password string) (models.Usuario, bool) { user, founded, _ := CheckIfExistUser(email) if !founded { return user, false } passwordBytes := []byte(password) passwordBD := []byte(user...
package controllers import ( "fmt" "github.com/astaxie/beego" "path" "github.com/SungKing/blogsystem/models/entity" "github.com/satori/go.uuid" "time" "encoding/json" "os" "io" "strconv" ) type CmsController struct { BaseController } //判断是否有修改文章的权限 //todo 权限管理太乱了 func (c *CmsController) youCan(id int32) b...
package main import ( "errors" "os" "os/user" "strconv" "strings" "unicode" "path/filepath" "crypto/sha1" "encoding/hex" ) // expand file path to absolute path func ExpandPath(path string) string { if path[0] == '~' { sep := strings.Index(path, string(os.PathSeparator)) if sep < 0 { sep = len(path) ...
package services import ( "fmt" "docktor/server/middleware" "docktor/server/types" "github.com/labstack/echo/v4" ) // AddRoute add route on echo func AddRoute(e *echo.Group) { services := e.Group("/services") // Basic services request services.GET("", getAll) services.POST("", save, middleware.WithAdmin) ...
package main import "fmt" func main() { fmt.Printf("Hello World") fmt.Printf("\nMy first local update") fmt.Printf("sandeep") }
package utils import ( "errors" "strings" "testing" "time" "github.com/stretchr/testify/assert" ) func TestShouldExecCommandOnAutheliaRootPath(t *testing.T) { cmd := Command("pwd") result, err := cmd.CombinedOutput() assert.NoError(t, err, "") str := strings.Trim(string(result), "\n") assert.NoError(t, e...
package main import ( "encoding/json" "fmt" ) type MyData struct { One int two string } /** * created: 2019/5/8 9:41 * By Will Fan */ func main() { in := MyData{1, "two"} fmt.Printf("%#v\n", in) // prints main.MyData{One:1, two:"two"} encoded, _ := json.Marshal(in) fmt.Println(string(encoded)) // prints ...
package easy543 import ( "math" ) type TreeNode struct { Val int Left *TreeNode Right *TreeNode } func diameterOfBinaryTree(root *TreeNode) int { if root == nil { return 0 } ans := -1 var search func(root *TreeNode) int search = func(root *TreeNode) int { if root == nil { return 0 } left := se...
// Copyright 2019 Drone.IO Inc. All rights reserved. // Use of this source code is governed by the Blue Oak Model License // that can be found in the LICENSE file. package internal import "testing" func Test_expandImage(t *testing.T) { testdata := []struct { from string want string }{ { from: "golang", ...