text
stringlengths
11
4.05M
package main import ( "fmt" "math" ) func main() { for i := 1.0; i < 16.0; i++ { fmt.Println(sumDigits(math.Pow(2, i))) } } func sumDigits(n float64) float64 { sum := 0.0 for n >= 1 { r := float64(int(n) % 10) sum += r n = n / 10 } return sum }
package wiki import ( "testing" "sort" "io/ioutil" "os" ) func setupPageStore() *diskStore { storePath, err := ioutil.TempDir("", "wikitest") if err != nil { panic(err) } return &diskStore{path: storePath} } func cleanPageStore(store *diskStore) { ids, _ := store.ListAll() for _, id := range ids { stor...
package main // 扫雷游戏 // https://leetcode.com/problems/minesweeper/#/description import ( "fmt" ) var updatedBoard [][]byte var visit [][]byte func updateBoard(board [][]byte, click []int) [][]byte { // 初始化 updatedBoard = make([][]byte, len(board)) copy(updatedBoard, board) visit = make([][]byte, len(board)) ...
package api import ( "errors" "fmt" "os" "sort" "strings" "time" "github.com/sirupsen/logrus" ) const ( ticketurl = "tickets/%d" ticketsurl = "tickets" ticketsquery = "?per_page=100&page=%d&updated_since=%s" converstaions = "tickets/%d/conversations?per_page=100" oldticketsurl = "search/tickets?q...
package odoo import ( "fmt" ) // IrQwebFieldDuration represents ir.qweb.field.duration model. type IrQwebFieldDuration struct { LastUpdate *Time `xmlrpc:"__last_update,omptempty"` DisplayName *String `xmlrpc:"display_name,omptempty"` Id *Int `xmlrpc:"id,omptempty"` } // IrQwebFieldDurations repres...
package main import ( "flag" "fmt" "github.com/hyperhq/hyper/client" "os" ) func main() { var ( proto = "unix" addr = "/var/run/hyper.sock" ) cli := client.NewHyperClient(proto, addr, nil) // set the flag to output flHelp := flag.Bool("help", false, "Help Message") flVersion := flag.Bool("version", fa...
package model import ( "fmt" "strings" "github.com/docker/libcompose/utils" "github.com/jinzhu/gorm" "github.com/rancher/go-rancher/v2" ) type Template struct { EnvironmentId string `json:"environmentId"` CatalogId uint `sql:"type:integer REFERENCES catalog(id) ON DELETE CASCADE"` Name strin...
package main import ( "crypto/tls" "fmt" "github.com/bigbank-as/go_camunda_client/rest" "github.com/bigbank-as/go_camunda_client/rest/dto" "net/http" ) func main() { httpTransport := &http.Transport{ TLSClientConfig: &tls.Config{ InsecureSkipVerify: true, }, } httpClient := http.Client{Transport: httpT...
package main import ( "fmt" "math/rand" "time" ) func init() { rand.Seed(time.Now().UnixNano()) } var letterRunes = []rune("abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ") // RandStringRunes generates random strings of length n func RandStringRunes(n int) string { b := make([]rune, n) for i := range b ...
package nsq type Config struct { Host string Port string Prefix string }
// 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-2020 Datadog, Inc. package flare import ( "bufio" "bytes" "fmt" "io" "regexp" "strings" ...
package main import ( "net" "log" "flag" "fmt" "bufio" "strings" "strconv" ) type conn struct { rw net.Conn dataHostPort string prevCmd string pasvListener net.Listener cmdErr error binary bool } func NewConn(cmdConn net.Conn) *conn { return &conn{rw: cmdConn} } func hostPortToFTP(hostport s...
package main import ( "bufio" "fmt" "net" ) func main() { conn, err := net.Dial("tcp", ":8080") if err != nil { panic(err) } defer conn.Close() // writeToServer(conn) readFromServer(conn) } func writeToServer(conn net.Conn) { fmt.Fprintf(conn, "Hello from client") } func readFromServer(conn net.Conn) { ...
package problem0003 import ( "fmt" "strings" ) func lengthOfLongestSubstring(s string) int { if len(s) == 0 { return 0 } maxLen := 0 cache := map[byte]int{} // 存储字符在字符串中的最后位置 //遍历,如果有重复,起点移动至cache中字符位置的后一字符 for start, i := 0, 0; i < len(s); i++ { //判断是否上一个相同字符位置,是否大于等于start位置,并且i 不等于 start //注意 map查找中的...
package config const Jwt_Signing_Key string = "jdsfhdsjkhsfjkhwqieyhncxmfhsu6353%$^&%&G"
package main import ( "github.com/moshloop/fireviz/cmd" "github.com/moshloop/fireviz/pkg" "github.com/spf13/cobra" ) func main() { pkg.LogError("fireviz " + pkg.VERSION) var rootCmd = &cobra.Command{ Use: "fireviz", Run: func(cmd *cobra.Command, args []string) {}, } rootCmd.AddCommand(&cmd.Export, &cmd.Lis...
// Copyright (c) 2016 Uber Technologies, Inc. // // Permission is hereby granted, free of charge, to any person obtaining a copy // of this software and associated documentation files (the "Software"), to deal // in the Software without restriction, including without limitation the rights // to use, copy, modify, merge...
package buqi import ( "errors" "io" "log" "math/rand" "net" "time" ) // BufSize 缓冲区大小 const BufSize = 1024 // Socket 用于传输的 TCP Socket type Socket struct { Cipher *Cipher ListenAddr *net.TCPAddr RemoteAddr *net.TCPAddr } func init() { // 更新随机种子 rand.Seed(time.Now().Unix()) } // Start 启动 func Start()...
package models import ( "context" "go.mongodb.org/mongo-driver/bson" "go.mongodb.org/mongo-driver/mongo" ) // // 公司管理表数据结构 type CompanyData struct { ComId int64 `json:"com_id" bson:"com_id"` ComName string `json:"com_name" bson:"com_name"` ExpirationDate string `json:"expiration_date" bson:"ex...
package tests import ( "testing" "github.com/ravendb/ravendb-go-client" "github.com/stretchr/testify/assert" ) func nextAndSeedIdentitiesTestNextIdentityFor(t *testing.T, driver *RavenTestDriver) { var err error store := driver.getDocumentStoreMust(t) defer store.Close() { session := openSessionMust(t, sto...
package sort_test import ( "github.com/ashwinrrao/algorithms/sort" . "github.com/onsi/ginkgo" . "github.com/onsi/gomega" ) var _ = Describe("Mergesort", func() { When("an empty input is given", func() { var ( numbers = []int{} output []int ) BeforeEach(func() { output = sort.Mergesort(numbers) ...
package odoo import ( "fmt" ) // MailMassMailingList represents mail.mass_mailing.list model. type MailMassMailingList struct { LastUpdate *Time `xmlrpc:"__last_update,omptempty"` Active *Bool `xmlrpc:"active,omptempty"` ContactNbr *Int `xmlrpc:"contact_nbr,omptempty"` CreateDate *Time `...
package FlatFS import ( "flag" "log" "github.com/sarpk/go-fuse/fuse" "github.com/sarpk/go-fuse/fuse/nodefs" "github.com/sarpk/go-fuse/fuse/pathfs" "os" "path/filepath" "strings" "fmt" "bytes" ) var ( AttrMapperManagerInjector AttrMapperManager ) func Prepare() { AttrMapperManagerInjector = *NewAttrMapper...
/* * Copyright (c) 2019 Entrust Datacard Corporation. * All rights reserved. */ package main import ( "context" "fmt" "github.com/hashicorp/vault/logical" "github.com/hashicorp/vault/logical/framework" ) func (b *backend) opWriteConfigProfile(ctx context.Context, req *logical.Request, data *framework.FieldDa...
package store_test import ( "testing" "github.com/golang/mock/gomock" "github.com/smartcontractkit/chainlink/internal/cltest" "github.com/smartcontractkit/chainlink/store" "github.com/smartcontractkit/chainlink/store/mock_store" "github.com/stretchr/testify/assert" ) func TestStore_Start(t *testing.T) { t.Par...
// Package httperror provides the needes to build and HTTPError package httperror
// Copyright 2020 The ChromiumOS Authors // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. package arc import ( "context" "fmt" "time" "chromiumos/tast/common/perf" "chromiumos/tast/ctxutil" "chromiumos/tast/local/arc" "chromiumos/tast/local/bundles/cros/a...
package udwSqlite3 import ( "github.com/tachyon-protocol/udw/udwFile" "github.com/tachyon-protocol/udw/udwLog" "github.com/tachyon-protocol/udw/udwStrings" ) type setExecReq struct { k1 string sql string valueBuf [][]byte respStatusCb func(status QueryRespStatus) UseStmtCache bool } fu...
package build import ( "fmt" "os" "path/filepath" "strings" "time" "github.com/dustin/go-humanize" dockerapi "github.com/fsouza/go-dockerclient" log "github.com/sirupsen/logrus" "github.com/docker-slim/docker-slim/pkg/app" "github.com/docker-slim/docker-slim/pkg/app/master/builder" "github.com/docker-slim...
package capital import ( "fmt" "github.com/spf13/cobra" ) var capitalCmd = &cobra.Command{ Use: "capital", Short: fmt.Sprint("这是capital命令很短的介绍"), Long: fmt.Sprint("这是capital命令很长很长很长的介绍"), } func Cmd() *cobra.Command { capitalCmd.AddCommand(anyCmd()) return capitalCmd }
package dz2 import ( "testing" ) type item struct { in string out string } func TestUnpackOk(t *testing.T) { items := []item{ {in: "a4bc2d5e", out: "aaaabccddddde"}, {in: "abcd", out: "abcd"}, {in: `qwe\4\5`, out: `qwe45`}, {in: `qwe\45`, out: `qwe44444`}, {in: `qwe\\5`, out: `qwe\\\\\`}, } for _, ...
package confirm_test import ( "net/http" "net/http/httptest" "sync" "testing" "time" "github.com/jrapoport/gothic/hosts/rest" "github.com/jrapoport/gothic/hosts/rest/account/confirm" "github.com/jrapoport/gothic/mail/template" "github.com/jrapoport/gothic/test/tconf" "github.com/jrapoport/gothic/test/tcore"...
/* * Copyright 2020 zpxio (Jeff Sharpe) * * 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 ag...
package middlewares import ( "log" "net/http" "strconv" "github.com/Anondo/graphql-and-go/conn" "github.com/Anondo/graphql-and-go/database/repos" "github.com/labstack/echo/v4" ) // AuthMiddleware ... func AuthMiddleware(next echo.HandlerFunc) echo.HandlerFunc { return func(c echo.Context) error { userID, _...
package nxrm import ( "context" "encoding/json" "errors" "fmt" "sync" "time" "github.com/hashicorp/errwrap" multierror "github.com/hashicorp/go-multierror" "github.com/hashicorp/vault/api" "github.com/hashicorp/vault/sdk/database/dbplugin" "github.com/hashicorp/vault/sdk/database/helper/credsutil" "github...
// Copyright 2016 CoreOS, 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 in...
package edsm import ( "encoding/json" "errors" "goed/edGalaxy" "io/ioutil" "log" "net/http" "net/url" "strings" "sync" "time" ) func edsmSysInfo2galaxyBriefSystemInfo(si *EDSMSysInfo) *edGalaxy.BriefSystemInfo { if si == nil { return nil } return &edGalaxy.BriefSystemInfo{ Allegiance: si.Allegiance...
package main import ( "io/ioutil" "net/http" "fmt" ) type page struct { Title string Body[]byte } func (p *page) save () error{ f := p.Title + ".txt" return ioutil.WriteFile(f, p.Body, 0600) } func load(title string) (*page, error) { f := title + ".txt" body, err := ioutil.ReadFile(f) if err != nil { return nil, e...
// Map project main.go package main import ( "fmt" ) type myMap struct { lat, long string } func main() { var m map[string]myMap m = make(map[string]myMap) m["John"] = myMap{"40", "40"} m2 := map[string]myMap{"Amy": {"10", "10"}, "Alex": {"20", "20"}} m3 := map[string]myMap{"Kyle": myMap{"30", "30"}} fmt.P...
package ent_ex type verifyInfo struct { Email string `json:"email"` Tel string `json:"tel"` Password string `json:"password"` }
package flatten //func flattenCloud(in v1beta1.Cloud) []interface{} { // att := make(map[string]interface{}) // // if len(in.Profile) > 0 { // att["profile"] = in.Profile // } // if len(in.Region) > 0 { // att["region"] = in.Region // } // att["secret_binding_ref"] = flattenLocalObjectReference(&in.SecretBindingRef)...
package service import ( "easynote/bean" "easynote/mongodb" "fmt" "gopkg.in/mgo.v2/bson" //"strings" //"log" ) func IsUserExist(name string) bool { session := mongodb.GetSession() fmt.Println("name = %s",name) c := session.DB("test").C("t_user") if c == nil { fmt.Println("get t_user fail"); return fals...
// Copyright 2017 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 config import ( "errors" "fmt" "sort" "strings" "github.com/spf13/viper" ) const UsersKey = "users" type Users map[string]User type User struct { APIToken string Email string ID uint64 Name string Username string } func (Config) GetAPITokenForUser(id uint64) (string, error) { var u...
package utils import ( md52 "crypto/md5" "fmt" "github.com/astaxie/beego" "github.com/jinzhu/gorm" _ "github.com/jinzhu/gorm/dialects/mysql" "time" ) type Txt struct { Project string User string Achievements string Goal string } type Text struct { gorm.Model Txt } type Usr struct { ...
package main import ( "clipper" "flag" "os" ) var opType = flag.Uint("op", 0, "-op") var path = flag.String("path", "", "-path") var masterAddr = flag.String("master", "", "-master") func main() { flag.Parse() client := clipper.NewClient() op := clipper.OpType(*opType) client.StartUp(op, *path, *masterAddr, o...
package flag import ( "reflect" "github.com/achilleasa/usrv/config/store" ) // Map provides a thread-safe flag wrapping a map[string]string value. Its // value can be dynamically updated via a watched configuration key or manually // set using its Set method. // // The flag also provides a mechanism for listening ...
package main type runeSorted []rune func (s runeSorted) Len() int { return len(s) } func (s runeSorted) Less(i, j int) bool { return s[i] < s[j] } func (s runeSorted) Swap(i, j int) { s[i], s[j] = s[j], s[i] }
package main // Leetcode 47. (medium) func permuteUnique(nums []int) [][]int { return recursivePermuteUnique(nums, []int{}, [][]int{}) } func recursivePermuteUnique(nums, arr []int, res [][]int) [][]int { if len(nums) == len(arr) { tmp := make([]int, len(arr)) for i, j := range arr { tmp[i] ...
// Copyright 2019 - 2022 The Samply Community // // 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 main import ishell "gopkg.in/abiosoft/ishell.v2" func cmdFiles(c *ishell.Context, d Data) Data { names := d.Names() initIndexes := []int{} for i := range names { initIndexes = append(initIndexes, i) } choices := c.Checklist(names, "Files", initIndexes) return d.Subset(choices) }
package model type Record struct { RecordID int `json:"record_id"` UserID int `json:"uid"` UserScore float64 `json:"user_score"` KindName string `json:"kind_name"` GameName string `json:"game_name"` EnterTime string `json:"enter_time"` LeaveTime string `json:"leave_time"` } func (t *Record) T...
package models import( "encoding/json" ) /** * Type definition for TierType1Enum enum */ type TierType1Enum int /** * Value collection for TierType1Enum enum */ const ( TierType1_KAZURETIERHOT TierType1Enum = 1 + iota TierType1_KAZURETIERCOOL TierType1_KAZURETIERARCHIVE ) fun...
package types import ( "math" "math/big" ) // Note, Zero and Max are functions just to make read-only values. // We cannot define constants for structures, and global variables // are unacceptable because it will be possible to change them. // Zero is the lowest possible Int128 value. func Int128Zero() Int128 { r...
// ===================================== // // author: gavingqf // // == Please don'g change me by hand == // //====================================== // /*you have defined the following interface: type IConfig interface { // load interface Load(path string) bool // clear interface Clear() }...
package data import ( "github.com/sirupsen/logrus" "poetryAdmin/worker/core/define" "reflect" ) const ChanMaxLen = 50000 //抓取结果处理 type GraspResult struct { err chan error close chan bool Data chan *define.HomeFormat ParseData chan *define.ParseData storage *Storage } var G_GraspResult *Gras...
package main import ( "bytes" "fmt" "io" ) const debug = false type A struct{} func main() { var buf *bytes.Buffer var a *A var w io.Writer if debug { buf = new(bytes.Buffer) // enable collection of output } fmt.Println(a == nil) fmt.Println(buf == nil) fmt.Println(w == nil) f(buf) // note: subtly wro...
package maximum_depth_of_binary_tree import ( "LeetCodeGo/base" "LeetCodeGo/utils" ) /* 给定一个二叉树,找出其最大深度。 二叉树的深度为根节点到最远叶子节点的最长路径上的节点数。 说明: 叶子节点是指没有子节点的节点。 示例: 给定二叉树 [3,9,20,null,null,15,7], 3 / \ 9 20 / \ 来源:力扣(LeetCode) 链接:https://leetcode-cn.com/problems/maximum-depth-of-binary-tree 著作权归...
package function import ( "errors" "log" "os" ) type Storage interface { AddEntityToOtherEntity(string, string, string) error } type Executor struct { Store Storage } var ExecutorLogger = log.New(os.Stdout, "Executor: ", log.Lshortfile) var ( // ErrCategoryCanNotBeAddedToProduct means that the category can't...
// Copyright 2013 - by Jim Lawless // License: MIT / X11 // See: http://www.mailsend-online.com/license2013.php // // Bear with me ... I'm a Go noob. package main import ( "flag" "fmt" ) // Define a type named "intslice" as a slice of ints type connections []string // Now, for our new type, implement the two meth...
package main import "fmt" func plusOne(digits []int) []int { size := len(digits) for i := size - 1; i >= 0; i-- { digits[i] += 1 if digits[i] > 9 && i > 0 { digits[i] %= 10 } else { break } } if digits[0] == 10 { digits[0] = 0 result := make([]int, 0) result = append(result, 1) result = appe...
// Alex Ray 2011 <ajray@ncsu.edu> // Reference: // http://en.wikipedia.org/wiki/Bencode package bencode import "fmt" // Bencode an Integer func EncInt(i int) []byte { return []byte(fmt.Sprintf("i%de", i)) } // Bencode a byte string func EncBytes(a []byte) []byte { return []byte(fmt.Sprintf("%d:%s",len(a),a...
package disc import ( "github.com/diamondburned/arikawa/v2/discord" "github.com/diamondburned/arikawa/v2/gateway" ) // Help prints the default help message. func (b *Bot) Help(_ *gateway.MessageCreateEvent) (*discord.Embed, error) { return &discord.Embed{ Description: b.Ctx.Help(), Footer: &discord.EmbedFooter...
package netsync import ( "github.com/constant-money/constant-chain/common" "github.com/constant-money/constant-chain/metadata" lru "github.com/hashicorp/golang-lru" "github.com/patrickmn/go-cache" "sync" "sync/atomic" "time" "github.com/constant-money/constant-chain/blockchain" "github.com/constant-money/con...
// Copyright 2021 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 linqo import ( "bytes" ) type SelectTermWhere interface { Where(term SearchTerm) SelectWhere } type SelectTermGroupBy interface { GroupBy(columns ...string) SelectGroupBy } type SelectTermHaving interface { Having(term SearchTerm) SelectHaving } type SelectTermOrderBy interface { OrderBy(sortSpecs ......
package chapters import "fmt" func structs() { type user struct { ID int FirstName string LastName string } var u user u.ID = 1 u.FirstName = "Arthur" u.LastName = "Fleck" fmt.Println(u) u2 := user{ ID: 1, FirstName: "Arthur", LastName: "Morgan", } fmt.Println(u2) }
package slacklogger import ( "fmt" ) type SlackLogger struct { webhookURL string environment string isDebug bool } // NewSlackLogger returns a new instance of SlackLogger func NewSlackLogger(webhookURL, environment string, isDebug bool) *SlackLogger { return &SlackLogger{ webhookURL: webhookURL, envir...
package main import _ "alpha.test/database/migration"
package builder import ( "net/http" "encoding/json" "bytes" "net/http/httputil" "log" ) type Request struct { Method string Path string Headers map[string]string QueryParams map[string]string Body interface{} } func NewRequest(method string, path string) *Request { return &Request{ ...
package handlers import ( "bytes" "database/sql" "encoding/json" "errors" "fmt" "net/http" "net/http/httptest" "os" "testing" "time" "github.com/go-redis/redis" "wayneli.me/m/servers/gateway/models/users" "wayneli.me/m/servers/gateway/sessions" ) // TestServeHTTP tests if ServeHTTP in cors.go correctly ...
package chat import ( "fmt" ) type Agent interface { Id() (string) Read(msg *string)(error) Write(msg string)(error) } type chatAgent struct{ a Agent r *Room } func NewRoomAgent(a Agent, r *Room)(ra *chatAgent){ ra = &chatAgent{a, r} // r.AddUser(ra) return } func(ra *chatAgent)Id()(string){ return ra.a.I...
package core import ( db "github.com/I-Reven/Hexagonal/src/infrastructure/repository/mongo" "github.com/go-bongo/bongo" "os" "sync" ) var ( config = bongo.Config{ ConnectionString: os.Getenv("MONGO_URL"), Database: "core", } once sync.Once connection *Connection ) type ( Connection struct ...
package add_two_numbers import ( "testing" ) func Test_addTwoNumbers(t *testing.T) { tests := []struct { name string l1 *ListNode l2 *ListNode want *ListNode }{ { l1: newList(2, 4, 3), l2: newList(5, 6, 4), want: newList(7, 0, 8), }, { l1: newList(0), l2: newList(0), wan...
/* ###################################################################### # Author: (__AUTHOR__) # Created Time: __CREATE_DATETIME__ # File Name: default_handler.go # Description: ####################################################################### */ package handlers import ( "__PROJECT_NAME__/libs" "github.co...
package main import ( "fmt" ) func main() { fmt.Println(countAndSay(5)) } func countAndSay(n int) string { /* 结束: n=0||n=1 处理: 得到后面的string,找连续数字,拼接 返回: 本级字符串 */ if n == 0 { return "" } else if n == 1 { return "1" } else if n == 2 { return "11" } str := countAndSay(n - 1) i, k := 1, 0 count := ...
package main import ( "fmt" "math/rand" "time" ) /* Задание 2. Нахождение первого вхождения числа в упорядоченном массиве (числа могут повторяться) Что нужно сделать Заполните упорядоченный массив из 12 элементов и введите число. Необходимо реализовать поиск первого вхождения заданного числа в массив. Сложность...
package main import ( "fmt" xir "github.com/ceftb/xir/lang/go" "github.com/ceftb/xir/tools/viz" ) func main() { a := xir.NewNet() s0 := a.Node().Set(xir.Props{"name": "s0"}) s1 := a.Node().Set(xir.Props{"name": "s1"}) for i := 0; i < 5; i++ { n := a.Node().Set(xir.Props{"name": fmt.Sprintf("n%d", i)}) a.L...
/* bogomilter is a milter service for postfix */ package main import ( "flag" "fmt" "github.com/phalaaxx/milter" "io" "io/ioutil" "log" "net" "net/textproto" "os" "os/exec" "strings" "syscall" ) /* global variables */ var BogoBin string var BogoDir string var LocalHold bool /* BogoMilter object */ type B...
package plug import ( "mqtts/core" "mqtts/utils" "strings" ) const iterStartDigits = 5 const iterEndDigits = 10 var clientIdTypes = []string{"string", "int", "effectiveNumber"} func FuzzAvailableClientId(opts *core.TargetOptions) []string { utils.OutputInfoMessage(opts.Host, opts.Port, "Start detecting availabl...
package fileutils import ( "fmt" "io" "io/ioutil" "os" "path/filepath" "strings" ) func CopyFile(srcPath string, dstPath string) error { srcFile, err := os.Open(srcPath) if err != nil { return err } defer srcFile.Close() dstFile, err := os.Create(dstPath) _, err = io.Copy(dstFile, srcFile) if err ...
package api import ( "bytes" "encoding/json" "fmt" "net/http" "net/http/httptest" "testing" "github.com/thetogi/YReserve2/model" ) func TestUpdateUserDetail(t *testing.T) { t.Log("Starting update user detail test case") apiTest := GetApiTest() user := GetTestUser() userAuth := apiTest.CreateUserAuthFromT...
package kademlia import ( "fmt" "io" ) // Ping is an empty ping message. type Ping struct{} // Marshal implements Serializable interface and returns a nil byte slice. func (r *Ping) Marshal() []byte { return nil } // Unmarshal implements decode interface and returns a Ping message and never throws an error. func...
package state import "time" // SystemState - All kinds of system-related information and metrics type SystemState struct { Info SystemInfo Scheduler Scheduler Memory Memory CPUInfo CPUInformation CPUStats CPUStatisticMap NetworkStats NetworkStatsMap Disks DiskMap DiskStats ...
package main import ( "flag" "net/http" "github.com/mgalela/akses" "github.com/mgalela/akses/utils" ) func main() { r := hard.BootstrapAPI() filename := flag.String("config", "config.json", "Path to configuration file") flag.Parse() hard.Initialize(*filename) utils.Log.Info("Starting app server at 9015"...
package parser import ( "errors" ) // ParseFunction returns a string of the build instruction function. func (p *Parser) ParseFunction() (result string, err error) { token := p.scnr.Peak() if !token.IsFunction() { return result, errors.New("called ParseFunction without the beginning token being a function declar...
// 대기오염정보 조회 서비스 package main import ( "encoding/json" "fmt" "io/ioutil" "log" "net/http" ) const API_Key = "api key" type Result1 struct { MangName string `json:"mangName"` DataTime string `json:"dataTime"` KhaiGrade string `json:"khaiGrade"` //통합지수 KhaiValue string `json:"khaiValue"` No2Grade string `...
package hard import "sort" //given a list of chars (as a string), and target word length, output all possible word combination func PickWords(charList string, wordLen int) []string { subsets := Subset(charList, wordLen) words := []string{} for _, subset := range subsets { words = append(words, Permutation(subset...
package template type TemplateUsecase interface { }
package main import ( _ "github.com/mattn/go-sqlite3" ) func main() { data := csvToArray() chart := makeChart(data) saveFile(chart) }
package requests type EditGuestList struct { Table int64 `json:"table"` AccompanyingGuests int64 `json:"accompanying_guests"` }
package container import ( "fmt" "math/rand" "os" "time" gormProm "gorm.io/plugin/prometheus" "go.uber.org/zap" "github.com/lenvendo/ig-absolut-fake-sms/service" "github.com/lenvendo/ig-absolut-fake-sms/lib/config" "github.com/lenvendo/ig-absolut-fake-sms/lib/db" "github.com/lenvendo/ig-absolut-fake-sms/li...
//常數練習 package main import "fmt" const ( a int = 2017 b int = 2018 c int = 2019 d int = 2020 ) func main() { fmt.Println(a) fmt.Println(b) }
// Copyright 2017 The go-interpreter 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 wasm import ( "bytes" "debug/dwarf" "errors" "fmt" "io" "reflect" "strings" "github.com/pgavlin/warp/wasm/internal/readpos" ) va...
package agent import ( "os" "path" "strconv" "strings" "github.com/sirupsen/logrus" "github.com/rancher/fleet/internal/config" "github.com/rancher/wrangler/pkg/name" appsv1 "k8s.io/api/apps/v1" corev1 "k8s.io/api/core/v1" networkv1 "k8s.io/api/networking/v1" rbacv1 "k8s.io/api/rbac/v1" metav1 "k8s.io/ap...
package main import ( "github.com/vicanso/elton" staticServe "github.com/vicanso/elton-static-serve" ) func main() { e := elton.New() sf := new(staticServe.FS) // static file route e.GET("/*file", staticServe.New(sf, staticServe.Config{ Path: "/tmp", // 客户端缓存一年 MaxAge: 365 * 24 * 3600, // 缓存服务器缓存一个小时 ...
// 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 arc import ( "github.com/shirou/gopsutil/v3/process" "chromiumos/tast/errors" "chromiumos/tast/local/sysutil" ) var errInitNotFound = errors.New("didn't find in...
package com import ( "JsGo/JsHttp" . "JsGo/JsLogger" "JsGo/JsStore/JsRedis" "JunSie/constant" ) func InitShow() { JsHttp.WhiteHttps("/getshowartone", GetShowArtOne) //获取首页产品板块 } type Showone struct { Title string //标题 UserHead string //用户头像 SubTitle string //副标题 Brief string //简介 Questio...
package docker import ( "context" "encoding/base64" "encoding/json" "errors" "fmt" "os" "strings" "time" "github.com/docker/distribution/reference" "github.com/docker/docker/api/types" "github.com/docker/docker/api/types/container" "github.com/docker/docker/api/types/filters" "github.com/docker/docker/ap...
package sdf import ( "fmt" "image" "github.com/macroblock/sdf/pkg/gfx" ) type ( // TileBuilder - TileBuilder struct { prefix string counter uint } // TileTemplateBuilder - TileTemplateBuilder struct { params []tileTemplateType } tileTemplateType struct { offs int extend *image.Rectangle fl...