text
stringlengths
11
4.05M
package main import "fmt" func main() { nautos := 0 placa := 0 amarilla := 0 rosada := 0 roja := 0 verde := 0 azul := 0 for nautos == 0 { fmt.Println("Numero de autos") fmt.Scanf("%v\n", &nautos) } i := 0 for i < nautos { fmt.Println("Auto", i+1) fmt.Println("Ultimo numero de placa") fmt.Scanf("%...
// Copyright 2018 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...
// 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 main import ( "fmt" "strconv" "strings" ) func main() { ss := strings.Split(input, "\n") buses := strings.Split(ss[1], ",") var earliest int t := 0 outer: for { // tracks the product of all seen busIds increment := 1 for i, bus := range buses { if bus == "x" { continue } busId, _ :...
package email import ( "ImaginatoGolangTestTask/shared/log" "bytes" "fmt" "github.com/aws/aws-sdk-go/aws" "github.com/aws/aws-sdk-go/aws/credentials" "github.com/aws/aws-sdk-go/aws/session" "github.com/aws/aws-sdk-go/service/ses" "html/template" "net/smtp" "os" ) const ( // Replace sender@example.com with ...
package main import "fmt" type person struct { fName string lName string age int } type footballer struct { person club string position string } func main() { f1 := footballer{ person: person{ fName: "Gerath", lName: "Bale", age: 30, }, club: "Real Madrid C.F.", position: "RWF", ...
package object // Null represents a null value (lack of a value) type Null struct { } // Inspect is used for debugging func (n *Null) Inspect() string { return "null" } // Type returns the null type func (n *Null) Type() Type { return NULL_OBJ }
// 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 client import ( "context" "github.com/square/p2/pkg/audit" "github.com/square/p2/pkg/grpc/auditlogstore" auditlogstore_protos "github.com/square/p2/pkg/grpc/auditlogstore/protos" "google.golang.org/grpc" ) type Client struct { client auditlogstore_protos.P2AuditLogStoreClient } func New(conn *grpc.Cl...
package main import ( "bufio" "bytes" "fmt" "os" ) type ByteCounter int type WordCounter int type LineCounter int func (c *ByteCounter) Write(p []byte) (int, error) { *c += ByteCounter(len(p)) // convert int to ByteCounter return len(p), nil } func (wc *WordCounter) Write(p []byte) (int, error) { fmt.Printf(...
package main import ( "net" "sync" "bench_dispatch/clog" "bench_dispatch/datamodels" "bench_dispatch/gopool" ) // Hub : type Hub struct { mu sync.RWMutex drivers map[int]*Driver pool *gopool.Pool } // NewHub : Creation du Hub de Driver func NewHub(pool *gopool.Pool) *Hub { hub := &Hub{ pool: poo...
package dbsrv import ( "time" "gopkg.in/doug-martin/goqu.v3" "github.com/empirefox/esecend/cerr" "github.com/empirefox/esecend/front" "github.com/empirefox/esecend/models" "github.com/empirefox/reform" ) const ( DaySeconds int64 = 3600 * 24 ) func (dbs *DbService) OrdersMaintain() error { now := time.Now()...
package generators import ( "math/rand" "time" ) //Randomer is a basic random generator interface (Int31n and Seed) type Randomer interface { Int31n(int32) int32 Seed(int64) } //globalRandom stores the APP Randomer var globalRandom Randomer //GetRandx returns the defined APP Randomer func GetRandx() Randomer { ...
package main import ( "fmt" "runtime" ) func PrintArch(){ fmt.Printf("Get GOOS and GOARCH.\n") fmt.Printf("GOOS:%s\n", runtime.GOOS) fmt.Printf("GOARCH:%s\n", runtime.GOARCH) }
package setting import ( "encoding/json" "fmt" "strings" "gopkg.in/yaml.v2" ) func sanitize(filename string, content []byte) ([]byte, error) { if strings.HasSuffix(filename, ".yml") || strings.HasSuffix(filename, ".yml") { return sanitizeYaml(content) } if strings.HasSuffix(filename, ".json") { return san...
package main import ( "context" "fmt" "time" ) func monitor(ctx context.Context, number int) { for { select { case <-ctx.Done(): fmt.Printf("监控器%v, 监控结束\n", number) return default: fmt.Printf("监控器%v, 正在监控 %v...\n", number, ctx.Value("test")) time.Sleep(time.Second * 2) } } } func main() { /...
// // Copyright (C) 2019-2021 vdaas.org vald team <vald@vdaas.org> // // 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 requir...
package main import ( "fmt" "until" ) /** * Definition for a binary tree node. * type until.TreeNode struct { * Val int * Left *until.TreeNode * Right *until.TreeNode * } */ // 层序遍历 核心就是队列先进先出 func levelOrder(root *until.TreeNode) [][]int { if root == nil { return [][]int{} } queue := []*u...
package main // 今天迷上自动机了,这题采用自动机进行解决 func hashOpt(opt uint8) int { // 操作 // 小写字母: 0 // 大写字母: 1 switch { case opt >= 'a' && opt <= 'z': return 0 case opt >= 'A' && opt <= 'Z': return 1 default: return 0 } } func detectCapitalUse(s string) bool { // 状态机矩阵 matrixOfDFA := [][]int{ {1, 2}, // 空白态 状态0...
package coinbase_api import ( "fmt" "os" "testing" ) var NotAuthenticated = fmt.Errorf("no API key present: can't make authenticated requests") func init() { ApiKey = os.Getenv("CB_API_KEY") } // FailWithError is a utility for dumping errors and failing the test. func FailWithError(t *testing.T, err error) { f...
package easy import "testing" type TreeNode struct { Val int Left *TreeNode Right *TreeNode } func Test100(t *testing.T) { } func isSameTree(p *TreeNode, q *TreeNode) bool { flag := true if p == nil && q == nil { return true } if p == nil || q == nil { return false } if p.Val == q.Val{ if !isSameTr...
package rbt type offset int const ( left offset = iota right ) func (o offset) other() offset { return o ^ right } func (o offset) String() string { if o == left { return "left" } return "right" }
package controllers import ( "./../../notify" "./../../utils" "cydex" "fmt" clog "github.com/cihub/seelog" ) type EmailController struct { BaseController } func (self *EmailController) Get() { rsp := new(cydex.GetEmailInfoRsp) rsp.Error = cydex.OK defer func() { self.Data["json"] = rsp self.ServeJSON()...
package functions import ( "github.com/elliotchance/pie/pie" ) // Strings transforms each element to a string. // // If the element type implements fmt.Stringer it will be used. Otherwise it // will fallback to the result of: // // fmt.Sprintf("%v") // func (ss SliceType) Strings() pie.Strings { l := len(ss) //...
package auth0 import ( "github.com/hashicorp/terraform/helper/schema" auth0 "github.com/yieldr/go-auth0" "github.com/yieldr/go-auth0/management" ) func newClientGrant() *schema.Resource { return &schema.Resource{ Create: createClientGrant, Read: readClientGrant, Update: updateClientGrant, Delete: delet...
package main import ( "fmt" "time" "encoding/xml" ) type CurrencyArray struct { CurrencyList []Currency } func (c *CurrencyArray) AddCurrency(currency string, amount int) { newc := Currency{Amount:amount} newc.XMLName.Local = currency c.CurrencyList = append(c.Cur...
package server import ( "fmt" "net/http" "github.com/Eldius/cors-interceptor-go/cors" ) func Start(port int) error { host := fmt.Sprintf(":%d", port) return http.ListenAndServe(host, cors.CORS(Routes())) }
package goSolution func maxScore(cardPoints []int, k int) int { n := len(cardPoints) m := n - k s := GetPrefixSum(cardPoints) r := s[m] for i := m + 1; i <= n; i++ { r = min(r, s[i] - s[i - m]) } r = s[n] - r return r }
package logger import ( "os" "go.uber.org/zap" "go.uber.org/zap/zapcore" ) var ( logger *zap.SugaredLogger level = zap.NewAtomicLevel() levelMapping = map[string]zapcore.Level{ "debug": zapcore.DebugLevel, "info": zapcore.InfoLevel, "warn": zapcore.WarnLevel, "error": zapcore.ErrorLevel,...
package easygraph import ( "bytes" "encoding/json" "io/ioutil" "net/http" "github.com/pkg/errors" ) // Client is a graphql client type Client interface { SetToken(token string) QueryBuilder() *QueryBuilder Run(q Query, response interface{}) error } type client struct { url string token string } // NewC...
package test_raftstore import ( "context" "io/ioutil" "log" "os" "path/filepath" "github.com/coocood/badger" "github.com/pingcap-incubator/tinykv/kv/config" "github.com/pingcap-incubator/tinykv/kv/engine_util" "github.com/pingcap-incubator/tinykv/kv/pd" tikvConf "github.com/pingcap-incubator/tinykv/kv/tikv/...
package main import ( "flag" "github.com/stretchkennedy/go-smtp-server" "log" ) func main() { addrPtr := flag.String("addr", ":2500", "a TCP address to bind to") certFilePtr := flag.String("cert-file", "", "a certificate") keyFilePtr := flag.String("key-file", "", "a private key file") flag.Parse() server :=...
package tree import ( "errors" "fmt" "sort" ) // Record is an input record representing a Node type Record struct { ID, Parent int } // Node of a tree struct type Node struct { ID int Children []*Node } // Build returns a tree from a slice of records // BenchmarkTwoTree-12 50 ...
package main import ( "fmt" "io" "io/ioutil" "net/http" "time" "encoding/json" "github.com/rs/xid" "github.com/zenazn/goji/web" ) func ensureGuidExists(guid string, w http.ResponseWriter) bool { exists, err := Redis.SIsMember(sessionsKey, guid).Result() if err != nil { panic(err) } if !exists { http....
// This file was generated for SObject StreamingChannel, API Version v43.0 at 2018-07-30 03:47:47.774719652 -0400 EDT m=+34.118606310 package sobjects import ( "fmt" "strings" ) type StreamingChannel struct { BaseSObject CreatedById string `force:",omitempty"` CreatedDate string `force:",omitempty...
package utils import ( "fmt" "strings" ) func Strike(s string) string { if len(s) == 0 { return s } return fmt.Sprintf("\u0336%s\u0336", strings.Join(strings.Split(s, ""), "\u0336")) }
package merkle import ( "bytes" "crypto/sha256" "errors" //"fmt" ) type BYTE []byte func doubleSha256(s []BYTE) BYTE { b := new(bytes.Buffer) for _, d := range s { b.Write([]byte(d)) } hash := sha256.New() hash.Write(b.Bytes()) temp := hash.Sum(nil) hash1 := sha256.New() hash1.Write(temp) return BYTE(...
package testcase import ( "testing" "time" "github.com/stretchr/testify/assert" ) const ( _account1 = "0x7c00f5a4312a6a3e458a07c2d650ce13c76b68b1" ) func Test_Transfer(t *testing.T) { amount := 1234 // Client test transferTo(t, CmdClient, _account1, amount) // Light Test transferTo(t, CmdLight, _account1,...
package printer import ( "bytes" "testing" "time" "github.com/stretchr/testify/assert" corev1 "k8s.io/api/core/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/utils/pointer" wfv1 "github.com/argoproj/argo/pkg/apis/workflow/v1alpha1" intstrutil "github.com/argoproj/argo/util/intstr" ) func TestPri...
package cli import ( "boltview/exec" "github.com/c-bata/go-prompt" ) var cmdHistory []string func Run() { for { t := prompt.Input("> ", completer, prompt.OptionHistory(cmdHistory)) addHistory(t) exec.Run(t) } } func addHistory(s string) { cmdHistory = append(cmdHistory, s) }
/* Copyright © 2022 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 main import ( "bytes" "flag" "fmt" "net/http" "os" "strconv" "strings" "sync" "golang.org/x/net/html" ) var client http.Client var initialSite string var wg sync.WaitGroup var sitemap Sitemap // Crawl uses fetcher to recursively crawl // pages starting with url, to a maximum of depth. func Crawl(ur...
package parser import ( "fmt" "server/data/datatype" "strconv" "strings" ) /* 字段类型 */ type Field struct { Name string Type string IsNull bool AutoInc bool } type TblField struct { FieldList []Field IndexInfo map[string][]string } func GetDbType(t string, size int) string { st := "" switch t { ca...
/* * Minio Client (C) 2014, 2015 Minio, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law ...
package stairs1 import "testing" func TestStairs(t *testing.T) { steps := Stairs(9) t.Log(steps) }
package main import "fmt" func main() { defer fmt.Println("Ini akan keluar dibagian terakhir. tulisan ini akan muncul saat sebuah fungsi telah sampai di return atau diakhir baris fungsi"); defer fmt.Println("terakhir 2"); defer fmt.Println("terakhir 3"); fmt.Println("1"); fmt.Println("2"); fmt.Println("3"...
package test import ( listen "cdc" "testing" ) func TestSetupUpdateColumnListenerForExistingColumn(t *testing.T) { table := "users" column := "name" update := listen.UpdateColumn{} listener, err := update.Listener(listen.Event{ ConnParams: connParams, Event: listen.InsertSQLEvent, Table: table...
package leetcode import ( "math" "testing" ) func TestMyAtoi(t *testing.T) { tests := []struct { str string val int }{ {"10", 10}, {"-10", -10}, {" -10", -10}, {" 10", 10}, {" a10", 0}, {"10a", 10}, {"1a0", 1}, {"a10", 0}, {"", 0}, {"2147483648", math.MaxInt32}, {"-2147483649", math.M...
// Package asset abstracts generated asset representations. package asset import ( "archive/zip" "bytes" "fmt" "path" ) // Asset is a named byte slice. type Asset interface { Name() string Data() []byte } // An asset is an in-memory Asset. type asset struct { name string data []byte } // New returns a new A...
package providers // Registry maps ClusterMetadata.Platform() to per-platform Gather methods. var Registry = make(map[string]NewFunc)
package stack import ( "testing" ) func Test_Stack(t *testing.T) { s := ArrayStack{} if s.Size() != 0 { t.Errorf("Length of an empty stack should be 0") } s.Push(1) if s.Size() != 1 { t.Errorf("Length should be 0") } if val, _ := s.Pop(); val != 1 { t.Errorf("Top item should have been 1") } if s....
package lox type Environment struct { enclosing *Environment values map[string]interface{} } func NewEnvironment(enclosing *Environment) *Environment { return &Environment{ enclosing: enclosing, values: make(map[string]interface{}), } } // Define creates a new variable func (e *Environment) Define(name strin...
package main func lengthOfLIS(nums []int) int { store := make([]int, len(nums)+1) for i := range store { store[i] = 1 } for r := 1; r < len(nums); r++ { for l := 0; l < r; l++ { if nums[l] < nums[r] { store[r] = max(store[l]+1, store[r]) } } } ans := -10000 for _, n := range store { if n > ans...
// 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 gokun import ( "github.com/mix3/go-irc" ) type Receiver struct { FromNick string Channel string Args []string conn *irc.Conn } func (receiver *Receiver) Reply(msg string) { receiver.Notice(msg) } func (receiver *Receiver) Notice(msg string) { receiver.conn.Notice(receiver.Channel, msg) } fu...
package leetcode /*Balanced strings are those who have equal quantity of 'L' and 'R' characters. Given a balanced string s split it in the maximum amount of balanced strings. Return the maximum amount of splitted balanced strings. 来源:力扣(LeetCode) 链接:https://leetcode-cn.com/problems/split-a-string-in-balanced-strings ...
package main import ( "errors" db2 "github.com/Hoovs/OpenLibraryClient/server/db" "github.com/Hoovs/OpenLibraryClient/server/handlers" "net/http" "os" "github.com/gorilla/mux" "go.uber.org/zap" ) const ( portDefault = ":8080" searchAPIBaseURI = "http://openlibrary.org/search.json?q=" ) var ( logger *...
package proxy import ( "bufio" "context" "crypto/rand" "crypto/tls" "encoding/base64" "errors" "io" "net" "net/http" "strings" "sync" "time" "github.com/ably-forks/flynn/pkg/random" "golang.org/x/crypto/nacl/secretbox" "gopkg.in/inconshreveable/log15.v2" ) type backendDialer interface { DialContext(c...
package binance import ( "testing" "github.com/stretchr/testify/suite" ) type baseOrderTestSuite struct { baseTestSuite } type orderServiceTestSuite struct { baseOrderTestSuite } func TestOrderService(t *testing.T) { suite.Run(t, new(orderServiceTestSuite)) } func (s *orderServiceTestSuite) TestCreateOrder()...
package render import ( "github.com/veandco/go-sdl2/sdl" ) var window *sdl.Window var surface *sdl.Surface var xScale int32 var yScale int32 // Init the sdl func Init(x int32, y int32) { xScale = x yScale = y if err := sdl.Init(sdl.INIT_EVERYTHING); err != nil { panic(err) } win, err := sdl.CreateWindow("tes...
package main import ( "context" "encoding/json" "net/http" "github.com/go-kit/kit/endpoint" ) type saleRequest struct{} type saleResponse struct { V Sale `json:"v"` Err string `json:"err,omitempty"` } func makeSaleEndpoint(svc SaleGeneratorService) endpoint.Endpoint { return func(ctx context.Context, _ ...
package seev import ( "encoding/xml" "github.com/thought-machine/finance-messaging/iso20022" ) type Document00500104 struct { XMLName xml.Name `xml:"urn:iso:std:iso:20022:tech:xsd:seev.005.001.04 Document"` Message *MeetingInstructionCancellationRequestV04 `xml:"MtgInstrCxlReq"` ...
package main import ( "bufio" "fmt" "os" ) func main() { //os.O_WRONLY | os.O_CREATE:只写方式打开,如果不存在则创建 file, err := os.OpenFile("F:/go/src/golangStudy/file_opt/my.txt", os.O_WRONLY|os.O_CREATE, 0666) if err != nil { fmt.Println(err) return } //及时关闭file句柄 defer file.Close() str := "abc English\r\n" //\r\...
package linkeddata import ( "encoding/base64" "encoding/json" "github.com/btcsuite/btcutil/base58" "log" "testing" ) func TestNewDocument(t *testing.T) { d, priv, err := NewDocument() if err != nil { t.Errorf(err.Error()) } v := Verify(d, base58.Decode(d.PublicKey[0].PublicKeyBase58)) if !v { t.Errorf(...
package buf4k import "sync" type Buffer4K []byte var pool4k sync.Pool = sync.Pool{ New: func() interface{} { return Buffer4K(make([]byte, 4096)) }, } func Get4K() Buffer4K { return pool4k.Get().(Buffer4K) } func Put4K(v []Buffer4K) { pool4k.Put(v) }
package main import ( "github.com/stretchr/testify/assert" "testing" ) func Test_Solve(t *testing.T) { a := Solve(3, 3, Matrix{ {1, 1, 1}, {2, 2, 2}, {0, 1, 0}, }, Matrix{ {3, 3, 3}, {4, 4, 4}, {5, 5, 100}, }) assert.Equal(t, a, Matrix{ {4, 4, 4}, {6, 6, 6}, {5, 6, 100}, }) }
package main import ( "context" "fmt" "os" "os/signal" "ui-backend-for-omotebako-site-controller/app/cmd/fileController" "ui-backend-for-omotebako-site-controller/app/database" "ui-backend-for-omotebako-site-controller/app/file" "ui-backend-for-omotebako-site-controller/app/server/router" "ui-backend-for-omot...
package kube import ( "crypto/rsa" "crypto/x509" "github.com/jetstack-experimental/cert-manager/pkg/util/errors" "github.com/jetstack-experimental/cert-manager/pkg/util/pki" api "k8s.io/api/core/v1" corelisters "k8s.io/client-go/listers/core/v1" ) func GetKeyPair(secretLister corelisters.SecretLister, namespac...
package uinput import "testing" func TestVirtualKeyboard(t *testing.T) { keyboard, err := CreateKeyboard() if err != nil { t.Fatal("Failed to create virtual keyboard") } for i := 0; i < KeyMax; i++ { err = keyboard.KeyPress(uint16(i)) if err != nil { t.Fatal("Failed to press key") } } err = keyboar...
package main //Using iota to calculate years I need to master Go //JK, it will probably take less/more time import "fmt" const ( current_year = 2020 + iota one_year_from_now = current_year + iota two_years_from_now = current_year + iota three_years_from_now = current_year + iota four_years_from_now...
// Copyright 2021 PingCAP, Inc. Licensed under Apache-2.0. package restore import ( "context" "math" "strconv" "sync" "github.com/pingcap/errors" backuppb "github.com/pingcap/kvproto/pkg/brpb" "github.com/pingcap/log" berrors "github.com/pingcap/tidb/br/pkg/errors" "github.com/pingcap/tidb/br/pkg/logutil" ...
/* * Copyright (c) 2020 - present Kurtosis Technologies LLC. * All Rights Reserved. */ package services type Socket struct { IPAddr string Port int }
package comp // DO NOT EDIT: This file was generated by vugu. Please regenerate instead of editing or add additional code in a separate file. import "fmt" import "reflect" import "github.com/vugu/vjson" import "github.com/vugu/vugu" import js "github.com/vugu/vugu/js" import "strings" import "log" var _ = log.Print...
/* Task Continuously print a random character (a-z, A-Z, 0-9) not separated by a newline (\n). Expected output b7gFDRtgFc67h90h8H76f5dD55f7GJ6GRT86hG7TH6T7302f2f4 ... Note: output should be randomised. Requirements/Rules Output must be continuous (i.e. never ending), Output may not comprise of newlines, Output must ...
package binarySearchTree import "fmt" /** @desc 参考自己的c代码逻辑 https://github.com/suhanyujie/DataStructure/blob/master/BSTree/BSTree.c 四种基本的遍历思想为: 前序遍历:根结点 ---> 左子树 ---> 右子树 中序遍历:左子树---> 根结点 ---> 右子树 后序遍历:左子树 ---> 右子树 ---> 根结点 层次遍历:仅仅需按层次遍历就可以(https://www.cnblogs.com/llguanli/p/7363657.html) 树的高度 高度的定义为:从结点x向下到某个叶...
package main type RateLimiterIFace interface { RateLimiter(int) Allow() bool }
package oceanstor import ( "crypto/md5" "encoding/hex" "regexp" "strconv" "strings" log "github.com/golang/glog" . "github.com/sodafoundation/dock/contrib/drivers/utils/config" ) type AuthOptions struct { Username string `yaml:"username,omitempty"` Password string `yaml:"password,omitempty"` ...
package user import ( "context" "github.com/globalsign/mgo" "github.com/globalsign/mgo/bson" ) //Interfaces type ( Repository interface { Insert(ctx context.Context, t *User) error FindByID(ctx context.Context, id string) (*User, error) FindAll(ctx context.Context, r FindingRequestObject) ([]*User, error) ...
package http import ( "database/sql" "net/http" "strconv" validation "github.com/go-ozzo/ozzo-validation" "github.com/labstack/echo" "github.com/syahidfrd/go-boilerplate/domain" "github.com/syahidfrd/go-boilerplate/transport/request" "github.com/syahidfrd/go-boilerplate/utils" ) type AuthorHandler struct { ...
package cooker type HeatOMatic struct { } func NewHeatOMatic() *HeatOMatic { panic("implement BuildApplianceError") }
package template import ( "fmt" "net/http" "github.com/rvillablanca/goweb/errutil" ) // Renderer is used for forward to view. type Renderer struct { Writer http.ResponseWriter } // Forward execute template with template name templateName. func (r *Renderer) Forward(templateName string, model interface{}) { che...
package main import ( "flag" "fmt" "os" "github.com/mayflower/docker-ls/cli/util" "github.com/mayflower/docker-ls/lib" ) const USAGE_TEMPLATE = `usage: docker-rm [options] <repository:reference> Delete a tag in a given repository. valid options: ` var flags *flag.FlagSet = flag.NewFlagSet("main", flag.ExitO...
/***************************************************************** * Copyright©,2020-2022, email: 279197148@qq.com * Version: 1.0.0 * @Author: yangtxiang * @Date: 2020-08-03 12:02 * Description: *****************************************************************/ package netstream import ( "fmt" "github.com/go-xe2/x/...
package request import ( "errors" "github.com/astaxie/beego/validation" "github.com/gin-gonic/gin" "github.com/huhaophp/eblog/models" "github.com/unknwon/com" "strings" ) func ArticleAddRequestValid(c *gin.Context) (error, models.Article) { article := models.Article{} tags := c.PostForm("tags") article.Tags ...
package models import ( "errors" "fmt" "nomadiclife/helper/mails" "reflect" "strings" "time" "github.com/beego/beego/v2/client/orm" validation "github.com/go-ozzo/ozzo-validation/v4" "github.com/go-ozzo/ozzo-validation/v4/is" "golang.org/x/crypto/bcrypt" ) type User struct { Id int64 `...
package main import ( "data" "db" "flag" "fmt" "os" "os/user" "path/filepath" "strings" tw "twitter" ) var usernames string func init() { flag.StringVar(&usernames, "u", "Mazafard,shib,baam", "the users who play with them") db.Settings().StorePath = settingsPath() } func settingsPath() string { current...
package main import ( "time" "github.com/stapelberg/zkj-nas-tools/ping" ) func pingBeast() { for { result := make(chan *time.Duration) go ping.Ping("beast", 1*time.Second, result) latency := <-result stateMu.Lock() state.beastPowered = latency != nil if state.beastPowered { lastContact["beast"] = ...
package main import "learngo/queue" func main() { q := queue.Queue{1} q.Push(2) }
package handler import ( "net/http" "strconv" "github.com/gitbufenshuo/relation/content" "github.com/labstack/echo" ) type ReadRes struct { Msg string Data []uint64 OneData uint64 } func ReadHandler(c echo.Context) error { var self uint64 { ss := c.Param("self") if n, err := strconv.ParseUint(s...
package main import ( "github.com/gin-gonic/gin" "github.com/gin-contrib/cors" "cms/config" "cms/framework" _ "cms/database/mysql" "log" "fmt" ) func main() { if config.AppConfig.Server.LogModelEnable { gin.SetMode(gin.DebugMode) } else { gin.SetMode(gin.ReleaseMode) } router := gin.New() router.Use...
package lsp import ( "context" "fmt" "path" "github.com/golangq/q" "golang.org/x/tools/lsp/protocol" ) // Mirrors config in // adl/vscode-ext/package.json type TronCfg struct { *TronExtCfg *TronLangCfg } type TronExtCfg struct { ApplyPTComp bool `json:"autoApplyStructCompletions"` Includes []stri...
package handlers import ( "encoding/json" "net/http" "github.com/yashdalfthegray/color-info/models" ) // NewStatusHandler configures a status handler with a server id // and returns it. The status handler will respond with a JSON // { status: "ok", serverId: "some string" } func NewStatusHandler(serverID string) ...
/***************************************************************** * Copyright©,2020-2022, email: 279197148@qq.com * Version: 1.0.0 * @Author: yangtxiang * @Date: 2020-09-01 17:51 * Description: *****************************************************************/ package rpcRouter import ( "context" "github.com/go-xe...
package main import ( "fmt" "log" "os" "os/exec" "os/signal" "path/filepath" "strings" "syscall" ) func main() { argc := len(os.Args) if argc < 2 { fmt.Println("Usage:", os.Args[0], " pragram args...") return } workdir, err := os.Getwd() if err != nil { fmt.Println("运行错误", err.Error()) } name...
package zip import ( "errors" "fmt" "io" "os" "os/exec" "path/filepath" "strings" ) // Backend config type Backend struct { Config *BackendConfig } // NewZipBackend instantiate a new ZIP Archive Backend // and configure it from config map func NewZipBackend(config map[string]interface{}) (zb *Backend, err er...
package compiler import "../utils" type MmlPattern struct { Name string Cmds []int HasAnyNote bool NumTicks int } type MmlPatternMap struct { keys [] string data []*MmlPattern } func (m *MmlPattern) GetCommands() []int { return m.Cmds } func (m *MmlPatternMap) FindKe...
// Copyright 2015 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 server defines a gRPC server. package server import ( "context" "crypto/tls" "crypto/x509" "fmt" "io" "io/ioutil" "net" "time" "github.com/danielkvist/botio/cache" "github.com/danielkvist/botio/db" "github.com/danielkvist/botio/proto" "github.com/dgrijalva/jwt-go" "github.com/golang/protobuf/...
package nv7 import ( "context" "github.com/filecoin-project/go-state-types/abi" "github.com/filecoin-project/go-state-types/big" cid "github.com/ipfs/go-cid" cbor "github.com/ipfs/go-ipld-cbor" "github.com/filecoin-project/specs-actors/v2/actors/builtin" power "github.com/filecoin-project/specs-actors/v2/acto...
package common import ( "log" "path/filepath" "reflect" "toml" ) //check the v passed whether is nil or not func IsNil(v interface{}) bool { return (v == nil) } //check the v passed whether is not nil or not func IsNotNil(v interface{}) bool { return !IsNil(v) } //now only write to console //will be ouptput t...