text
stringlengths
11
4.05M
package gonbt import ( "errors" ) // TagType values const ( TagEnd byte = iota TagByte TagShort TagInt TagLong TagFloat TagDouble TagByteArray TagString TagList TagCompound TagIntArray TagLongArray ) // Tag interface to provide a nbt reader / writer type Tag interface { Read(reader Reader) error Writ...
package 二分 import "math/rand" func smallestK(arr []int, k int) []int { makeKthSmallToRightPlace(arr,k) return arr[:k] } func makeKthSmallToRightPlace(nums []int, KthSmall int) { l, r := 0, len(nums)-1 for l <= r { index := randomPartition(nums, l, r) XthSmall := index+1 if XthSmall == KthSmall { return...
package service import ( "backend/src/cache" "backend/src/constants" "backend/src/global" "backend/src/module" "backend/src/repository" "backend/src/utils" "errors" "gopkg.in/ldap.v2" "log" "reflect" "strings" "time" ) const ( // 默认密码 DefaultPassword string = "123456" // 登录token长度 LoginTokenLength int...
//import "github.com/solomonooo/mercury" //author : solomonooo //create time : 2016-09-08 package mercury import ( "errors" ) const ( CODE_SUCCESS = iota CODE_INVALID_PARAM CODE_ROUTER_FAILED CODE_INVALID_WORKER CODE_CLIENT_CONN = 100 CODE_CLIENT_READ = 101 CODE_CLIENT_WRITE = 102 CODE_UNKNOWN = 9999...
package operators import ( "context" "fmt" . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" corev1 "k8s.io/api/core/v1" rbacv1 "k8s.io/api/rbac/v1" apierrors "k8s.io/apimachinery/pkg/api/errors" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/apimachinery/pkg/runtime" "k8s.io/apimachinery/pkg/...
package main import ( "errors" "io" "log" "os" "os/exec" "os/signal" "path/filepath" "syscall" "time" ) var file string var args []string func main() { if len(os.Args) < 2 { log.Fatal("at least two args are required") } file = os.Args[1] args = os.Args[2:] log.Printf("main file: %s", file) log.Prin...
package model import ( "database/sql" "github.com/barrydev/api-3h-shop/src/constants" ) type Shipping struct { /** Response Field */ Id *int64 `json:"_id,omitempty"` Carrier *string `json:"carrier,omitempty"` Status *string `json:"status,omitempty"` OrderId *int64 `json:"order_id,o...
package apiserver import ( "encoding/json" "errors" "fmt" "github.com/bolshagin/xsolla-be-2020/model" "github.com/dgrijalva/jwt-go" "github.com/google/uuid" "net/http" "strings" "time" ) var ( zeroDate = time.Date(1000, 1, 1, 0, 0, 0, 0, time.UTC) sessDuration float64 = 60 * 15 layout ...
package game_map import ( "fmt" "github.com/faiface/pixel/pixelgl" "github.com/steelx/go-rpg-cgm/animation" "github.com/steelx/go-rpg-cgm/state_machine" "math" "reflect" ) type CSMoveParams struct { Dir, Distance, Time float64 } type CSMove struct { Name string Character *Char...
/* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may ...
package main import ( "fmt" "github.com/sunmi-OS/gocore/hbase" "github.com/sunmi-OS/gocore/log" "github.com/sunmi-OS/gocore/viper" "go.uber.org/zap" "os" ) func main() { // 初始化配置文件 viper.NewConfig("config", "conf") // 初始化日志库 log.InitLogger("example-Hbase") err := hbase.NewHbase() if err != nil { fmt....
package aws import ( "net/http" "sort" "strings" survey "github.com/AlecAivazis/survey/v2" "github.com/AlecAivazis/survey/v2/core" "github.com/aws/aws-sdk-go/aws" "github.com/aws/aws-sdk-go/aws/awserr" "github.com/aws/aws-sdk-go/aws/session" "github.com/aws/aws-sdk-go/service/route53" "github.com/pkg/errors...
package staticdata type Mall_Data struct { ID int Name string Money int Discount float32 Icon int } func (self *Mall_Data) GetName() string { return "mall" } func (self *Mall_Data) GetFilePath() string { return "csv/mall_data.csv" }
package solution import ( "testing" ) func TestBasic(t *testing.T) { testcases := []int{1234567, 123456789, 1221, 12321, 11, 9, -1, 0, 11111} for _, testcase := range testcases { t.Log(testcase, isPalindrome3(testcase)) } }
package cache type CacheManager interface { // Cache returns kv cache with specific name Cache(name string) Cache }
package main import ( "fmt" "github.com/zdq0394/algorithm/base/tree" ) func main() { r := getCommontree() a := tree.InOrderTraversal(r) fmt.Printf("%s", "InOrder:") for _, v := range a { fmt.Printf("%d ", v) } fmt.Println() b := tree.PreorderTraversal(r) fmt.Printf("%s", "PreOrder:") for _, v := range ...
package consumer import ( "sync" "container/list" "log" ) type memQueue struct { name string sync.RWMutex queue *list.List // exposed via ReadChan() readChan chan interface{} // internal channels writeChan chan interface{} writeResponseChan chan error exitChan chan int waitGroup WaitG...
// unmarshal. package main import ( "encoding/json" "fmt" ) type JSON struct { String string `json:"string"` Array []string `json:"array"` } var str = []byte(`{ "string": "hello world", "array": [ "string 1", "string 2" ] }`) var invalidStr = []byte(`{ string: "hello world" }`) func main() { // vali...
package blocks import ( "bytes" "crypto/ecdsa" "crypto/elliptic" "crypto/rand" "crypto/sha256" "cryptom/internal" "encoding/gob" "encoding/hex" "errors" "fmt" "log" "math/big" ) /** Outputs are where “coins” are stored. Each output comes with an unlocking script, which determines the logic of unlocking th...
package coins_test import ( "context" "testing" "google.golang.org/grpc" "github.com/stretchr/testify/assert" coins "github.com/angelospillos/coinsorchestrator" pricing "github.com/angelospillos/pricingservice/proto" ranking "github.com/angelospillos/rankingservice/proto" ) type MockPricingService struct { ...
package two_sums type Numbers interface { TwoSum() []int } type numbers struct { nums []int target int } func (n *numbers) TwoSum() []int { theMap := map[int]int{} for i, num := range n.nums { theMap[num] = i } for i, num := range n.nums { if val, ok := theMap[n.target-num]; ok { if val <= i { c...
package iot import ( "encoding/json" "github.com/aliyun/alibaba-cloud-sdk-go/sdk" "github.com/aliyun/alibaba-cloud-sdk-go/sdk/requests" "github.com/zhuiyi1997/go-gin-api/app/config" "log" "reflect" ) type Iot struct { RegionId string AccessKey string AccessSecret string Client *sdk.Client } func NewIot() (...
package wps import ( `encoding/json` ) type ( // UploadByLocalFileReq 本地文件上传 UploadLocalFileReq struct { // 文件 File string `json:"file"` } // UploadNetworkFileReq HTTP/HTTPS网络文件上传 UploadNetworkFileReq struct { // 网络文件地址 Url string `json:"url" url:"url"` } // UploadFileRsp 文件上传返回结果 UploadFileRsp str...
// Copyright 2020 MongoDB 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...
// This file was generated for SObject ContentWorkspaceMember, API Version v43.0 at 2018-07-30 03:47:23.111111129 -0400 EDT m=+9.454072311 package sobjects import ( "fmt" "strings" ) type ContentWorkspaceMember struct { BaseSObject ContentWorkspaceId string `force:",omitempty"` ContentWorkspacePermiss...
package transformation import ( "fmt" "time" ) //ModuleBuildTime type definition representing the build time of a Module type ModuleBuildTime struct { ModuleName string BuildTime time.Duration } //ReactorSummary type definition for the parsed Maven reactor summary of a build type ReactorSummary []ModuleBuildTim...
package main import ( "log" "net/http" "strconv" "github.com/vlad-belogrudov/gopl/pkg/lissajous" ) func main() { http.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) { var err error if err = r.ParseForm(); err != nil { log.Println("cannot parse params: ", err) w.WriteHeader(http.StatusBad...
package iavl import ( "github.com/ColorPlatform/color-sdk/codec" ) var cdc = codec.New()
package main import ( "bytes" "fmt" "io/ioutil" //"ms/sun/shared/helper" "os" "path/filepath" "regexp" //"ms/sun/shared/helper" "io" "strconv" "time" ) //const DIR = `E:\WEB\files\file\dl\file\pic\music\2013\06\` /*const DIR = `E:\WEB\files\file\dl\file\pic\photo\` const OUT_LOG = `C:\Go\_gopath\src\ms\sun...
package core import ( "net/http" "bytes" "os" "log" "io/ioutil" ) type DialogFlow struct { query string lang string sessionId string } const endpoint = "https://api.api.ai/v1/query" const envKeyVar = "SINGLE_TANGO_KEY" func (df *DialogFlow) MakeRequest() ([]byte, error) { client := &http.Client{} req, er...
package zigzag_conversion import ( "strings" ) func convert(s string, numRows int) string { if len(s) <= 2 { return s } lines := getLines(s, numRows) columns := len(lines)/2*(numRows-1) + 1 elements := make([][]string, numRows) for i, _ := range elements { elements[i] = make([]string, columns) } for i...
package main import "testing" // TestGenerate tests that we can still generate the list, to catch // if anything changes on Chromium side. func TestGenerate(t *testing.T) { sites, err := get() if err != nil { t.Fatal(err) } // 2019-05-01 list was 69567 domains long. if len(sites) < 50000 { t.Errorf("too few ...
/* Adam West passed away, and I'd like to honor his memory here on PPCG, though I doubt he knew of our existence. While there are many, many different things that this man is known for, none are more prominent than his role as the original batman. I'll always remember my step-father still watching the old-school Batma...
/* --- Day 2: Inventory Management System --- You stop falling through time, catch your breath, and check the screen on the device. "Destination reached. Current Year: 1518. Current Location: North Pole Utility Closet 83N10." You made it! Now, to find those anomalies. Outside the utility closet, you hear footsteps an...
package cluster import ( "fmt" "github.com/pkg/errors" "k8s.io/klog" providerv1 "sigs.k8s.io/cluster-api-provider-openstack/pkg/apis/openstackproviderconfig/v1alpha1" "sigs.k8s.io/cluster-api-provider-openstack/pkg/cloud/openstack" clusterv1 "sigs.k8s.io/cluster-api/pkg/apis/cluster/v1alpha1" client "sigs.k8s....
package p06 func checkPossibility(nums []int) bool { i := 0 j := len(nums) - 1 for i < len(nums)-1 && nums[i] <= nums[i+1] { i++ } if i == len(nums)-1 { return true } for j > 0 && nums[j] >= nums[j-1] { j-- } if i == j-1 { if i == 0 || j == len(nums)-1 { return true } if nums[j] >= nums[i-1] { ...
package mysqldb import ( "context" "time" ) // TransactionNumber 流水号 type TransactionNumber struct { TransactionDate time.Time `gorm:"primary_key"` // 日期 TransactionNumber int // 流水号 CreatedAt time.Time // 创建时间 UpdatedAt time.Time // 更新时间 } // TableName 返回 TransactionNumber 所在的表名 func (...
package pg import ( "github.com/kyleconroy/sqlc/internal/sql/ast" ) type RangeTableFuncCol struct { Colname *string TypeName *TypeName ForOrdinality bool IsNotNull bool Colexpr ast.Node Coldefexpr ast.Node Location int } func (n *RangeTableFuncCol) Pos() int { return n.Location ...
package controllers import ( "github.com/gin-gonic/gin" ) func Initialize(router *gin.Engine){ api := router.Group("/api") { UserController(api) FriendController(api) } }
package engine import ( "errors" "fmt" "io/ioutil" "log" "os" "os/user" "strings" "github.com/debarshibasak/go-kubeadmclient/kubeadmclient" "github.com/debarshibasak/go-kubeadmclient/kubeadmclient/networking" ) type KubeadmEngine struct { Networking Networking `yaml:"networking" json:"net...
package main import ( "fmt" "log" "os" "path" diskfs "github.com/diskfs/go-diskfs" "github.com/diskfs/go-diskfs/disk" "github.com/diskfs/go-diskfs/filesystem" "github.com/diskfs/go-diskfs/partition/mbr" ) func check(err error) { if err != nil { log.Fatal(err) } } func CreateFSAndDir(diskImg string) { i...
/* Copyright (C) 2018 Intel Corporation. SPDX-License-Identifier: Apache-2.0 */ package oimcommon import ( "context" "crypto/tls" "crypto/x509" "io/ioutil" "net" "strings" "time" // "github.com/grpc-ecosystem/go-grpc-middleware" // "github.com/grpc-ecosystem/grpc-opentracing/go/otgrpc" // "github.com/open...
package config import "github.com/spf13/viper" func init() { viper.SetConfigName("visitor") viper.SetConfigType("yaml") viper.AddConfigPath(".") viper.AddConfigPath("..") viper.AddConfigPath("/etc/visitor") if err := viper.ReadInConfig(); err != nil { panic(err) } }
package main import ( "fmt" "log" "os" "time" bolt "github.com/coreos/bbolt" "github.com/labstack/echo" "github.com/labstack/echo/middleware" _ "github.com/joho/godotenv/autoload" ) func createMux() (*bolt.DB, *echo.Echo) { // Setup Bolt dbPath := os.Getenv("DB_PATH") dbFile := fmt.Sprintf("%s/imascg.db"...
// 数组的组合算法,也是对二维数组的应用。 package main import ( "errors" "fmt" ) // pernutate1 和permutate2方法思想类似。permutate2简化一些,但是最后需要转换成实际的组合。 func main() { s := []int{1, 0, -1, 2, -2} if solution1, err := permutate1(s, 4); err == nil { fmt.Println(solution1) fmt.Println(len(solution1)) } if solution2, err := permutate2(s, ...
package git import ( "bytes" "fmt" "os" "os/exec" "path/filepath" "strings" "sync" "github.com/abhinav/git-pr/gateway" "go.uber.org/multierr" ) // Gateway is a git gateway. type Gateway struct { mu sync.RWMutex dir string } var _ gateway.Git = (*Gateway)(nil) // NewGateway builds a new Git gateway. fu...
package rp_kit import ( "time" ) const ( DATETIME_LAYOUT = "2006-01-02 15:04:05" DATE_LAYOUT = "2006-01-02" DATE_LAYOUT_SHORT_CN = "01月02日" DATE_LAYOUT_SHORT_EN = "01-02" TIME_LAYOUT = "15:04:05" TIME_LAYOUT_SHORT = "15:04" ) //获取当前标准格式时间 func GetTimeNow(time2 ...time.Time) string { ...
// Copyright 2020 orivil.com. All rights reserved. // Use of this source code is governed by a MIT-style // license that can be found at https://mit-license.org. package modes import ( "github.com/orivil/morgine/utils/sql" "time" ) type Book struct { ID int PtID int `gorm:"index"` PtBookID int `gorm:"index"` T...
package popcount import ( "testing" ) func bench(b *testing.B, f func(uint64) int) { for i := 0; i < b.N; i++ { f(uint64(i)) } } func BenchmarkTable(b *testing.B) { bench(b, PopCountTable) } func BenchmarkTableLoop(b *testing.B) { bench(b, PopCountTableLoop) } func BenchmarkShiftValue(b *testing.B) { bench...
package helper import ( "log" "net/http" "github.com/PuerkitoBio/goquery" ) // BookScraper is... func Scraper() []string { url := "https://www.penguin.co.uk/articles/2018/100-must-read-classic-books.html" res, err := http.Get(url) if err != nil { log.Fatal(err) } defer res.Body.Close() if res.StatusCod...
package taxjar type Category struct { Name string `json:"name"` ProductTaxCode string `json:"product_tax_code"` Description string `json:"description"` } type CategoryList struct { Categories []Category `json:"categories"` } type categoryListParams struct{} type CategoryService struct { Repository...
/* * EVE Swagger Interface * * An OpenAPI for EVE Online * * OpenAPI spec version: 0.4.1.dev1 * * Generated by: https://github.com/swagger-api/swagger-codegen.git */ package swagger import ( "net/url" "strings" "encoding/json" "fmt" ) type UniverseApi struct { Configuration *Configuration } func NewU...
package main import "fmt" func main() { <<<<<<< HEAD fmt.Println("hey hey hey") ======= fmt.Println("hey") >>>>>>> 940aeb5dcd3c44eddf54018f79a6c1bc55d1eab9 }
// Copyright 2016-2017 The psh Authors. All rights reserved. package psh import ( "bytes" "fmt" ) const ( // SegmentHostnameBackground is the background color to use SegmentHostnameBackground = 238 // #444444 ) // SegmentHostname implements the hostname partial of the prompt. // // It renders the current hostna...
/** * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you...
//go:generate pkger -o cmd/bofhchan package main import ( "github.com/gofiber/fiber" "github.com/gofiber/template/html" "github.com/imdario/BOFHchan/internal/post" "github.com/markbates/pkger" ) var ( mode = "debug" ) func main() { app := fiber.New(&fiber.Settings{ Views: views(), }) post.RegisterURLs(app)...
package camt import ( "encoding/xml" "github.com/thought-machine/finance-messaging/iso20022" ) type Document02900101 struct { XMLName xml.Name `xml:"urn:iso:std:iso:20022:tech:xsd:camt.029.001.01 Document"` Message *ResolutionOfInvestigation `xml:"camt.029.001.01"` } func (d *Document02900101)...
package protocol_test import ( "encoding/hex" "strings" "testing" "time" // Frameworks "github.com/djthorpe/gopi" "github.com/djthorpe/sensors" // Modules _ "github.com/djthorpe/gopi/sys/logger" _ "github.com/djthorpe/sensors/protocol/ook" ) func Test_OOK_000(t *testing.T) { // Create an OOK module if a...
package main import ( "context" "fmt" "github.com/PacktPublishing/Go-Programming-Cookbook-Second-Edition/chapter7/grpc/greeter" "google.golang.org/grpc" ) func main() { conn, err := grpc.Dial(":4444", grpc.WithInsecure()) if err != nil { panic(err) } defer conn.Close() client := greeter.NewGreeterService...
package analyzer import ( "search-engine/chapter7/analysis" "search-engine/chapter7/analysis/token" "search-engine/chapter7/analysis/tokenizer" ) // 定义简单分析器 = 不分词 + N-Gram func SimpleAnalyzer() (*analysis.Analyzer, error) { analyzer := &analysis.Analyzer{ Tokenizer: tokenizer.NewSingleTokenTokenizer(), TokenF...
/* =============What is Unsafe code?================================ unsafe code is th code in go program that bypasses safety and security of yur program.mostly it is related to pointers.using it is dangerous for your program. ============= */ package main import ( "fmt" "unsafe" ) // func main() { // var valu...
package accesscontrol import ( "net/http" "testing" "encoding/base64" "github.com/danielsomerfield/authful/server/service/oauth" ) var validClientId = "valid-client-id" var validClientSecret = "valid-client-secret" var invalidClientSecret = "invalid-client-secret" type MockClient struct { } func (MockClient) Ch...
package chart import ( "io/ioutil" "os" "path" "testing" "github.com/bitnami-labs/charts-syncer/api" "github.com/bitnami-labs/charts-syncer/pkg/repo" "github.com/bitnami-labs/charts-syncer/pkg/utils" ) var ( source = &api.SourceRepo{ Repo: &api.Repo{ Url: "https://charts.bitnami.com/bitnami", Kind: ...
package sqlx import ( "testing" "fmt" "github.com/ellsol/gox/testx" ) func TestStatementBuilder(t *testing.T) { stb, params := NewSelectStatement("*", "tablename"). AddEqualCondition("label", 45). AddInCondition("inlabel", []string{"p1", "p2"}). AddEqualCondition("label2", 88). AddOffset(1200). AddLimi...
/***************************************************************** * Copyright©,2020-2022, email: 279197148@qq.com * Version: 1.0.0 * @Author: yangtxiang * @Date: 2020-07-30 17:11 * Description: *****************************************************************/ package xthrift import ( "fmt" "github.com/apache/thri...
package repository type ThroughRepository interface { Get() []string }
// デフォルトで標準入力のSHA256ハッシュを表示するプログラムを書きなさい。 // ただし、SHA384ハッシュやSHA512ハッシュを表示するコマンドラインのフラグもサポートしなさい。 package main import ( "crypto/sha256" "crypto/sha512" "flag" "fmt" "io/ioutil" "log" "os" ) var width = flag.Int("w", 256, "hash width (256, 384 or 512)") func main() { flag.Parse() b, err := ioutil.ReadAll(os...
package models import ( "github.com/evil-router/isfired/database" uuid2 "github.com/satori/go.uuid" "log" "golang.org/x/net/idna" ) type comment struct { Name string Reason string Time string Location string Status bool } type site struct { ID string Name string Site string } func GetSite(...
// GoFigure is a small utility library for reading configuration files. It's usefuly especially if you want // to load many files recursively (think /etc/apache2/mods-enabled/*.conf). // // It can support multiple formats, as long as you take a file and unmarshal it into a struct containing // your configurations. Righ...
package main // This is an example of using go-iapclient for a purpose that is not usage by // a golang http.Client. It uses GetToken() to retrieve the token, then inserts // it into a curl commandline // Example usage: // go run iapwrap.go --client-id $CLIENT_ID -- -v -k https://$HOST import ( "context" "fmt" "lo...
/* Copyright 2019 The Kubernetes 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, ...
package dynamic_programming func numDecodings(s string) int { if len(s) == 0 { return 0 } dp := make([]int, len(s)+1) dp[0] = 1 for i := 1; i <= len(s); i++ { if s[i-1] > '0' { dp[i] = dp[i-1] } if i > 1 && s[i-2:i] >= "10" && s[i-2:i] <= "26" { dp[i] += dp[i-2] } } return dp[len(s)] }
package WeightedRandomChoice import ( "math/rand" "sort" "time" ) type WeightedRandomChoice struct { Elements [] string Weights [] int TotalWeight int calibratedWeights bool precision int calibrateValue int } func (wrc *WeightedRandomChoice) AddElement(element string, wei...
package schema import ( "errors" "fmt" "io/ioutil" "os" "path/filepath" gojsonschema "github.com/xeipuuv/gojsonschema" ) //map of resources : schemaLoader var Schemas = make(map[string]gojsonschema.JSONLoader) func init() { loadAllSchemas() } // Read /schemas directory contents, and create schemaLoader for ...
package sns import ( "fmt" "github.com/aws/aws-sdk-go/aws" "github.com/aws/aws-sdk-go/aws/session" "github.com/aws/aws-sdk-go/service/sns" "github.com/aws/aws-sdk-go/service/sns/snsiface" "github.com/pkg/errors" "github.com/utilitywarehouse/go-pubsub" ) type messageSink struct { client snsiface.SNSAPI topic ...
package sploit import ( "bytes" "debug/elf" "encoding/binary" "errors" "io/ioutil" "os" ) // ELF is a struct that contains methods for operating on an ELF file type ELF struct { E *elf.File Processor *Processor PIE bool Mitigations *Mitigations raw []byte } // NewELF loads an E...
package day9 import ( "testing" "github.com/achakravarty/30daysofgo/assert" ) type testCase struct { num int expected int } var testCases = []testCase{ testCase{num: 3, expected: 6}, } func TestRecursion(t *testing.T) { for _, testInput := range testCases { actual := GetFactorial(testInput.num) asse...
package main import ( "fmt" ) type User struct { Id string `json:"id"` Name string `json:"name"` Balance int `json:"balance"` } func main() { //user := User{"Baby", 12} //user1 := user //user1.Name = "Val" //inc(&user) //fmt.Println(user) //fmt.Println(GetUser().Balance) //str := ` {"name":"Ali...
package main import ( "bufio" "crypto/tls" "flag" "math/rand" "net" "net/http" "net/url" "os" "strings" "sync" "sync/atomic" "syscall" "time" "github.com/gorilla/websocket" "github.com/sirupsen/logrus" ) const ( RULE_MAX = 500000 TCP_QUICK_ACK = 1 TCP_NO_DELAY = 2 ) var outTimeLess1Cnt uint3...
package mavlink2 /* Generated using mavgen - https://github.com/ArduPilot/pymavlink/ Copyright 2020 queue-b <https://github.com/queue-b> Permission is hereby granted, free of charge, to any person obtaining a copy of the generated software (the "Generated Software"), to deal in the Generated Software without restric...
package strings import ( "strings" "testing" ) func TestIndex(t *testing.T) { t.Parallel() type args struct { str string strPart string } tests := []struct { name string args args want int }{ {"Mass 1", args{"Cod3r é show", "Cod3r"}, 0}, {"Mass 2", args{"", ""}, 0}, {"Mass 3", args{"Opa", "...
package main import ( "os" "github.com/infra-whizz/wzsd" "github.com/isbm/go-nanoconf" "github.com/urfave/cli/v2" ) func run(ctx *cli.Context) error { stateDaemon := wzsd.NewWzStateDaemon() stateDaemon.Run().AppLoop() conf := nanoconf.NewConfig(ctx.String("config")) stateDaemon.GetTransport().AddNatsServerU...
package main import "fmt" type Test interface { } type Stu struct { Name string } func main() { var stu Stu var t Test = stu fmt.Println(t) var t2 interface{} = stu fmt.Println(t2) var num = 888 t2 = num fmt.Println(t2) }
package main import ( "flag" "fmt" "os" "path/filepath" "strings" "github.com/pkg/errors" "github.com/syncromatics/go-kit/database" "k8s.io/client-go/rest" "k8s.io/client-go/tools/clientcmd" ) type settings struct { KubernetesConfig *rest.Config DatabaseSettings *database.PostgresDatabaseSettings ShouldS...
package stack // stackOverflowError ... type stackOverflowError struct{} // Error ... func (s *stackOverflowError) Error() string { return "Error: stack overflow!" }
package cmd import ( "fmt" "log" "os" "path" "github.com/ncw/rclone/fs" "github.com/spf13/cobra" ) // Version is rhttpserve's current version number. const Version = "v0.0.1" var ( // Verbose tracks whether a verbose flag was passed into the command line. Verbose bool // version tracks whether a version f...
package log import ( "fmt" "log" ) type Entity struct { message string Data interface{} Err interface{} } func Newf(format string, args ...interface{}) *Entity { e := &Entity{} e.message = fmt.Sprintf(format, args...) return e } func New(args ...interface{}) *Entity { e := &Entity{} e.message = fmt...
package game import ( "fmt" "testing" "time" ) func TestCreateCard(t *testing.T) { var cards []int var n1 = 9 for i := 0; i < 10; i++ { time.Sleep(time.Millisecond*100) result := createCard(cards, n1) v := result[3]%13 + 1 + result[4]%13 + 1 if v != n1 { t.Error("错误") return } var tResult []i...
package main import ( "crypto/tls" "crypto/x509" "fmt" "io/ioutil" "log" "net/http" "strings" ) func main() { roots := x509.NewCertPool() pem, err := ioutil.ReadFile("./conf/server.pem") if err != nil { log.Printf("read crt file error:%v\n", err) } ok := roots.AppendCertsFromPEM(pem) if !ok { panic("...
package test import ( db "bareksa-test/database" md "bareksa-test/model" r "bareksa-test/repository" st "bareksa-test/struck" "context" "github.com/stretchr/testify/suite" ) type NewsRepositorySuite struct { suite.Suite newsRepository md.NewsRepository } func (suite *NewsRepositorySuite) SetupSuite() { rep...
package worker import ( "context" "fmt" "github.com/rs/zerolog" "github.com/tomarrell/lbadd/internal/executor" ) // Worker is a database worker node. // // w := worker.New(log, exec) // err := w.Connect(ctx, ":34213") type Worker struct { log zerolog.Logger exec executor.Executor } // New creates a new wor...
// +build gotask package gotasks import ( "archive/zip" "encoding/xml" "fmt" "io" "log" "net/http" "os" "path" "path/filepath" "regexp" "strings" "text/template" "github.com/huin/goutil/codegen" "github.com/jingweno/gotask/tasking" "gx/ipfs/QmVwfv63beSAAirq3tiLY6fkNqvjThLnCofL7363YkaScy/goupnp" "gx/i...
package watcher import ( "context" "encoding/json" "fmt" "io/ioutil" "net/http" api "nighthawkapi/api/core" "nighthawkapi/api/handlers/config" "github.com/gorilla/mux" elastic "gopkg.in/olivere/elastic.v5" yaml "gopkg.in/yaml.v2" ) func GetWatcherResults(w http.ResponseWriter, r *http.Request) { r.Header...
package chars import ( "bytes" "fmt" "testing" "github.com/lioneagle/goutil/src/test" ) func TestUnescape(t *testing.T) { testdata := []struct { escaped string unescaped string }{ {"a%42c", "aBc"}, {"a%3B", "a;"}, {"a%3b%42", "a;B"}, {"ac%3", "ac%3"}, {"ac%P3", "ac%P3"}, {"ac%", "ac%"}, } ...
package jsonv const ( // messages for bad destination types ERROR_BAD_INT_DEST = "Cannot assign integer to variable of type %v, path %v" ERROR_BAD_FLOAT_DEST = "Cannot assign float to variable of type %v, path %v" ERROR_BAD_STRING_DEST = "Cannot assign string to variable of type %v, path %v" ERROR_BA...
package model import "github.com/jschweizer78/fusion-ng/pkg/service/model/question" // User of the application type User struct { Email string `json:"email" storm:"id"` Customers map[string]*UserCustomer `json:"customers"` } // UserQuestion meta data type UserQuestion struct { Email *que...
package utils /*Contains ...*/ func Contains(source []string, item string) bool { for _, v := range source { if v == item { return true } } return false } /*RemoveFirst ...*/ func RemoveFirst(source []string, item string) (bool, []string) { found, index := FindIndex(source, item) if !found { return fals...
package setr import ( "encoding/xml" "github.com/thought-machine/finance-messaging/iso20022" ) type Document00600102 struct { XMLName xml.Name `xml:"urn:iso:std:iso:20022:tech:xsd:setr.006.001.02 Document"` Message *RedemptionMultipleOrderConfirmationV02 `xml:"setr.006.001.02"` } ...
/* WARNING This piece of code will attempt to break the CXE liveagent go routine server and the meralco main chatbot server. Please use this code with CAUTION. */ package main import ( "bytes" "encoding/base64" "encoding/json" "fmt" "io/ioutil" "log" "math/rand" "net/http" "os" "strconv" "sync" "time" ...
package manager import ( "github.com/rancher/longhorn-manager/types" "time" ) type event struct{} func TimeEvent() types.Event { return &event{} } type Ticker interface { Start() Ticker Stop() Ticker NewTick() types.Event } type tickerImpl struct { ch chan types.Event interval time.Duration timer ...