text
stringlengths
11
4.05M
package gotoml import ( "strconv" "time" ) func (m TOMLMap) GetString(key string) (s string, e error) { exists := false s, exists = m[key] if !exists { e = NewKeyNotFoundError(key, "string") return } return } func (m TOMLMap) GetBool(key string) (b bool, e error) { str, exists := m[key] if !exists { e...
package main import ( "fmt" "os" "strconv" ) func sieve(max int) []bool { a := make([]bool, max+1) for i := 0; i <= max; i++ { a[i] = true } for p := 2; p*p <= max; p++ { if a[p] == true { for idx := p * p; idx <= max; idx += p { a[idx] = false } } } return a } func main() { args := os.A...
// DRUNKWATER TEMPLATE(add description and prototypes) // Question Title and Description on leetcode.com // Function Declaration and Function Prototypes on leetcode.com //99. Recover Binary Search Tree //Two elements of a binary search tree (BST) are swapped by mistake. //Recover the tree without changing its structure...
package main import ( "fmt" ) // func main() { // // v := "/a/b/c/" // // if strings.HasSuffix(v, "/") { // // v = strings.TrimSuffix(v, "/") // // } // // fmt.Println(v) // // s := fmt.Sprintf("%%%s%%", 433) // fmt.Println(string(s)) // } type TestStruck struct { msg string }...
package main import ( "fmt" "bytes" ) type Writer interface { Write([]byte) (int, error) } type Closer interface { Close() (error) } type WriterCloser interface { Writer Closer } type BufferedWriterCloser struct { buffer *bytes.Buffer } func(bwc *BufferedWriterCloser) Write(data []byte) (int, error){ ...
package message const ( // MaxMessageLength limit the Marshaled message length MaxMessageLength = 8192 ) // Message Type const ( MessageTypeHello = 0 MessageTypeVcardEx1 = 1 MessageTypeVcardEx2 = 2 MessageTypeMessage = 3 MessageTypeReceipt = 4 )
package main import ( "context" "fmt" "log" "github.com/silviog1990/grpc-golang-course/streaming-client/ComputeAverage/computeaveragepb" "google.golang.org/grpc" ) func main() { cc, err := grpc.Dial("localhost:50000", grpc.WithInsecure()) if err != nil { log.Fatalf("could not connect to: %v", err) } defe...
package main import ( "context" "fmt" "github.com/Whisker17/goMicroDemo/proto/model" "github.com/Whisker17/goMicroDemo/proto/rpcapi" "github.com/Whisker17/goMicroDemo/util" "github.com/lpxxn/gomicrorpc/example2/lib" "github.com/micro/go-micro" "github.com/micro/go-micro/client" "io" "os" "os/signal" ) func...
package common import "strconv" // PriceLevel is a common structure for bids and asks in the // order book. type PriceLevel struct { Price string Quantity string } // Parse parses this PriceLevel's Price and Quantity and // returns them both. It also returns an error if either // fails to parse. func (p *Price...
package main import ( "context" pb "github.com/little-go/practices/grpc/helloworld/proto" zipkin "github.com/openzipkin/zipkin-go" zipkingrpc "github.com/openzipkin/zipkin-go/middleware/grpc" httpReporter "github.com/openzipkin/zipkin-go/reporter/http" "google.golang.org/grpc" "log" "net" ) const ( port = ":...
package aiven import ( "fmt" "github.com/aiven/aiven-go-client" "github.com/hashicorp/terraform-plugin-sdk/helper/schema" ) var aivenAccountTeamMemberSchema = map[string]*schema.Schema{ "account_id": { Type: schema.TypeString, Description: "Account id", Required: true, ForceNew: true, }, "t...
package remt import ( "encoding/xml" "github.com/thought-machine/finance-messaging/iso20022" ) type Document00100101 struct { XMLName xml.Name `xml:"urn:iso:std:iso:20022:tech:xsd:remt.001.001.01 Document"` Message *RemittanceAdviceV01 `xml:"RmtAdvc"` } func (d *Document00100101) AddMessage() *Remit...
package main import "io" import "os" import "fmt" import "sync" import "time" import "strconv" import "path/filepath" import "math/rand" import "github.com/bnclabs/gostore/api" import "github.com/bnclabs/gostore/bubt" import humanize "github.com/dustin/go-humanize" func perfbubt() error { paths := bubtpaths(options...
// 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 i...
package test import ( "reflect" "testing" "unsafe" "github.com/cilium/ebpf/internal/testutils" ) func TestLoadingSpec(t *testing.T) { spec, err := loadTest() testutils.SkipIfNotSupported(t, err) if err != nil { t.Fatal("Can't load spec:", err) } if spec == nil { t.Fatal("Got a nil spec") } } func Tes...
var res []string func generateParenthesis(n int) []string { res = make([]string, 0) genHelper(n, n, "") return res } func genHelper(left, right int, cur string){ if left == 0 && right == 0 { res = append(res, cur) return } if left == 0 { genHelper(left, right - 1, cur +...
package bidi import ( "strings" "github.com/gioui/uax/internal/tracing" "golang.org/x/text/unicode/bidi" ) // We create a set of bidi rules as layed out in UAX#9. // To understand the rules it is probably best to consult the UAX algorithm // description. Headers and rule names will be similar to names in UAX#9. /...
package main import ( "go-study/rpcclient/funcs" ) func main(){ funcs.RpcClient() }
// Copyright 2019 Radiation Detection and Imaging (RDI), LLC // Use of this source code is governed by the BSD 3-clause // license that can be found in the LICENSE file. package message import ( "context" "encoding/json" "log" "github.com/go-redis/redis" "github.com/gorilla/websocket" ) type Msg struct { Type...
package models type SuccessMessage struct { Message string `json:"success"` }
package main import ( "bufio" "fmt" "net" "os" "strings" ) import "project/errorDispose" func main() { // 使用tcp链接服务器 tcpAddr, _ := net.ResolveTCPAddr("tcp", ":7777") tcpConn, error := net.DialTCP("tcp", nil, tcpAddr) defer func() { _ = tcpConn.Close() fmt.Println("链接关闭") }() errorDispose.ErrorPrint(err...
package gotten_test import ( "github.com/Hexilee/gotten" "github.com/Hexilee/gotten/headers" "github.com/stretchr/testify/assert" "io" "io/ioutil" "net/http" "reflect" "strconv" "testing" ) type ( EmptyParams struct { } EmptyService struct { EmptyGet func(*EmptyParams) (*http.Request, error) } ) func...
package main import ( "fmt" ) func main() { // arrays var arr [3]int arr[0] = 1 arr[1] = 2 arr[2] = 3 fmt.Println(arr) // implicit initialization arr1 := [3]int{1, 2, 3} fmt.Println(arr1) // slice from array declaration slice := arr1[:] arr1[1] = 42 slice[2] = 27 fmt.Println(arr1, slice) // slices s...
// +build !windows package analytics import ( "os" ) func sigterm(pid int) { p, err := os.FindProcess(pid) if err != nil { return } p.Signal(os.Interrupt) }
package service import ( "github.com/gorilla/mux" "github.com/moorara/log" ) // Mock is the interface for a mock type. type Mock interface { String() string Hash() uint64 RegisterRoutes(*mux.Router) } // MockService provides functionalities to manage mocks. type MockService struct { logger log.Logger mocks m...
package oracle import ( "github.com/InjectiveLabs/injective-oracle-scaffold/injective-chain/modules/oracle/keeper" "github.com/InjectiveLabs/injective-oracle-scaffold/injective-chain/modules/oracle/types" sdk "github.com/cosmos/cosmos-sdk/types" ) func InitGenesis(ctx sdk.Context, keeper keeper.Keeper, data types....
package rdq import ( "context" "errors" "fmt" "sync" "time" ) // RDQOptions is a settings for RDQ. type RDQOptions struct { // Queue is the name of the ZSet in redis Queue string // Redis is redis client Redis Redis // Now is function returning current time (usefull for tests). By default time.Now. Now fun...
package request import "github.com/astaxie/beego/validation" func TagAddRequestValid(name string, state int) validation.Validation { valid := validation.Validation{} valid.Required(name, "name").Message("标签名称不能为空") valid.MaxSize(name, 100, "name").Message("标签名称最长为100字符") valid.Range(state, 0, 1, "state").Message(...
/* Copyright 2016 Padduck, 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...
package main import ( "log" "os" app "github.com/chutommy/metal-price/api-server/app" config "github.com/chutommy/metal-price/api-server/config" _ "github.com/chutommy/metal-price/api-server/docs" // documentation ) // @title Metal Price API // @version 1.0 // @description This API returns the current price of ...
package main import ( "context" "crypto/rand" "encoding/base64" "encoding/json" "log" "net/http" "os" "github.com/gorilla/mux" "github.com/gorilla/sessions" "golang.org/x/oauth2" ) // ClientID for Auth0 const ClientID = "RpIMZwjG6BQ9uR6I6IUOPLt4kdmN68Ck" // Domain for Sharks SBYS Auth0 const Domain = "sha...
package wuser type User struct { Name string Phone string Email string UserName string Password string Token string }
//Package permuter provides a utility for permuting lists package permuter import () //Permute permutates the original list in the sink function //the sink must not modify the list func Permute(original []interface{}, sink func(permutation []interface{})) { //length := len(original) }
package main //#include <stdint.h> //#include <stdlib.h> //#include <string.h> //#include "moc.h" import "C" import ( "runtime" "strings" "unsafe" "github.com/therecipe/qt" std_core "github.com/therecipe/qt/core" ) func cGoUnpackString(s C.struct_Moc_PackedString) string { if int(s.len) == -1 { return C.GoSt...
package c21_mt19937 // w: word size (in number of bits) // n: degree of recurrence // m: middle word, an offset used in the recurrence relation defining the series x, 1 ≤ m < n // r: separation point of one word, or the number of bits of the lower bitmask, 0 ≤ r ≤ w - 1 // a: coefficients of the rational normal form t...
package main // Lab 1. Hello World // Requirements: // As a lonely person, I would like an application to greet the world // // Objective: // 01 - Understand package main // 02 - Be able to run, build, and install basic applications // // Steps: // 01 - Import the 'fmt' (format) package // 02 - Use fmt.Println to wri...
//+build ignore package drm //#cgo pkg-config: libdrm //#include <linux/types.h> //#include <stddef.h> //#include <asm/ioctl.h> //#include <libdrm/drm.h> //#include <libdrm/drm_mode.h> //#include <libdrm/drm_fourcc.h> //#include <libdrm/drm_sarea.h> import "C" import "syscall" type ( Handle C.drm_handle_...
package types import ( "github.com/segmentio/kafka-go" ) // RelayMessage encapsulates a kafka message that is read by relay.Run() type RelayMessage struct { Value *kafka.Message Options *RelayMessageOptions } // RelayMessageOptions contains any additional options necessary for processing of Kafka messages by th...
/* Copyright 2017 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 main import ( "github.com/omise/omise-go" "github.com/omise/omise-go/internal" ) var client *omise.Client func getClient() (*omise.Client, error) { if client != nil { return client, nil } cl, e := omise.NewClient(config.PKey, config.SKey) if e != nil { return nil, e } client = cl return client...
package suites import ( "os" "strings" "time" log "github.com/sirupsen/logrus" "github.com/authelia/authelia/v4/internal/utils" ) //nolint:unparam func waitUntilServiceLogDetected( interval time.Duration, timeout time.Duration, dockerEnvironment *DockerEnvironment, service string, logPatterns []string) er...
package pathfileops import ( "errors" "io" "os" "strings" "testing" "time" ) func TestFileHelper_OpenFileReadOnly_01(t *testing.T) { fh := FileHelper{} source := "../../logTest/topTest2.txt" source = fh.AdjustPathSlash(alogtopTest2Text) target := "../../checkfiles/TestFileHelper_OpenFileReadOnl...
// +k8s:deepcopy-gen=package // +groupName=amritgill.alpha.coveros.com package v1alpha1
// This file was generated for SObject CustomPermissionDependency, API Version v43.0 at 2018-07-30 03:47:24.059760542 -0400 EDT m=+10.402757321 package sobjects import ( "fmt" "strings" ) type CustomPermissionDependency struct { BaseSObject CreatedById string `force:",omitempty"` CreatedDate ...
package domain import ( "fmt" ) type Products []Product func (this Products) ToMap() (map[string]*Product, error) { result := make(map[string]*Product) for i := range this { v := this[i] if len(v.Code) == 0 { return nil, fmt.Errorf("missing code for product, cannot convert to map") } result[v.Code] = &...
// ˅ package main import ( "fmt" "os" "github.com/lxn/walk" . "github.com/lxn/walk/declarative" ) // ˄ type AppLogin struct { // ˅ // ˄ radioLogin *ColleagueRadioButton radioGuest *ColleagueRadioButton textUsername *ColleagueTextField textPassword *ColleagueTextField buttonOk *ColleagueButton but...
package utils import ( "encoding/json" "github.com/riposa/utils/log" "github.com/valyala/fasthttp" url2 "net/url" "time" ) type requests struct { // nothing } type HTTPCallback interface { Do(req *fasthttp.Request, resp *fasthttp.Response) interface{} } type HTTPResponse struct { status int contentTyp...
package remove /*import ( "encoding/base64" "encoding/json" "io/ioutil" "os" "path/filepath" "strings" "testing" "time" cloudpkg "github.com/devspace-cloud/devspace/pkg/devspace/cloud" cloudconfig "github.com/devspace-cloud/devspace/pkg/devspace/cloud/config" cloudlatest "github.com/devspace-cloud/devspace...
package main import ( "context" "fmt" "log" "math/big" "github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/core/types" "github.com/ethereum/go-ethereum/ethclient" ) func main() { client, err := ethclient.Dial("https://mainnet.infura.io/v3/YOUR_PROJECT_ID") if err != nil { log.Fatal(e...
package mmap import ( "testing" "fmt" ) func TestBitMap(t *testing.T) { m := NewBitMap(10) m.SetBit(1) m.SetBit(3) m.SetBit(5) m.SetBit(7) fmt.Println("是否包含5?", m.Contain(5)) fmt.Println(m.PrintBit()) fmt.Println(m.PrintNum()) m.Clear(5) fmt.Println("是否包含5?", m.Contain(5)) }
// +build !linux package sstable func (t *SSTable) tryMMap() error { return errNotImplemented } func (t *SSTable) tryMunmap() { }
package examples import ( "fmt" "github.com/corbym/gocrest/then" "testing" // import these to test a postgres container "github.com/corbym/gocrest/is" "github.com/cybernostics/cntest" "github.com/cybernostics/cntest/postgres" "github.com/jmoiron/sqlx" ) func TestPostgresRunWith(t *testing.T) { cntest.PullIm...
package gui import ( "tetra/lib/geom" "tetra/lib/glman" ) // Pane3D is a pane for 3D scene type Pane3D struct { Pane MatP geom.Mat4 MatV geom.Mat4 } // Init a new object func (pn *Pane3D) Init() { pn.Pane.Init() pn.MatP = geom.Mat4Ident() pn.MatV = geom.Mat4Ident() } // State to string func (pn *Pane3D) Sta...
/* You are given a binary array nums (0-indexed). We define xi as the number whose binary representation is the subarray nums[0..i] (from most-significant-bit to least-significant-bit). For example, if nums = [1,0,1], then x0 = 1, x1 = 2, and x2 = 5. Return an array of booleans answer where answer[i] is true if xi i...
package boost import ( "github.com/caddyserver/caddy" "strings" "testing" "time" ) func TestSetup(t *testing.T) { tests := []struct { input string shouldErr bool err string method Method pingCount int pingInterval time.Duration pingTimeout time.Duration }{ {"boost", ...
package main import "fmt" func main() { v := 42 fmt.Printf("v is of type %T\n", v) x := 42.111 fmt.Printf("x is of type %T\n", x) y := -42 fmt.Printf("y is of type %T\n", y) z := "42" fmt.Printf("z is of type %T\n", z) }
package time_machine import ( "context" "time" "time_machine/dao" "time_machine/model" ) type Machine struct { timeDuration time.Duration //存储数据的时间 storage dao.Storage // 存储引擎 } func NewTimeMachine(conf *TimeMachineConf) *Machine { return &Machine{storage: dao.InitRedisStorage(conf.RedisConf, conf.TTL)...
package releaze import ( "encoding/json" "net/http" ) func HttpHandler(resp http.ResponseWriter, req *http.Request) { info := Get() bytes, err := json.MarshalIndent(info, "", " ") if err != nil { http.Error(resp, err.Error(), http.StatusInternalServerError) } resp.Write(bytes) }
package signer import ( "crypto" "errors" "fmt" "io" "github.com/HNB-ECO/HNB-Blockchain/HNB/bccsp" "github.com/HNB-ECO/HNB-Blockchain/HNB/bccsp/utils" ) type bccspCryptoSigner struct { csp bccsp.BCCSP key bccsp.Key pk interface{} } func New(csp bccsp.BCCSP, key bccsp.Key) (crypto.Signer, error) { if csp ...
package elasticsearch import ( "elktools/cmd/utils" "encoding/json" "fmt" "github.com/desertbit/grumble" ) func init() { Register("route", initRoot) } func initRoot(name string) { routeCommand := &grumble.Command{ Name: name, Help: "POST /_cluster/reroute", HelpGroup: defaultApp.App.Config().N...
package main import "fmt" func main() { // mySlice := []string{"a", "b", "c", "g", "m", "z"} // fmt.Println(mySlice) // // everything from 2 to 4, 4 excluded // fmt.Println(mySlice[2:4]) // slicing a slice // fmt.Println(mySlice[2]) // index access ; acessing by index // fmt.Println("myString"[2]) // inde...
// Copyright 2015-2018 trivago N.V. // // 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 ( "flag" "github.com/DimkaTheGreat/sittme/models" "github.com/DimkaTheGreat/sittme/routing" ) var ( timeout = flag.Int("timeout", 20, "timeout between interrupted and finished state") port = flag.String("port", "8086", "server port") ) func main() { flag.Parse() translations := models...
// Copyright 2019 The OpenSDS 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 agre...
package backup import ( "bytes" "context" "encoding/json" "fmt" "golang.org/x/sync/errgroup" "golang.org/x/sync/semaphore" "io/ioutil" "os" "path" "path/filepath" "strings" "sync/atomic" "time" "github.com/AlexAkulov/clickhouse-backup/pkg/clickhouse" "github.com/AlexAkulov/clickhouse-backup/pkg/metadat...
package server import ( "context" "errors" "fmt" "github.com/RecleverLogger/customerrs" "github.com/RecleverLogger/logger" "github.com/gorilla/mux" "net" "net/http" "time" ) type Server struct { ctx context.Context cancel context.CancelFunc config *Config errCh chan<- error stopCh chan struct{} li...
package main import ( "fmt" "time" // "time" ) func main() { id := uint(0) op := 1 flag := false c := make(chan uint) for op != 0 { fmt.Println("1) Agregar proceso") fmt.Println("2) Mostrar proceso") fmt.Println("3) Eliminar proceso") fmt.Println("0) Salir") fmt.Scanln(&op) switch op { case 1:...
/** Copyright xuehuiit Corp. 2018 All Rights Reserved. http://www.xuehuiit.com QQ 411321681 */ package main import ( //"os" //"path" //"testing" //"time" //"github.com/hyperledger/fabric-sdk-go/api/apiconfig" //ca "github.com/hyperledger/fabric-sdk-go/api/apifabca" //fab "github.com/hyperledger/f...
package api import ( "bytes" "context" "encoding/json" "errors" "fmt" "io" "net/http" "net/url" "os" "strconv" "strings" tks "github.com/birchwood-langham/go-toolkit/io/strings" pd "github.com/birchwood-langham/portdb-ws/protocol" bapi "github.com/birchwood-langham/web-service-bootstrap/api" "github.co...
// Package migration provides an operatorkit resource that migrates awsconfig CRs // to reference the default credential secret if they do not already. // It can be safely removed once all awsconfig CRs reference a credential secret. // // Latest changes: // // * v24: Added migration code to fill spec.Cluster.Scaling.{...
package config type Reader interface { Read(path string) (*Config, error) }
/* * Copyright (C) 2017-Present Pivotal Software, Inc. All rights reserved. * * This program and the accompanying materials are made available under * the terms of the under the Apache License, Version 2.0 (the "License”); * you may not use this file except in compliance with the License. * You may obtain a copy ...
package command import ( "errors" "fmt" "strings" "sync" "awesome-dragon.science/go/goGoGameBot/pkg/log" ) const noAdmin = 0 type prefixFunc func(string) (string, bool) // NewManager creates a Manager with the provided logger and messager. The prefixes vararg sets the prefixes for the // commands. Note that t...
package main import ( "google.golang.org/api/calendar/v3" "time" ) type Cal struct { Srv *calendar.Service Id string } // Get the events on calendar. func (cal *Cal) GetEvents() (*calendar.Events, error) { events, err := cal.Srv.Events. List(cal.Id). ShowDeleted(false). SingleEvents(true). OrderBy("sta...
package morse import ( "bytes" "fmt" "strings" "unicode" ) type Morse struct { charMap map[rune]string codeMap map[string]rune } func New() (*Morse, error) { letters := "ABCDEFGHIJKLMNOPQRSTUVWXYZ .,?/@1234567890" codes := []string{".-", "-...", "-.-.", "-..", ".", "..-.", "--.", "....", "..", ".---", "-.-...
package main import "fmt" func main() { fmt.Println("Hello world!") myIntSlice := []int{1, 2, 3} fmt.Println("asdsda ", myIntSlice) a := 1 b := 2 c := 3 myPointerIntSlice := []*int{&a, &b, &c} fmt.Println("asad", myPointerIntSlice) }
package mempid import ( "crypto/sha1" "encoding/hex" "errors" "fmt" "os" "strconv" "syscall" "unsafe" ) type ProgMutex struct { AppName string key *uint16 handle syscall.Handle } const ( PAGE_READWRITE = 0x0004 FILE_MAP_READ = 0x0004 FILE_MAP_WRITE = 0x0008 int_size = strconv.IntSize ) fu...
package schema_test import ( "io/ioutil" "os" "path" "testing" "github.com/syncromatics/kafmesh/internal/schema" "github.com/stretchr/testify/assert" ) func Test_ProtobufDescribeSchema(t *testing.T) { tmpDir, err := ioutil.TempDir("", "Test_ProtobufDescribeSchema") if err != nil { t.Fatal(err) } tmpDir ...
package qiwi import ( "fmt" "time" ) type PaymentType string const ( CardPayment = "CARD" TokenPayment = "TOKEN" ApplePayPayment = "APPLE_PAY_TOKEN" GooglePayPayment = "GOOGLE_PAY_TOKEN" ) type Payment struct { token string `json:"-"` // Authtorisation token apiLin...
package issuer_test import ( "context" "time" "github.com/golang-jwt/jwt/v4" . "github.com/onsi/ginkgo" . "github.com/onsi/gomega" "google.golang.org/protobuf/types/known/wrapperspb" system_proto "github.com/kumahq/kuma/api/system/v1alpha1" "github.com/kumahq/kuma/pkg/core" "github.com/kumahq/kuma/pkg/core/...
package deployment_test import ( . "github.com/onsi/ginkgo" . "github.com/onsi/gomega" . "github.com/cloudfoundry/bosh-micro-cli/deployment" ) var _ = Describe("Deployment", func() { var ( deployment Deployment ) Describe("NetworksSpec", func() { Context("when the deployment has networks", func() { Bef...
package pgsql // PostgreSQL `timestamp` read/write natively supported with: // `time.Time` // `string` // `[]byte` type _ native
package g2db import ( "context" "fmt" "strings" "sync" "time" "github.com/go-redis/redis/v8" "github.com/spf13/cast" "github.com/atcharles/gof/v2/g2util" "github.com/atcharles/gof/v2/json" ) // constants defined const ( redisSubChannel = "Sub" redisSubDelMemCache = "DelMemCache" redisSubDelMemAll ...
package main import ( "context" "log" "os/exec" ) func main() { ctx, cancel := context.WithCancel(context.Background()) defer cancel() c := exec.CommandContext(ctx, "dpkg", "-l", "hoge") out, err := c.Output() if exitErr, ok := err.(*exec.ExitError); ok { log.Println(string(exitErr.Stderr)) return } log...
package stores import ( "github.com/jakewitcher/pos-server/graph/model" "strconv" ) type StoreLocationEntity struct { Id int64 `json:"id"` Street string `json:"street"` City string `json:"city"` State string `json:"state"` ZipCode string `json:"zip_code"` } type StoreEntity struct { Id in...
package employees import ( "encoding/json" "fmt" "net/http" "github.com/akshayvinodpunnath/webserver/db" "github.com/akshayvinodpunnath/webserver/models" ) func GetEmployees() []dbModels.Employee { var employee []dbModels.Employee db := db.DbConn() defer db.Close() rows, _ := db.Query("SELECT * FROM employ...
package manifest_test import ( . "github.com/onsi/ginkgo" "github.com/spf13/afero" . "github.com/onsi/gomega" "github.com/simonjohansson/go-linter/manifest" "github.com/simonjohansson/go-linter/model" ) var _ = Describe("RequiredFiles", func() { var ( fs afero.Fs ) BeforeEach(func() { fs = afero.NewMemMa...
package main import ( "context" "flag" "fmt" "log" "os" "regexp" "strconv" "sync" "github.com/algolia/algoliasearch-client-go/algoliasearch" "github.com/cheggaaa/pb" "github.com/go-resty/resty" "github.com/gocolly/colly" jsoniter "github.com/json-iterator/go" "go.uber.org/ratelimit" "golang.org/x/oauth...
package utils import ( "fmt" "github.com/pkg/errors" ) // ReaderError represents an error of an error type ReaderError struct { error Reader *RuneReader Location ReaderPosition } // Cause returns the underlying cause of this error func (r ReaderError) Cause() error { return r.error } // Error returns the e...
package base import ( "bytes" "context" "sync" mnet "github.com/ka2n/masminer/net" "golang.org/x/crypto/ssh" ) type Client struct { SSH *ssh.Client MU sync.RWMutex } func (c *Client) SetSSH(client *ssh.Client) { c.MU.Lock() defer c.MU.Unlock() c.SSH = client } func (c *Client) Setup(ctx context.Context)...
// +build windows package main import ( "os" ) // IsTerminal returns false on Windows. func IsTerminal(f *os.File) bool { return false } // MakeRaw is a no-op on windows. It returns nil. func MakeRaw(f *os.File) error { return nil } // RestoreTerm is a no-op on windows. It returns nil. func RestoreTerm(f *os.Fi...
package core import ( "fmt" "os" "path" "regexp" "strings" "github.com/jessevdk/go-flags" "gopkg.in/op/go-logging.v1" ) var log = logging.MustGetLogger("core") // A BuildLabel is a representation of an identifier of a build target, e.g. //spam/eggs:ham // corresponds to BuildLabel{PackageName: spam/eggs name...
package _105_Construct_Binary_Tree_from_Preorder_and_Inorder_Traversal /** * Definition for a binary tree node. * type TreeNode struct { * Val int * Left *TreeNode * Right *TreeNode * } */ type TreeNode struct { Val int Left *TreeNode Right *TreeNode } func buildTree(preorder []int, inorder ...
package log import "log" // Implements standard functions of go's log // Printf log.Printf func Printf(format string, v ...interface{}) { log.Printf(format, v...) } // Println log.Println func Println(v ...interface{}) { log.Println(v...) } // Add more when needed
package main import ( "bytes" "fmt" "net/url" "github.com/aws/aws-lambda-go/events" "github.com/aws/aws-lambda-go/lambda" "github.com/aws/aws-sdk-go/aws" "github.com/aws/aws-sdk-go/aws/session" "github.com/aws/aws-sdk-go/service/dynamodb" "github.com/aws/aws-sdk-go/service/dynamodb/dynamodbiface" "github.co...
package main import ( "fmt" "github.com/awslabs/aws-sdk-go/aws" "github.com/awslabs/aws-sdk-go/gen/route53" "log" "os" ) var region = "us-west-1" // Connect will create a valid ec2 client func Connect() *route53.Route53 { creds := aws.Creds(os.Getenv("AWS_ACCESS_KEY"), os.Getenv("AWS_SECRET_KEY"), "") // HL r...
package ovirt import "github.com/openshift/installer/pkg/destroy/providers" func init() { providers.Registry["ovirt"] = New }
package main import ( "context" "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/dynamodbattribute" . "github.com/pobo380/network-games/card-game/server/websocket/handler" "github.com/pobo380/netw...
package station type Station struct { name string }
// Copyright (c) WSO2 Inc. (http://www.wso2.org) All Rights Reserved. // // WSO2 Inc. licenses this file to you 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/L...