text
stringlengths
11
4.05M
/* Copyright 2018 Blindside Networks Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http:// www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, soft...
package starttls import ( "crypto/tls" "fmt" log "github.com/sirupsen/logrus" config "github.com/spf13/viper" . "github.com/trapped/gomaild2/smtp/structs" . "github.com/trapped/gomaild2/structs" ) func initTLS() { WaitConfig("config.loaded") if config.GetBool("tls.enabled") { log.Info("Enabled TLS") Exten...
package types import "github.com/docker/distribution/reference" // Ref reference to a registry/repository // If the tag or digest is available, it's also included in the reference. // Reference itself is the unparsed string. // While this is currently a struct, that may change in the future and access // to contents ...
package handlers import ( "fmt" "net/http" ) // IndexHandler is the root at "/" func IndexHandler(w http.ResponseWriter, r *http.Request) { fmt.Fprint(w, "Welcome to the JSON restAPI!") }
package main import ( "log" "os" "github.com/logic/gkp/keepassrpc" "github.com/logic/gkp/keepassrpc/cli" ) var config *cli.Configuration var client *keepassrpc.Client func main() { ParseEnvironment() var err error config, err = cli.LoadConfig() if err != nil { log.Fatal("loadConfig: ", err) } client, ...
package main import "sort" type point struct { x, y int } func minAreaRect(points [][]int) int { projectionX := make(map[int][]int) projectionY := make(map[int][]int) pointSet := make(map[point]bool) for _, pair := range points { x := pair[0] y := pair[1] projectionX[x] = append(projectionX[x], y) proj...
package main import ( "github.com/stretchr/testify/assert" "strings" "testing" ) func TestRunCircuit(t *testing.T) { instructions := `123 -> x 456 -> y x AND y -> d x OR y -> e x LSHIFT 2 -> f y RSHIFT 2 -> g NOT x -> h NOT y -> i ` c := NewCircuit(strings.Split(strings.TrimSpace(instructions), "\n")) assert.E...
// 147. Concurrency Is Not Parallelism 並行 非 併發 解說? // 解說 // https://medium.com/mr-efacani-teatime/concurrency%E8%88%87parallelism%E7%9A%84%E4%B8%8D%E5%90%8C%E4%B9%8B%E8%99%95-1b212a020e30 // Concurrency:相同的工作集合,一起完成同一份工作,互相合作,做團稽 // Parallelism:不同的工作集合,各自完成自己的工作,不互相干擾,有各自的考績 package main import "fmt" func main() {...
package housepassword import "testing" func isTrue(t *testing.T, v bool) { if !v { t.Error("Expect true but false") } } func isFalse(t *testing.T, v bool) { if v { t.Error("Expect false but true") } } func TestCheckio(t *testing.T) { isFalse(t, checkio("A1213pokl")) isTrue(t, checkio("bAse730onE")) isFals...
// Copyright (c) 2016-2019 Uber Technologies, 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 metrics import ( "fmt" "net/http" "sync" "time" "github.com/prometheus/client_golang/prometheus/promhttp" "github.com/sirupsen/logrus" "github.com/void616/gotask" ) // Service is metrics service that serves Prometheus /metrics endpoint type Service struct { logger *logrus.Entry port uint16 } // N...
package handler import ( "context" "github.com/jacexh/golang-ddd-template/internal/domain/user" "github.com/jacexh/golang-ddd-template/internal/eventbus" "github.com/jacexh/golang-ddd-template/internal/logger" "go.uber.org/zap" ) type ( UserPrinter struct{} ) func (up UserPrinter) Handle(ctx context.Context, ...
package record import ( "fmt" "github.com/NodeFactoryIo/vedran/internal/models" "github.com/NodeFactoryIo/vedran/internal/repositories" aMock "github.com/NodeFactoryIo/vedran/mocks/actions" mocks "github.com/NodeFactoryIo/vedran/mocks/repositories" "github.com/stretchr/testify/mock" "testing" ) func TestFailed...
package main import "fmt" /* *Target- 适配的目标抽象类 对应为 MediaPlayer *request():void 对应为 pay(audioType string,fileName string) */ type MediaPlayer interface { Pay(audioType string,fileName string) } /* *Adaptee -适配者接口 对应 AdvancedMediaPlayer -高级媒体播放器接口 *SpecificRequest 对应为 PlayVlc(fileName string) *SpecificRequest...
package osc import ( "encoding/binary" "strings" "time" ) type Bundle struct { timeTag time.Time elements []Packet } func (bnd *Bundle) internal() {} func NewBundle() *Bundle { return &Bundle{} } func (bnd *Bundle) Clear() *Bundle { bnd.timeTag = time.Time{} bnd.elements = nil return bnd } func (bnd *Bu...
package test import ( "context" ) type DependencyStruct struct { Ctx context.Context } func (t *DependencyStruct) InnerDependency() context.Context { return t.Ctx } type DependencyInterface interface { InnerDependency() context.Context }
package migration import ( "context" "k8s.io/client-go/rest" "github.com/harvester/harvester/pkg/config" virtv1 "github.com/harvester/harvester/pkg/generated/clientset/versioned/typed/kubevirt.io/v1" ) const ( vmiControllerName = "migrationTargetController" vmimControllerName = "migrationAnnotationController...
package shardmaster import ( "container/heap" "fmt" "log" "sync" ) const Debug = 0 func DPrintf(format string, a ...interface{}) (n int, err error) { if Debug > 0 { log.Printf(format, a...) } return } type Wait struct { l sync.RWMutex m map[string]chan OpResult } // New creates a Wait. func NewWait() *W...
package main import "fmt" /* Given an array, rotate the array to the right by k steps, where k is non-negative. Example 1: Input: [1,2,3,4,5,6,7] and k = 3 Output: [5,6,7,1,2,3,4] Explanation: rotate 1 steps to the right: [7,1,2,3,4,5,6] rotate 2 steps to the right: [6,7,1,2,3,4,5] rotate 3 steps to the right: [5,6...
package main import ( "fmt" "math" ) var setIndex int var originalLength int func findMatchVal(text string, pattern string) bool { if text == pattern || pattern == "*" || len(pattern) == 0 { return true } if len(text) == 0 { return false } if string(pattern[0]) == "*" { return findMatchVal(text, pattern[...
package main import ( "fmt" //"log" "os" "path/filepath" ) // scanDir stands for the directory scanning implementation func scanDir(dir string) error { var files []string //dirs := 0 dirs, symlink, blocked,other := 0,0,0,0 // Directories, Symbolic Links, Acess Denied and others //total := 0 //Testing c...
// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved. // See LICENSE.txt for license information. // package aws import ( "context" "database/sql" "encoding/json" "fmt" "math" "strconv" "strings" "time" "github.com/mattermost/mattermost-cloud/internal/common" "github.com/aws/aws-sdk-go-v2/aw...
//switch case 範例 package main import "fmt" var x string = "p1" func main() { sw_sample_0() sw_sample_1() x = "p2" fmt.Println("更換x=p2") sw_sample_1() } // 沒指定 true fallthrough func sw_sample_0() { switch { case false: fmt.Println("sw_0_1s") case true: fmt.Println("sw_0_2n") fallthrough case false: ...
// Copyright (c) 2018 soren yang // // Licensed under the MIT License // you may not use this file except in complicance with the License. // You may obtain a copy of the License at // // https://opensource.org/licenses/MIT // // Unless required by applicable law or agreed to in writing, software // distributed und...
package main import ( "flag" "io" "log" "net" "os" ) var addr = flag.String("addr", "localhost:8080", "address of tcp server") func main() { flag.Parse() conn, err := net.Dial("tcp", *addr) if err != nil { log.Fatal(err) } defer conn.Close() go mustCopy(os.Stdout, conn) mustCopy(conn, os.Stdin) } f...
package udwSqlite3Test var ggetBcDbEncrypt []uint8 = []byte{0xf3, 0x0f, 0xf7, 0x46, 0x27, 0xb9, 0x58, 0x7d, 0x99, 0xcc, 0x46, 0xb6, 0x16, 0x78, 0xd5, 0x99, 0xb0, 0x1f, 0xc8, 0xa9, 0x23, 0xfb, 0xca, 0x1c, 0xad, 0xa4, 0x66, 0xa5, 0x0f, 0x82, 0x21, 0x13, 0x1c, 0x64, 0xdb, 0x1e, 0x13, 0x7f, 0x14, 0xdd, 0x86, 0xb4, 0x74,...
package executors import ( "os/exec" tasker "github.com/Herlitzd/tasker/lib/core" ) type Local struct { } func (l *Local) Execute(t *tasker.Task) *tasker.TaskResult { command := exec.Command(t.Program, t.Args...) stdoutStderr, err := command.CombinedOutput() output := string(stdoutStderr) result := tasker.T...
package endpoint import ( "context" "github.com/go-kit/kit/endpoint" "github.com/payfazz/fazzkit/server/http" ) func Get() endpoint.Endpoint { return func(ctx context.Context, request interface{}) (response interface{}, err error) { var data [][]string data = append(data, []string{"1", "2", "3"}) data = ap...
// +build !linux,!darwin,!windows,!openbsd package container import ( "context" "github.com/nektos/act/pkg/common" ) func NewDockerVolumeRemoveExecutor(volume string, force bool) common.Executor { return func(ctx context.Context) error { return nil } }
package air import ( "context" "crypto/tls" "errors" "fmt" "io/ioutil" "log" "net/http" "net/http/httptest" "net/url" "os" "path/filepath" "testing" "time" "github.com/stretchr/testify/assert" ) func TestNewServer(t *testing.T) { a := New() s := a.server assert.NotNil(t, s) assert.NotNil(t, s.a) ...
package main import ( "bytes" "crypto/sha256" "encoding/binary" "encoding/gob" "flag" "fmt" "github.com/boltdb/bolt" "log" "math" "math/big" "os" "strconv" "time" ) const dbFile = "blockchain.db" const blocksBucket = "blocks" const targetBits = 24 //创建block与chain type Block struct {...
package zerver type ( TaskHandlerFunc func(interface{}) TaskHandler interface { Component Handle(interface{}) } ) func convertTaskHandler(i interface{}) TaskHandler { switch t := i.(type) { case func(interface{}): return TaskHandlerFunc(t) case TaskHandler: return t } return nil } func (TaskHandlerF...
// Copyright (C) 2018-Present Pivotal Software, Inc. All rights reserved. // // This program and the accompanying materials are made available under the // terms of the under the Apache License, Version 2.0 (the "License"); you may // not use this file except in compliance with the License. // // You may obtain a copy ...
package odoo import ( "fmt" ) // AccountFiscalPosition represents account.fiscal.position model. type AccountFiscalPosition struct { LastUpdate *Time `xmlrpc:"__last_update,omptempty"` AccountIds *Relation `xmlrpc:"account_ids,omptempty"` Active *Bool `xmlrpc:"active,omptempty"` AutoApply...
package stores import ( "jean/instructions/base" "jean/instructions/factory" "jean/rtda/jvmstack" ) type LSTORE struct { base.Index8Instruction } func (l *LSTORE) Execute(frame *jvmstack.Frame) { _lstore(frame, l.Index) } func _lstore(frame *jvmstack.Frame, index uint) { val := frame.OperandStack().PopLong() ...
package p2p import ( "container/list" "errors" "math" "sync" ) type clientMapEntry struct { el *list.Element client *Client } type clientMap struct { sync.Mutex cap uint order *list.List entries map[string]clientMapEntry } func newClientMap(cap uint) *clientMap { return ...
package server import ( "encoding/json" "github.com/kosotd/go-microservice-skeleton/cache" "github.com/kosotd/go-microservice-skeleton/config" "github.com/kosotd/go-microservice-skeleton/server" "github.com/pkg/errors" "gotest.tools/assert" "io/ioutil" "net/http/httptest" "testing" "time" ) type testConfig ...
/* Rotate List Given a list, rotate the list to the right by k places, where k is non-negative. Example: Given 1->2->3->4->5->NULL and k = 2, return 4->5->1->2->3->NULL. */ package main func rotateRight(head *ListNode, k int) *ListNode { if head == nil || head.Next == nil { return head } pre,curr,length := head...
package kubernetes import ( "fmt" "strings" "github.com/kiali/kiali/config" apps_v1 "k8s.io/api/apps/v1" autoscaling_v1 "k8s.io/api/autoscaling/v1" core_v1 "k8s.io/api/core/v1" meta_v1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/apimachinery/pkg/runtime" "k8s.io/apimachinery/pkg/runtime/schema" ) const (...
package handler import ( "cgon/master/handler/api/opt" "cgon/master/handler/api/v1" "cgon/master/middleware" "github.com/gin-gonic/gin" ) func InitRouters() *gin.Engine { var ( r *gin.Engine apiv1 *gin.RouterGroup ) r = gin.New() r.Use(gin.Logger()) r.Use(gin.Recovery()) initOpt(r) apiv1 = r.Group...
package v1alpha2 import ( "encoding/json" "errors" "fmt" ) // ImageType defines the content type for mirrored images type ImageType int const ( TypeInvalid ImageType = iota TypeOCPRelease TypeOCPReleaseContent TypeCincinnatiGraph TypeOperatorCatalog TypeOperatorBundle TypeOperatorRelatedImage TypeGeneric ...
package gen import ( "fmt" "strings" "unicode" ) func getNestedSpaces(level int) string { var spaces string for i := 0; i < level; i++ { spaces += " " } return spaces } func getYamlTag(key string) string { for i, value := range key { if i == 0 { continue } if unicode.IsUpper(value) { return ...
// Copyright (c) 2016 The Decred developers // Use of this source code is governed by an ISC // license that can be found in the LICENSE file. package walletseed import ( "crypto/rand" "crypto/sha256" "encoding/hex" "strconv" "strings" "github.com/EXCCoin/exccwallet/v2/errors" "github.com/EXCCoin/exccwallet/v...
package workspace import ( "path/filepath" "runtime" "testing" "github.com/stretchr/testify/assert" ) func TestNewSolutions(t *testing.T) { _, cwd, _, _ := runtime.Caller(0) root := filepath.Join(cwd, "..", "..", "fixtures", "solutions") paths := []string{ filepath.Join(root, "alpha"), filepath.Join(root...
// This Source Code Form is subject to the terms of the MIT License. // If a copy of the MIT License was not distributed with this // file, you can obtain one at https://opensource.org/licenses/MIT. // // Copyright (c) DUSK NETWORK. All rights reserved. package agreement import ( "testing" crypto "github.com/dusk-...
// Copyright 2020 The Cockroach Authors. // // Use of this software is governed by the Business Source License // included in the file licenses/BSL.txt. // // As of the Change Date specified in that file, in accordance with // the Business Source License, use of this software will be governed // by the Apache License, ...
package cache import ( "context" "github.com/twcclan/goback/backup" "github.com/twcclan/goback/proto" "github.com/twcclan/goback/storage/wrapped" ) var _ backup.ObjectStore = (*Store)(nil) var _ wrapped.Wrapper = (*Store)(nil) func cacheable(obj *proto.Object) bool { if obj == nil { return false } switch ...
// Copyright 2017 The Cockroach Authors. // // Licensed as a CockroachDB Enterprise file under the Cockroach Community // License (the "License"); you may not use this file except in compliance with // the License. You may obtain a copy of the License at // // https://github.com/cockroachdb/cockroach/blob/master/li...
package v3 import "github.com/cockroachdb/cockroach/pkg/sql/sem/types" type scalarProps struct { // Columns used by the scalar expression. inputCols bitmap typ types.T }
package solutions type Trie struct { children [26]*Trie isEndOfWord bool root *Trie } func Constructor() Trie { return Trie{children: [26]*Trie{}, isEndOfWord: false, root: &Trie{}} } func (this *Trie) Insert(word string) { if len(word) == 0 { return } current := this.root ...
package config import ( "flag" "fmt" "io/ioutil" "os" "runtime" "strings" "github.com/derry6/gleafd/version" yaml "gopkg.in/yaml.v2" ) type parser struct { Cfg *Config `yaml:"gleafd"` showVersion bool `yaml:"-"` flagSet *flag.FlagSet `yaml:"-"` fileName string `yaml:"...
package models import ( "../utils" ) func GetUserInfo(key string) string { if key == "key" { return "" } var val string // 准备预处理语句 err := db.QueryRow("SELECT `val` FROM `setting` WHERE `key` = ? LIMIT 1", key).Scan(&val) utils.CheckErr(err) return val } func EditSiteInfo(na...
package delta import ( "bytes" "encoding/json" //"time" "github.com/adamar/delta-server/models" ) func BuildEvent(serial string, native string, msgType string, data map[string]string) *models.Event { var uuid, err = GenUuid() if err != nil { panic(err) } timestamp := GenTi...
package cberrors import "sync" type ErrorsContainer struct { providers []ErrorProvider suppressErrors bool } func NewErrorContainer(providers ...ErrorProvider) *ErrorsContainer { return &ErrorsContainer{ providers: providers, } } type ErrorProvider interface { Error(e error) Recover(e interface{}) Def...
package config import ( "fmt" "path/filepath" "testing" "github.com/xuperchain/xupercore/lib/utils" ) func TestLoadEngineConf(t *testing.T) { engCfg, err := LoadEngineConf(getConfFile()) if err != nil { t.Fatal(err) } fmt.Println(engCfg) } func getConfFile() string { dir := utils.GetCurFileDir() return...
package tree import ( "fmt" "testing" "github.com/deepak-muley/golangexamples/data-structures/tree" ) func Test_tree_traversals(t *testing.T) { // (3 + 4) * 6 // * // + 6 //3 4 root := new(tree.TreeNode) root.SetValue("*") root.AddRightChild("6") plusNode := root.AddLeftChild("+") plusNode.A...
/* * Flow CLI * * Copyright 2019-2021 Dapper Labs, 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 appl...
package leetcode_1360_日期之间隔几天 import ( "strconv" "strings" "time" ) /* 请你编写一个程序来计算两个日期之间隔了多少天。 日期以字符串形式给出,格式为 YYYY-MM-DD,如示例所示。 示例 1: 输入:date1 = "2019-06-29", date2 = "2019-06-30" 输出:1 示例 2: 输入:date1 = "2020-01-15", date2 = "2019-12-31" 输出:15 提示: 给定的日期是 1971 年到 2100 年之间的有效日期。 */ // 非闰年每月天数固定 var months = []in...
// Copyright (C) 2016-Present Pivotal Software, Inc. All rights reserved. // This program and the accompanying materials are made available under the terms of the under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. // You may obtain a copy of the Licen...
package main import "fmt" type person struct { firstName string lastName string contactinfo } type contactinfo struct { email string zip int } func main() { alex := person{ firstName: "prabhaker", lastName: "saxena", contactinfo: contactinfo{ email: "abc@gmail.com", zip: 4}} /* var alex pe...
/* Copyright 2021 The KServe 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, soft...
// Copyright 2017 Zhang Peihao <zhangpeihao@gmail.com> // Package register 注册Broker package register import ( "github.com/golang/glog" "github.com/zhangpeihao/zim/pkg/broker" ) // NewBrokerHandler 新建Broker函数,参数:viper参数perfix type NewBrokerHandler func(string) (broker.Broker, error) var ( brokerHandlers = make(ma...
package tools import ( "io/ioutil" "os" ) //判断文件是否存在 func PathExists(file string) (ret bool, err error) { if _, err = os.Stat(file); err != nil { return false, err } if os.IsNotExist(err) { return false, err } return true, nil } //读取文件内容 func ReadFile(file string) (bytes []byte, err error) { return iouti...
package main import "fmt" func main() { name, power := "Goku", 9000 fmt.Printf("%s's power is over %d\n", name, power) }
package main import ( "fmt" "log" "net" "net/rpc" "net/rpc/jsonrpc" "os" "strconv" "strings" ) //Args struct to passed to server type Args struct { Budget float64 StockpercentMap map[string]int } //PortfolioResponsedata to be send from server to client type PortfolioResponsedata struct { //E.g. “...
package lc // Benchmark: 72ms 11mb | 97% 35% type elem struct { key int next *elem } type MyHashSet struct { m [1024]*elem } /** Initialize your data structure here. */ func Constructor() MyHashSet { return MyHashSet{[1024]*elem{}} } func (this *MyHashSet) Add(key int) { if this.Contains(key) { return } ...
package draft import ( "fmt" "regexp" "k8s.io/api/core/v1" "k8s.io/api/extensions/v1beta1" "k8s.io/client-go/kubernetes/scheme" platform "kolihub.io/koli/pkg/apis/core/v1alpha1" ) func (d *Deployment) GetClusterPlan() *MapValue { return &MapValue{Val: d.GetLabel(platform.LabelClusterPlan).String()} } func (d...
package main import ( "reflect" "testing" xenAPI "github.com/johnprather/go-xen-api-client" ) func TestParseLegendEntry(t *testing.T) { cases := []struct { input string expected Entry expectErr bool }{ {"AVERAGE:vm:15f9d56e-938a-34fc-73f3-a7e08a0445eb:vbd_xvdd_io_throughput_write", Entry{"AVERAGE",...
package main import ( "fmt" "strings" ) /* 将一个给定字符串根据给定的行数,以从上往下、从左到右进行 Z 字形排列。 比如输入字符串为 "LEETCODEISHIRING" 行数为 3 时,排列如下: L C I R E T O E S I I G E D H N 之后,你的输出需要从左往右逐行读取,产生出一个新的字符串,比如:"LCIRETOESIIGEDHN"。 请你实现这个将字符串进行指定行数变换的函数: string convert(string s, int numRows); 示例 1: 输入: s = "LEETCODEISHIRING...
package linkedlist import ( "fmt" "sync" ) type item struct { next *item val interface{} } // LinkedList represents a single linked list type LinkedList struct { lock sync.RWMutex head *item } var ( // ErrorNotFound is returned when an item is not in the single linked list ErrorNotFound = fmt.Errorf("not f...
// Copyright 2019 The ChromiumOS Authors // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. package gtest import ( "encoding/xml" "fmt" "io/ioutil" "chromiumos/tast/errors" ) // Report is a parsed gtest output report. // See https://github.com/google/googlete...
package main import( "fmt" "time" "net/http" "io/ioutil" "log" "encoding/json" "github.com/labstack/echo" "github.com/labstack/echo/middleware" ) type Cat struct { Name string `json:"name"` Type string `json:"type"` } type Slugs struct { Name string `json:"name"`...
package main import ( "encoding/json" _ "fmt" "io/ioutil" "net/http" ) type Github struct{} type Repo struct { SshUrl string `json:"ssh_url"` CloneUrl string `json:"clone_url"` GitUrl string `json:"git_url"` Fork bool `json:"fork"` } func (g Github) Retrieve() []Repo { api := "https://ap...
package requests import ( "encoding/json" "fmt" "io/ioutil" "net/url" "strings" "github.com/atomicjolt/canvasapi" "github.com/atomicjolt/canvasapi/models" ) // DeleteCommunicationChannelType Delete an existing communication channel. // https://canvas.instructure.com/doc/api/communication_channels.html // // P...
package lib func TranscodeGV(array [] [] []uint8,config *ConfigInfo) [] uint8 { var IPageArrays [][][]uint8 var BPageArrays [][][][]uint8 length := len(array) pageSkip := config.MaxBPageNum + 1 for i := 0; i < length; i += pageSkip { IPageArrays = append(IPageArrays, array[i]) var _BPageArrays [][][]uint8 f...
package config import ( "fmt" "io/ioutil" "github.com/pkg/errors" log "github.com/sirupsen/logrus" yaml "gopkg.in/yaml.v2" ) // Settings is a struct yaml configuration type Settings struct { Static DB } type Static struct { Host string `yaml:"host"` Port string `yaml:"port"` Dir string `yaml:"dir"` } ty...
package elliptic import "math/big" // Bitcoin's secp256k1 elliptic curve // Reference: https://en.bitcoin.it/wiki/Secp256k1 var Secp256k1 = new(CurveParams) func init() { var ok bool Secp256k1.P, ok = new(big.Int).SetString("FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEFFFFFC2F", 16) if !ok { panic(...
package individualparsers import ( "bytes" ) type Raw64MZHeader struct{} func (b Raw64MZHeader) Match(content []byte) (bool, error) { // Raw MZ header if len(content) < 3 { return false, nil } if bytes.Equal(content[:3], []byte{0x4d, 0x5a, 0x90}) { return true, nil } return false, nil } func (b Raw64MZ...
package merger import ( "github.com/stretchr/testify/assert" "github.com/stretchr/testify/suite" "github.com/threez/intm/internal/model" "github.com/threez/intm/internal/port" ) type MergerTestSuite struct { Merger port.Merger suite.Suite } func (suite *MergerTestSuite) TestEmpty() { assert.Equal(suite.T(), [...
package memfs import ( "encoding/json" "fmt" "log" "os" "path/filepath" "testing" "time" "github.com/shuLhan/share/lib/test" "github.com/shuLhan/share/lib/text/diff" ) var ( _testWD string ) func TestMain(m *testing.M) { var err error _testWD, err = os.Getwd() if err != nil { log.Fatal(err) } err ...
package nil import ( u "lib/utils" ui "lib/UI" c "github.com/skilstak/go/colors" p "lib/pythagorean" a "lib/area" pe "lib/perimeter" t "lib/trig" ) func TriangleMenu() { // Quick thanks to @whitman-colm on github for this system isDone := false var choice string for isDone...
package node import ( "net/http" "github.com/rancher/apiserver/pkg/types" "github.com/rancher/steve/pkg/schema" "github.com/rancher/steve/pkg/server" "github.com/rancher/wrangler/pkg/schemas" "github.com/harvester/harvester/pkg/config" ) func RegisterSchema(scaled *config.Scaled, server *server.Server, option...
package db import ( _ "github.com/joho/godotenv/autoload" "go.mongodb.org/mongo-driver/mongo" ) var db *mongo.Client func InitDB(client *mongo.Client) { db = client }
// Copyright © 2017 Wei Shen <shenwei356@gmail.com> // // 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,...
package prometheus import ( "crypto/tls" "net/http" "os/exec" "time" "fmt" "github.com/tmax-cloud/hypercloud-multi-agent/internal/util" "k8s.io/klog" // "k8s.io/kubectl/pkg/cmd/annotate" ) const ( URL_PREFIX = "http://" URL_HYPERCLUSTERRESOURCE_PATH = ...
package counter type ChannelCounter struct { ch chan func() number uint64 } func NewChannelCounter() Counter { counter := &ChannelCounter{make(chan func(), 100), 0} go func(counter *ChannelCounter) { for f := range counter.ch { f() } }(counter) return counter } func (c *ChannelCounter) Add(num uint6...
package user import ( "net/http" noter "github.com/romycode/bank-manager/internal" "github.com/gin-gonic/gin" "log" ) func CreateUserHandler(repository noter.UserRepository) gin.HandlerFunc { return func(ctx *gin.Context) { u := new(noter.User) err := ctx.Bind(u) if err != nil { log.Fatal(err) } r...
package account import ( "github.com/agiledragon/gomonkey/v2" "github.com/kenlabs/pando/pkg/registry" "github.com/libp2p/go-libp2p-core/peer" . "github.com/smartystreets/goconvey/convey" "reflect" "testing" ) func TestFetchPeerType(t *testing.T) { Convey("TestFetchPeerType", t, func() { r := &registry.Regist...
package main import ( "bufio" "fmt" "log" "os" "strconv" "strings" ) func computeRibbon(a int, b int, c int) int { var x int = a var y int = b var maxSide int = c if x > maxSide { maxSide, x = x, maxSide /* swap */ } if y > maxSide { maxSide, y = y, maxSide } return 2*(x+y) + a*b*c } func compute...
package controller import ( "yes-blog/graph/model" "yes-blog/pkg/database" "yes-blog/pkg/database/status" "yes-blog/pkg/jwt" ) /* singleton object for userController this controller task is to perform CRUD for user.User model it takes a dbDriver implementing database.UserDBDriver and speaks to the database with ...
// Copyright 2018 The gVisor 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 agree...
/* 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 distributed under the License ...
package scraper import ( "errors" "github.com/mkamadeus/nicscraper/models" ) type Scraper struct { IsVerbose bool Students chan models.Student Failed chan string Args *models.Arguments } func New(args *models.Arguments) (*Scraper, error) { scraper := &Scraper{ Students: make(chan models.Student), ...
package purchasepersister type ErrPurchaseInvalid struct { Message string } func (e ErrPurchaseInvalid) Error() string { return e.Message }
package static import ( "io/fs" "strings" "testing" ) func TestEmbed(t *testing.T) { scenarios := []struct { path string shouldExist bool expectedContainString string }{ { path: "index.html", shouldExist: true, expectedContainString: "</body>...
// Copyright 2021 The ChromiumOS Authors // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. package crossdevice import ( "context" "regexp" crossdevicecommon "chromiumos/tast/common/cros/crossdevice" "chromiumos/tast/common/testexec" "chromiumos/tast/errors" ...
package structs import "fmt" // Declaring a struct type user struct { name string email string ext int privileged bool } type admin struct { person user level string } func (u user) notify() { fmt.Printf("Sending user e-mail to %s<%s>\n", u.name, u.email) } // Call - Calls the structs...
package main /* A game on an undirected graph is played by two players, Mouse and Cat, who alternate turns. The graph is given as follows: graph[a] is a list of all nodes b such that ab is an edge of the graph. Mouse starts at node 1 and goes first, Cat starts at node 2 and goes second, and there is a Hole at node 0....
// +build darwin,!go1.12 package udwFile import ( "os" "syscall" ) func FileSync(f *os.File) error { _, _, err := syscall.Syscall(syscall.SYS_FCNTL, f.Fd(), syscall.F_FULLFSYNC, 0) if err == 0 { return nil } return err }
package cmd import ( "fmt" "math/rand" "time" "github.com/spf13/cobra" ) // snappleCmd represents the snapple command var snappleCmd = &cobra.Command{ Use: "snapple", Short: "Generate a random fact", Long: ` Ever get bored and just want to hear a random fact? Same. Beware these are snapple facts...Who k...