text
stringlengths
11
4.05M
package initial_cluster import ( util "github.com/verlandz/clustering-phone/utility" ) const ( N_DIVIDER = "N-Divider" RANDOMIZED = "Randomized" ) type req struct { N_Data int N_Feature int N_Cluster int data []util.Data distance string } func Get(N_Data, N_Feature, N_Cluster int, data []util.Data...
/* * @lc app=leetcode.cn id=204 lang=golang * * [204] 计数质数 * * https://leetcode-cn.com/problems/count-primes/description/ * * algorithms * Easy (30.50%) * Likes: 235 * Dislikes: 0 * Total Accepted: 35K * Total Submissions: 112.2K * Testcase Example: '10' * * 统计所有小于非负整数 n 的质数的数量。 *...
package main import ( "fmt" "math" ) func main() { a := []int{2, 3, 1, 3, 3} nextPermutation(a) fmt.Println(a) a = []int{1, 3, 2} nextPermutation(a) fmt.Println(a) } func nextPermutation(nums []int) { i := len(nums) - 1 min := math.MaxInt32 for ; i > 0; i-- { if nums[i] > nums[i-1] { k := i for j ...
package global import ( "io/ioutil" "os" "strings" "github.com/jinzhu/configor" ) type ConfigClass struct { Conf *Config } var ( GlobalConfig = ConfigClass{} ) func InitConfig(configFilePtr *string, secretFilePtr *string) { GlobalConfig.LoadConfig(configFilePtr, secretFilePtr) } type ConfigDB struct { Use...
package blocker import ( "testing" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/suite" ) // DefaultBlockerTestSuite 是 DefaultBlocker 的单元测试的 Test Suite type DefaultBlockerTestSuite struct { suite.Suite blockerPool *BlockerPool } // 改进单元测试 const ( blockerConfigPath = "./testdata/config_doc....
package clickhousespanstore import ( "database/sql" "database/sql/driver" "encoding/json" "fmt" "math/rand" "strconv" "testing" "time" "github.com/stretchr/testify/require" "github.com/stretchr/testify/assert" "github.com/hashicorp/go-hclog" "github.com/DATA-DOG/go-sqlmock" "github.com/gogo/protobuf/p...
package refcount import ( "reflect" "sync" "sync/atomic" ) // Interface following reference countable interface. // We have provided inbuilt embeddable implementation of the reference countable entryPool. // This interface just provides the extensibility for the implementation. type ReferenceCountable interface { ...
package propertypricehistorycom_test import ( . "github.com/DennisDenuto/property-price-collector/site/propertypricehistorycom" "fmt" "github.com/DennisDenuto/property-price-collector/data" "github.com/DennisDenuto/property-price-collector/site" "github.com/DennisDenuto/property-price-collector/site/propertypric...
// Copyright (c) 2013-2018 KIDTSUNAMI // Author: alex@kidtsunami.com package util import ( "bytes" "math" "time" ) func MinString(a, b string) string { if a < b { return a } return b } func MaxString(a, b string) string { if a > b { return a } return b } func MinBytes(a, b []byte) []byte { if bytes.C...
package main import ( "fmt" "io/ioutil" "os" "os/signal" "path/filepath" "runtime" "strings" "syscall" "github.com/codingeasygo/serviced" log "github.com/sirupsen/logrus" ) func usage() { switch runtime.GOOS { case "windows": fmt.Printf("Usage: serviced <install|uninstall|stat|stop|list|add|remove>\n"...
package router import ( HomeHandler "github.com/shwetha-pingala/HyperledgerProject/InvoiveProject/go-api/routes/home" "github.com/shwetha-pingala/HyperledgerProject/InvoiveProject/go-api/models" StatusHandler "github.com/shwetha-pingala/HyperledgerProject/InvoiveProject/go-api/routes/status" ) func GetRoutes() mod...
// Copyright 2019 GoAdmin Core Team. All rights reserved. // Use of this source code is governed by a Apache-2.0 style // license that can be found in the LICENSE file. package context import "fmt" type node struct { children []*node value string method []string handle [][]Handler } func tree() *node { ...
package todolist import ( "sort" "strings" "time" ) type sortFunc func(p1, p2 *TodoStat) int type StatSorter struct { stats []*TodoStat less sortFunc } func DateSort(asc bool) sortFunc { d := func(t1, t2 *TodoStat) int { ret := 0 if t1.PeriodStartDate.Before(t2.PeriodStartDate) { ret = -1 } else if ...
package controllers import ( "FinalProject/BlogApi/models" "encoding/json" "github.com/astaxie/beego" ) // Operations about Users type ArticleController struct { beego.Controller } // @Title CreateUser // @Description create users // @Param body body models.User true "body for user content" // @Success 200 {...
package text import ( "unicode" "github.com/texttheater/golang-levenshtein/levenshtein" "github.com/yandex-cloud/examples/serverless/alice-shareable-todolist/app/model" ) var levensteinOpts = levenshtein.Options{ InsCost: 1, DelCost: 1, SubCost: 1, Matches: func(r rune, r2 rune) bool { return unicode.ToLowe...
// Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. package operations import ( "bytes" "fmt" "log" "net" "golang.org/x/crypto/ssh" ) // RemoteRun executes remote command func RemoteRun(user string, addr string, port int, sshKey []byte, cmd string) (string, error) { ...
package transportador import ( "context" "encoding/json" "net/http" ) type ( CriarEntregaRequest struct { Entrega Entrega } CriarEntregaResponse struct { Voucher Voucher } ) func encodeResponse(ctx context.Context, w http.ResponseWriter, response interface{}) error { return json.NewEncoder(w).Encode(re...
package route import ( "github.com/kataras/iris" "github.com/kataras/iris/context" "github.com/kataras/iris/core/router" "gocherry-api-gateway/admin/controllers" ) func RegisterRoutes(app *iris.Application) { app.Get("/", func(ctx context.Context) { _, _ = ctx.WriteString("admin 200") }) app.Post("/login", ...
package 矩阵 // -------------------------------- SubrectangleQueries -------------------------------- // 执行用时:56 ms, 在所有 Go 提交中击败了92.31% 的用户 // 内存消耗:7.2 MB, 在所有 Go 提交中击败了100.00% 的用户 // // 概述: 这是一种非暴力的解决方案, // UpdateSubrectangle 时间复杂度: O(1) // GetValue 时间复杂度: O(x),其中 x 为 UpdateSubrectangle 的调用次数。 type Subrectang...
package soapboxd import "database/sql" func newNullString(s string) sql.NullString { return sql.NullString{String: s, Valid: true} } func nullString(ns sql.NullString) string { if ns.Valid { return ns.String } return "" }
package nominetuk import ( "encoding/json" "github.com/nbio/xx" ) // Result represents an EPP <result> element. type Result struct { Code int `xml:"code,attr" json:"code"` Message string `xml:"msg" json:"message"` ExtValue `json:"ext_value"` } // IsError determines whether an EPP status code is an error...
package _006_zigzag_conversion func convert(s string, numRows int) string { if numRows == 0 { return s } n := min(numRows, len(s)) z := make([]string, n) res := "" curRow, goingDown := 0, false for _, c := range s { z[curRow] += string(c) if curRow == 0 || curRow == numRows-1 { goingDown = !goingDown...
func rotate(matrix [][]int) { size := len(matrix) //Transformation for i := 0; i < size; i++ { for j := 0; j < size; j++ { if i != j && i > j { temp := matrix[i][j] matrix[i][j] = matrix[j][i] matrix[j][i] = temp } ...
package c31_hmac_sha1_timing_leak import ( "bytes" "fmt" "strings" "testing" "github.com/vodafon/cryptopals/set1/c1_hex_to_base64" ) type TTable struct { key string exp string } func TestHMACImplementation(t *testing.T) { ttb := []TTable{ { key: "KEY", exp: "c4473eba2b6e74a0adc0abbb4216676967626127"...
package main import ( "encoding/json" "fmt" ) type Server struct { ServerName string ServerIP string } type Serverslice struct { Servers []Server } func main() { var s Serverslice str := `{"servers":[{"serverName":"Shanghai_VPN","serverIP":"127.0.0.1"},{"serverName":"Beijing_VPN","serv...
/* Copyright 2019 The Yingxi.company Authors. All rights reserved. Go go get github.com/spf13/viper go get github.com/go-fsnotify/fsnotify Util */ package util import ( "github.com/fsnotify/fsnotify" "github.com/spf13/viper" "github.com/lexkong/log" ) // 配置结构 type Config struct { Name string } // 初始化 func (...
package main import ( "fmt" "log" "net/http" "os" "github.com/gorilla/mux" "github.com/kylegrantlucas/platform-exercise/handlers/session" "github.com/kylegrantlucas/platform-exercise/handlers/user" "github.com/kylegrantlucas/platform-exercise/pkg/postgres" "github.com/pascaldekloe/jwt" "github.com/sirupsen/...
/* * Copyright (c) 2020 - present Kurtosis Technologies LLC. * All Rights Reserved. */ package networks_impl import ( "github.com/kurtosis-tech/kurtosis-go/lib/networks" "github.com/kurtosis-tech/kurtosis-go/lib/services" "github.com/kurtosis-tech/kurtosis-go/testsuite/services_impl/api" "github.com/kurtosis-t...
// Security: // - api_key: // // SecurityDefinitions: // - api-key: // type: apiKey // name: session_id // in: header // // swagger:meta package handlers import ( "crypto/sha1" "encoding/hex" "encoding/json" "io" "io/ioutil" "log" "net/http" "github.com/rest_service_task/impl...
//go:build tools // This package exists to cause `go mod` and `go get` to believe these tools // are dependencies, even though they are not runtime dependencies. package tools import ( _ "github.com/client9/misspell/cmd/misspell" _ "github.com/golang/protobuf/protoc-gen-go" _ "golang.org/x/lint/golint" _ "golang...
package module import ( "math" "buddin.us/eolian/dsp" ) func init() { Register("Compress", func(Config) (Patcher, error) { return newCompress() }) } type compress struct { IO in, attack, release *In envelope dsp.Float64 dcBlock *dsp.DCBlock } func newCompress() (*compress, error) { m := &compress{ in: ...
package basic import ( "log" "os" ) var ( Logger, LoggerFile = getLogger() ) func getLogger() (*log.Logger, *os.File) { file, _:= os.Create("debuglog.txt") logger := log.New(file, "[goStudy] ", log.Ldate|log.Ltime) return logger, file }
package main import ( "encoding/json" "flag" "fmt" log "github.com/cihub/seelog" "github.com/goodsign/gosmsc" "github.com/goodsign/gosmsc/rpcservice" "github.com/goodsign/goutils/mgo" "github.com/goodsign/rpc" gjson "github.com/goodsign/rpc/json" "io/ioutil" lmgo "labix.org/v2/mgo" "net/http" "os" "os/si...
package zookeeper import ( "context" "github.com/marsmay/golib/logger" "github.com/samuel/go-zookeeper/zk" "strings" "sync" "time" ) const ( EventTypeAll = 0 ) const ( FlagPersistent = 0 FlagEphemeralAndSequence = zk.FlagEphemeral + zk.FlagSequence ) const ( WatchTypeNode = iota WatchTypeChildr...
package proxy_core import ( "encoding/binary" "fmt" "io" "log" "net" "sync" "time" ) type Request struct { Conn net.Conn Buff []byte } type Server struct { Server net.Listener V int Client net.Conn ProxyPort int32 } func (s *Server) IncrCycle(client net.Conn) Server { s.V++ s.Client = c...
// DRUNKWATER TEMPLATE(add description and prototypes) // Question Title and Description on leetcode.com // Function Declaration and Function Prototypes on leetcode.com //482. License Key Formatting //You are given a license key represented as a string S which consists only alphanumeric character and dashes. The string...
// Copyright 2020 Ant Group. All rights reserved. // // SPDX-License-Identifier: Apache-2.0 package rule type Rule interface { Validate() error Name() string }
package main func main() { makeServer() }
// Package handler 是 RPC 调用的 Handler package handler
package asm import ( "os" "regexp" "strings" "emperror.dev/errors" "github.com/aws/aws-sdk-go/service/secretsmanager" "github.com/aws/aws-sdk-go/service/secretsmanager/secretsmanageriface" log "github.com/sirupsen/logrus" ) const SMPatern = "arn:aws:secretsmanager:" const DefaultRegion = "eu-west-1" // Clien...
package fundsquarenet import ( "context" "fmt" "net/http" "strings" "github.com/PuerkitoBio/goquery" "github.com/mmbros/quote/internal/quotegetter" "github.com/mmbros/quote/internal/quotegetter/scrapers" ) // scraper gets stock/fund prices from fundsquare.net type scraper struct { name string client *http...
package friend import ( "fmt" "spapp/src/common/constants" helper "spapp/src/common/helpers" "spapp/src/models/apimodels" friendmodels "spapp/src/models/apimodels/friend" "spapp/src/models/domain" "spapp/src/persistence" "strconv" ) func GetRecipientsCommand(input friendmodels.GetRecipientsInput) friendmodels...
package gsm7bit import ( "bytes" "golang.org/x/text/transform" ) type gsm7Decoder struct { packed bool } func (d gsm7Decoder) Reset() { /* no needed */ } func (d gsm7Decoder) Transform(dst, src []byte, atEOF bool) (nDst, nSrc int, err error) { if len(src) == 0 { return } var buf bytes.Buffer septets := un...
package main import ( "fmt" "io/ioutil" ) func main() { text, errorFile := ioutil.ReadFile("example.txt") showError(errorFile) fmt.Println(string(text)) } func showError(e error) { if e != nil { panic(e) } }
package mongo_utils import ( "context" "errors" "fmt" "github.com/subosito/gotenv" "go.mongodb.org/mongo-driver/bson/primitive" "go.mongodb.org/mongo-driver/mongo" "go.mongodb.org/mongo-driver/mongo/options" "go.mongodb.org/mongo-driver/mongo/readpref" "log" "os" "strings" "time" ) const ( dbhost = "1...
// Copyright 2023 PingCAP, Inc. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // // http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed to i...
package utils import ( "errors" "io/ioutil" "strings" ) var ( ErrNoSuchDirOrFile = errors.New("ERR: no such file or direcory") ) func GetDirOrFilePathFromRoot(root string, target string) (string, error) { RootDirs := strings.Split(root, "/") if len(RootDirs) != 0 { if RootDirs[len(RootDirs)-1] == target { ...
package core type Receipt struct { } func NewReceipt() *Receipt { r := &Receipt{} return r }
package users import ( json "github.com/json-iterator/go" "github.com/klaytn/klaytn/common" "github.com/klaytn/klaytn/common/hexutil" "github.com/perlin-network/noise" "github.com/perlin-network/noise/payload" "github.com/pkg/errors" uuid "github.com/satori/go.uuid" ) var ( _ noise.Message = (*SignUpRequest)(...
package main import ( "fmt" "sort" "strings" ) func main() { fmt.Println(groupAnagrams([]string{ "eat", "tea", "tan", "ate", "nat", "bat", })) } func sortStr(str string) string { a := strings.Split(str, "") sort.Slice(a, func(i, j int) bool { return a[i] < a[j] }) return strings.Join(a, "") } func gr...
package main // Token represents a lexical token type Token int const ( // EOF represents the end of file EOF Token = iota // Error represents an error Error // Assign represents the assignment '=' Assign // Number represents a simple number Number // Operator an operator such as '+' '-' '*' '**' 'max' 'min'...
// golrn04 - Learning go // Maps // // 2016-02-28 PV package main import "fmt" func main() { var m1 map[string] int m1 = make(map[string]int, 3) m1["blue"] = 1 m1["white"] = 2 m1["red"] = 3 fmt.Println("red:", m1["red"]) fmt.Println("green:", m1["green"]) r,e := m1["orange"] fmt.Println("orange ->", ...
package main type Response struct { WeatherInfo WeatherInfo `json:"weatherinfo"` } type WeatherInfo struct { City string `json:"city"` CityId string `json:"cityid"` Temp string `json:"temp"` WD string `json:"WD"` WS string `json:"WS"` SD string `json:"SD"` WSE string `json:"WSE"` Ti...
package main import ( "crypto/tls" "crypto/x509" "errors" "io/ioutil" "path/filepath" ) func PrepareTLSCfg(certPath string, rootPath string, caPath string) (*tls.Config, error) { tlsConfig := &tls.Config{InsecureSkipVerify: true} if certPath != "" && rootPath != "" { cert, err := filepath.Abs(certPath) if ...
/* Copyright 2016 The Rook Authors. 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 applicable law or agreed to ...
package routers import ( "basic_blog_go/auth" "basic_blog_go/controllers" "github.com/astaxie/beego" ) func init() { ns := beego.NewNamespace("/v1", beego.NSNamespace("/posts", beego.NSInclude(&controllers.PostController{}), ), beego.NSNamespace("/users", beego.NSInclude(&controllers.UserContr...
package main import ( "flag" "fmt" "log" "os" "github.com/nsf/jsondiff" ) func main() { verbose := flag.Bool("v", false, "`true` provides a verbose output with the result of the comparison") help := flag.Bool("help", false, "provides this help message") flag.Parse() if *help == true { flag.PrintDefault...
package dcp import "testing" func Test_applePicking(t *testing.T) { type args struct { types []int } tests := []struct { name string args args want int }{ {"0", args{types: []int{2, 1, 2, 3, 3, 1, 3, 5}}, 4}, {"1", args{types: []int{}}, 0}, {"2", args{types: []int{2, 1, 2, 3, 1, 3, 5}}, 3}, {"3", ...
package main import ( "bufio" "fmt" "io" "log" "net" "strings" "github.com/hfgo/datafile" ) func main() { fileName := "input.txt" clientReader, err := datafile.GetString(fileName) if err != nil { log.Fatal(err) } conn, err := net.Dial("tcp", "127.0.0.1:8011") if err != nil { log.Fatalln(err) } def...
package main import ( "fmt" ) // https://leetcode-cn.com/problems/find-the-duplicate-number/ //------------------------------------------------------------------------------ // 类似于二分查找 // * 数组内数字的范围是 [1,n], 即 l,r 的初始值为 1,n // * 求 [1,n] 的中间值 m, 并统计数组内比 m 小的个数, 值为 less; 比 m 大的个数, 记为 gt. // * 如果 less > m-1, 说明 [...
// Copyright 2023 PingCAP, Inc. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // // http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed to i...
package main import ( "flag" "html/template" "io/ioutil" "log" "math/rand" "net/http" "strings" "time" ) func handler(w http.ResponseWriter, r *http.Request) { type Image struct { Filename string } var paths []string dir, err := ioutil.ReadDir("assets/") if err != nil { log.Println("ERROR: ", err) ...
package pie // All will return true if all callbacks return true. It follows the same logic // as the all() function in Python. // // If the list is empty then true is always returned. func All[T any](ss []T, fn func(value T) bool) bool { for _, value := range ss { if !fn(value) { return false } } return tr...
package online import ("im/engine" "sync") var onlineUser sync.Map type User struct { Id string Client *engine.Client } func GetAllUser() *sync.Map { return &onlineUser } func GetClientById(id string) *engine.Client { c,ok:= onlineUser.Load(id) if ok { return c.(*engine.Client) } return nil } func SetOnli...
package main func main() { // Run generate access token GenerateAccessToken() // Run basic sample for me BasicMe() // Run basic sample for feed BasicFeed() // Run basic sample for how to POST a feed BasicFeedPost() // Run basic sample for how to DELETE a feed BasicFeedDelete() }
package controllers import ( "context" "fmt" "github.com/genshen/ssh-web-console/src/models" "github.com/genshen/ssh-web-console/src/utils" "golang.org/x/crypto/ssh" "io" "log" "net/http" "nhooyr.io/websocket" "time" ) //const SSH_EGG = `genshen<genshenchu@gmail.com> https://github.com/genshen/sshWebConsole...
package apiservice import ( "context" "reflect" apiservicev1alpha1 "github.com/ligangty/api-service/pkg/apis/apiservice/v1alpha1" appsv1 "k8s.io/api/apps/v1" corev1 "k8s.io/api/core/v1" "k8s.io/apimachinery/pkg/api/errors" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/apimachinery/pkg/runtime" "k8s.i...
package types import ( "errors" . "grm-service/util" ) var ( ErrInvalidDBInfo = errors.New(TR("Invalid database connection info")) ErrInvalidNFSInfo = errors.New(TR("Invalid nfs file system info")) ErrDeviceNameExists = errors.New(TR("device name already exists")) ErrDeviceVolume = errors.New(TR("inva...
/* Given two integers, compute the two numbers that come from the blending the bits of the binary numbers of equal length(same number of digits, a number with less digits has zeros added), one after the other, like such: 2 1 10 01 1 0 1001 0 1 0110 some examples: Input Binary Conversion Output 1,0 1,0 10,01 2,1 1,2 ...
package ui import ( "image" "io" "net/http" "os" "path" "strings" "github.com/go-gl/gl/v2.1/gl" ) const textureSize = 4096 const textureDim = textureSize / 256 const textureCount = textureDim * textureDim type Texture struct { texture uint32 lookup map[string]int reverse [textureCount]string access [te...
// Copyright 2016 PingCAP, Inc. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // // http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed to i...
package main import "fmt" func main() { var name string name = "Mohd Zhuhry" fmt.Println(name) name = "Muhammad Zhuhry" fmt.Println((name)) var friendName = "Budi" fmt.Println(friendName) var age = 23 fmt.Println(age) country := "indonesia" fmt.Println(country) var ( firstName = "Muhammad" lastN...
package raftor import ( "time" "github.com/coreos/etcd/raft" "github.com/coreos/etcd/raft/raftpb" "golang.org/x/net/context" ) // Commit is used to send to the cluster to save either a snapshot or log entries. type Commit struct { State RaftState Entries []raftpb.Entry Snapshot raftpb.Snapshot Messages [...
package manifests import ( "crypto/x509" "encoding/pem" "fmt" "path/filepath" "strings" "github.com/pkg/errors" "github.com/sirupsen/logrus" corev1 "k8s.io/api/core/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "sigs.k8s.io/yaml" "github.com/openshift/installer/pkg/asset" "github.com/openshift/instal...
package main import ( "log" "os" "strings" ) const usage = ` usage: tasks insert "my new task" tasks list tasks update <task-id> true|false tasks purge ` func main() { //create a new logger with no date/time prefix. //Use this to write responses back to the terminal. //Use logger.Fatalf() to log a fatal m...
package core import "context" type behavior interface { AddNext(next behavior) behavior Run(ctx context.Context, request Request) Result Next() Result setParameters(ctx context.Context, request Request, handler RequestHandler) } type Middleware struct { ctx context.Context request Request handler RequestH...
package file import . "github.com/rainmyy/easyDB/library/strategy" func ParserJsonContent(data []byte) ([]*TreeStruct, error) { return nil, nil }
package problem0507 func checkPerfectNumber(num int) bool { if num == 1 { return false } sum := 1 i := 2 for ; i*i < num; i++ { if num%i == 0 { sum += num/i + i } } if i*i == num { sum += i } return sum == num }
// Copyright © 2020, 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 a...
/* Description As part of an arithmetic competency program, your students will be given randomly generated lists of from 2 to 15 unique positive integers and asked to determine how many items in each list are twice some other item in the same list. You will need a program to help you with the grading. This program sh...
package main import ( "fmt" "html/template" "log" "net/http" ) func HomeHandler(w http.ResponseWriter, r *http.Request) { w.Write([]byte("Please go to /cluster or /graph")) } func ClusterHandler(w http.ResponseWriter, r *http.Request) { tmpl, err := template.ParseFiles("view/cluster.html") if err != nil { h...
package msutil import "github.com/mauricelam/genny/generic" import x "github.com/dearcj/golangproj/network" import "reflect" type GenericData generic.Type var _ x.ServerData type GenericDataMsg struct { Changed bool data *GenericData backup *GenericData } func (n *GenericDataMsg) WriteToMsg() *GenericData {...
package main import ( "fmt" router "./http" "net/http" "os" "path/filepath" "./controllers" "./service" "./repos" ) var httpRouter router.Router = router.NewChiRouter() var postRepository repos.PostRepo = repos.NewFirestoreRepository() var postService service.PostService = service.NewPostService(postRepositor...
package backend_service import ( "2021/yunsongcailu/yunsong_server/backend/backend_dao" "2021/yunsongcailu/yunsong_server/web/web_model" ) type BackendArticleServer interface { // 获取所有文章 FindArticleAll() (articleAll []web_model.ArticleModel,err error) // 根据ID删除文章 RemoveArticleById(id int64) (err error) // 批量删除...
package worker import ( "context" "crypto/sha1" "fmt" "io" "path/filepath" "time" "golang.org/x/time/rate" "github.com/apex/log" "github.com/gocraft/work" "github.com/gomodule/redigo/redis" "gopkg.in/tomb.v2" "git.scc.kit.edu/sdm/lsdf-checksum/internal/lengthsafe" "git.scc.kit.edu/sdm/lsdf-checksum/int...
package arangodb import ( "context" common "github.com/Nubes3/common/models/arangodb" arangoDriver "github.com/arangodb/go-driver" "time" ) const ContextExpiredTime = 30 var ( userCol arangoDriver.Collection ) func InitArangoRepo() { ctx, cancel := context.WithTimeout(context.Background(), ContextExpiredTime*...
package main import ( "context" "log" "os" "github.com/joho/godotenv" "github.com/rbonnat/blockchain-in-go/server" ) func main() { var err error // Fetch environment variables err = godotenv.Load() if err != nil { log.Fatal(err) } port := os.Getenv("PORT") // Launch http server err = server.Run(con...
/* Copyright 2020 Humio https://humio.com 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 nebulatest import ( "bufio" "bytes" "fmt" "io/ioutil" "log" "strconv" "strings" "time" nebula "github.com/vesoft-inc/nebula-go" "github.com/vesoft-inc/nebula-go/graph" ) const ( testPrefix = "=== test" inPrefix = "--- in" outPrefix = "--- out" ) type Tester struct { client *nebula.GraphClie...
package api import ( "github.com/graphql-go/graphql" "github.com/graphql-go/relay" "golang.org/x/net/context" ) var nodeDefinitions = *relay.NewNodeDefinitions(relay.NodeDefinitionsConfig{ IDFetcher: func(id string, info graphql.ResolveInfo, ctx context.Context) (interface{}, error) { /* c := NewContext(ctx) */...
package urlutil import ( "encoding/base64" "fmt" "net/url" "strconv" "time" "github.com/pomerium/pomerium/pkg/cryptutil" ) // SignedURL is a shared-key HMAC wrapped URL. type SignedURL struct { uri url.URL key []byte signed bool // mockable time for testing timeNow func() time.Time } // NewSignedU...
package handler import ( "fmt" "io" "io/ioutil" "net/http" "os" ) func UploadHandler(w http.ResponseWriter, r *http.Request){ if r.Method == "GET" { // 返回上传html页面 data,err := ioutil.ReadFile("./static/view/index.html") if err != nil{ io.WriteString(w,"internal server error"+err.Error()) return }el...
package platform import ( "bytes" "fmt" "testing" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" ) type testClient struct { Num int Buf []byte } func (tcl testClient) Update(_ *Context) error { return nil } func TestPlatform_state_reload(t *testing.T) { var save []byte require...
package main import "fmt" func main() { a := [...]int{1,2,3,4,5} s1 := a[2:5] fmt.Println("s1:", s1) fmt.Println("s1:", len(s1), cap(s1)) s2 := a[:3] fmt.Println("s2:", len(s2), cap(s2)) fmt.Println("s2:", s2) /////////////////////////////////////// fmt.Println("a:", a) s2 = a...
// Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. package azurestack import ( "context" "github.com/Azure/azure-sdk-for-go/services/resources/mgmt/2016-06-01/subscriptions" ) // ListLocations returns the Azure regions available to the subscription. func (az *AzureClie...
// +build plan9 solaris package goselect import ( "fmt" "runtime" "syscall" ) // ErrUnsupported . var ErrUnsupported = fmt.Errorf("Platofrm %s/%s unsupported", runtime.GOOS, runtime.GOARCH) func sysSelect(n int, r, w, e *FDSet, timeout *syscall.Timeval) (int, error) { return 0, ErrUnsupported }
package generic import ( "context" "github.com/loft-sh/vcluster/pkg/util/loghelper" kerrors "k8s.io/apimachinery/pkg/api/errors" "k8s.io/apimachinery/pkg/api/meta" "k8s.io/apimachinery/pkg/runtime" "k8s.io/apimachinery/pkg/types" "k8s.io/client-go/util/workqueue" ctrl "sigs.k8s.io/controller-runtime" "sigs.k8...
package main import "fmt" func NewMap(name string) map[string]string { if name == "" { return nil } else { return map[string]string{ "name": name, } } } func main() { // Nil sendiri hanya bisa digunakan di beberapa tipe data, seperti interface, function, map, slice, pointer dan channel ...
package main import ( "fmt" "time" "runtime" ) func main() { //tryGoRoutine() printCpuNum() cpuLimit() } func tryGoRoutine() { for i := 0; i < 1000; i++ { go func(i int) { for { fmt.Printf("go routine %d\n", i) } }(i) } time.Sleep(time.Millisecond) } func printCpuNum(){ num:=runtime.NumCPU(...
package main import ( "fmt" "log" "github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/ethclient" hello "github.com/sanguohot/medichain/contracts/hello" // for demo ) func main() { client, err := ethclient.Dial("http://10.6.250.56:8545") if err != nil { log.Fatal(err) return } // 0xb...