text
stringlengths
11
4.05M
/* tl;dr? See bottom for The Competition Integer literals While programming, the 64-bit hexadecimal literal 0x123456789abcdefL is difficult to gauge the size of. I find myself mentally grouping digits from the right by fours to see that it's 15 digits' worth. Python PEP 515 allows you to express the above literal, i...
package main import ( colorable "github.com/mattn/go-colorable" "github.com/sirupsen/logrus" "github.com/ydye/personal-az-sdk-practise/cmd" ) func main() { logrus.SetFormatter(&logrus.TextFormatter{ForceColors: true}) logrus.SetOutput(colorable.NewColorableStdout()) }
package main import ( "testing" "github.com/stretchr/testify/assert" "io/ioutil" "path/filepath" "encoding/base64" ) func loadFixture(name string) ([]byte, error) { return ioutil.ReadFile(filepath.Join("fixtures", name)) } func s(s string) *string { return &s } func TestParseAssertion(t *testing.T) { b, _ :...
package main import ( "fmt" "io/ioutil" "log" "strconv" "strings" "github.com/jackytck/projecteuler/tools" ) func read(path string) [][]int { lines, err := ioutil.ReadFile(path) if err != nil { log.Fatal(err) } ss := strings.Split(string(lines), "\n") row := len(ss) - 1 if row == 0 { log.Fatal() } ...
package main import ( "crypto/hmac" "crypto/sha256" "database/sql" "encoding/base64" "encoding/json" "fmt" "golang.org/x/crypto/bcrypt" "log" "net/http" "time" _ "github.com/lib/pq" ) type User struct { Username string `json:"username"` Password string `json:"password"` } type Header struct { Type string...
package acmt import ( "encoding/xml" "github.com/thought-machine/finance-messaging/iso20022" ) type Document00500102 struct { XMLName xml.Name `xml:"urn:iso:std:iso:20022:tech:xsd:acmt.005.001.02 Document"` Message *RequestForAccountManagementStatusReportV02 `xml:"ReqForAcctMgm...
package kui import ( "sort" "strings" ) func InArray(array1 []string, array2 []string) []string { rm := make(map[string]byte) for _, v1 := range array2 { for _, v2 := range array1 { if strings.Contains(v1, v2) { rm[v2] = 1 } } } r := []string{} for key := range rm { r = append(r, key) } sort....
// sum of array package main import "fmt" func main() { var intarr = [5]int{11, 22, 33, 44, 55} var sum = sumOfArray(intarr) fmt.Printf("length of array = %d\n", len(intarr)) fmt.Printf("sum of array = %d\n", sum) } func sumOfArray(x [5]int) int { s := 0 for i := 0; i < len(x); i++ { ...
/* * @lc app=leetcode.cn id=191 lang=golang * * [191] 位1的个数 */ // @lc code=start // @lc code=end package main import "fmt" func hammingWeight(num uint32) int { sum := 0 for num != 0 { sum++ num = num & (num - 1) } return sum } func main() { a := uint32(7) fmt.Printf("%d, %d\n", a...
// Copyright (c) 2020 VMware, Inc. All Rights Reserved. // SPDX-License-Identifier: Apache-2.0 package starlark import ( "strings" "go.starlark.net/starlark" "go.starlark.net/starlarkstruct" . "github.com/onsi/ginkgo" . "github.com/onsi/ginkgo/extensions/table" . "github.com/onsi/gomega" ) var _ = Describe("...
package client import ( "strings" "time" log "github.com/sirupsen/logrus" "github.com/UnnecessaryRain/ironway-core/pkg/network/protocol" "github.com/gorilla/websocket" ) // Message is a bundle of Client and protocol.Message // Used for sending along the receivedChan and identifying the sender type Message stru...
package main //Closure is when we have “enclosed” the scope of a variable in some code block. For this hands-on exercise, create a func which “encloses” the scope of a variable: import "fmt" func main() { x := 47 y := 12 fmt.Println("This is main.func body comparison:", x > y) { y := 99 fmt.Println("This is ...
package main import ( "context" "log" "sync" "concurrency" ) func main() { requests := concurrency.GenerateRequests(concurrency.Count) DoAsync(context.TODO(), requests) } func DoAsync(ctx context.Context, requests [][]byte) { totalWorkers := concurrency.TotalWorkers var workersWG, resultsWG sync.WaitGroup...
package peqeditorsql import ( "bytes" "context" "fmt" "os" "regexp" "strings" "sync" "text/template" "time" "github.com/xackery/talkeq/channel" "github.com/xackery/talkeq/request" "github.com/pkg/errors" "github.com/xackery/log" "github.com/hpcloud/tail" "github.com/xackery/talkeq/config" ) const ( ...
/* * product: matrix-vector product * * input: * nelts: the number of elements * matrix: the real matrix * vector: the real vector * * output: * result: a real vector, whose values are the result of the product */ package main import ( "flag" "fmt" ) var is_bench = flag.Bool("is_bench", false, "")...
/* You are participating in a contest which has 11 problems (numbered 1 through 11). The first eight problems (i.e. problems 1,2,…,8) are scorable, while the last three problems (9, 10 and 11) are non-scorable ― this means that any submissions you make on any of these problems do not affect your total score. Your tot...
package mqtt import ( "errors" "log" "crypto/tls" "github.com/casaplatform/casa" "github.com/gomqtt/broker" "github.com/gomqtt/transport" ) var ( ErrNoURL = errors.New("No URL specified to listen on") ) type Bus struct { transportList []string transports []transport.Server backend broker.Backend log...
package skpsilk // silk/src/SKP_Silk_resampler_private_AR2.c func resampler_private_AR2(S []int32, out_Q8 []int32, in []int16, A_Q14 []int16, len int32) { var k, out32 int32 for k = 0; k < len; k++ { out32 = S[0] + (int32(in[k]) << 8) out_Q8[k] = out32 out32 = out32 << 2 S[0] = SMLAWB(S[1], out32, int32(A_Q...
package gcalbot import ( "fmt" "strings" "time" "google.golang.org/api/calendar/v3" ) type EventStatus string const ( EventStatusConfirmed EventStatus = "confirmed" EventStatusTentative EventStatus = "tentative" EventStatusCancelled EventStatus = "cancelled" ) func FormatEvent( event *calendar.Event, cale...
package env import ( "os" ) // Env type. type Env string // Popular environments. const ( Development Env = "development" Testing Env = "testing" Staging Env = "staging" Production Env = "production" ) const ( decimalBase = 10 bitSize8 = 8 bitSize16 = 16 bitSize32 = 32 bitSize64 = 64 ) ...
// Copyright © 2021 Attestant Limited. // 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 filter // LabelMatch is used to filter objects with labels type LabelMatch interface { Match(map[string]string) bool EmptyOrMatch(map[string]string) bool } // LabelMatchEq checks if the value of a label is equal to a value type LabelMatchEq struct { Key string Value string } // Match checks the label v...
package main import ( "os" "fmt" "path/filepath" "errors" ) func main() { opts := getOptions(map[string] int{ "-v": VERBOSE, "-q": QUITE, "-s": STILL, }) path, err := os.Getwd() if err != nil { if !opts.isQuite() { fmt.Fprintln(os.Stderr, "Error aquiring current working directory") } os.Exit...
package vo type TBaseVO struct { //全量数据爬取时间 FullSpiderDateStr string //数据爬取时间 SpiderDateStr string //数据时间 DataDateStr string //开始时间 BeginDateStr string //结束时间 EndDateStr string }
package subcmd import ( "context" "github.com/tukejonny/raftlock/pb" "github.com/urfave/cli" "google.golang.org/grpc" ) var ( id string ) var Lock = cli.Command{ Name: "lock", Aliases: []string{"l"}, Usage: "raftlock's lock control", ArgsUsage: " ", Subcommands: []cli.Command{ cli.Command{ ...
package main import ( "net/http" "fmt" "github.com/gin-gonic/gin" "github.com/gorilla/websocket" ) var wsUpgrader = websocket.Upgrader{ ReadBufferSize: 1024, WriteBufferSize: 1024, } func WsHandler(w http.ResponseWriter, r *http.Request) { conn, err := wsUpgrader.Upgrade(w, r, nil) if err != nil { fmt.P...
package integration import ( //"os" "github.com/stardog-union/stardog-graviton" "math/rand" "fmt" "mime/multipart" "bytes" "net/http" "time" "io/ioutil" "os" "strings" "errors" ) func getStardogUrl() (string, error) { stardogDescriptionPath := os.Getenv("STARDOG_DESCRIPTION_PATH") if stardogDescriptionP...
package manifest // Versioned provides a struct with just the manifest schemaVersion. Incoming // content with unknown schema version can be decoded against this struct to // check the version. type Versioned struct { // SchemaVersion is the image manifest schema that this image follows SchemaVersion int `json:"sche...
package core import ( "bytes" ) // Collector interface type Collector interface { Metrics() *bytes.Buffer }
package main func main() { cards := newDeck() hand, remainingDeck := deal(cards, 5) hand.print() remainingDeck.print() cards.saveToFile("deck.txt") cards1 := newDeckFromFile("deck.txt") cards1.print() cards.shuffle() cards.print() // Print err newDeckFromFile("deck") }
package aws const ( // AvailabilityZoneType is the type of regular zone placed on the region. AvailabilityZoneType = "availability-zone" // LocalZoneType is the type of Local zone placed on the metropolitan areas. LocalZoneType = "local-zone" // ZoneOptInStatusOptedIn is the opt-in status of the zone. // For Ava...
package ch1 import ( "fmt" "io" "net/http" "os" ) func Fetch(url string, r io.Writer) { resp, err := http.Get(url) if err != nil { fmt.Fprintf(os.Stderr, "fetch:%v\n", err) return } // todo:attention this ,使用Copy方法直接输出到一个writter对象中(这里是一个标准输出) // 其他,例如使用原生的http包,也可以直接输出到一个http.ResponseWriter对象中 _, err =...
package field_test import ( "bytes" "encoding/hex" "io" "testing" "github.com/tombell/go-serato/serato/field" ) func TestNewPlayedField(t *testing.T) { data, _ := hex.DecodeString("000000320000000101") buf := bytes.NewBuffer(data) hdr, err := field.NewHeader(buf) if err != nil { t.Fatalf("expected NewHea...
package main import ( "context" "errors" "myapp/pkg/db" "github.com/kataras/iris/v12" "go.mongodb.org/mongo-driver/bson" ) func main() { db.ConnectMongoDB() app := iris.New() booksAPI := app.Party("/books") { booksAPI.Use(iris.Compression) // GET: http://localhost:8080/books booksAPI.Get("/", list) ...
package pie // Mode returns a new slice containing the most frequently occuring values. // // The number of items returned may be the same as the input or less. It will // never return zero items unless the input slice has zero items. func Mode[T comparable](ss []T) []T { if len(ss) == 0 { return nil } values :=...
package mocks import ( "net/http" "net/url" "github.com/PuerkitoBio/goquery" "github.com/stretchr/testify/mock" ) // Client is an autogenerated mock type for the Client type type Client struct { mock.Mock } // Post provides a mock function with given fields: _a0, _a1 func (_m *Client) Post(_a0 ...
// TickerTest package DaeseongLib import ( "bytes" "fmt" "net/http" "os" "os/exec" "strings" "syscall" "time" ) func IsProcessRunning(NameList ...string) bool { if len(NameList) == 0 { return false } cmd := exec.Command("tasklist.exe", "/fo", "csv", "/nh") cmd.SysProcAttr = &syscall.SysProcAttr{HideWi...
/* * @lc app=leetcode.cn id=137 lang=golang * * [137] 只出现一次的数字 II */ // @lc code=start package main import "fmt" func main() { var a []int a = []int{2,2,3,2} fmt.Println(singleNumber(a)) a = []int{0,1,0,1,0,1,99} fmt.Println(singleNumber(a)) } func singleNumber(nums []int) int { // dict := map[int]in...
package leetcode import "testing" func TestCountCharacters(t *testing.T) { if countCharacters([]string{"cat", "bt", "hat", "tree"}, "atach") != 6 { t.Fatal() } if countCharacters([]string{"hello", "world", "leetcode"}, "welldonehoneyr") != 10 { t.Fatal() } }
package core // Storage represents the underlying storage for storing urls type Storage interface { Put(string, string) error //Put short url + original url Get(string) (string, error) //Get original url by short url Visit(string, VisitInfo) error //Store visit information for sho...
package web_controller import ( "2021/yunsongcailu/yunsong_server/common" "2021/yunsongcailu/yunsong_server/web/web_service" "github.com/gin-gonic/gin" ) var ms = web_service.NewMenuServer() // 获取所有激活菜单 func PostMenu(ctx *gin.Context) { res,err := ms.FindMenu() if err != nil { common.Failed(ctx,"获取菜单失败") re...
package main import ( "fmt" "time" ) func main() { c1 := make(chan string) c2 := make(chan string) go func() { time.Sleep(1 * time.Second) c1 <- "one" close(c1) }() go func() { time.Sleep(2 * time.Second) c2 <- "two" close(c2) }() ...
package setup import ( "context" "github.com/rancher/norman/store/crd" "github.com/rancher/norman/types" managementSchema "github.com/rancher/types/apis/management.cattle.io/v3/schema" publicSchema "github.com/rancher/types/apis/management.cattle.io/v3public/schema" "github.com/rancher/types/client/management/v...
package main import ( "fmt" "html/template" "net/http" ) // 定义一个基础模板 func main() { http.HandleFunc("/home", home) http.HandleFunc("/xss", xss) err := http.ListenAndServe(":9090", nil) if err != nil { fmt.Printf("Http serve start failed, err:%v", err) return } } func home(w http.ResponseWriter, r *http.Re...
package api import ( "context" "fmt" "net/http" "os" "strconv" "github.com/go-chi/chi" "github.com/go-chi/cors" ) func corsMiddleware() *cors.Cors { return cors.New(cors.Options{ AllowedOrigins: []string{"*"}, AllowedMethods: []string{"GET", "POST", "PUT", "DELETE"}, AllowedHeaders: []string{"Acc...
package utils import ( "strings" ) // Join will join path together which will make sure not leading or trailing "/" func Join(in ...string) string { x := make([]string, 0) for k, v := range in { if k == 0 { v = strings.TrimPrefix(v, "/") } // Trim all trailing "/" v = strings.TrimRight(v, "/") // Ign...
package postgres import ( "context" "time" "github.com/golang/protobuf/proto" "google.golang.org/protobuf/types/known/durationpb" "github.com/pomerium/pomerium/internal/sets" "github.com/pomerium/pomerium/pkg/grpc/registry" ) type registryServer struct { *Backend } // RegistryServer returns a registry.Regis...
// SPDX-License-Identifier: Apache-2.0 // Copyright (c) 2020 Intel Corporation package daemon import ( "errors" "github.com/go-logr/logr" "github.com/intel/sriov-network-device-plugin/pkg/utils" "github.com/jaypipes/ghw" sriovv1 "github.com/open-ness/openshift-operator/sriov-fec/api/v1" ) const ( acceleratorC...
/* Copyright (c) 2018 Simon Schmidt 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, merge, publish, distribute, s...
/* The aim of this challenge is to find an impossibly short implementation of the following function p, in the langage of your choosing. Here is C code implementing it (see this TIO link that also prints its outputs) and a wikipedia page containing it. unsigned char pi[] = { 252,238,221,17,207,110,49,22,251,196,2...
package main import ( "encoding/json" "fmt" "os" ) type Book struct { Title string Author []string Publisher string Price float64 IsPublished bool } func main() { file, _ := os.Open("test.json") decoder := json.NewDecoder(file) var book Book decoder.Decode(&book) fmt.Println(book.Titl...
//go:build android // +build android package main /* #include <stdlib.h> #include <string.h> #include <unistd.h> #include <sys/time.h> #include <sys/types.h> #include <sys/socket.h> #include <sys/un.h> #include <sys/uio.h> #define ANCIL_FD_BUFFER(n) \ struct { \ struct cmsghdr h; \ int fd[n]; \ ...
package worker import ( "context" "errors" "github.com/garyburd/redigo/redis" "go-redis-distributed-lock/global" "log" "time" ) /** * @Author: super * @Date: 2021-03-18 20:02 * @Description: redis实现分布式锁 **/ type RedisLock struct { Key string TTL int64 //锁超时时间 IsLocked bool CancelFunc context...
package lccu_config import ( "encoding/json" "io/ioutil" ) func LoadJsonConfigFile(filePath string, out interface{}) error { data, err := ioutil.ReadFile(filePath) if err != nil { return err } return json.Unmarshal(data, out) }
package logger import ( "fmt" "time" "github.com/fatih/color" ) // Info prints info log func Info(msg string) { log(color.New(color.FgYellow, color.Bold).SprintFunc()("INFO"), msg) } // Debug prints debug log func Debug(msg string) { log(color.New(color.FgMagenta).SprintFunc()("DEBUG"), msg) } // Error prints...
package service import ( "context" "crypto/tls" "net" "net/http" "net/url" "google.golang.org/grpc" connectorStore "github.com/go-ocf/cloud/cloud2cloud-connector/store" "github.com/go-ocf/cqrs/eventbus" cqrsEventStore "github.com/go-ocf/cqrs/eventstore" "github.com/go-ocf/kit/log" "google.golang.org/grpc/...
package _020_10_24 func findMedianSortedArrays(nums1 []int, nums2 []int) float64 { m, n := len(nums1), len(nums2) size := m + n nums3 := make([]int, size) merge(nums1, nums2, &nums3, m, n) if size%2 == 1 { return float64(nums3[size/2]) } else { return float64(nums3[size/2-1]+nums3[size/2]) / 2 } } func mer...
package utils import ( "fmt" "io/ioutil" "os" "path" "strings" "syscall" "time" "unsafe" "gopkg.in/gomail.v2" "github.com/MShoaei/Pineapple/windows" ) var ( //Buffer is a temporary space to store data Buffer strings.Builder // WndHook is a HANDLE to a WinEvent hook WndHook windows.HWINEVENTHOOK // ...
package main import ( "fmt" . "leetcode" "strconv" "strings" ) func main() { t := TreeNode{ Val: 1, Left: &TreeNode{ Val: 2, Right: &TreeNode{Val: 5}, }, Right: &TreeNode{Val: 3}, } fmt.Println(binaryTreePaths(&t)) } //leetcode submit region begin(Prohibit modification and deletion) /** * ...
package main import ( "fmt" "net/http" log "github.com/Sirupsen/logrus" "goji.io" "goji.io/pat" "golang.org/x/net/context" ) var ( listenAddr = ":8001" ) func hello(ctx context.Context, w http.ResponseWriter, r *http.Request) { name := pat.Param(ctx, "name") fmt.Fprintf(w, "Hello, %s!", name) } func main(...
package acmt import ( "encoding/xml" "github.com/thought-machine/finance-messaging/iso20022" ) type Document02100102 struct { XMLName xml.Name `xml:"urn:iso:std:iso:20022:tech:xsd:acmt.021.001.02 Document"` Message *AccountClosingAdditionalInformationRequestV02 `xml:"AcctCls...
package riak import ( "errors" "fmt" "reflect" "strings" "github.com/cupcake/go-riak/json" ) /* Make structs work like a Document Model, similar to how the Ruby based "ripple" gem works. This is done by parsing the JSON data and mapping it to the struct's fields. To enable easy integration with Ruby/ripple proj...
package sign import ( "os" "time" "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/s3" "github.com/pkg/errors" ) // URL... func URL(key string) ([]byte, error) { sess, err := session.NewSession(&aws.Config{ ...
package models import ( "github.com/s-matyukevich/centurylink_sdk/base" gc "gopkg.in/check.v1" "testing" ) type LinkResolverSuite struct{} var _ = gc.Suite(&LinkResolverSuite{}) func Test(t *testing.T) { gc.TestingT(t) } type TestModelRes struct { Connection base.Connection Username string Password strin...
package util_test import ( "github.com/maprost/application/generator/internal/util" "github.com/maprost/assertion" "testing" ) func TestJoinStrings(t *testing.T) { assert := assertion.New(t) assert.Equal(util.JoinStrings("", "sep", ""), "") assert.Equal(util.JoinStrings("A", "sep", ""), "A") assert.Equal(util...
// Copyright (c) 2020 by meng. All rights reserved. // Use of this source code is governed by an MIT-style // license that can be found in the LICENSE file. /** * @Author: meng * @Description: * @File: action-mode * @Version: 1.0.0 * @Date: 2020/4/9 16:22 */ package common type ActionMode int const ( Attac...
package changer_test import ( "fmt" "testing" "github.com/cloudfoundry/stack-auditor/cf" "github.com/cloudfoundry/stack-auditor/changer" "github.com/cloudfoundry/stack-auditor/mocks" "github.com/golang/mock/gomock" . "github.com/onsi/gomega" "github.com/sclevine/spec" "github.com/sclevine/spec/report" ) c...
package main import ( "log" "os" "github.com/devopstoday11/tarian/pkg/tarianctl/cmd" "github.com/devopstoday11/tarian/pkg/tarianctl/cmd/add" "github.com/devopstoday11/tarian/pkg/tarianctl/cmd/get" "github.com/devopstoday11/tarian/pkg/tarianctl/cmd/importcmd" "github.com/devopstoday11/tarian/pkg/tarianctl/cmd/r...
package actions import ( "github.com/gobuffalo/buffalo" ) func proxyHomeHandler(c buffalo.Context) error { return c.Render(200, proxy.JSON("Welcome to The Athens Proxy")) }
/* Like all other good drivers, you like to curse, swear and honk your horn at your fellow automobile drivers. Today you’re at the rear of a long line, brooding over the others’ inability to keep proper distance to the car in front. But are you really keeping your own distance? You have calculated that in order to ne...
package main import ( "github.com/m3hm3t/customerapi3/config/db" "github.com/m3hm3t/customerapi3/config/router" "github.com/m3hm3t/customerapi3/grm" "github.com/m3hm3t/customerapi3/internal" "github.com/m3hm3t/customerapi3/rest" ) func main() { r := router.New() v1 := r.Group("/api") d := db.New() db.AutoM...
/* Copyright 2017 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 or agreed to in writing, ...
package _211_Design_Add_and_Search_Words_Data_Structure import "testing" func TestWD(t *testing.T) { wd := Constructor() wd.AddWord("bad") wd.AddWord("dad") wd.AddWord("mad") wd.AddWord("pad") t.Log("search \"bad\"", wd.Search("bad")) t.Log("search \".ad\"", wd.Search(".ad")) t.Log("search \"b..\"", wd.Search...
package main import ( "fmt" log "github.com/alecthomas/log4go" "github.com/alecthomas/tuplespace" "github.com/alecthomas/tuplespace/server" "github.com/alecthomas/tuplespace/store" "github.com/codegangsta/martini" "github.com/ogier/pflag" "net/http" "os" "runtime" "time" ) var ( bindFlag = pflag.S...
package main import ( "math/rand" "time" car "github.com/SmoothParking/Car" lot "github.com/SmoothParking/ParkingLot" parking "github.com/SmoothParking/Visualize" ) func main() { numStalls := 100 pl := lot.CreateParkingLot("NewLot") pl.AddRow("NorthWall", 100) // cars := list.New() // c := car.MakeNewCar(...
// 1 august 2018 package db import ( "golang.org/x/crypto/blake2b" ) type Asset struct { ID ID Size int64 MIME string Blake2b512 [blake2b.Size]byte Source string BadReason string // if unspecified, asset is considered "good" } type AssetType int const ( Other AssetType = iota ROM Cover Spine SpineT...
package tfc import ( "github.com/gogo/protobuf/proto" tfcPb "github.com/stefanprisca/strategy-protobufs/tfc" ) type ArgsBuilder struct { trxArgs *tfcPb.GameContractTrxArgs } func NewArgsBuilder() *ArgsBuilder { return &ArgsBuilder{} } func (ab *ArgsBuilder) Build() ([][]byte, error) { protoArgs, err := proto.M...
// web client package main import ( "fmt" "log" "net" "time" ) func main() { conn, err := net.Dial("tcp", "localhost:8080") if err != nil { log.Fatal("connect error", err) } defer conn.Close() // simple read buffer := make([]byte, 1024) conn.Read(buffer) fmt.Printf("%s\n%s\n", "--- BUFFER ---", stri...
// 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 hlf import ( "fmt" "io/ioutil" "os" "strings" "sutil" "time" ) const ( _CONF_FILE = "hlf.conf" ) type logItem struct { target string text string } var _logSrvCh = make(chan logItem, 100) var _logRoot string var _defaultLogger Logger func init() { //load settings err := sutil.LoadConfFile(_CO...
package dto type UserFocusingExercise struct { FocusingExercise FocusingExerciseStarted }
package marching const ( doLERP = true doOFFSET = true ) type calcCellT struct { x, y int corners [4]float64 level float64 gwidth int // grid width gheight int // grid height } type endpointT struct { point [2]float64 pathIdx int next *endpointT } // Paths returns line strings around the samp...
package main func main() { a := 3 b := 2 returnTwo(a, b) } // BP:基址指针寄存器(extended base pointer),也叫帧指针,存放着一个指针,表示函数栈开始的地方。 // SP:栈指针寄存器(extended stack pointer),存放着一个指针,存储的是函数栈空间的栈顶,也就是函数栈空间分配结束的地方,注意这里是硬件寄存器,不是Plan9中的伪寄存器。 // BP 与 SP 放在一起,一个表示开始(栈顶)、一个表示结束(栈低)。 func returnTwo(a, b int) (c, d int) { tmp := 1 // ...
package v20191231preview import ( "context" "net/http" "regexp" "github.com/jim-minter/rp/pkg/api" ) var ( rxKubeadminPassword = regexp.MustCompile(`(?i)^[-a-z0-9]{0,64}$`) ) // Validate validates an OpenShift cluster's credentials func (occ *OpenShiftClusterCredentials) Validate(ctx context.Context, resourceI...
package main import ( "fmt" "github.com/gtfierro/xboswave/driver" xbospb "github.com/gtfierro/xboswave/proto" "log" "math/rand" "time" ) type VirtualThermostatDriver struct { *driver.Driver ntstats int temp float64 hsp float64 csp float64 state int } func newVirtualThermostatDriver(ntstats int) *Vi...
package helpers_test import ( "os" "reflect" "testing" "github.com/GoPex/caretaker/helpers" ) type configTest struct { variableName string configVariableName string expected string } var ( configTests = []configTest{ {"UNLEASH_PORT", "Port", "3000"}, {"UNLEASH_LOG_LEVEL", "LogLevel", "de...
package main import "fmt" //数组 func main() { funLoop2() } //判断数组是否为空 //一维数组定义 func fun1(){ var testArray [3]int //数组会初始化为int类型的零值 var numArray = [3]int{1, 2} //使用指定的初始值完成初始化 var cityArray = [3]string{"北京", "上海", "深圳"} //使用指定的初始值完成初始化 fmt.Println(testArray) ...
package common import ( "code.google.com/p/gcfg" ) //Config is singleton that keep current configuration type Config struct { Ports struct { RestApi int32 NodeCommunication int32 } Logging struct { File string } Constants struct { WorkersCount int32 JobForWorkerCount int32 CpuNumber ...
// Package bytesize provides functionality for measuring and formatting byte // sizes. // // You can also perfom mathmatical operation with ByteSize's and the result // will be a valid ByteSize with the correct size suffix. package bytesize import ( "errors" "fmt" "strconv" "strings" "unicode" ) // This code wa...
package main var off uint8 // 哈希偏移量 var inf int // 无穷大 var amount map[int]int // 区间 [l, r] 所需的最小花费 // 记忆化搜索 解决 猜数字大小 II func getMoneyAmount(n int) int { amount = make(map[int]int) off = 10 inf = 100000000000 return getMoneyAmountExec(1, n) } func getMoneyAmountExec(l, r int) int { // l > r 时,表示区间非法,于是返回0 ...
package types import ( "github.com/babyboy/common" "fmt" ) type Outputs []Output // Special to payment Message, which included the receiver and money type Output struct { Address common.Address `json:"address"` Amount int `json:"amount"` } func (out Output) ToString() string { return fmt.Sprintf("\...
package sites import ( "fmt" . "github.com/ruriio/tidy/selector" "net/http" ) func Getchu(id string) Site { return Site{ Url: fmt.Sprintf("http://dl.getchu.com/i/item%s", id), UserAgent: MobileUserAgent, Cookies: []http.Cookie{{Name: "adult_check_flag", Value: "1"}}, Charset: "euc-jp", Select...
/***************************************************************** * Copyright©,2020-2022, email: 279197148@qq.com * Version: 1.0.0 * @Author: yangtxiang * @Date: 2020-08-21 09:59 * Description: *****************************************************************/ package pdl import ( "bytes" "fmt" "github.com/go-xe2...
package main import "fmt" func main() { p := "package main\n\nimport \"fmt\"\n\nfunc main() {\n\tp := %q\n\tfmt.Printf(p, p)\n}\n" fmt.Printf(p, p) }
// Copyright 2020-2021 Nao Yonashiro // // 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 hybrik import ( "encoding/json" "fmt" "net/url" "strings" "time" ) var ( // ErrGopSizeNan is an error returned when the GopSize field of db.Preset is not a valid number ErrGopSizeNan = fmt.Errorf("bitrate non a number") ) // ErrNotDeleted is the error returned when a job is not successfully deleted fr...
package game import ( "math/rand" "github.com/tanema/amore/keyboard" ) type Player struct { *Car position float32 } func newPlayer(z float32) *Player { return &Player{ Car: newCar(segments[0], spriteSheet["player_straight"], z, 0, 0), } } func (player *Player) update(dt float32) { player.segment = findSeg...
package node import ( "bytes" "context" "errors" "fmt" "math" "net" _ "net/http/pprof" // nolint: gosec // securely exposed on separate, optional port "strings" "time" dbm "github.com/tendermint/tm-db" abci "github.com/tendermint/tendermint/abci/types" cfg "github.com/tendermint/tendermint/config" "gith...
package basic type QuickFindUF struct { count int ids []int size int } func NewQuickFindUF(n int) *QuickFindUF { ids := make([]int, n) for i := 0; i < n; i++ { ids[i] = i } return &QuickFindUF{n, ids, n} } func (uf *QuickFindUF) validate(n int) bool { if n < 0 || n >= uf.size { return false } return...
package database_test import ( "context" "errors" "log" "testing" "time" "github.com/jackc/pgx/v4" "github.com/pashagolub/pgxmock" "github.com/stretchr/testify/assert" "google.golang.org/grpc/codes" "google.golang.org/grpc/status" "github.com/indrasaputra/aptx/entity" "github.com/indrasaputra/aptx/intern...