text
stringlengths
11
4.05M
// Copyright 2015 Elphas Tori // // 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...
// This contains all necessary tools for the producer to accept connections and process the recieved data package producer import ( "bytes" "database/sql" "encoding/hex" "fmt" "io/ioutil" "log" "net" "os" "os/signal" "runtime" "syscall" "time" "github.com/SIGBlockchain/project_aurum/internal/accountstabl...
package api import ( "sharemusic/models/util" ) func PlayListDetail(query map[string]interface{}) map[string]interface{} { data := map[string]interface{}{ "id": query["id"], "n": 100000, //"n": 3, "s": query["s"], } if query["s"] == nil { data["s"] = 8 } options := map[string]interface{}{ "crypto":...
package conditions import ( "context" "fmt" "yunion.io/x/jsonutils" "yunion.io/x/pkg/errors" "yunion.io/x/onecloud/pkg/apis/monitor" "yunion.io/x/onecloud/pkg/hostman/hostinfo/hostconsts" "yunion.io/x/onecloud/pkg/mcclient/auth" "yunion.io/x/onecloud/pkg/mcclient/modulebase" mc_mds "yunion.io/x/onecloud/pkg...
package pgconnect import ( "fmt" "log" "os" "github.com/jackc/pgx" "github.com/joho/godotenv" ) func envPGConfig() pgx.ConnConfig { err := godotenv.Load(".env") if err != nil { log.Fatalf("Error loading .env file") } fmt.Println(os.Getenv("DB_NAME")) return pgx.ConnConfig{ Host: os.Getenv("D...
package rivescript_test // This test file contains the unit tests that had to be segregated from the // others in the `src/` package. // // The only one here so far is an object macro test. It needed to use the public // RiveScript API because the JavaScript handler expects an object of that type, // and so it couldn'...
// Package recursivelistener implements a Listener that closes its connections // when it is closed. // // This is useful in tests for shutting down code that will run forever until // an error is encountered from the connection(s) that it is using. package recursivelistener import ( "bytes" "net" "sync" "time" ...
package main import ( "fmt" "io" "os" "os/exec" "strconv" "syscall" "time" ) func startSlirp(containerPID int, ifName string, mtu int) (slirpPID int, err error) { slirp4netns, err := findSlirp4netnsBinary() if err != nil { return } readyPipeR, readyPipeW, err := os.Pipe() if err != nil { return 0, fm...
package aiven import ( "fmt" "github.com/hashicorp/terraform-plugin-sdk/helper/acctest" "github.com/hashicorp/terraform-plugin-sdk/helper/resource" "github.com/hashicorp/terraform-plugin-sdk/terraform" "os" "testing" ) func TestAccAivenKafkaSchemaConfiguration_basic(t *testing.T) { t.Parallel() resourceName ...
package blob import ( "github.com/iotaledger/wasp/packages/coretypes/coreutil" "github.com/iotaledger/wasp/packages/hashing" ) const ( Name = "blob" description = "Blob Contract" ) var ( Interface = &coreutil.ContractInterface{ Name: Name, Description: description, ProgramHash: hashing.HashS...
package leetcode /*Given a string s formed by digits ('0' - '9') and '#' . We want to map s to English lowercase characters as follows: Characters ('a' to 'i') are represented by ('1' to '9') respectively. Characters ('j' to 'z') are represented by ('10#' to '26#') respectively. Return the string formed after mapping...
package isHappy func isHappy(n int) bool { // 1 -> true // 2 -> 4,16,37,58,89,145,42,20,4 -> false // 3 -> 9,81,65,61,37 -> false // 4 -> false // 5 -> 25,29,85 -> false // 6 -> 36,45,41,17,50,25 -> false // 7 -> 49,97,130,10 -> true // 8 -> 64,52 -> false // 9 -> 81 -> false //10 -> true m := map[int]bool{...
// Copyright 2017 Yahoo Holdings Inc. // Licensed under the terms of the 3-Clause BSD License. package provider import ( "k8s.io/api/extensions/v1beta1" ) type Annotation string const ( // IngressClass is the annotation on ingress resources for the class of controllers responsible for it IngressClass Annotation =...
package ui import ( "fmt" "github.com/dpordomingo/learning-exercises/ant/actors" "github.com/dpordomingo/learning-exercises/ant/geo" "github.com/dpordomingo/learning-exercises/ant/literals" ) //GetRepresentation returns a stringified representation of a Map, target and Rover func GetRepresentation(m *geo.Map, ta...
package models import ( "github.com/jinzhu/gorm" _ "github.com/jinzhu/gorm/dialects/postgres" ) type DB struct { *gorm.DB } type DBConfig struct { Url string MaxIdleConn int MaxOpenConn int LogMode bool } func NewDB(c DBConfig) (db *DB, err error) { conn, err := gorm.Open("postgres", c.Url) if ...
package main import ( "fmt" "github.com/l6p/utils/client/json" "time" ) type Context struct { BaseUrl string } func SimpleCase(ctx *Context, client *json.Client) { _ = client.R().Get(fmt.Sprintf("%s/todos/1", ctx.BaseUrl)) time.Sleep(5 * time.Second) } func Export() map[string]interface{} { return map[string...
package pkg import "fmt" func Fn() { var s string //lint:ignore SA1006 this is fine fmt.Printf(s) }
package system import "laravel-go/pkg/orm/config" type SystemLog struct { config.Model Request string `json:"request"` Message string `json:"message"` }
package main import "fmt" func Add(a int, b int) int { result := a + b return result } func Sub(a int, b int) int { return a - b } func Mult(a int, b int) int { return a * b } func main() { fmt.Println("Hello!") }
package webdriver import ( "Neo/codes/jsonstruct" "fmt" "os/exec" "github.com/tebeka/selenium" ) var err error //Wdinit return an instance of webdriver func Wdinit() (selenium.WebDriver, error) { caps := selenium.Capabilities(map[string]interface{}{"browserName": "chrome"}) var Driver, err = selenium.NewRemot...
package panic import ( "fmt" "strconv" ) // Panic panics with a divide by zero func Panic() { zero, err := strconv.ParseInt("0", 10, 64) if err != nil { panic(err) } a := 1 / zero fmt.Println("we'll never get here", a) } // Catcher calls Panic func Catcher() { defer func() { if r := recover(); r != nil ...
package abi import ( "fmt" "strings" "github.com/qlcchain/go-qlc/common" "github.com/qlcchain/go-qlc/common/types" "github.com/qlcchain/go-qlc/common/util" "github.com/qlcchain/go-qlc/vm/abi" "github.com/qlcchain/go-qlc/vm/vmstore" ) const ( jsonMiner = ` [ {"type":"function","name":"MinerReward","inputs"...
package integers var Three = 2
package main import ( "encoding/json" "github.com/btcsuite/btcutil/base58" "log" "lucastetreault/did-tangaroa/pkg/did" ) func main() { log.SetFlags(0) ddoc, priv, err := did.NewDocument() if err != nil { panic(err.Error()) } b, err := json.Marshal(ddoc) if err != nil { panic(err.Error()) } log.Print...
package clusterdata // Copyright (c) Microsoft Corporation. // Licensed under the Apache License 2.0. // azureAuthConfig holds auth related part of cloud config type azureAuthConfig struct { // The AAD Tenant ID for the Subscription that the cluster is deployed in TenantID string `json:"tenantId,omitempty" yaml:"te...
package router import ( "github.com/gin-gonic/gin" "myzone/controller" "github.com/gin-contrib/sessions/cookie" "github.com/gin-contrib/sessions" ) func InitRouter() *gin.Engine{ router := gin.Default() store := cookie.NewStore([]byte("secret")) router.Use(sessions.Sessions("session", store)) //设置静态资源路径 ro...
package config // EdgeProxyConfig indicates the edgeproxy config type EdgeProxyConfig struct { // Enable indicates whether enable edgeproxy // default true Enable bool `json:"enable,omitempty"` // SubNet indicates the subnet of proxier // default "10.0.0.0/24", equals to k8s default service-cluster-ip-range SubN...
package mat func Scale(x, y, z float64) Mat4x4 { scaleMatrix := IdentityMatrix // NewMat4x4(make([]float64, 16)) // copy(scaleMatrix.Elems, IdentityMatrix.Elems) scaleMatrix[0] = x scaleMatrix[5] = y scaleMatrix[10] = z return scaleMatrix }
package main import ( "github.com/gorilla/websocket" "net/http" "os" "fmt" "io/ioutil" "time" "encoding/json" ) //First we’ll need to define our Person type: type Person struct { Name string Age int } //We’ll also need to create an upgraded variable, in which we define our read a...
package structs type Article struct { Title string `redis:"title"` Link string `redis:"link"` Poster string `redis:"poster"` PostAt string `redis:"time"` Votes string `redis:"votes"` } type User struct { Name string `redis:"name"` Password string `redis:"password"` Funds string `redis:"funds"` } t...
package cli import ( "encoding/hex" "fmt" "github.com/irisnet/irishub/app/protocol" "github.com/irisnet/irishub/app/v1/rand" "github.com/irisnet/irishub/client/context" "github.com/irisnet/irishub/client/rand/types" "github.com/irisnet/irishub/codec" "github.com/spf13/cobra" "github.com/spf13/viper" ) // Ge...
// Copyright 2023 Google LLC. All Rights Reserved. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // // http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applica...
package zabbix import ( "encoding/json" "fmt" "net/http" "strings" ) var ( actionGetTemplate = `{ "jsonrpc":"2.0", "method":"action.get", "params":{ "output":"extend", "selectOperations":"extend", "selectRecoveryOperations":"extend", "selectFilter":"extend", "filter":{ "eventsource":0, ...
package main import "fmt" func main() { fmt.Println(singleNumbers([]int{4, 1, 4, 6})) } func singleNumbers(nums []int) []int { t := 0 // t 为 两个不相等值的异或值 for _, v := range nums { t ^= v } m := 1 // m 为第一个为 1 的那一位 for m&t == 0 { m <<= 1 } x, y := 0, 0 for _, v := range nums { if v&m == 0 { //如果此数字这一位...
package auth import ( "context" "errors" "net/http" "strings" "time" jwt "github.com/dgrijalva/jwt-go" "github.com/harriklein/pBE/pBEServer/utils" ) // TInfoClaims struct type TInfoClaims struct { User string `json:"user,omitempty"` System string `json:"system,omitempty"` } // TJWTClaim adds email as a c...
// Copyright 2016 Martin Hebnes Pedersen (LA5NTA). All rights reserved. // Use of this source code is governed by the MIT-license that can be // found in the LICENSE file. package main import ( "encoding/json" "fmt" "os" "path/filepath" "runtime" "time" "github.com/la5nta/pat/internal/buildinfo" "github.com/...
package tester import ( "io" "strings" "net/http" "net/http/httptest" "github.com/gin-gonic/gin" "github.com/zeuxisoo/go-zenwords/pkg/keywords" ) // CreateWebEngine return the gin engine for test case func CreateWebEngine() *gin.Engine { keywords.NewKeywords("../../words.txt") engine := gin.New() engine.U...
package main import ( "flag" "io" ) const ( ExitCodeOk = iota ExitCodeParseFlagError ) type CLI struct { outStream, errStream io.Writer } func (c *CLI) Run(args []string) int { flags := flag.NewFlagSet("gophue", flag.ContinueOnError) flags.SetOutput(c.errStream) if err := flags.Parse(args[1:]); err != nil...
package baremetal import ( "crypto/rand" "math/big" "github.com/openshift/installer/pkg/asset" ) // IronicCreds is the asset for the ironic user credentials type IronicCreds struct { Username string Password string } var _ asset.Asset = (*IronicCreds)(nil) // Dependencies returns no dependencies. func (a *Iro...
package main func reverseList(head *ListNode) *ListNode { if head == nil { return nil } arr := []*ListNode{head} cur := head.Next for cur != nil { arr = append(arr, cur) cur = cur.Next } cur = arr[len(arr)-1] r := cur for i := len(arr) - 2; i >= 0; i-- { cur.Next = arr[i] cur = cur.Next } cur.Next...
package main import ( "github.com/naughtydevelopment/todo-go/config" "github.com/naughtydevelopment/todo-go/db" "github.com/naughtydevelopment/todo-go/i18n" "github.com/naughtydevelopment/todo-go/model" "github.com/naughtydevelopment/todo-go/server" ) func init() { i18n.Init() config.Init() db.Init() model.I...
package v1 import "github.com/gin-gonic/gin" func LoginEndpoint(c *gin.Context){ }
/* Background A continued fraction is a way to represent a real number as a sequence of integers in the following sense: x = a0 + (1 / (a1 + 1 / (a2 + ...(1/an)))) Finite continued fractions represent rational numbers; infinite continued fractions represent irrational numbers. This challenge will focus on finite one...
package chain import ( "errors" "math" "testing" "github.com/btcsuite/btcd/btcutil" "github.com/btcsuite/btcd/chaincfg/chainhash" "github.com/btcsuite/btcd/wire" "github.com/stretchr/testify/require" ) // TestCachedInputs tests that the cachedInputs works as expected. func TestCachedInputs(t *testing.T) { re...
package command import ( "fmt" "github.com/jclem/graphsh/types" ) // Pp shows present node path type Pp struct{} func testPp(input string) (Command, error) { if input == "pp" { return &Pp{}, nil } return nil, nil } // Execute implements the Command interface func (c Pp) Execute(s types.Session) error { fm...
package trie import ( "testing" "github.com/openacid/slim/encode" "github.com/stretchr/testify/require" ) var ( levelCases = map[string]struct { keys []string slimStr string levels []levelInfo }{ "empty": { keys: []string{}, slimStr: trim(""), levels: []levelInfo{{0, 0, 0, nil}}, }, ...
package env import ( "fmt" "os" ) // GetBool extracts bool value from env. if not set, returns default value. func GetBool(key string, def bool) bool { s, ok := os.LookupEnv(key) if !ok { return def } if s == "" || s == "1" || s == "true" { return true } return false } // MustGetBool extracts bool valu...
package types import ( "encoding/json" "fmt" ) // Wrapper is a generic wrapper, with a type field for distinguishing its // contents. type Wrapper struct { // Type is the fully-qualified type name, e.g. // github.com/sensu/sensu-go/types.Check, // OR, a short-hand name that assumes a package path of // github.c...
package main import ( ospaf "../../lib" "bufio" "fmt" "io" "os" "strings" ) func processLine(value string, pool ospaf.Pool) int { url := fmt.Sprintf("https://api.github.com/users/%s", value) _, statusCode := pool.ReadURL(url, nil) if statusCode == -1 { return -1 } else if statusCode != 200 { fmt.Println...
// Copyright 2017 The Fuchsia Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. package wlan_test import ( mlme "garnet/public/lib/wlan/fidl/wlan_mlme" "testing" . "wlan/wlan" ) func addBss(index int, ssid string, channel uint8, c...
package main import ( "strconv" "github.com/freignat91/mlearning/api" "github.com/spf13/cobra" ) // BackPropagateCmd . var BackPropagateCmd = &cobra.Command{ Use: "backPropagate", Short: "push value to out layer value1, value2, ...", Run: func(cmd *cobra.Command, args []string) { if err := mlCli.backPropag...
package events // constants for hooks event, there are default allowed event names const ( // OnAppInitBefore On app init before OnAppInitBefore = "app.init.before" // OnAppInitAfter On app init after OnAppInitAfter = "app.init.after" // OnAppStop = "app.stopped" // OnAppBindOptsBefore bind app options OnApp...
package main /** * 阶乘, 0 的阶乘等于 1 */ /** * 递归 */ func Fac_0(n int) int { if n <= 1 { return 1 } return n * (Fac_0(n-1)) } /** * 迭代 */ func Fac_1(n int) int { ret := 1 for n > 0 { ret *= n n-- } return ret }
package main import ( "fmt" //"math/rand" //"math" //"math/cmplx" //"math" //"runtime" //"time" //"io" //"strings" //"os" "strconv" "flag" "os" //"lib1" //"lib2" "ppgo" "github.com/labstack/echo" ) func main() { //primeTest() //func1.DoTest() //func2.DoTest2() //ppgo.PpgoRun() //初始化ECHO路由 ppgo...
package main func main() { print(gcd(10086, 23247)) } func gcd(x int, y int) int { min := 0 GCD := 0 if x > y { min = y } else { min = x } for i := 1; i < min+1; i++ { if x%i == 0 && y%i == 0 { GCD = i } } return GCD }
package str_test import ( "testing" "github.com/stretchr/testify/assert" "github.com/ywardhana/golib/str" ) func TestReverse(t *testing.T) { strTest := "test" reverseStr := "tset" result := str.Reverse(strTest) assert.Equal(t, reverseStr, result) } func TestContains(t *testing.T) { arr := []string{"satu", "...
package admin import ( "github.com/GoAdminGroup/go-admin/context" "github.com/GoAdminGroup/go-admin/modules/config" "github.com/GoAdminGroup/go-admin/modules/service" "github.com/GoAdminGroup/go-admin/modules/system" "github.com/GoAdminGroup/go-admin/modules/utils" "github.com/GoAdminGroup/go-admin/plugins" "gi...
package handler import ( "context" "path/filepath" "testing" smspb "github.com/jinmukeji/proto/v3/gen/micro/idl/partner/xima/sms/v1" generalpb "github.com/jinmukeji/proto/v3/gen/micro/idl/ptypes/v2" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/suite" ) // SendMessageSuite 测试发送短信 type Send...
package gosnowth import ( "bytes" "context" "encoding/json" "fmt" "net/url" ) // ExtensionParam values contain information about an extension parameter. type ExtensionParam struct { Type string `json:"type"` Optional bool `json:"optional"` Default interface{} `json:"default,omitempty...
// SPDX-License-Identifier: Apache-2.0 // Copyright © 2020 Intel Corporation package af import ( "context" "encoding/json" "net/http" ) func patchPfdAppTransaction(cliCtx context.Context, pfdData PfdData, afCtx *Context, pfdID string, appID string) (PfdData, *http.Response, []byte, error) { cliCfg := NewConfi...
// // import RPi.GPIO as GPIO // // import time // // GPIO.setmode(GPIO.BCM) // // TRIG = 23 // // ECHO = 24 // // print "Distance Measurement In Progress" // // GPIO.setup(TRIG,GPIO.OUT) // // GPIO.output(TRIG,0) // // GPIO.setup(ECHO,GPIO.IN) // // time.sleep(0.1) // // print "Stargin measurement" // // GPIO....
package main func correctPath(path string) string { if path[len(path)-1:] == `/` || path[len(path)-1:] == `\` { // Case: E.g. remote dir = /myfiles/ return path[:len(path)-1] } else { // Case: E.g. remote dir = /myfiles return path } }
package tools import ( "net" "time" ) // StreamReader implements buffering for an io.StreamReader object. type StreamReader struct { conn net.Conn timeout time.Duration } // NewStreamReader returns a new Reader. func NewStreamReader(conn net.Conn, timeout time.Duration) *StreamReader { return &StreamReader{ ...
// Copyright © 2017 Aeneas Rekkas <aeneas+oss@aeneas.io> // // 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 appl...
package main import "fmt" func main() { f := func(x int) int { return x * x } fmt.Println("2^2 =", f(2)) fmt.Println("3^3 =", f(3)) fmt.Println("4^4 =", f(4)) fmt.Println("5^5 =", f(5)) }
package virtual_security import ( "reflect" "testing" ) func Test_StockExecutionCondition_IsContractableMorningSession(t *testing.T) { t.Parallel() tests := []struct { name string stockExecutionCondition StockExecutionCondition want bool }{ {name: "未指定 は前場で約定不可能", st...
package api import ( "fmt" "testing" ) func getRole() *DingRole { tocken := "9dabccc23ddb37aab2964c3ef4ead528" return NewDingRole(BASEURL, tocken) } func TestRoleList(t *testing.T) { role := getRole() result, err := role.List(nil, nil) if err != nil { t.Error(err) return } fmt.Println(result.HasMore) } ...
package cmd import ( "io/ioutil" "os" "path/filepath" "regexp" "strconv" "strings" "github.com/devspace-cloud/devspace/pkg/devspace/build/builder/helper" "github.com/devspace-cloud/devspace/pkg/devspace/cloud" "github.com/devspace-cloud/devspace/pkg/devspace/config/constants" latest "github.com/devspace-clo...
/* * Minio Cloud Storage, (C) 2017 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 la...
package md import ( "fmt" "strings" "gopkg.in/yaml.v2" ) type Elem interface { String() string } type JoinType struct { elems []Elem with string } func (p JoinType) String() string { s := "" for _, e := range p.elems { s += p.with + e.String() } return strings.TrimPrefix(s, p.with) } func Paragraph(e...
// 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...
// Copyright 2022 PingCAP, Inc. Licensed under Apache-2.0. package streamhelper_test import ( "context" "fmt" "sync" "testing" "time" "github.com/pingcap/errors" logbackup "github.com/pingcap/kvproto/pkg/logbackuppb" "github.com/pingcap/log" "github.com/pingcap/tidb/br/pkg/streamhelper" "github.com/pingcap...
package consensus import ( "fmt" "math/big" ) func SetCompact(nCompact uint32) (res *big.Int) { size := nCompact >> 24 neg := (nCompact & 0x00800000) != 0 word := nCompact & 0x007fffff if size <= 3 { word >>= 8 * (3 - size) res = big.NewInt(int64(word)) } else { res = big.NewInt(int64(word)) res.Lsh(re...
package main import ( "context" "encoding/json" "fmt" "log" "os" "strconv" "time" "gopkg.in/alecthomas/kingpin.v2" "github.com/sirupsen/logrus" "github.com/square/p2/pkg/cli" "github.com/square/p2/pkg/ds" ds_fields "github.com/square/p2/pkg/ds/fields" "github.com/square/p2/pkg/labels" "github.com/squar...
package httpserver import ( "bufio" "io" "net/http" "time" ) // buffer memory to store log before writing them into writer/file type buffer chan []byte // Write overwrite io.Writer Write method to instead of writing directly into file, // it passes the bytes into buffer memory to be written into actual writer/fi...
package main import ( "log" "net/http" "github.com/gorilla/mux" ) type Route struct { Name string Method string Pattern string HandlerFunc http.HandlerFunc } type Routes []Route var routes = Routes{ Route{ Name: "TaskRun", Method: "POST", Pattern: "/", HandlerFunc: T...
// src/correct: Takes sorted input from src/parse // and performs illumina read error correction, // discarding reads without enough support. package main import ( "bufio" "fmt" "log" "os" "strconv" "strings" ) //import "github.com/davecheney/profile" var ( bcCountsFile string bcPosition int confirmed...
package main import "fmt" func main() { mm := map[int]string{1: "a", 2: "b", 3: "c"} b := mm[2] fmt.Println(b) mm[2] = b + "b" fmt.Println(b) fmt.Println(mm[2], mm) delete(mm, 2) fmt.Println(mm) val, ok := mm[3] if ok { fmt.Println("get index 2 ok,", val) } else { fmt.Println("get index 2 error") } v...
//source: https://doc.qt.io/qt-5/qtsql-masterdetail-example.html package main import ( "os" "github.com/therecipe/qt/core" "github.com/therecipe/qt/widgets" ) var qApp *widgets.QApplication func main() { qApp = widgets.NewQApplication(len(os.Args), os.Args) if !createConnection() { return ...
package plumber import ( "os" "github.com/batchcorp/plumber-schemas/build/go/protos/encoding" "github.com/batchcorp/plumber-schemas/build/go/protos/records" "github.com/batchcorp/plumber/backends" "github.com/batchcorp/plumber/printer" "github.com/batchcorp/plumber/reader" "github.com/batchcorp/plumber/validat...
package core import ( "github.com/golang/protobuf/ptypes" mh "github.com/multiformats/go-multihash" "github.com/textileio/go-textile/pb" ) // AddFlag adds an outgoing flag block targeted at another block to flag func (t *Thread) AddFlag(block string) (mh.Multihash, error) { t.mux.Lock() defer t.mux.Unlock() if...
package images import ( "context" "errors" "testing" "time" "github.com/dollarshaveclub/acyl/pkg/models" "github.com/dollarshaveclub/acyl/pkg/nitro/metrics" "github.com/dollarshaveclub/acyl/pkg/persistence" ) type testImageBuildBackend struct { f func(ctx context.Context, envName, repo, imagerepo, ref string...
package _334_Increasing_Triplet_Subsequence import "math" func increasingTriplet(nums []int) bool { if len(nums) < 3 { return false } //return increasingTripletDP(nums) return increasingTripletSimple(nums) } func increasingTripletSimple(nums []int) bool { n1, n2 := math.MaxInt, math.MaxInt for i := 0; i < le...
package tropical // // Coords gives a functional interface to a 2D coordinate system. // type Coords interface { X() int //relative to parent Y() int //relative to parent Width() int Height() int SetX(int) SetY(int) SetWidth(int) SetHeight(int) } // // Manipulating the tree // type TreeManipulator interface {...
package gographs import ( "fmt" "math" "runtime" "sync" "github.com/sbromberger/gographs/heap" "github.com/sbromberger/gographs/priorityqueue" ) // DijkstraState is a state holding dijkstra SP info type oDijkstraState struct { Parents []uint32 Dists []float32 Predecessors [][]uint32 Pathcounts ...
package readAvaatechSpe import ( "io/ioutil" "strconv" "strings" "time" ) const defaultChannelN int = 2048 func (spe *SPE) ParseFileContents(UTCoffset string) error { var nextRow string var measureTimes []string var errArr []error errArr = make([]error, 9) fileBytes, errRead := ioutil.ReadFile(spe.FilePath...
package main import ( "os" "fmt" "log" "flag" "bytes" "strings" "os/user" "net/http" "io/ioutil" "path/filepath" "encoding/json" "gopkg.in/yaml.v2" ) type config struct { Url string `yaml:"url"` Timeout int `yaml:"timeout"` } type Tasks struct { ...
package main import ( "fmt" ) // 155. 最小栈 // 设计一个支持 push ,pop ,top 操作,并能在常数时间内检索到最小元素的栈。 // push(x) —— 将元素 x 推入栈中。 // pop() —— 删除栈顶的元素。 // top() —— 获取栈顶元素。 // getMin() —— 检索栈中的最小元素。 // 提示: // pop、top 和 getMin 操作总是在 非空栈 上调用。 // https://leetcode-cn.com/problems/min-stack func main() { stack := Constructor() stac...
/* * EVE Swagger Interface * * An OpenAPI for EVE Online * * OpenAPI spec version: 0.4.1.dev1 * * Generated by: https://github.com/swagger-api/swagger-codegen.git */ package swagger // 200 ok object type GetCorporationsCorporationIdRoles200Ok struct { // character_id integer CharacterId int32 `json:"char...
package main //create a func with the identifier foo that returns an int //create a func with the identifier bar that returns an int and a string //call both funcs //print out their results import "fmt" func main() { result0 := foo() result1, result2 := bar() fmt.Println(result0, result1, result2) } func bar() (...
package ruicao_test import ( "fmt" "github.com/mxmCherry/translit/ruicao" "golang.org/x/text/transform" ) func ExampleToLatin() { ru := ruicao.ToLatin() // this is recommended to be a global variable in your own package // https://ru.wikipedia.org/wiki/Панграмма s, _, _ := transform.String(ru.Transformer(), "...
package lib import "github.com/raulk/clock" var Clock = clock.New()
package main import ( "bufio" "fmt" "os" "strconv" ) func part2(mass int) (total int) { total = 0 for mass > 0 { mass = ((mass / 3) - 2) if mass < 0 { mass = 0 } total += mass } return total } func getMass(n []int) (int, int) { total := 0 total2 := 0 l := len(n) for i := 0; i < l; i++ { mass...
/* # -*- coding: utf-8 -*- # @Author : joker # @Time : 2021/11/30 9:39 上午 # @File : lt_239_滑动窗口最大值.go # @Description : # @Attention : */ package v2 // 关键: // // func maxSlidingWindow(nums []int, k int) []int { // left, right, l := 0, 0, 0 // ret := make([]int, 0) // currentMax := nums[0] // for left < len(nums) { ...
package apm // import ( // "context" // "net/http" // "stash.bms.bz/bms/monitoringsystem" // ) // // HandlerInterface ... A wrapper interface on top of the apm (monitoringsystem) to help out during testing // type HandlerInterface interface { // StartTransaction(name string) (transaction interface{}, err error) ...
package main import ( "fmt" "net/http" "os" "github.com/DexterLB/mvm/imdb/jsonapi" ) func serve(address string) error { s := &jsonapi.Server{http.DefaultClient} return http.ListenAndServe(address, s) } func main() { if len(os.Args) != 2 { fmt.Printf("usage: $0 <bind address>\n") os.Exit(2) } err := ser...
package config import ( "errors" "fmt" "github.com/codegangsta/inject" "github.com/phillihq/racoon/util" ) //输入配置接口 type InputContextConfig interface { ContextConfig Start() } type InputConfig struct { StandardConfig } type InputHandler interface{} var registedInputHandlers = map[string]InputHandler{} //注册...
/* * Strava API v3 * * The [Swagger Playground](https://developers.strava.com/playground) is the easiest way to familiarize yourself with the Strava API by submitting HTTP requests and observing the responses before you write any client code. It will show what a response will look like with different endpoints depen...
package system import ( "github.com/SirMetathyst/zinc" ) // NewConvSystemsWith ... func NewConvSystemsWith(e *zinc.EntityManager) []zinc.S { return []zinc.S{ NewConvCreateWindowSystemWith(e), } } // NewConvSystems ... func NewConvSystems() []zinc.S { return NewConvSystemsWith(zinc.Default()) }
package util import ( "errors" "io/ioutil" "net/http" "strconv" ) //获取HTTP请求返回数据 func GetHttpResponse(url string) (string, error) { resp, err := http.Get(url) if err != nil { return "", err } defer resp.Body.Close() if resp.StatusCode != http.StatusOK { return "", errors.New("NET ERROR:" + strconv.Itoa(...