text
stringlengths
11
4.05M
package main import "fmt" func main() { fmt.Println("Go言語はじめました!") } // こちらの方は、型が少ない // func main() { // println("Go言語はじめました!") // }
package builder import ( "github.com/crossplane/crossplane-runtime/apis/core/v1alpha1" "k8s.io/apimachinery/pkg/runtime" "sigs.k8s.io/controller-runtime/pkg/client" "github.com/oam-dev/kubevela/apis/core.oam.dev/v1alpha2" "github.com/oam-dev/kubevela/pkg/appfile/config" "github.com/oam-dev/kubevela/pkg/controll...
// // Copyright 2021 The AVFS 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 main import ( "fmt" "time" ) func main() { ch := make(chan int) go func() { for i:=10; i<13; i++ { fmt.Printf("Sending %d\n",i) ch<-i time.Sleep(time.Second) } close(ch) }() for i:= range ch { fmt.Printf("Received %d\n",i) } }
/** * Definition for a binary tree node. * type TreeNode struct { * Val int * Left *TreeNode * Right *TreeNode * } */ // time: O(n), space: O(1) type Arg struct { Head *TreeNode Nums []int } func sortedArrayToBST(nums []int) *TreeNode { if len(nums) == 0 { return nil } he...
package leetcode type RecentCounter struct { buffer []int offset int } func Constructor() RecentCounter { return RecentCounter{buffer: []int{}} } func (this *RecentCounter) Ping(t int) int { for this.offset < len(this.buffer) && this.buffer[this.offset]+3000 < t { this.offset++ } this.buffer = append(this.bu...
package main import "fmt" // 680. 验证回文字符串 Ⅱ // 给定一个非空字符串 s,最多删除一个字符。判断是否能成为回文字符串。 // 注意: // 字符串只包含从 a-z 的小写字母。字符串的最大长度是50000。 // https://leetcode-cn.com/problems/valid-palindrome-ii/ func main() { fmt.Println(validPalindrome2("abca")) } // 法一:递归 func validPalindrome(s string) bool { return validPalindromeHelper(s,...
// 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 ( log "code.google.com/p/log4go" "encoding/json" "errors" "github.com/samuel/go-zookeeper/zk" "path" "strings" "time" ) const ( ROOT_PATH = "/im_comet" // node event eventNodeAdd = 1 eventNodeDel = 2 eventNodeUpdate = 3 // wait node waitNodeDelay = 3 waitNodeDelaySecond ...
package discord // Role defines a role on a Discord server type Role struct { Name string `json:"name"` ID string `json:"id"` Managed bool `json:"managed"` Position int `json:"position"` Permissions int `json:"permissions"` Hoist bool `json:"hoist"` Color int `jso...
// 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 util import ( "fmt" "github.com/Dataman-Cloud/omega-es/src/config" "github.com/garyburd/redigo/redis" ) var pool *redis.Pool func RedisInit() { pool = initPool() } func initPool() *redis.Pool { return redis.NewPool(func() (redis.Conn, error) { c, err := redis.Dial("tcp", fmt.Sprintf("%s:%d", conf...
/* * @lc app=leetcode.cn id=238 lang=golang * * [238] 除自身以外数组的乘积 */ package main import "fmt" // @lc code=start func productExceptSelf(nums []int) []int { numsLen := len(nums) ans := make([]int, numsLen) ans[0] = 1 for i := 1; i < numsLen; i++ { ans[i] = ans[i-1] * nums[i-1] } r := 1 for i := numsLen - 1...
/* Copyright 2017 Heptio 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, software dis...
package main import "fmt" /** slice 就是对array的一个view slice 可以向后扩展 */ func main() { arr := [...]int{0, 1, 2, 3, 4, 5, 6, 7} fmt.Println(arr[2:6]) // 不包含6元素的 fmt.Println(arr[:6]) fmt.Println(arr[2:]) fmt.Println(arr[:]) s1 := arr[2:] updateSlice(s1) fmt.Println(s1) s1 = arr[2:6] fmt.Println("reslice s1: ", s...
import "strconv" // time: O(1), space: O(1) func isValidSudoku(board [][]byte) bool { memo1 := make(map[int]bool) memo2 := make(map[int]bool) // row and col for i := 0; i < len(board); i++ { memo1 = make(map[int]bool) memo2 = make(map[int]bool) for j := 0; j < len(board); j++ { // row v, _ := strconv....
package web import ( "encoding/json" "github.com/gofiber/fiber/v2" "github.com/google/uuid" "github.com/iamtraining/forum/entity" "github.com/iamtraining/forum/store" ) type PostHandler struct { store *store.Store } func (h *PostHandler) getPost(c *fiber.Ctx) error { type data struct { ThreadID string `jso...
// Copyright (c) The Tellor Authors. // Licensed under the MIT License. package cli import ( "context" "math/big" "github.com/ethereum/go-ethereum/crypto" "github.com/go-kit/kit/log" "github.com/go-kit/kit/log/level" "github.com/pkg/errors" "github.com/tellor-io/telliot/pkg/contracts" tEthereum "github.com/t...
package logic import ( "context" "fmt" "strings" "tpay_backend/model" "tpay_backend/payapi/internal/common" "tpay_backend/payapi/internal/svc" "tpay_backend/payapi/internal/types" "tpay_backend/utils" "github.com/tal-tech/go-zero/core/logx" ) type SystemTransferLogic struct { logx.Logger ctx context....
package virtual_security import ( "errors" "reflect" "testing" ) type testStockPositionStore struct { getAll1 []*stockPosition getByCode1 *stockPosition getByCode2 error getByCodeHistory []string getBySymbolCode1 []*stockPosition getBySymbolCode2 error...
package database import ( "github.com/jinzhu/gorm" _ "github.com/jinzhu/gorm/dialects/mysql" "log" ) var SqlDB * gorm.DB func init() { var err error SqlDB, err = gorm.Open("mysql","root:root@/test?charset=utf8&parseTime=true&loc=Local") if err != nil { log.Fatal(err.Error()) } }
package main import ( "fmt" "log" "net" "sync" ) type Users struct { mu sync.Mutex name map[string]net.Conn mirror map[net.Conn]string } func NewUsers() *Users { return &Users{name: make(map[string]net.Conn), mirror: make(map[net.Conn]string)} } func (users *Users) Add(conn net.Conn) error { var us...
package msgHandler import ( "encoding/json" cmn "github.com/HNB-ECO/HNB-Blockchain/HNB/consensus/algorand/common" ) func (h *TDMMsgHandler) HandleProposalHeartBeatMsg(tdmMsg *cmn.TDMMessage) error { proposalHbMsg := &cmn.ProposalHeartbeatMessage{} err := json.Unmarshal(tdmMsg.Payload, proposalHbMsg) if err != n...
package artifacts import ( "context" "net/http" "net/url" "testing" "github.com/stretchr/testify/assert" testhttp "github.com/stretchr/testify/http" "github.com/stretchr/testify/mock" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" kubefake "k8s.io/client-go/kubernetes/fake" "github.com/argoproj/argo/persist...
package hive import "sync" type UsersStatsData struct { TotalConnectionsAccepted uint64 CurrentConnections uint32 TotalUsersConnected uint64 CurrentUsersConnected uint32 MessagesReceived uint64 MessagesTransmitted uint64 } type UsersStats struct { inData UsersStatsData out cha...
package utils func Uint64ToString(item uint64) string { return "123" }
package main import ( "common/compile" "common/utils" "flag" "fmt" "os" "path/filepath" "runtime" log "common/log4go" ) //版本号 var ( ver string = "1.0.1" ) func getExeName() string { ret := "" ex, err := os.Executable() if err == nil { ret = filepath.Base(ex) } return ret } func setLog() { logJson ...
package blobstore import ( "fmt" "hash" "io" ) // checkedReader is a reader wrapper that fails the last read if the readed contents don't match the // expected hash key as computed by the given hasher type checkedReader struct { io.Reader key Key hasher hash.Hash } // Read will return an error prefixed by '...
package bitmap import ( "fmt" "sync" ) const ( //表示的最大个数是2^32,可以配合crc32一类的hash法使用,占用空间大约512M 可以修改。 // 但如果超过uint64最大值,得改下结构,不过内存估计也不允许 MaxSize = 0x01 << 32 ) type bitMap struct { //存储数据 value []byte //bitmap最大容量 maxSize uint64 //已经置位的最大值,方便后面的输出 max uint64 lock sync.RWMutex } //越界错误 type OutOfRange stru...
// Copyright © 2021 Banzai Cloud // // 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 ...
package cherry import ( "golang.org/x/net/context" ) type Message struct { Ctx context.Context Msg interface{} } func NewMessage(ctx context.Context, msg interface{}) *Message { m := &Message{} m.Ctx = ctx m.Msg = msg return m } type HandlerFunc func(ctx context.Context, msgByte interface{}...
package main func InitializeRoutes() { router.GET("/", ShowIndexPage) router.GET("/article/view/:id", ShowArticlePage) }
package routines import ( "fmt" "strconv" "time" ) func Service(config ServiceConfig, machines []chan interface{}, broken chan int) { var states = make([]bool, len(machines)) var brokenQueue = make([]int, 0) var repairmen = 0 var repairs = make(chan int) for { select { case brokenMachine := <-broken: i...
// DRUNKWATER TEMPLATE(add description and prototypes) // Question Title and Description on leetcode.com // Function Declaration and Function Prototypes on leetcode.com //468. Validate IP Address //Write a function to check whether an input string is a valid IPv4 address or IPv6 address or neither. //IPv4 addresses are...
package main import ( "path/filepath" "testing" ) func TestValidSrc(t *testing.T) { for _, tc := range []struct { src string valid bool }{ {}, {filepath.Join("github.com", "pkg1"), true}, {filepath.Join("github.com", "pkg1", "sp1"), true}, {filepath.Join("github.com", "pkg1", "vendor"...
package day1 import ( "aoc-2020/internal/utils" "fmt" ) func Solution() { lines := utils.ReadIntInput("internal/day1/input1") res1, err := calcTwoNum(&lines) if err != nil { fmt.Println("error on solution 1") } res2, err := calcThreeNum(&lines) if err != nil { fmt.Println("error on solution 1") } fmt....
package main import ( "flag" ) const ( OPTION_RECURSION_LEVEL = 1 << iota OPTION_STATISTICS OPTION_PROGRESS OPTION_JSON_OUTPUT OPTION_MANIFEST_VERSION OPTION_INTERACTIVE_PASSWORD OPTION_TABLE_OUTPUT ) const ( OPTIONS_FULL = 0xFFFF OPTIONS_NONE = 0 ) type Config struct { recursionLevel uint manifest...
package platform func SetupAll(setupFuncs ...func() error) error { for _, s := range setupFuncs { if err := s(); err != nil { return err } } return nil }
/* Package dsmiddleware does not have anything, but it has a middleware group as a subpackage. */ package dsmiddleware // import "go.mercari.io/datastore/dsmiddleware"
package infra import ( "fmt" "github.com/gin-contrib/cors" "github.com/gin-gonic/gin" "github.com/sirupsen/logrus" ) // GinServer is the struct gathering all the server details type GinServer struct { host string port int Router *gin.Engine } // NewServer creates the gin Server func NewServer(host string...
package dfm import ( "errors" "fmt" "strconv" "strings" ) func parse(code []rune) (*Object, error) { return newParser(code).parseObject() } func newParser(code []rune) *parser { return &parser{tokens: newTokenizer(code)} } type parser struct { tokens tokenizer previewToken token hasPreviewToken...
package util import ( "fmt" "os" "syscall" "golang.org/x/crypto/ssh/terminal" "github.com/mayflower/docker-ls/lib" ) func PromptPassword(config *lib.Config) (err error) { credentials := config.Credentials() fmt.Fprintf(os.Stderr, "please enter password for user %s: ", credentials.User()) binaryPassword, e...
package archive import ( "errors" "io" "github.com/root-gg/plik/client/archive/tar" "github.com/root-gg/plik/client/archive/zip" ) // Backend interface describe methods that the different // types of archive backend must implement to work. type Backend interface { Configure(arguments map[string]interface{}) (er...
package parser const ( SComment = '#' STabSeparator = " " )
package controllers import ( "encoding/json" "mall/models" "mall/utils" "strconv" ) // Operations about Tag type TagController struct { BaseController } // @Title CreateTag // @Description create tag // @Param body body models.Tag true "body for tag content" // @Success 200 {int} models.Tag.Id // @Failure 40...
package main import ( "errors" "math/rand" ) func kPerm(k, n int) ([]int, error) { if k > n { return nil, errors.New("k cannot be greater than n") } perm := rand.Perm(n) return perm[:k], nil }
package main import "fmt" type esportivo interface { ligarTurbo() } type luxuoso interface { fazerBaliza() } type esportivoLuxuoso interface { esportivo luxuoso } type bmw struct { } func (bmw bmw) ligarTurbo() { fmt.Println("Turbo ligado") } func (bmw bmw) fazerBaliza() { fmt.Println("Baliza feita") } fu...
package frenyard // ExitFlag when set to true, exits the application. var ExitFlag bool = false // Backend is the set of "entrypoint" functions to the core API. type Backend interface { // Begins the frame loop. Stops when ExitFlag is set to true. Run(ticker func(frameTime float64)) error CreateWindow(name string,...
package main import ( "encoding/json" "fmt" _ "github.com/go-sql-driver/mysql" "io/ioutil" "log" "net/http" "net/url" "strconv" "time" ) type feedbackData struct { UserId int Android_id string Pkg_name string Contact_way string Content string Ch...
// Copyright The OpenTelemetry Authors // SPDX-License-Identifier: Apache-2.0 package ptraceotlp // import "go.opentelemetry.io/collector/pdata/ptrace/ptraceotlp" import ( "bytes" otlpcollectortrace "go.opentelemetry.io/collector/pdata/internal/data/protogen/collector/trace/v1" "go.opentelemetry.io/collector/pdat...
package postgres_backend import ( "database/sql" _ "github.com/lib/pq" "github.com/straumur/straumur" "testing" "time" ) func TestDB(t *testing.T) { const connection = "dbname=teststream host=localhost sslmode=disable" db, err := sql.Open("postgres", connection) if err != nil { t.Error("Error:", err) re...
package coldcall_test import ( "context" "github.com/imulab/coldcall" "github.com/imulab/coldcall/addr" "github.com/imulab/coldcall/body" "github.com/imulab/coldcall/header" "github.com/imulab/coldcall/status" "net/http" "testing" ) func ExampleRequest_get() { type Data struct { Message string `json:"messa...
package main import ( "fmt" ) func main() { { var inner = "inner" fmt.Println(inner) } // fmt.Println(inner) // this line can't be used because variable exists within the nearest curly braces { } var inner = "outer scope" fmt.Println(inner) }
package repository; // SettingRepository handles recipe manipulations in the database type SettingRepository struct { } // ProvideSettingRepository is the provider for SettingRepository func ProvideSettingRepository() (*SettingRepository, error) { return &SettingRepository{}, nil }
// +build !windows // +build cgo package frida_go /* extern void* device_onSpawnAdded(void*, void*,void*); extern void* device_onSpawnRemoved(void*, void*,void*); extern void* device_onChildAdded(void*, void*, void*); extern void* device_onChildRemoved(void*, void*, void*); extern void* device_onProcessCrashed(void*,...
package main import ( "encoding/json" "os" "strings" ) type Activity struct { Unique Name string `json:"name"` Desc string `json:"desc"` Categ string `json:"categ"` Point string `json:"point"` Loc string `json:"loc"` Start string `json:"start"` End string `json:"end"` Owner int `json:"owner"` Pa...
package dushengchen /** Submission: https://leetcode.com/submissions/detail/371282799/ */ func rotateRight(head *ListNode, k int) *ListNode { if head == nil || head.Next == nil || k == 0 { return head } kStart, kEnd := head, head for i := 0; i < k; i++ { if kEnd.Next != nil { kEnd = kEnd.Next } else ...
package main import ( "flag" "fmt" ) func main() { // A string flag that returns a pointer to the value stringFlag := flag.String("name_of_flag", "default value", "description of how this flag should be used") // You can also use the typeVar method where you pass a var to the function var intFlag int flag...
package handler import ( "context" "path/filepath" "testing" proto "github.com/jinmukeji/proto/v3/gen/micro/idl/partner/xima/user/v1" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/suite" ) type RegionTestSuite struct { suite.Suite JinmuIDService *JinmuIDService Account *Account } ...
package metadata import ( "errors" "fmt" "io" "log" "net/url" "os" "os/exec" "regexp" "strings" "testing" "time" "github.com/root-gg/logger" "github.com/root-gg/plik/server/common" "github.com/stretchr/testify/require" "gorm.io/gorm" ) func getTestBackend() string { backend := os.Getenv("BACKEND") i...
// Unless explicitly stated otherwise all files in this repository are licensed // under the Apache License Version 2.0. // This product includes software developed at Datadog (https://www.datadoghq.com/). // Copyright 2016-2019 Datadog, Inc. package scheduler import ( "testing" "time" corev1 "k8s.io/api/core/v1"...
package main import ( "io/ioutil" "os" "testing" ) func Test_CheckDockerFile(t *testing.T) { dir, err := ioutil.TempDir(".", "tmp") defer os.RemoveAll(dir) if err != nil { t.Fatal(err) } err = CheckDockerFile(dir, "django", "",false) if err != nil { t.Fatal(err) } } func Test_djangoDocker(t *testing.T...
package main import( "fmt" ) func main() { cards := newDeckFromFile("my_card") cards.shuffle() fmt.Println(cards.toString()) }
package hashring import ( "fmt" "testing" ) func Test_HashRing(t *testing.T) { nodes := make([]string, 0) for i := 0; i < 10; i++ { nodes = append(nodes, fmt.Sprintf("node-%04d", i)) } // ring := NewHashRing(nodes) list := make([]string, 0) for _, code := range ring.sortCode { keys := ring.codeKey[code] ...
package webhook import ( corev1 "k8s.io/api/core/v1" ) type EdgeServiceAutonomy struct { sidecarConfig *Config } type Config struct { Containers []corev1.Container `yaml:"containers"` } type patchOperation struct { Op string `json:"op"` Path string `json:"path"` Value interface{} `json:"value,om...
package binaryheap type BinaryHeapInts struct { l []int } func NewInts() BinaryHeapInts { return BinaryHeapInts{} } func (h *BinaryHeapInts) Insert(key int) int { h.l = append(h.l, key) if len(h.l) == 1 { return 0 } i := len(h.l) - 1 for j := (i - 1) / 2; j >= 0 && h.l[j] > h.l[i]; j = (i - 1) / 2 { h....
package cache import ( "time" "github.com/containerd/containerd/log" "github.com/dragonflyoss/image-service/contrib/nydus-snapshotter/pkg/store" "github.com/pkg/errors" ) type Manager struct { db DB store Store cacheDir string period time.Duration eventCh chan struct{} } type Opt struct { Cach...
/* * Print details of a single Server Policy given its server-policy-ID, or server name. */ package main import ( "flag" "fmt" "os" "path" "github.com/grrtrr/clcv2" "github.com/grrtrr/clcv2/clcv2cli" "github.com/grrtrr/clcv2/utils" "github.com/grrtrr/exit" "github.com/olekukonko/tablewriter" ) func main()...
package store import ( "encoding/json" "log" "time" "github.com/balchua/balsa/pkg/fsm" "github.com/hashicorp/raft" ) // StoreHandler struct handler type StoreHandler struct { raft *raft.Raft } func New(raft *raft.Raft) *StoreHandler { return &StoreHandler{ raft: raft, } } func (h StoreHandler) Store(key ...
package main import ( "crypto/sha256" "encoding/hex" "encoding/json" "io/ioutil" "log" "net/http" "os" "time" "github.com/gorilla/mux" ) type Question struct { ID string Question string answer bool } type AnswerPost struct { Answers map[string]bool Signature string UserID string } type ...
package main import ( "./matrix" "./multiplication" "fmt" ) func main() { a := matrix.New(3, 3) ( 1, 2, 3, 4, 5, 6, 7, 8, 9) b := matrix.New(3, 3)( 1, 0, 0, 0, 1, 0, 0, 0, 1) fmt.Println("Матрица А:") a.Out() fmt.Println("Матрица Б:") b.Out() c := multiplication.Multiply(a, b) fmt.Println(...
package models_test import ( "github.com/cloudfoundry-incubator/notifications/models" . "github.com/onsi/ginkgo" . "github.com/onsi/gomega" ) var _ = Describe("Database", func() { var db *models.DB BeforeEach(func() { db = models.Database() }) It("returns a connection to the dat...
package main import ( "context" "encoding/json" "encoding/xml" "fmt" "io" "net/http" "os" "strings" "github.com/caarlos0/env/v6" "github.com/go-redis/redis/v9" ) type config struct { RSSURL string `env:"RSS_URL"` } func main() { // // config cfg := config{} opt := env.Options{ Prefix: "OP...
// Copyright 2021 BoCloud // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // // http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed to in wri...
package chaos //some constant forever never change const CONST_TIME_LAYOUT="2006-01-02" const CONST_TIME_LAYOUT_COMPLETE="2006-02-01 15:04:05.000"
package models import "errors" func falseAndError(msg string) (bool, error) { return false, errors.New(msg) } func raiseIfError(err error) { if err != nil { panic(err) } }
/* * OpenAPI Petstore * * This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters. * * API version: 1.0.0 * Generated by: OpenAPI Generator (https://openapi-generator.tech) */ package petstoreserver type InlineObject struct { // Update...
package fateRPGtest import ( "testing" "github.com/faterpg" ) func TestNewExtra(t *testing.T) { var extra *faterpg.Extra extra = faterpg.NewExtra() if extra == nil { t.Error("NewExtra return nil") } }
package loader import ( "regexp" "strconv" "strings" "github.com/devspace-cloud/devspace/pkg/devspace/config/versions/latest" "github.com/devspace-cloud/devspace/pkg/devspace/config/versions/util" "github.com/pkg/errors" yamlpatch "github.com/krishicks/yaml-patch" yaml "gopkg.in/yaml.v2" ) // ApplyPatches a...
package messaging import ( "encoding/json" "fmt" "log" "math/rand" "sort" "strconv" "strings" "time" ) var topic = "Multiplay" // Hub - used to control message flow to clients type Hub struct { clients []Client subscriptions []Subscription } // NewHub creates a new hub func NewHub(clients []Client, ...
package yaml // Cluster represent a configuration of a single upstream cluster. type Cluster struct { Name string RoundRobin []string `yaml:"round_robin"` }
package pkg import ( "github.com/api7/ingress-controller/conf" "k8s.io/apimachinery/pkg/labels" "k8s.io/api/core/v1" ) func ListPods(m map[string]string) ([]*v1.Pod, error){ podInformer := conf.GetPodInformer() selector := labels.Set(m).AsSelector() ret, err := podInformer.Lister().List(selector) for _, pod :=...
package main import ( "github.com/woohhan/dropbox-csi/pkg/dropbox" "flag" "fmt" "os" "path" ) const ( version = "v1.0.0" ) var ( // TODO: change endpoint endpoint = flag.String("endpoint", "unix://tmp/csi.sock", "CSI endpoint") driverName = flag.String("drivername", "dropbox.csi.k8s.io", "name of the d...
package docker import ( "context" "encoding/base64" "encoding/json" "errors" "io" "os" "path" "testing" "github.com/docker/docker/api/types" "github.com/docker/docker/api/types/container" "github.com/saucelabs/saucectl/internal/cypress" "github.com/saucelabs/saucectl/internal/mocks" "github.com/stretchr/...
package main import ( "fmt" "context" "net" "log" "os" "google.golang.org/grpc" "google.golang.org/grpc/reflection" pb "../proto" ) func main(){ l, _ := net.Listen("tcp", ":50051") s := grpc.NewServer() pb.RegisterEchoServer(s, &server{}) reflection.Register(s) if err := s.Serve(l); err != nil{ fmt.Er...
package main import "fmt" func multi_ret() (str1 string, str2 string) { str1="hello" str2="world!" return str1,str2 } func main() { str1,str2:=multi_ret() fmt.Println(str1,str2) }
package main import ( "context" _ "embed" "fmt" "log" "os" "time" "github.com/alexflint/go-arg" "github.com/gagliardetto/solana-go/rpc" "github.com/go-co-op/gocron" twapConfig "github.com/gopartyparrot/goparrot-twap/config" "github.com/gopartyparrot/goparrot-twap/swap" "github.com/joho/godotenv" "go.uber...
package utils import ( "os" "strconv" "strings" uberrors "github.com/IBM/ubiquity-k8s/utils/errors" "github.com/IBM/ubiquity/resources" ) func LoadConfig() (resources.UbiquityPluginConfig, error) { config := resources.UbiquityPluginConfig{} config.LogLevel = os.Getenv("LOG_LEVEL") LogRotateMaxSize, err := s...
package main import ( "time" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" "github.com/hashicorp/terraform-provider-vsphere/vsphere" ) // defaultAPITimeout is a default timeout value that is passed to functions // requiring contexts, and other various waiters. const defaultAPITimeout = time.Minute ...
package main import "fmt" import t "time" func main(){ //print my first statement fmt.Println("Hy my first golang program!") //using go's import statement fmt.Println(t.Now()) //go formatting fmt.Printf("Number: %T,%v", 100, 100) //binary formatting fmt.Printf("Binary formatting: %b", 3435) }
package main import ( "fmt" "io" "os" "time" ) // SLICING UP REQUIREMENTS: // [*] (1) Get the program to print just '3' // [*] (2) Get the program to print 3,2,1 and Go! on separate lines // [*] (3) Get the program to wait one second between each line /*Sleeper ... interface that requires Sleep method implement...
package main import "fmt" func main(){ fmt.Println("program to demonstrate relational operations in Go:") var ( num1 = 19 num2 = 25 ) fmt.Println("Numbers are:", num1, num2) fmt.Println(num1, ">", num2, ":", num1 > num2) fmt.Println(num1, "<", num2, ":", num1 < num2) fmt.Println(num1, ">=", num1, ":", n...
package request type User struct { ID int `gorm:"primarykey"` Name string Password string Token string ExpireTime int64 FailNum int64 FailTime int64 } // User LoginStruct type LoginStruct struct { Username string `json:"username"` Password string `json:"password"` } // ChangePasswo...
package shasum import ( "crypto/sha1" "crypto/sha256" "crypto/sha512" "flag" "fmt" "hash" "io" "os" ) var ( flagSet = flag.NewFlagSet("shasum", flag.PanicOnError) helpFlag = flagSet.Bool("help", false, "Show this help") ) //Sha1sum calculates the checksum of file with sha1 hashing algorithm func Sha1sum(c...
package main import "fmt" func main() { var si []uint64 var c, i, d uint64 fmt.Scan(&c) d = c for i = 0; i < d; { fmt.Scan(&c) si = append(si, c) i = i + 1 } //fmt.Println(si) c = 0 for i = 0; i < d; { c = c + si[i] //fmt.Println(c) i = i + 1 } fmt.Println(c) }
// +build !providerless /* Copyright 2019 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 ...
/* Copyright 2017 The Kubernetes Authors. Copyright (C) 2018 Intel Corporation SPDX-License-Identifier: Apache-2.0 */ package oimcsidriver import ( "github.com/intel/oim/pkg/spec/csi/v0" ) func (od *oimDriver03) setControllerServiceCapabilities(cl []csi.ControllerServiceCapability_RPC_Type) { var csc []*csi.Contr...
// 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 epsp import ( "context" "strconv" "strings" "time" "github.com/pkg/errors" ) // Loop は、EPSPサーバと定期的な接続を行うことで、ピアとの接続を維持するメソッドです。 func (peer *Peer) Loop(ctx context.Context, port int) (err error) { peerIsRegistered := peer.PeerID != `` restart: for i := 0; ; i++ { if i >= len(peer.hosts) { i -= le...
package main import ( "fmt" "reflect" "unicode/utf8" "unsafe" ) var x = `/* 9大复杂类型: 参考源码 type.go 底部 func (t *Basic) Underlying() Type { return t } func (t *Array) Underlying() Type { return t } func (t *Slice) Underlying() Type { return t } func (t *Struct) Underlying() Type { return t } func (t *P...