text
stringlengths
11
4.05M
package adapter import ( "context" "github.com/kyleterry/tenyks/pkg/message" ) type Adapter interface { GetName() string GetType() AdapterType Dial(ctx context.Context) error Close(ctx context.Context) error SendAsync(ctx context.Context, msg message.Message) error RegisterMessageHandler(message.HandlerFunc)...
package vmm import ( "errors" "fmt" "os" "path/filepath" "runtime" "github.com/768bit/vutils" "github.com/cloudius-systems/capstan/cmd" "github.com/cloudius-systems/capstan/core" "github.com/cloudius-systems/capstan/util" ) func BuildBaseCapstanImage(name string, cmdPath string, entryPoint string, imageSize...
package maccount import ( "time" "webserver/models" ) type UserReport struct { Id int UserId int ForUserId int ArticleId int From int Reason string Remark string Extra string Status int CreatedAt time.Time UpdatedAt time.Time } func FindUserReportByUserId(userId, from interfa...
// 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 ( "bufio" "bytes" "encoding/json" "fmt" "io/ioutil" "log" "net/http" "os" "strconv" ) const ( initurl = "http://localhost:9200/fazhi_company/_search?scroll=1m" url = "http://localhost:9200/_search/scroll" query = `{"size":1000,"query": {"match_all" : {}}}` ) type scroll struct { scr...
package elering const URI = "https://dashboard.elering.ee/api" type NpsPrice struct { Success bool Data map[string][]Price } type Price struct { Timestamp int64 Price float64 }
// Copyright 2019 Copyright (c) 2019 SAP SE or an SAP affiliate company. All rights reserved. This file is licensed under the Apache Software License, v. 2 except as noted otherwise in the LICENSE file. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in complian...
package main import ( "fmt" "unsafe" ) func main() { // unsafe.Sizeof函数返回操作数在内存中的字节大小,参数可以是任意类型的表达式,但是它并不会对表达式进行求值。 a := 12 fmt.Println("length of a:", unsafe.Sizeof(a)) //8 var b int = 12 fmt.Println("length of b(int):", unsafe.Sizeof(b)) //8 var c int8 = 12 fmt.Println("length of c(int8)", unsafe.Sizeof(c...
package delta import ( "io/ioutil" "encoding/json" ) type Triggers struct { Triggers []Trigger `json:"triggers"` } type Trigger struct { EventType string `json:"eventtype"` Subscriber string `json:"subscriber"` } func LoadTriggers() *Triggers { content, err := ioutil.ReadFile("triggers.d/t...
package main import "fmt" // chap3 상수 func main() { // 상수 선언 방법 // "const" 를 사용한다. // example1 const i int = 0 fmt.Println(i) // example2 const j float32 = 0.3 fmt.Println(j) // example3 const k, l = 3, "상수!" fmt.Println(k, l) // example4 const ( z = "i am the king!" x = 13124 ) fmt.Println(z, x) ...
package main import ( "floqars/models" "floqars/shared" "encoding/json" "fmt" "os" "strconv" "github.com/aws/aws-lambda-go/events" "github.com/aws/aws-lambda-go/lambda" "github.com/mmcloughlin/geohash" ) func GetPeople(req events.APIGatewayProxyRequest) (events.APIGatewayProxyResponse, error) { latStr, ln...
package main import ( "bufio" "encoding/json" "fmt" "os" "strings" ) func main() { // Get user input for name and address reader := bufio.NewReader(os.Stdin) fmt.Println("Please enter your name: ") inputName, err1 := reader.ReadString('\n') fmt.Println("Please enter your address: ") inputAddr, err2 := r...
// Copyright (C) 2017 Google 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 t...
package decimalUtils import ( "fmt" "github.com/shopspring/decimal" "math/big" "strconv" ) func Pow(a *big.Float, e int64) *big.Float { result := Zero().Copy(a) for i := int64(0); i < e-1; i++ { result = Mul(result, a) } return result } func Root(a *big.Float, n uint64) *big.Float { limit := Pow(NewFloat(...
package main import ( "math/rand" "fmt" "time" ) func bubble(tab *[10]int) { for i := 0; i < 10; i++ { for j := 1; j < 10-i; j ++ { if tab[j-1] > tab[j] { tmp := tab[j-1] tab[j-1] = tab[j] tab[j] = tmp } } } } func main() { random := rand.New(rand.NewSource(time.Now().UnixNano()))...
// Copyright 2020 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...
package main import ( "fmt" "os" "sync" ) //START1 OMIT type Repo struct { sync.RWMutex items map[string]int } var ( r *Repo once sync.Once ) func GetInstance() *Repo { once.Do(func() { r = &Repo{ items: make(map[string]int), } }) return r } // END1 OMIT //START2 OMIT func (r *Repo) Set(key st...
package cornercase import "fmt" /* Given a sorted integer array without duplicates, return the summary of its ranges. Example 1: Input: [0,1,2,4,5,7] Output: ["0->2","4->5","7"] Explanation: 0,1,2 form a continuous range; 4,5 form a continuous range. Example 2: Input: [0,2,3,4,6,8,9] Output: ["0","2->4","6","8->...
package icalendar import ( "bufio" "fmt" "io" "reflect" "sort" "strings" "time" ) type VTIMEZONE struct { // tzid are REQUIRED, but MUST NOT occur more than once. TZID string // 'last-mod' and 'tzurl' are OPTIONAL, and MAY occur more than once. LASTMODIFIED string TZURL string // One of 'standardc...
package types import ( "fmt" "strings" sdk "github.com/cosmos/cosmos-sdk/types" ) type Order struct { Id string `json:"id"` Borrower string `json:"borrower"` Lender string `json:"lender"` TokenGet sdk.Coin `json:"tokenGet"` TokenGive sdk.Coin `json:"tokenGive"` Owner sdk.AccAddress `json:"owner"` } f...
package gocloudfiles import ( "bytes" "crypto/rand" "fmt" "io/ioutil" "os" "testing" ) var ( TestUserName = os.Getenv("TEST_USERNAME") TestApiKey = os.Getenv("TEST_KEY") ) func TestMain(m *testing.M) { if TestUserName == "" || TestApiKey == "" { fmt.Println("Please set the environment variables TEST_USE...
package main import ( "fmt" "math/big" ) /* Consider all integer combinations of ab for 2 ≤ a ≤ 5 and 2 ≤ b ≤ 5: 2ˆ2=4, 2ˆ3=8, 2ˆ4=16, 2ˆ5=32 3ˆ2=9, 3ˆ3=27, 3ˆ4=81, 3ˆ5=243 4ˆ2=16, 4ˆ3=64, 4ˆ4=256, 4ˆ5=1024 5ˆ2=25, 5ˆ3=125, 5ˆ4=625, 5ˆ5=3125 If they are then placed in num...
package tracing import ( "fmt" "net/http" "strconv" zipkin "github.com/openzipkin/zipkin-go" zipkinhttp "github.com/openzipkin/zipkin-go/middleware/http" "github.com/openzipkin/zipkin-go/model" reporterhttp "github.com/openzipkin/zipkin-go/reporter/http" ) const endpointURL = "http://localhost:9411/api/v2/spa...
// An anagram set finder. package main import ( "bufio" "flag" "fmt" "log" "os" "sort" "strings" ) type runes []rune // Len method returns the length of the runes list. func (r runes) Len() int { return len(r) } // Less method compares two runes lexicographically. func (r runes) Less(i, j int) bool { retu...
package main import("fmt") //Implementação de Struct de Pilha-> utiliza slices para facilitar type Stack struct { data []Tree } func (s Stack) push(info Tree) Stack { s.data = append(s.data, info) return s } func (s Stack) pop() (Stack, *Tree) { var info = s.data[len(s.data)-1] s.data = s.data[:len(s.data)-1] ...
package stringutils import ( "github.com/asktop/gotools/acast" "regexp" "strconv" "strings" "unicode/utf8" ) func Len(s string) int { return len([]rune(s)) } //截取字符串 // @param length 不设置:截取全部;负数:向前截取 func Substr(s string, start int, length ...int) string { rs := []rune(s) l := len(rs) if len(length) > 0 { ...
package main // Leetcode 1483. (hard) type TreeAncestor struct { dp [][]int } func Constructor(n int, parent []int) TreeAncestor { dp := make([][]int, n) for i := range dp { dp[i] = make([]int, 1) dp[i][0] = parent[i] } j := 1 for { finish := true for i := range dp { if dp[i][j-1] == -1 { dp[i] =...
package main import ( "container/list" "sync" pb "../protobuf/go" "sort" "fmt" "github.com/op/go-logging" mysha2 "../sha256-simd-master" ) type Miner struct { lock sync.RWMutex longest *RichBlock miningTxs TxList uuidmap map[string]int32 alarm Notification } type TxList []*pb.Transaction func ...
package JsJdk import ( "JsGo/JsConfig" "JsGo/JsHttp" "JsGo/JsLogger" "crypto/sha1" "encoding/json" "fmt" "log" "net/http" "strconv" "strings" "sync" "time" "github.com/astaxie/beego" ) type ST_WeChat_AccessToken struct { Access_token string `json:"access_token"` Expires_in int `json:"expires_in"`...
// Copyright © 2017 Microsoft <wastore@microsoft.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, modif...
package xml import "testing" var testData = []byte(` <?xml version="1.0" encoding="utf-8"?> <resources> <string name="app_name">GASTT</string> <string name="title_section1">Section 1</string> <string name="title_section2">Section 2</string> <string name="title_section3">Section 3</string> <string ...
package auth import ( "bytes" "context" "encoding/json" "errors" "strings" "github.com/aquasecurity/lmdrouter" "github.com/aws/aws-lambda-go/events" ) type key string var keyUser = key("authUser") func UserFromContext(ctx context.Context) string { if v, ok := ctx.Value(keyUser).(string); ok { return v }...
package fileio import ( "os" ) // Reads the input of a file and returns it as a string func ReadInput(fileName string) string { file, err := os.Open(fileName) if err != nil { panic(err) } // close the file when we are done with it defer file.Close() // get the file size stat, err := file.Stat() if err != ...
/* Name : Kamil KAPLAN Date : 27.07.2019 */ package goweather import ( "github.com/PROJECTS/goWeatherPackage/models" "os" "strings" ) func fileIsExists(name string) bool { _, err := os.Stat(name) if err != nil { // dosyanın ver olup olmasdığını kontrol eeriz. if os.IsNotExist(err) { return fal...
package todo_module import ( "github.com/astaxie/beego" "github.com/astaxie/beego/orm" models "todos/modules/todo/models" "fmt" "strconv" ) type TodoController struct { beego.Controller } func (this *TodoController) Prepare() { beego.ViewsPath="modules/todo/views" this.Layout = "layout.tpl" } func (thi...
package main import ( "fmt" ) // An interface type FI interface { F() } // A parent with a default implementation of FI type parent struct { FI } func (s *parent) F() { fmt.Printf("parent.F()\n"); } func (s *parent) doit() { s.FI.F() } func NewParent() (rv * parent) { rv = new(parent) rv.FI = rv return...
// Unless explicitly stated otherwise all files in this repository are licensed // under the Apache License Version 2.0. // This product includes software developed at Datadog (https://www.datadoghq.com/). // Copyright 2016-present Datadog, Inc. package common import ( "time" appsv1 "k8s.io/api/apps/v1" ) // Data...
package hookstage import ( "context" "github.com/prebid/openrtb/v19/openrtb2" ) // ProcessedAuctionRequest hooks are invoked after the request is parsed // and enriched with additional data. // // At this stage, account config is available, // so it can be configured at the account-level execution plan, // the acc...
package userssvc import ( "context" "fmt" pb "github.com/cagodoy/tenpo-challenge/lib/proto" users "github.com/cagodoy/tenpo-users-api" "github.com/cagodoy/tenpo-users-api/database" "github.com/cagodoy/tenpo-users-api/service" "golang.org/x/crypto/bcrypt" ) var _ pb.UserServiceServer = (*Service)(nil) // Serv...
package util import ( "board" ) func AvailableMoves(b *board.Board) []*board.Move { av := make([]*board.Move, 0) availableMoves := &av addAvailableWallMoves(b, availableMoves) addAvailableStepMoves(b, availableMoves) addAvailableJumpMoves(b, availableMoves) return *availableMoves } func addAvailableWallMoves...
package main import ( "fmt" ) func main() { var numFirst int var operator string var numSecond int var result int fmt.Print("Please enter operator : ") fmt.Scan(&operator) operator = operatorCheck(operator) fmt.Print("Please enter first number : ") fmt.Scan(&numFirst) // numFirstType := fmt.Sprintf("%T", ...
package main import ( "fmt" "log" "os" ) func main() { args := os.Args if len(args) < 2 { fmt.Println("Usage: permission filename") return } stat,err := os.Stat(args[1]) if err != nil { log.Fatal(err) } fmt.Println(stat.IsDir(),stat.Name(),stat.Size(),stat.Mode().Perm()) }
package data type ClashX struct { Port int SocksPort int `yaml:"socks-port"` AllowLan bool `yaml:"allow-lan"` Mode string LogLevel string `yaml:"log-level"` ExternalController string `yaml:"external-controller"` Secret string Dns ...
// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved. // See LICENSE.txt for license information. // package utility import ( "github.com/mattermost/mattermost-cloud/model" log "github.com/sirupsen/logrus" ) type unmanaged struct { utilityName string logger log.FieldLogger } func newUnmanaged...
// Defining the root command. package cmd import ( "errors" "fmt" "github.com/JosephLai241/shift/utils" "github.com/spf13/cobra" "github.com/spf13/viper" ) // rootCmd represents the base command when called without any subcommands. var rootCmd = &cobra.Command{ Use: "shift", Short: "A command-line applicat...
package nfsserver import ( "context" goerrors "errors" "strings" "time" appsv1 "k8s.io/api/apps/v1" corev1 "k8s.io/api/core/v1" "k8s.io/apimachinery/pkg/api/errors" "k8s.io/apimachinery/pkg/runtime" "k8s.io/client-go/rest" "k8s.io/client-go/tools/record" "sigs.k8s.io/controller-runtime/pkg/client" "sigs.k...
package firebase import ( "context" "log" firebase "firebase.google.com/go" "firebase.google.com/go/auth" "firebase.google.com/go/db" ) // Controller contains app and client instances for Firebase related requests. type Controller struct { // Instance is the instance of the Firebase app. Instance *firebase.Ap...
package migrate import ( "github.com/pkg/errors" "github.com/vim-volt/volt/lockjson" "github.com/vim-volt/volt/transaction" ) func init() { m := &lockjsonMigrater{} migrateOps[m.Name()] = m } type lockjsonMigrater struct{} func (*lockjsonMigrater) Name() string { return "lockjson" } func (m *lockjsonMigrate...
package model import ( "gamesvr/manager" "shared/common" "shared/statistic/logreason" "shared/utility/errors" ) func (u *User) ReceiveChapterReward(rewardId int32) error { chapterRewardCfg, err := manager.CSV.ChapterEntry.GetChapterReward(rewardId) if err != nil { return err } chapterId := chapterRewardCfg...
package main import ( "encoding/json" "fmt" "io/ioutil" "os" ) func init() { // config := &Config{MaxGoroutines: 3} // config.Store() // config := &Config{} // config.Load("config.json") // fmt.Printf("%+v\n", config) } // Config . type Config struct { MaxGoroutines int `json:"maxGoroutines"` // maximum n...
// Copyright © 2018 The TK8 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...
package util var itemsPerPage = 10 func PageLength(page int) (n, n2 int) { start := (page - 1) * itemsPerPage stop := start + itemsPerPage start = start+1 return start, stop } func SqlOrder(order string) (string, from string) { switch order { case `recentlyAdded`: order = `DATA_CADASTRO` from = `ASC` ...
package testing import ( "github.com/loft-sh/devspace/pkg/devspace/build" "github.com/loft-sh/devspace/pkg/devspace/config/versions/latest" devspacecontext "github.com/loft-sh/devspace/pkg/devspace/context" "github.com/loft-sh/devspace/pkg/util/randutil" ) // FakeController is the fake build controller type FakeC...
package wasp import ( "syscall/js" "./webgl" dom "github.com/schabby/go-wasm-dom" ) var jsDrawCallback, jsResizeCallback js.Func func CreateWebGLApp( init func(webgl.RenderingContext), resize func(webgl.RenderingContext), draw func(webgl.RenderingContext, int)) { canvas := dom.FullPageCanvas() glDOM := can...
package newfile import ( "fmt" ) func Return_value(val string) { fmt.Println(val) }
package main import ( "fmt" "time" "net/http" "log" ) func Logger(h http.Handler) http.Handler { return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { startTime := time.Now() h.ServeHTTP(w, r) endTime := time.Since(startTime) log.Printf("%s %d %v", r.URL, r.Method, endTim...
package main import ( "encoding/json" "fmt" "net/http" "os" "github.com/neckhair/smn_to_influx/core" ) func getJson(url string, target interface{}) error { r, err := http.Get(url) if err != nil { return err } defer r.Body.Close() return json.NewDecoder(r.Body).Decode(target) } func main() { if os.Gete...
package cmd import ( "github.com/spf13/cobra" e "github.com/cloudposse/atmos/internal/exec" u "github.com/cloudposse/atmos/pkg/utils" ) // describeAffectedCmd produces a list of the affected Atmos components and stacks given two Git commits var describeDependentsCmd = &cobra.Command{ Use: "depende...
package ravendb import ( "testing" "time" "github.com/stretchr/testify/assert" ) func TestCanSerializeDuration(t *testing.T) { tests := []struct { d time.Duration exp string }{ {time.Hour*24*5 + time.Hour*2, `"5.02:00:00"`}, {time.Millisecond * 5, `"00:00:00.0050000"`}, } for _, test := range tests ...
package httpx_test import ( "net/http" "net/http/httptest" "testing" "time" "github.com/stretchr/testify/assert" "github.com/socialpoint-labs/bsk/httpx" "github.com/socialpoint-labs/bsk/metrics" ) func TestInstrument_RequestsDuration(t *testing.T) { const waitTime = 50 * time.Millisecond const deltaTime = ...
package main func execOpen(input string) (string, error) { return "TODO: Implement open executor.", nil }
package sdk import ( "bufio" "github.com/sirupsen/logrus" "os" "regexp" "strings" "sync" "worker/common" ) type M3u8DownloadTool struct { name string // 视频名 saveDir string // 保存目录 link string // m3u8链接 keyLink string // key链接 prefix string // 视频前缀 progress i...
package control import ( "JVM-GO/ch05/instructions/base" "JVM-GO/ch05/rtda" ) /* tableswitch <0-3 byte pad> defaultbyte1 defaultbyte2 defaultbyte3 defaultbyte4 lowbyte1 lowbyte2 lowbyte3 lowbyte4 highbyte1 highbyte2 highbyte3 highbyte4 jump offsets... */ // Access jump table by index and jump type TABLE_SWITCH stru...
package postgresql import ( // "database/sql" "errors" "fmt" "log" ) var Default string = "DEFAULT" var DefaultFloat64 float64 = -1 var DefaultDate string = "0001-01-01" func Recover() { if r := recover(); r != nil { fmt.Println("Panic:", r) log.Println("\n*** Panic:", r) } } func (MSR *Metrics_step_req...
package main import ( "cloud.google.com/go/civil" "errors" "github.com/manifoldco/promptui" "log" "strconv" ) func handle(err error) { if err != nil { if err == promptui.ErrAbort { log.Panic("aborted", err) } log.Panic(err) } } func validateInt(arg string) error { _, err := strconv.Atoi(arg) if er...
package frequence import ( "testing" ) func BenchmarkIoFileInfo(b *testing.B) { for n := 0; n < b.N; n++ { IoFileInfo("C:\\Users\\Gamer\\go\\src\\is105gruppe20\\is105-ica03\\misc\\pg100.txt") } }
package xmodel import "github.com/ionous/sashimi/util/ident" // ParserAction commands that beome an action type ParserAction struct { Action ident.Id Commands []string }
package sys import ( "fmt" "io/ioutil" "os" ) // FS is the interface to a file system. type FS interface { // ReadAll gets the contents of filename, or an error if the file didn't exist or there was an // error reading it. ReadFile(filename string) ([]byte, error) // RemoveAll removes all of the files under t...
// Slice2 project doc.go /* Slice2 document */ package main
// Copyright 2019 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, ...
/* * binary_search.go: Binary search for slices containing integers. * * For Introduction to Go, Spring 2010 * Kimmo Kulovesi <kkuloves@cs.helsinki.fi> */ package main import ( "fmt" ) // Returns the index of the (or an) element with value e // in the sorted slice s, or -1 if no element has value e. func search...
// 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 main import ( "reflect" "sort" "testing" ) func TestBuddy(t *testing.T) { type args struct { start int limit int } tests := []struct { name string args args want []int }{ {name: "0", args: args{start: 10, limit: 50}, want: []int{48, 75}}, {name: "1", args: args{start: 48, limit: 50}, want...
package controller import ( "context" "fmt" "net/http" "strings" "time" "github.com/mylxsw/adanos-alert/internal/extension" "github.com/mylxsw/adanos-alert/internal/job" "github.com/mylxsw/adanos-alert/internal/repository" "github.com/mylxsw/adanos-alert/internal/template" "github.com/mylxsw/adanos-alert/pk...
package writeapi type Persistence interface { Store(Paste) error DeleteExpired() error } type Paste struct { ExpireTime int64 Route string Text string Created int64 }
package operations // This file was generated by the swagger tool. // Editing this file might prove futile when you re-run the swagger generate command import ( "time" "github.com/go-openapi/errors" "github.com/go-openapi/runtime" cr "github.com/go-openapi/runtime/client" strfmt "github.com/go-openapi/strfmt" ...
// SPDX-License-Identifier: MIT package protocol import ( "strings" "github.com/caixw/apidoc/v7/core" ) // ResourceOperationKind the kind of resource operations supported by the client. type ResourceOperationKind string const ( // ResourceOperationKindCreate supports creating new files and folders. ResourceOpe...
/* Copyright 2020 Docker Compose CLI 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 a...
package main import ( "fmt" "io" "bytes" "os" ) //w is a interface with nil type and nil value var w io.Writer //一个包含nil指针的接口不是nil接口 func f(out io.Writer) { if out != nil { fmt.Println("out is not nil") } else { fmt.Println("out is nil") } return } func main() { ...
package anilist import ( "strings" ) type User struct { Id int `json:"id"` Name string `json:"name"` About string `json:"about"` BannerImage string `json:"bannerImage"` Stats UserSt...
// Copyright 2020 Comcast Cable Communications Management, 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 ...
// 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 p_00001_00100 // 98. Validate Binary Search Tree, https://leetcode.com/problems/validate-binary-search-tree/ /** * Definition for a binary tree node. * type TreeNode struct { * Val int * Left *TreeNode * Right *TreeNode * } */ type TreeNode struct { Val int Left *TreeNode Right *Tree...
package huffman import ( "container/heap" "fmt" ) type HuffmanTree interface { Freq() int } type HuffmanLeaf struct { freq int value rune //int32 } type HuffmanNode struct { freq int left, right HuffmanTree } func (leaf *HuffmanLeaf) Freq() int { return leaf.freq } func (node *HuffmanNode) Freq() ...
package types import ( "testing" cm "github.com/zhaohaijun/matrixchain/common" ) func TestDataReqSerializationDeserialization(t *testing.T) { var msg DataReq msg.DataType = 0x02 hashstr := "8932da73f52b1e22f30c609988ed1f693b6144f74fed9a2a20869afa7abfdf5e" bhash, _ := cm.HexToBytes(hashstr) copy(msg.Hash[:], ...
package redis2 import ( "fmt" "github.com/gin-gonic/gin" "github.com/go-redis/redis/v7" "net/http" "os" "testing" "time" ) var RedisClient *redis.Client func init() { host := os.Getenv("REDISHOST") port := os.Getenv("REDISPORT") RedisClient = NewClientWithParam(host, port) fmt.Println("go-redis init.") } ...
package optgen import ( "bufio" "bytes" "fmt" "io" "unicode" ) var _ = fmt.Println type Token int const ( ILLEGAL Token = iota EOF IDENT STRING WHITESPACE COMMENT LPAREN RPAREN LBRACKET RBRACKET LBRACE RBRACE DOLLAR COLON ASTERISK EQUALS ARROW AMPERSAND COMMA CARET ELLIPSES PIPE // Key...
// Copyright (c) 2020 Tailscale Inc & 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 interfaces import ( "encoding/json" "testing" "inet.af/netaddr" ) func TestGetState(t *testing.T) { st, err := GetState() if err != ...
package main // Leetcode 79. (medium) func exist(board [][]byte, word string) bool { if word == "" { return true } if len(board) == 0 { return false } mr, mc := len(board), len(board[0]) for i := 0; i < mr; i++ { for j := 0; j < mc; j++ { if board[i][j] == word[0] && dfsExist(board, i, j, word, 0) { ...
package controllers type IndexController struct { BaseController } func (c *IndexController) Get() { c.TplName="index.html" c.Show() }
// +build !darwin package main import ( "errors" "net" ) func LaunchdSocket() (net.Listener, error) { return nil, errors.New("launchd is only supported on darwin") }
package main import ( "fmt" "time" "github.com/miekg/dns" ) func main() { c := new(dns.Client) c.Timeout = 1 * time.Second m := new(dns.Msg) m.SetQuestion(dns.Fqdn("!runprobe"), dns.TypeA) t := time.NewTicker(time.Second * 5) for range t.C { fmt.Println("TICK") r, _, err := c.Exchange(m, "127.0.0.1:...
/* Copyright 2020 The Skaffold 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, sof...
package comparetriplets // CompareTriplets ... // Link to the task: https://www.hackerrank.com/challenges/compare-the-triplets/problem func CompareTriplets(a []int32, b []int32) []int32 { var r []int32 r = make([]int32, 2) for i, v := range a { if v > b[i] { r[0] = r[0] + 1 } else if v < b[i] { r[1] = r...
package messages import "github.com/AsynkronIT/protoactor-go/actor" type Result struct { Pid *actor.PID } type UnknownResult struct { Pid *actor.PID } type FailedButConsistentResult struct { Pid *actor.PID } type FailedAndInconsistent struct { Pid *actor.PID } type SuccessResult struct { Pid *actor.PID }
package _1_Factory_Pattern // 工厂模式 //步骤 1 //创建一个接口: type Shape interface { Draw() string } type Color interface { Fill() string } //步骤 2 //创建实现接口的实体类。 type Rectangle struct{} type Square struct{} type Circle struct { Color string X, Y, Radius int } func (r Rectangle) Draw() string { return "Rectangle" }...
package app import ( "bytes" "fmt" "html/template" "log" "net/http" "time" "bitbucket.com/barrettbsi/broadvid-adscoops-shared/adscoopUtils" "bitbucket.com/barrettbsi/broadvid-adscoops-shared/structs" "github.com/BurntSushi/toml" "github.com/go-martini/martini" _ "github.com/go-sql-driver/mysql" "github.co...
package dig import "github.com/mazrean/gold-rush-beta/openapi" type Point struct { *openapi.Dig Amount int32 Type string } var ( depthTimeMap = [10]float64{8, 9, 10, 11, 12, 12.5, 13, 13.5, 14, 14.5} depthCoinMap = [10]float64{0.5, 1, 2, 3, 4, 5, 7.5, 10, 15, 35} ) func (p *Point) priority() float64 { retur...
package main import ( myjs "syscall/js" "github.com/robertkrimen/otto" ) var document = myjs.Global().Get("document") func getElementByID(id string) myjs.Value { return document.Call("getElementById", id) } func renderEditor(parent myjs.Value) myjs.Value { editorMarkup := ` <div id="editor" style="display: f...
package main import ( "io" "io/ioutil" "log" "github.com/classmethod/aurl/profiles" "github.com/classmethod/aurl/request" "gopkg.in/alecthomas/kingpin.v2" ) // Exit codes are int values that represent an exit code for a particular error. const ( ExitCodeOK int = 0 ExitCodeError int = 1 + iota ) // CLI is...