text
stringlengths
11
4.05M
package ecs import ( "encoding/csv" "strings" ) func parseCommandOverride(command string) ([]string, error) { reader := csv.NewReader(strings.NewReader(command)) reader.Comma = ' ' commands, err := reader.Read() if err != nil { return nil, err } return commands, nil }
package main import ( "time" "fmt" ) func main() { msg := make(chan string) go func() { time.Sleep(time.Second * 5) msg <- "head" }() select { case res := <-msg: fmt.Println("main rx: ", res) default: fmt.Println("default, no block") } }
package pci import ( "fmt" "runtime" "defs" "mem" ) var IRQ_DISK int = -1 var INT_DISK int = -1 // our actual disk var Disk Disk_i const ( VENDOR int = 0x0 DEVICE = 0x02 STATUS = 0x06 CLASS = 0x0b SUBCLASS = 0x0a HEADER = 0x0e _BAR0 = 0x10 _BAR1 = 0x14 _BAR...
package main import ( "fmt" "github.com/gtfierro/xboswave/ingester/types" xbospb "github.com/gtfierro/xboswave/proto" ) type add_fn func(types.ExtractedTimeseries) error func has_device(msg xbospb.XBOS) bool { return msg.XBOSIoTDeviceState.WeatherStationPrediction != nil } // This contains the mapping of each f...
package kvs import ( "fmt" "strconv" "strings" ) type Firewall interface { Init() error Ports() ([]FirewallPort, error) EnablePort(port int) error DisablePort(port int) error } type LiveFirewall struct { KVS } var _ Firewall = &LiveFirewall{} func NewLiveFirewall(backend KVS) *LiveFirewall { return &LiveF...
package cni import ( "net" "github.com/google/gopacket" "github.com/google/gopacket/layers" ) func NewArpRequestPacket(srcMac net.HardwareAddr, srcIp net.IP, dstIp net.IP) ([]byte, error) { rEth := layers.Ethernet{ SrcMAC: srcMac, DstMAC: net.HardwareAddr{0xff, 0xff, 0xff, 0xff, 0xff, 0xff}, E...
/* Copyright 2020 Frederic Branczyk 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 ...
package network import ( "fmt" "math/rand" ) type mlLayer struct { id string neurons []*mlNeuron linksTo []*mlLink nextLayer *mlLayer isIn bool isOut bool biais bool } type mlNeuron struct { id string sum float64 value float64 errorDiff float64 } func newNeuron(...
package ads import ( "log" "net/http" "strings" ) func (this *TwitchRequest) RunAd() { if debugMode { this.Channel = "ipldev" } http.Post(this.Url+this.Channel+"/commercial?oauth_token="+this.OAuth, "application/json", strings.NewReader(``)) log.Println("Fired a Twitch Ad") }
package medium022 func generateParenthesis(n int) []string { var ans []string var rec func(left, right int, str string) rec = func(left, right int, str string) { if right > left || left > n || right > n { return } if left == n && right == n { ans = append(ans, str) } rec(left+1, right, str+"(") re...
package main import "log" type Staplefood interface { Eat() } type RiceStaplefood struct { } type NoodleStaplefood struct { } type BreadStaplefood struct { } type EatContext struct { staplefood Staplefood } func (RiceStaplefood)Eat(){ log.Printf("吃米饭\n") } func (NoodleStaplefood)Eat(){ log.Printf("吃面条\n") } ...
// Implementing the solution from the book of course in idiomatic go package main import "fmt" type FlyBehaviour interface { Fly() } type DefaultFly struct { Height int Speed int } func (df *DefaultFly) Fly() { fmt.Printf("flying normally at speed %v and height %v\n", df.Speed, df.Height) } type RocketPowered...
package main import ( "context" "encoding/json" "net/http" "github.com/spf13/cobra" cmder "github.com/yaegashi/cobra-cmder" ) type AppSPJobSchemaFilters struct { *AppSPJobSchema } func (app *AppSPJobSchema) AppSPJobSchemaFiltersComder() cmder.Cmder { return &AppSPJobSchemaFilters{AppSPJobSchema: app} } func...
package math import ( "testing" ) func TestSqrt(t *testing.T) { t.Log(Sqrt(2)) //t.Log(float64(math.Pi)) }
package db type MySqlDriver struct { } func (m MySqlDriver) Add(text string) { MySql{}.Insert(text) } func (m MySqlDriver) Get(q string) string { return MySql{}.Select(q) }
package main import ( "fmt" "gopkg.in/ini.v1" "house365.com/studyGo/logtransfer/conf" "house365.com/studyGo/logtransfer/es" "house365.com/studyGo/logtransfer/kafka" ) //将日志数据从kafka取出来发往ES func main() { // 0 加载配置文件 cfg := new(conf.LogTransferCfg) err := ini.MapTo(&cfg, "./conf/cfg.ini") //要传指针 if err != nil {...
// 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 pleasanter type View struct { NearCompletionTime bool `json:"NearCompletionTime,omitempty"` ColumnFilterHash ColumnFilter `json:"ColumnFilterHash,omitempty"` ColumnSorterHash ColumnSorter `json:"ColumnSorterHash,omitempty"` } type ColumnFilter map[string]string type ColumnSorter map[string]str...
func sortByBits(arr []int) []int { sort.Slice(arr, func(a, b int) bool { c1 := countBit(arr[a]) c2 := countBit(arr[b]) if c1 == c2 { return arr[a] < arr[b] } return c1 < c2 }) return arr } func countBit(num int) int { count := 0 for ...
package core import ( "github.com/lovoo/goka" "log" "microservices_template_golang/payment_storage/src/eventmanager" "microservices_template_golang/payment_storage/src/models" "microservices_template_golang/payment_storage/src/repository" ) var ( brokers = []string{"kafka:9090"} topic goka.Strea...
package examples import ( "fmt" "html/template" "io/ioutil" "net/http" "os" ) func StartHttp() { get() server() } func get() string { res, err := http.Get("http://google.com") if err != nil { panic(err) } defer res.Body.Close() data, err := ioutil.ReadAll(res.Body) ioutil.WriteFile("./1", data, o...
package _25_Reverse_Nodes_in_k_Group import "fmt" type ListNode struct { Val int Next *ListNode } func (l *ListNode) String() string { var s string for l != nil { s += fmt.Sprintf("%d", l.Val) l = l.Next } return s } func reverseKGroup(head *ListNode, k int) *ListNode { var ( count int tmp = &List...
package main import ( "net/http" "testing" ) func TestHandler(t *testing.T) { req, err := http.NewRequest("GET", "", nil) if err != nil { t.Fatal(err) } }
package handler import ( "github.com/code7unner/vk-scrapper/internal/api/controller" "github.com/code7unner/vk-scrapper/internal/app" "github.com/go-chi/chi" "github.com/rs/cors" "net/http" "os" ) type Handler struct { *chi.Mux app *app.App } func New(app *app.App) *Handler { r := chi.NewRouter() r.Use(co...
package service import ( "fmt" "net/http" "github.com/prometheus/client_golang/prometheus" "github.com/prometheus/client_golang/prometheus/promhttp" ) func init() { prometheus.MustRegister(rpcRequestCount) prometheus.MustRegister(rpcRequestDuration) } var ( rpcRequestCount = prometheus.NewCounterVec( prome...
package codeGeneration import ( . "ast" "fmt" "strconv" ) // CONSTANTS ------------------------------------------------------------------- // Type sizes in bytes const ( INT_SIZE = 4 ARRAY_SIZE = 4 BOOL_SIZE = 1 CHAR_SIZE = 1 STRING_SIZE = 4 PAIR_SIZE = 4 ADDRESS_SIZE = 4 // Maximum offset...
package main import ( "fmt" "reflect" "syscall" ) type ( HANDLE uintptr WORD uint16 DWORD uint32 ) const ( STD_OUTPUT_HANDLE = 0xFFFFFFF5 FOREGROUND_BLUE = 0x01 FOREGROUND_GREEN = 0x02 FOREGROUND_RED = 0x04 FOREGROUND_INTENSITY = 0x08 BACKGROUND_BLUE = 0x10 BACKGROUND_GREEN ...
package collector import ( "context" "github.com/jenningsloy318/panos_exporter/panos" "github.com/prometheus/client_golang/prometheus" "github.com/prometheus/common/log" ) var ( NetworkSubsystem = "network" NetworkLabelNames = []string{"domain", "category", "interface", "type", "group", "class"} ...
/* 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...
/* * @lc app=leetcode.cn id=138 lang=golang * * [138] 复制带随机指针的链表 */ // @lc code=start /** * Definition for a Node. * type Node struct { * Val int * Next *Node * Random *Node * } */ package main import "fmt" type Node struct { Val int Next *Node Random *Node } func main() { v1 := &No...
// Copyright 2023 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 db import ( "encoding/json" "io/ioutil" "os" ) type Setting struct { StorePath string Data map[string]string } var instance *Setting func Settings() *Setting { if instance == nil { instance = &Setting{} } return instance } func (setting *Setting) Get(value string) string { setting.Default(...
package main import "fmt" func main() { fmt.Println(constructArr([]int{1, 2, 3, 4, 5})) fmt.Println(constructArr([]int{1, 0, 3, 4, 5})) } func constructArr(a []int) []int { ans := make([]int, len(a)) cur := 1 for i := 0; i < len(a); i++ { ans[i] = cur cur *= a[i] } cur = 1 for i := len(a) - 1; i >= 0; ...
package rd import ( "encoding/json" "fmt" "time" ) const ( authBaseUrl = "https://api.real-debrid.com/oauth/v2" deviceUrl = authBaseUrl + "/device/code" credentialsUrl = authBaseUrl + "/device/credentials" tokenUrl = authBaseUrl + "/token" defaultClientID = "X245A4XAIBGVM" ) type ( AuthClient s...
package caaa import ( "encoding/xml" "github.com/thought-machine/finance-messaging/iso20022" ) type Document01000105 struct { XMLName xml.Name `xml:"urn:iso:std:iso:20022:tech:xsd:caaa.010.001.05 Document"` Message *AcceptorReconciliationResponseV05 `xml:"AccptrRcncltnRspn"` } func (d ...
package pg import ( "github.com/kyleconroy/sqlc/internal/sql/ast" ) type FieldSelect struct { Xpr ast.Node Arg ast.Node Fieldnum AttrNumber Resulttype Oid Resulttypmod int32 Resultcollid Oid } func (n *FieldSelect) Pos() int { return 0 }
package main // TODO: use gopkg wherever possible import ( "errors" "fmt" "log" "math/rand" "net" "os" "os/signal" "path/filepath" "sync" "syscall" "time" "strconv" "os/exec" "github.com/droundy/goopt" "github.com/gamejolt/joltron/game" "github.com/gamejolt/joltron/game/data" ...
// Copyright 2023 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 models import ( "database/sql" "log" ) /** - table: hits - version: 1.0.0 -----------------------------------------------------------------------------------------+ | id | slug | ts | referer | ua | -----------------------------------------------------------...
package builders import ( "testing" "github.com/influx6/flux" ) var session = NewJSSession(nil, true, false) func TestJSPkgBundler(t *testing.T) { js, jsmap, err := session.BuildPkg("github.com/influx6/reactors/builders/base", "base") if err != nil { flux.FatalFailed(t, "Error build gopherjs dir: %s", err) ...
package server_test import ( . "github.com/nomkhonwaan/myblog/pkg/server" "github.com/sirupsen/logrus" "github.com/stretchr/testify/assert" "net" "testing" "time" ) func TestInsecureServer_ListenAndServe(t *testing.T) { t.Run("With successful listening and serving the server", func(t *testing.T) { // Given ...
// Default implementation of item service. // // @author TSS package service import ( "encoding/base64" "encoding/json" "fmt" "sort" "strings" "github.com/mashmb/1pass/1pass-core/core/domain" "github.com/mashmb/1pass/1pass-core/port/out" ) type dfltItemService struct { keyService KeyService itemRepo out....
package main import ( "github.com/wx13/genesis/installer" "github.com/wx13/genesis/modules" ) func main() { inst := installer.New() defer inst.Done() // Ensure a directory exists. inst.AddTask(modules.Mkdir{Path: "/tmp/genesis_test"}) // Copy a file from the tempdir to the system. inst.AddTask(modules.Copy...
// Copyright 2022 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 dao import ( "fmt" "github.com/xormplus/xorm" "go.uber.org/zap" "mix/test/codes" entity "mix/test/entity/cold" mapper "mix/test/mapper/cold" "mix/test/utils/status" ) func (p *Dao) CreateAddress(logger *zap.Logger, session *xorm.Session, item *entity.Address) (id int64, err error) { res, err := mappe...
package main import "fmt" func main() { str :="AFADFDAFAREAFDAFCZVRFSWTGDAFIHDKADFJLAFJDLA" map1 :=make(map[string]int) for i:=0;i<len(str);i++{ val,ok :=map1[string(str[i])] if ok{ val++ }else{ val =1 } map1[string(str[i])] =val } fmt.Println(map1) }
package cerebro import ( "bytes" "encoding/json" "fmt" "io/ioutil" "net/http" "strings" "github.com/sirupsen/logrus" ) type Client struct { host string port int url string client http.Client name string understandEndpoint string } // ...
/* * Copyright (c) 2018 Juniper Networks, Inc. All rights reserved. * * file: main.go * details: Entry point for the ipfix-translator, the binary creates Command * Line Interface (CLI) utility to run the application. */ package main import ( "os" kc "github.com/Juniper/collector/flow-translator/ka...
package main import ( "bufio" "fmt" "os" "github.com/abates/orange-ts" "github.com/abates/orange-ts/psip" ) func fail(err error) error { if err != nil { panic(err.Error()) } return err } func main() { if len(os.Args) < 2 { println("Usage: ", os.Args[0], "<input file>") os.Exit(-1) } file, err := o...
// Copyright 2020 Rainer Grosskopf (KI7RMJ). All rights reserved. // Use of this source code is governed by the MIT-license that can be // found in the LICENSE file. // Processes Winlink-compatible message template (aka Winlink forms) package forms import ( "archive/zip" "bufio" "bytes" "context" "encoding/json...
package main import ( "bufio" "fmt" "io" "log" "os" "github.com/graphaelli/jpg/structure" ) // printable returns the printable chars in b up to length chars, kind of like strconv.QuoteToASCII func printable(b []byte, length int) string { var clean []byte for i, c := range b { add := c if c < ' ' || c > 1...
package doclient import ( "testing" "github.com/bryanl/dolb/entity" "github.com/bryanl/dolb/mocks" "github.com/bryanl/dolb/pkg/app" "github.com/digitalocean/godo" . "github.com/smartystreets/goconvey/convey" "github.com/stretchr/testify/mock" ) func TestDOClient(t *testing.T) { Convey("DOClient", t, func() {...
// Copyright 2017 The Cockroach 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 ag...
package service import ( "fmt" "testing" tassert "github.com/stretchr/testify/assert" trequire "github.com/stretchr/testify/require" ) func TestUnmarshalMeshService(t *testing.T) { assert := tassert.New(t) require := trequire.New(t) namespace := "randomNamespace" serviceName := "randomServiceName" meshServ...
package handler import ( "bankBigData/AutomaticTask/entity/config" "bankBigData/BankServerJournal/db/query" "bankBigData/BankServerJournal/entity" "bankBigData/BankServerJournal/msg" "bankBigData/BankServerJournal/redis" "bankBigData/BankServerJournal/table" "encoding/json" "gitee.com/johng/gf/g" "gitee.com/j...
// Licensed to Elasticsearch B.V. under one or more contributor // license agreements. See the NOTICE file distributed with // this work for additional information regarding copyright // ownership. Elasticsearch B.V. licenses this file to you under // the Apache License, Version 2.0 (the "License"); you may // not use ...
package main import ( "fmt" "net/http" "os" ) func main() { go func() { if err := changeWatcher(os.Getenv("PWD")); err != nil { fmt.Printf("watcher error: %s\n", err) } }() if err := http.ListenAndServe(`127.0.0.1:8080`, http.FileServer(http.Dir(`.`))); err != nil { fmt.Printf("serve error: %s\n", err)...
// Copyright 2022 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 ( "encoding/json" "fmt" "io/ioutil" ) type pattern struct { Name string Notes []int Weights []float64 } func loadJSON(filename string) (map[string]interface{}, error) { data, err := ioutil.ReadFile(filename) if err != nil { return nil, err } jsonMap := make(map[string]interface{...
package validator import ( "crypto/ecdsa" "crypto/ed25519" "crypto/rsa" "crypto/x509" "errors" "fmt" "net/url" "os" "sort" "strings" "testing" "time" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" "github.com/authelia/authelia/v4/internal/configuration/schema" "github.com/...
package node import ( "errors" "math/rand" "net" "time" "github.com/agusss19/global/pkg/qsy" ) // onTerminalFound se encarga de manejar el evento cuando se encuentra la terminal. // Es thread-safe. func (node *Node) onTerminalFound() { if !node.handleRunningState(true) { return } node.command.Reset() nod...
package common const ( APP_INI_PATH = "pcpsd/conf/app.ini" READ_LOG_PATH = "/Users/chenle/Work/www/pcps/internal/file/temp/camera.log" )
package params_test import ( "bytes" "encoding/json" "github.com/cloudfoundry-incubator/notifications/models" "github.com/cloudfoundry-incubator/notifications/web/params" . "github.com/onsi/ginkgo" . "github.com/onsi/gomega" ) var _ = Describe("Template", func() { Describe("NewTemplate",...
package amqp import ( "context" "github.com/Azure/go-amqp" ) // Sender is an interface for the subset of go-amqp *Sender functions that we // actually use. Using this interface in our messaging abstraction, instead of // using the go-amqp type directly, allows for the possibility of utilizing mock // implementatio...
package preference import ( "log" "os" yaml "gopkg.in/yaml.v2" ) // Client 客户端ID到Version的映射 type Client map[string]Version // Version 版本到Environment的映射 type Version map[string]Environment // Environment 环境到ClientPreference的映射 type Environment map[string]ClientPreference // ClientPreference 客户端的资源配置 type Client...
package main import ( "fmt" "io/ioutil" "math" "strconv" "strings" "sync" ) func main() { data, err := ioutil.ReadFile("input.txt") if err != nil { panic(err) } lines := strings.Split(strings.TrimSpace(string(data)), ",") part1(lines) part2(lines) } func part1(lines []string) { permutes := permutati...
// Copyright 2019 The Dice Authors. 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 // // https://www.apache.org/licenses/LICENSE-2.0 // // Unless required by app...
/* Description We were all taught addition, multiplication, and exponentiation in our early years of math. You can view addition as repeated succession. Similarly, you can view multiplication as repeated addition. And finally, you can view exponentiation as repeated multiplication. But why stop there? Knuth's up-arrow...
package entity import ( "github.com/dgrijalva/jwt-go" "go_web/app/http/models" "go_web/app/http/models/auth_model" "go_web/pkg/logger" "time" ) var jwtKey = []byte("mushan") var expireTime = time.Now().Add(7 * 24 * time.Hour) type Claims struct { UserId int64 `json:"user_id"` jwt.StandardClaims } func JwtGe...
package api import ( "bytes" "encoding/json" "encoding/xml" "fmt" "net/http" ) type ThirdApi struct { url string method string contentType ContentType } func (rcv ThirdApi) GetURL() string { return rcv.url } type thirdApiRequest struct { SourceAddress string `json:"consignee"` DestAddress...
//go:build integration // +build integration package test import ( "testing" confluent "github.com/confluentinc/confluent-kafka-go/kafka" "github.com/etf1/kafka-transformer/pkg/transformer/kafka" ) // Default case with a simple transformer func TestTransformer_default(t *testing.T) { srcTopic := getTopic(t, "so...
package main import "fmt" //匿名字段 //不常用 type Person struct { string int } func main() { p1 := Person{ "lujing", 9000, } fmt.Println(p1.string) }
package main import ( "fmt" "io" "net/http" ) type aType string func (a aType) ServeHTTP(w http.ResponseWriter, r *http.Request) { //sjekk hva url path inneholder, og kjør en switch på det switch r.URL.Path { case "/a": io.WriteString(w, "Du er nå på /a") case "/b": io.WriteString(w, "Du er nå på /b") } ...
package dsstore import ( "context" "encoding/json" "errors" "fmt" "path" "time" "github.com/hashicorp/consul/api" "github.com/gofrs/uuid" klabels "k8s.io/kubernetes/pkg/labels" "github.com/square/p2/pkg/ds/fields" "github.com/square/p2/pkg/logging" "github.com/square/p2/pkg/manifest" "github.com/square/...
package traffic import ( "context" "net/http" "strings" "github.com/selectel/go-selvpcclient/selvpcclient" ) const resourceURL = "traffic" // Get returns the domain traffic information. func Get(ctx context.Context, client *selvpcclient.ServiceClient) (*DomainTraffic, *selvpcclient.ResponseResult, error) { url...
package mylog import ( "fmt" "log" "os" ) const ( LOG_FILE_PATH = "my_log" ) func Log2(a ...interface{}) { filename := LOG_FILE_PATH logfile, err := os.OpenFile(filename, os.O_RDWR|os.O_CREATE|os.O_APPEND, 0) defer logfile.Close() if err != nil { log.Fatalln("open file error ! \n") } debuglog := log.New(...
/* Copyright © 2021 SUSE 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 by applicable law or agreed to in writing, software distrib...
package api import ( "bytes" "fmt" "net/http" "testing" "github.com/gin-gonic/gin" ) func init() { Start() } func TestMapMemory(t *testing.T) { expected := 2048 val, err := mapMemory("2048MB") if err != nil { fmt.Printf(err.Error()) t.FailNow() } if val != expected { fmt.Printf("Expected: %v, got: ...
// Copyright (C) 2020 Cisco Systems 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 agr...
// Copyright 2019 The Dice Authors. 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 // // https://www.apache.org/licenses/LICENSE-2.0 // // Unless required by app...
package tooling import ( "fmt" "log" "os" "os/exec" "time" ) // DockerLogin uses a docker client to login to metahub func DockerLogin(pass, user, registry string) (err error) { log.Println("Use docker login via client") cmd := fmt.Sprintf("docker --log-level=debug --debug login --password %s --username %s %s"...
// MIT License // // Copyright (c) 2019 Oncilla // // Permission is hereby granted, free of charge, to any person obtaining a copy // of this software and associated documentation files (the "Software"), to deal // in the Software without restriction, including without limitation the rights // to use, copy, modify, mer...
package checkout import ( "encoding/json" "io/ioutil" ) // DecodeCheckoutData takes a filePath and returns a slice of instances of CheckoutLine. // // An error is returned if the file cannot be read due to a non-existent file or invalid filePath, // or if the the files content is not JSON data capable of being bein...
package hi import h "../hello" func Test() { h.SayHello() }
package main func main() { deck := newDeck().shuffle() hand, deck := deal(deck, 5) hand.print() hand.writeToFile("./deck.txt") }
package daemon import ( "github.com/docker/docker/daemon/execdriver" "github.com/docker/docker/runconfig" ) // setPlatformSpecificExecProcessConfig sets platform-specific fields in the // ProcessConfig structure. This is a no-op on Windows func setPlatformSpecificExecProcessConfig(config *runconfig.ExecConfig, cont...
package tool import ( r "reflect" ) type S struct { I int Str string } func MapToStruct(mapVal map[string]interface{}, val interface{}) (ok bool) { structVal := r.Indirect(r.ValueOf(val)) for name, elem := range mapVal { structVal.FieldByName(name).Set(r.ValueOf(elem)) } return } func StructToMap(val int...
package fs import ( "github.com/little-go/tools/hash" "io/ioutil" "os" ) // TempFileWithText The caller has responsibility to close the fd and delete file with name func TempFileWithText(text string) (*os.File, error) { tmpFile, err := ioutil.TempFile(os.TempDir(), hash.Md5Hex([]byte(text))) if err != nil { re...
//structure functions / types into packages //that exhibit natural cohesion package game import ( "io" "log" "strconv" ) const ( TypeFizz = "fizz" TypeBuzz = "buzz" TypeFizzBuzz = "fizzbuzz" ) type FizzBuzzer interface { GetLimit() int check(int) string On() } type Fizz struct { limit int } func ...
/* # -*- coding: utf-8 -*- # @Author : joker # @Time : 2020-09-16 07:37 # @File : lt_725_Split_Linked_List_in_Parts.go # @Description : # @Attention : */ package v0 /* 切割链表 */ func splitListToParts(root *ListNode, k int) []*ListNode { nodeNum := 0 temp:=root for temp != nil { nodeNum++ temp = temp.Next } ...
/* Create a function that takes in an array of full names and returns the initials. Examples initialize(["Stephen Hawking"]) ➞ ["S. H."] initialize(["Harry Potter", "Ron Weasley"]) ➞ ["H. P.", "R. W."] initialize(["Sherlock Holmes", "John Watson", "Irene Adler"]) ➞ ["S. H.", "J. W.", "I. A."] Notes Each initi...
package types import ( "bytes" "fmt" "net" "golang.org/x/crypto/ssh" ) // GetSSHSession return ssh session func (d *Daemon) GetSSHSession() (*ssh.Client, *ssh.Session, error) { if d.SSH.Port == 0 { d.SSH.Port = 22 } config := &ssh.ClientConfig{ User: d.SSH.User, Auth: []ssh.AuthMethod{ ssh.Password...
package main import ( "fmt" "github.com/prometheus/client_golang/prometheus/promhttp" "github.com/weAutomateEverything/go2hal/database" "github.com/weAutomateEverything/go2hal/remoteTelegramCommands" "github.com/weAutomateEverything/goFidoGo/monitor" monitor2 "github.com/weAutomateEverything/prognosisHalBot/moni...
package etcd import ( "context" clientv3 "go.etcd.io/etcd/client/v3" "time" ) type etcd struct { client *clientv3.Client kv clientv3.KV } func New() (*etcd,error) { // 客户端配置 config := clientv3.Config{ Endpoints: []string{"172.27.43.50:2379"}, DialTimeout: 5 * time.Second, } // 建立连接 clt, err := clien...
package main import ( "os" "github.com/iwanbk/gosqlbencher/query" "gopkg.in/yaml.v2" ) type plan struct { DataSourceName string `yaml:"data_source_name"` NumWorker int `yaml:"num_worker"` Queries []query.Query `yaml:"queries"` } func readPlan(filename string) (p plan, err error) {...
package handlers import ( "encoding/json" "log" "net/http" "github.com/Kaukov/gopher-translator/utils" ) // TranslatorHistory - struct for the history of translated words and sentences // // Has logger (*log.Logger) and data (utils.Storage) type TranslatorHistory struct { logger *log.Logger data utils.Storag...
package main //24. 两两交换链表中的节点 //给你一个链表,两两交换其中相邻的节点,并返回交换后链表的头节点。你必须在不修改节点内部的值的情况下完成本题(即,只能进行节点交换)。 //输入:head = [1,2,3,4] //输出:[2,1,4,3] //示例 2: // //输入:head = [] //输出:[] //示例 3: // //输入:head = [1] //输出:[1] type ListNode struct { Val int Next *ListNode } func swapPairs(head *ListNode) *ListNode { if head == nil |...
package main import ( "flag" "fmt" "io" "log" "net" "net/http" "sync" "github.com/gorilla/websocket" ) var upgrader = websocket.Upgrader{CheckOrigin: func(r *http.Request) bool { return true }} // use default options var ( host string port int path string addr string ) func init() { flag.StringVar(&ho...
package renderer_test import ( "bytes" "testing" "encoding/xml" "fmt" "regexp" "strconv" "github.com/ONSdigital/dp-map-renderer/geojson2svg" "github.com/ONSdigital/dp-map-renderer/models" . "github.com/ONSdigital/dp-map-renderer/renderer" "github.com/ONSdigital/dp-map-renderer/testdata" "github.com/ruben...
// Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. package armhelpers import ( "bytes" "context" "encoding/json" "fmt" "strings" "github.com/Azure/aks-engine/pkg/api" "github.com/Azure/azure-sdk-for-go/services/resources/mgmt/2018-05-01/resources" "github.com/siru...