text
stringlengths
11
4.05M
package htm import "strings" /////////////////////////////////////////////////////////////////////////// // Panel structure. type Panel struct { widget *Widget // Pointer to widget for rendering html id string header string footer Renderer fields []Renderer class []string params map[string]string t...
package scrabble import "strings" // GetScore function using case to set value for each letter func GetScore(r rune) int { switch r { case 'A', 'E', 'I', 'L', 'N', 'O', 'R', 'S', 'T', 'U': return 1 case 'D', 'G': return 2 case 'B', 'M', 'C', 'P': return 3 case 'F', 'H', 'V', 'W', 'Y': return 4 case 'K':...
package web import ( "encoding/json" "fmt" "io" "log" "net/http" // "errors" core "pro/core" "github.com/gorilla/mux" ) // w.Write([]byte("Gorilla!\n")) // type Jsondata struct { // Voter string `json:"voter"` // Candidate string `json:"candidate"` // } type ResponseToVoter struct { Status in...
package run import floc "gopkg.in/workanator/go-floc.v1" /* IfOrElse runs jobTrue if the condition is met or runs jobFalse otherwise. Summary: - Run jobs in goroutines : NO - Wait all jobs finish : YES - Run order : SEQUENCE Diagram: +----->[JOB_TRUE]---+ ...
package runtime import ( "fmt" "time" ) const ( Run = "run" Block = "Block" ) type GoRoutine struct { ID string // goroutine的唯一ID status string // 当前状态,运行和阻塞 data map[*GoChan]interface{} // 数据map } func NewGoroutine(id string) *GoRoutine { fmt.Printf("[Goroutine] ID...
// Copyright 2015 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 ( "github.com/aws/aws-lambda-go/lambda" "github.com/ryomak/ouin-line-bot/line-bot/src/handler" ) func main() { // Make the handler available for Remote Procedure Call by AWS Lambda lambda.Start(handler.LineHandler) }
package main import ( "reflect" "testing" . "github.com/onsi/ginkgo" . "github.com/onsi/gomega" ) func TestDateCalculator(t *testing.T) { DateCalculator() } func TestInputDate(t *testing.T) { input := Date{ 31, 12, 2017, } result := inputDate(input) Describe("Comparing Two Dates Structs", func() { ...
package main import ( "errors" "fmt" "os" "os/signal" "syscall" "github.com/Duroktar/trabWatcher/watcher" "github.com/logrusorgru/aurora" ) func handleCtrlC(c chan os.Signal, w *watcher.Watcher) { sig := <-c if sig != os.Interrupt { return } fmt.Println(aurora.Green("\rSignal: "), sig) fmt.Println(auro...
package crons import ( "context" "errors" "fmt" "log" "math" "math/big" "strings" "github.com/constant-money/constant-event/config" "github.com/constant-money/constant-event/daos" "github.com/constant-money/constant-event/ethereum" "github.com/constant-money/constant-event/services" helpers "github.com/co...
package engine import ( "net" "sync" "testing" ) // fakeBlocker implements the BlockCloser interface. type fakeBlocker struct { blockCalled chan bool } // Block will track whether it has been called, returning a nil error always. func (fb *fakeBlocker) Block(_ *net.IP) error { fb.blockCalled <- true return nil...
package main import "fmt" func main() { fmt.Println(jump22([]int{ 2, 3, 1, 1, 4, })) } func jump(nums []int) int { //max := func(a, b int) int { // if a > b { // return a // } // return b //} n := len(nums) maxPos := 0 step := 0 for i := 0; i < n-1; i++ { if d := i + nums[i]; d > maxPos { maxP...
package catm import ( "encoding/xml" "github.com/thought-machine/finance-messaging/iso20022" ) type Document00100105 struct { XMLName xml.Name `xml:"urn:iso:std:iso:20022:tech:xsd:catm.001.001.05 Document"` Message *StatusReportV05 `xml:"StsRpt"` } func (d *Document00100105) AddMessage() *StatusReportV0...
package customer_test import ( "testing" . "github.com/dogmatiq/dogmatest/assert" "github.com/koden-km/dogma-app-setup/internal/testrunner" "github.com/koden-km/dogma-app-setup/messages/commands" "github.com/koden-km/dogma-app-setup/messages/events" ) func TestCustomer_Signup(t *testing.T) { t.Run( "it signs...
package main import "fmt" func main() { // closure adalah kemampuan sebuah function berinteraksi dengan data-data disekitarnya dalam scope yang sama // scope variabel adalah lingkup kerja sebuah variabel name := "danil" counter := 0 increment := func() { fmt.Println("Increment") name := "udin" ...
package aliyun import ( "encoding/json" "fmt" "github.com/aliyun/alibaba-cloud-sdk-go/services/ecs" "github.com/aliyun/alibaba-cloud-sdk-go/services/slb" "github.com/sirupsen/logrus" ) func (p *Aliyun) CreateVServerGroup() (err error) { balancersConfig := p.Config.GetConfig("aliyun.slb.balancer") if balancer...
package main import ( "fmt" ) func main() { cities := []string{ "Santa Monica", "Jakarta", "Bandung", } fmt.Println(len(cities)) countries := make([]string, 42) fmt.Printf("%q\n", cities) fmt.Printf("%q\n", countries) fmt.Println(len(countries)) }
package main import ( "fmt" "math" ) func main() { no := 1087.0 res := sqrt(no) fmt.Println(res) fmt.Println("Difference: ", makePositive(res-math.Sqrt(no))) } func makePositive(x float64) float64 { if x >= 0 { return x } return (x * -1) } //Get square root using newton's method zn+1 = (zn - (((zn^2)-x)...
package main import ( "fmt" "html/template" "net/http" ) type User struct { Name string `json:"name"` Gender string `json:"gender"` Age int `json:"age"` } func f1(w http.ResponseWriter, r *http.Request) { //2解析模板 t, err := template.ParseFiles("./t.tmpl", "./ul.tmpl") if err != nil { fmt.Printf("Pa...
package main import ( "os" "strings" "sync" "github.com/uber-go/zap" ) var writeLock sync.Mutex // writeToFile writes string content to file func writeToFile(filename, content string) { writeLock.Lock() defer writeLock.Unlock() logger.Info("Writing to", zap.String("filename", filename), zap.String("content"...
package main import ( "fmt" ) func main() { var multi [9][9]string for j := 0; j < 9; j++ { for i := 0; i < 9; i++ { n1 := i + 1 n2 := j + 1 multi[i][j] = fmt.Sprintf("%dx%d=%d", n2, n1, n1 * n2) // fmt.Println(multi[i][j]) //依2迴圈規則印出 } } for _, v1 := range multi { // fmt.Println(v1)...
package pgeo import ( "database/sql/driver" ) // NullPath allows path to be null type NullPath struct { Path Valid bool `json:"valid"` } // Value for database func (p NullPath) Value() (driver.Value, error) { if !p.Valid { return nil, nil } return valuePath(p.Path) } // Scan from sql query func (p *NullPat...
package config import ( "reflect" "github.com/pkg/errors" "github.com/yamil-rivera/flowit/internal/utils" ) func versionValidator(version interface{}) error { switch version := version.(type) { case *string: var supportedVersions = []string{"0.1"} if found := utils.FindStringInArray(*version, supportedVersi...
package main import ( "fmt" "net/http" "sync" ) func waitGroup() { var wg sync.WaitGroup url := []string{ "https://blog.golang.org/context", "https://google.co.uk", } wg.Add(len(url)) for _, u := range url { go func(u string) { defer wg.Done() res, _ := http.Get(u) if res.StatusCode == http.Sta...
package main import "fmt" func main() { var i byte for { fmt.Printf("%v string", i) i++ } }
package main import ( "context" "fmt" "os" "net/http" "github.com/gorilla/websocket" "google.golang.org/grpc" r5 "./r5" // protoc -I ../protos/ --go_out=plugins=grpc:./r5 r5.proto ) const GRPC_R5_URL = "localhost:50001" const indexHtml = ` <html> <head> <title>WebRTC-RTP Forwarder Sample - Video Sender</title...
package cacheutil import ( "fmt" "net" "net/http" "sync" "time" ) //Updater ... type Updater struct { client *http.Client keyStorage *KeyStorage port int } //NewUpdater ... func NewUpdater(port int, transportTimeout int, dialerTimeout int) *Updater { return &Updater{ client: &http.Client{ Tim...
package api import ( "bufio" "bytes" "context" "encoding/json" "fmt" "io/ioutil" "log" "net/http" "net/http/httptest" "os" "testing" "time" "github.com/dollarshaveclub/acyl/pkg/nitro/metahelm" "github.com/dollarshaveclub/acyl/pkg/spawner" "github.com/google/uuid" "github.com/gorilla/mux" "github.com/...
package main import "fmt" import "io/ioutil" import "strings" import "sort" func main() { fData, err := ioutil.ReadFile("names.txt") // read in the external file if err != nil { fmt.Println("Err is ", err) // print any error } strbuffer := string(fData) // convert read in file to a string names := strings.Spl...
package main import ( "fmt" "testing" ) func TestSubsets(t *testing.T) { } func TestSubsets_bit(t *testing.T) { fmt.Println(subsets_bit([]int{1, 2, 3})) } func TestMask(t *testing.T) { //i := 7 //for mask := 0 ; mask < 7 ; mask ++ { // if mask >> i & 1 > 0 { // // } //} //110 mask := 6 mover := 0 f...
package mcchat type color string func (c color) Color() color { return c } type Colorer interface { Color() color } const ( Black color = "§0" DarkBlue color = "§1" DarkGreen color = "§2" DarkAqua color = "§3" DarkRed color = "§4" DarkPurple color = "§5" Gold color = "§6" Gray col...
package decoder import ( "context" "fmt" "io" "net/http" "time" ) type Devices struct { Desk Device } type Device struct { Address string Client http.Client context.Context context.CancelFunc } type Command interface { Request() *http.Request } func (d *Device) Run() { for { if err := d.Connect(); ...
package openid import ( "fmt" "net/http" "testing" ) // Data used for negative tests of GetIdTokenAuthorizationHeader. var badHeaders = []struct { header string // The wrong header. errorCode ValidationErrorCode // The expected error code. httpStatus int // The expected http st...
package main import ( "crypto/aes" "crypto/cipher" "crypto/sha256" "flag" "fmt" "io/ioutil" "log" "os" "github.com/howeyc/gopass" "github.com/starius/encio" ) func NewAEAD(key []byte) (cipher.AEAD, error) { h := sha256.Sum256(key) block, err := aes.NewCipher(h[:]) if err != nil { return nil, fmt.Error...
package nests import ( "encoding/json" "fmt" "io/ioutil" "time" "github.com/freignat91/mlearning/network" ) // GraphicData . type GraphicData struct { Foods []*Food `json:"foods"` Nests []*NestData `json:"nests"` } //GlobalInfo . type GlobalInfo struct { Xmin float64 `json:"xmin"` Xma...
package main import "testing" func Test1(t *testing.T) { infix := "a.b" postfix := in2post(infix) expect := "ab." if postfix != expect { t.Errorf("Expect %s match %s", postfix, expect) } } func Test2(t *testing.T) { infix := "a|b" postfix := in2post(infix) expect := "ab|" if postfix != expect { t.Errorf...
package main import ( "fmt" "math/rand" ) func main() { // define slice fmt.Println("define slices") var numbers[]int numbers = make([]int, 5) matrix := make([][]int, 3*3) // insert data fmt.Println(">>>>>>>>>>insert slice data") for i := 0;i < 5;i++ { numbers[i] = rand.Intn(100) } // ...
/* Go Language Raspberry Pi Interface (c) Copyright David Thorpe 2018 All Rights Reserved Documentation http://djthorpe.github.io/gopi/ For Licensing and Usage information, please see LICENSE.md */ package openthings import ( "encoding/binary" "encoding/hex" "fmt" "math/rand" "strings" "time" // Fram...
package romanToInt func romanToInt(s string) int { m := map[byte]int{'I': 1, 'V': 5, 'X': 10, 'L': 50, 'C': 100, 'D': 500, 'M': 1000} num := 0 for index := 0; index < len(s); { if index != len(s)-1 { switch s[index] { case 'I': if s[index+1] == 'V' { num += 4 index += 2 continue } els...
package publisher import ( "strconv" "time" "github.com/streadway/amqp" "github.com/vdntruong/rabbitmq/util" ) func Topic(ch *amqp.Channel, stop chan bool) { err := ch.ExchangeDeclare( "logs", // name "fanout", // type true, // durable false, // auto-deleted false, // internal false, ...
package searcher import ( "fmt" "github.com/emicklei/go-restful" . "grm-searcher/dbcentral/pg" . "grm-searcher/types" "grm-service/dbcentral/pg" "grm-service/log" "grm-service/util" ) var ( volUnit = map[string]string{"K": "KB", "M": "MB", "G": "GB", "T": "TB"} META_INDEX = "datameta" ) //用于数据分发时,对传入的数据,按照...
package integration_test import ( "encoding/xml" "io/ioutil" "net/http/httptest" "os" "testing" "time" "github.com/microsoft/azure-databricks-operator/mockapi/middleware" "github.com/microsoft/azure-databricks-operator/mockapi/model" "github.com/microsoft/azure-databricks-operator/mockapi/router" "github.co...
// 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...
package k8s import ( "fmt" "os" "path/filepath" "time" "github.com/sirupsen/logrus" "k8s.io/cli-runtime/pkg/printers" ) type ObjectWriter struct { writeDir string } func (w ObjectWriter) Write(result SearchResult) (string, error) { // namespaced on group and version to avoid overwrites grp := func() string...
// Package adb is a simple wrapper around calling adb. package adb import ( "bytes" "context" "fmt" "testing" "github.com/stretchr/testify/assert" "go.skia.org/infra/go/exec" "go.skia.org/infra/go/testutils/unittest" ) // adbMockHappy returns a context that mocks out a response when calling exec.Run(). func a...
package templates import ( th "html/template" "io" tt "text/template" ) // Templates is the struct which holds all the *template.Template values. type Templates struct { notification NotificationTemplates asset AssetTemplates oidc OpenIDConnectTemplates } type OpenIDConnectTemplates struct { fo...
package context import ( "errors" "sync" ) // RuleCtx 存储解析出来的规则 type RuleCtx struct { ruleLock sync.Mutex rules map[string]interface{} } func NewRuleCtx() *RuleCtx { return &RuleCtx{ rules: make(map[string]interface{}), } } func (r *RuleCtx) AddRule(key string, method interface{}) { r.ruleLock.Lock() r...
package main import( "fmt" "net/http" ) func setCookie(w http.ResponseWriter, r *http.Request) { c := http.Cookie{ Name: "username", Value: "Eric", HttpOnly: true, } http.SetCookie(w, &c) fmt.Fprintln(w, "Set Cookie Success") } func getCookie(w http.ResponseWr...
package handlers import ( "log" "regexp" "strings" "gopher-translator/pkg/translation" "gopher-translator/pkg/models" "encoding/json" "gopher-translator/pkg/storage" "net/http" ) // TranstatorHandler Handles translate routes type TranstatorHandler interface { Welcome() http.HandlerFunc TranslateWord() http....
package main type JobDTO struct { CityName string JobDescription string Title string Link string Today bool Lat float64 Lng float64 }
package main import ( "log" "strings" "github.com/PuerkitoBio/goquery" ) const PRICE_SELECTOR = "p.product-price" const WASNOW_SELECTOR = "p.was-now-price" func GetPriceForForever21(url string) (price float64) { doc, err := goquery.NewDocument(url) if err != nil { log.Fatal(err) } var hasWasNowPrice bool ...
package main import ( "fmt" "io/ioutil" "math" "os" "path/filepath" "strings" "./cfg" "./fontconfig" "./helper" "github.com/lxn/walk" . "github.com/lxn/walk/declarative" ) type Reader interface { Read(p []byte) (n int, err error) } type MyMainWindow struct { *walk.MainWindow prevFilePath string AppPa...
package render_test import ( "strings" . "github.com/onsi/ginkgo" . "github.com/onsi/gomega" "github.com/werf/werf/integration/pkg/utils" ) var _ = Describe("helm render with extra annotations and labels", func() { BeforeEach(func() { SuiteData.CommitProjectWorktree(SuiteData.ProjectName, utils.FixturePath("...
package scope import ( "sort" "strings" ) const ( OpenID = "openid" Email = "email" OfflineAccess = "offline_access" ) func Split(scope string) []string { return strings.Split(scope, " ") } func IncludeAll(scopes string, targetScopes []string) (bool, string) { list := Split(scopes) existanceM...
package main import ( "bufio" "fmt" "os" "github.com/achakravarty/30daysofgo/day13" ) func main() { var price int reader := bufio.NewReader(os.Stdin) title, _ := reader.ReadString('\n') author, _ := reader.ReadString('\n') fmt.Scanf("%d\n", &price) book := day13.MyBook{}.NewMyBook(title, author, price) fm...
package db import ( "encoding/binary" "os" "github.com/spf13/viper" ) // Store is a store type Store struct { Path string } // GetStore gets a store func GetStore() *Store { return &Store{ Path: viper.GetString("db"), } } // fileExists checks if a file exists and is not a directory before we // try using i...
// Copyright 2019 Radiation Detection and Imaging (RDI), LLC // Use of this source code is governed by the BSD 3-clause // license that can be found in the LICENSE file. package ingress import ( "context" "io" "github.com/go-redis/redis" ) // PubSubWriter is an io.Writer that publishes to a redis PubSub channel ...
package constant const ( SMALL = "small" MEDIUM = "medium" LARGE = "large" XLARGE = "xlarge" XXLARGE = "2xlarge" XXXXLARGE = "4xlarge" SINGLE = "SINGLE" MULTIPLE = "MULTIPLE" ) type VmConfig struct { ID int `json:"id"` Cpu int `json:"cpu"` Memory int `json:"memory"` Disk int `...
package bindings // CreateOrganization is the API payload representation when creating a new Organization type CreateConversation struct { Title string `json:"title" binding:"required"` Purpose string `json:"purpose" binding:"required"` }
package iobuffer const ( SIZE_1_K int = 1024 SIZE_10_K int = 10240 SIZE_20_K int = 20480 SIZE_64_K int = 65536 SIZE_1_M int = 1048576 MAX_WRITE_BUFF int = 65535 ) type InBuffer struct { Buff []byte maxSize int defaultSize int } func NewInBuffer(defaultCap, maxCap int) *...
package xlsx import ( "github.com/plandem/xlsx/format" "github.com/plandem/xlsx/options" "github.com/stretchr/testify/require" "testing" ) func TestRow(t *testing.T) { xl, err := Open("./test_files/example_simple.xlsx") if err != nil { panic(err) } defer xl.Close() sheet := xl.Sheet(0) r := sheet.Row(5) ...
package mails import ( "net/mail" "net/smtp" ) func ValidEmail(email string) bool { _, err := mail.ParseAddress(email) return err == nil } type smtpServer struct { host string port string } // Address URI to smtp server func (s *smtpServer) Address() string { return s.host + ":" + s.port } func SendMail(fro...
package controllers import ( "fmt" "github.com/gin-gonic/gin" "github.com/go-playground/validator" "github.com/hunterhug/fafacms/core/config" "github.com/hunterhug/fafacms/core/flog" "github.com/hunterhug/fafacms/core/model" "github.com/hunterhug/fafacms/core/util" "github.com/hunterhug/fafacms/core/util/mail"...
package utils // import ( // "bytes" // "image/jpeg" // "io" // "io/ioutil" // "github.com/nfnt/resize" // ) // // 调整JPEG图片大小 // // 宽 高 // // inerp算法:NearestNeighbor Bilinear MitchellNetravali Lanczos2 Lanczos3 (0-4) // func ImgResizeJPEG(width, height uint, r io.Reader, // interp int, w io.Writer) (err error)...
package usecase import ( "fmt" "io/ioutil" "net/http" "net/url" "regexp" "strconv" "strings" "time" entity "silverfish/silverfish/entity" "github.com/PuerkitoBio/goquery" "github.com/pkg/errors" "github.com/robertkrimen/otto" "github.com/sirupsen/logrus" ) // FetcherMangabz export type FetcherMangabz s...
package rpmmdtests import ( "path/filepath" "reflect" "testing" "github.com/osbuild/osbuild-composer/internal/distro/test_distro" "github.com/osbuild/osbuild-composer/internal/rpmmd" "github.com/stretchr/testify/assert" ) func getConfPaths(t *testing.T) []string { confPaths := []string{ "./confpaths/priorit...
package tickets import ( "encoding/json" "log" "net/http" // Mongo DB "gopkg.in/mgo.v2" "gopkg.in/mgo.v2/bson" ) type Pricing struct { ID int `json:"id"` // Adult ticket price AdultPrice float32 `json:"adultprice"` // Child ticket price ChildPrice float32 `json:"childprice"` // Concession ticket price C...
package fileutil import "testing" func TestExperiment(t *testing.T) { }
package dice import ( "crypto/rand" "fmt" "log" "math/big" ) type die struct { faces []int } func (d die) side(f int) int { return d.faces[f] } func NewDie(s int) (d die) { d = die{} d.faces = make([]int, s) for s > 0 { d.faces[s-1] = s s-- } return } func (d die) Roll() (r int) { roll, err := getR...
package main import ( "log" "net" "./spellcheck" "golang.org/x/net/context" "google.golang.org/grpc" ) const port = ":50051" type server struct{} func (s *server) StemWord(ctx context.Context, req *spellcheck.StemRequest) (*spellcheck.WordListReply, error) { return &spellcheck.WordListReply{WordList: spellch...
package semt import ( "encoding/xml" "github.com/thought-machine/finance-messaging/iso20022" ) type Document00100102 struct { XMLName xml.Name `xml:"urn:iso:std:iso:20022:tech:xsd:semt.001.001.02 Document"` Message *SecuritiesMessageRejectionV02 `xml:"SctiesMsgRjctnV02"` } func (d *Documen...
package newprinter import "fmt" // Closures type Printer func(string) () func PrintNoLine (s string) { fmt.Print(s) } func PrintLine (s string) { fmt.Println(s) } func CustomPrintLine (custom string) Printer { return func (s string) { fmt.Println(s + " " + custom) } } func Print(message st...
package alliance import ( "fmt" "log" "math/rand" "strconv" "testing" "github.com/stretchr/testify/require" "github.com/golang/protobuf/proto" "github.com/hyperledger/fabric/core/chaincode/shim" pb "github.com/hyperledger/fabric/protos/peer" "github.com/stefanprisca/strategy-code/tfc" tfcPb "github.com/s...
package auth import ( "os" "path" "testing" jwt "github.com/dgrijalva/jwt-go" "github.com/stretchr/testify/assert" ) var ( testPrivateKey = []byte("very_sekrit_key") testToken = "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.e30.AqFWnFeY9B8jj7-l3z0a9iaZdwIca7xhUF3fuaJjU90" testInertiaKeyPath = path.Join(...
// Copyright 2015-2018 trivago N.V. // // 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 main import ( "log" "os" "regexp" "strings" "github.com/coreos/go-iptables/iptables" "github.com/nxadm/tail" ) func getIp(str string) string { re1 := regexp.MustCompile(`rhost=([^ ]*)[ ]`) result := re1.FindStringSubmatch(str) if len(result) != 0 { return result[1] } re2 := regexp.MustCompile(`...
package gcp import ( "context" "github.com/pkg/errors" computev1 "google.golang.org/api/compute/v1" "google.golang.org/api/option" gcpconfig "github.com/openshift/installer/pkg/asset/installconfig/gcp" ) // MachineTypeGetter returns the machine type info for a type in a zone using GCP API. type MachineTypeGett...
//go:build linux // +build linux // package main produces stubs for the nerdctl subcommands (and their // options); this is expected to be overridden for options that involve paths. // All options generated this will have their values ignored. package main import ( "flag" "fmt" "io" "os" "os/exec" "runtime" "r...
// Copyright 2023 Google LLC. 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 applica...
package main import ("SNOW-3G/Functions") func main(){ key := [4]uint32{0x00000000, 0x00000000, 0x00000000, 0x80000000} IV := [4]uint32{0x00000001, 0x00000002, 0x00000003, 0x00000004} Functions.Init(key,IV) for i:=0; i<(1024*1024*1024)/4; i++{ Functions.Next() } }
// DRUNKWATER TEMPLATE(add description and prototypes) // Question Title and Description on leetcode.com // Function Declaration and Function Prototypes on leetcode.com //140. Word Break II //Given a non-empty string s and a dictionary wordDict containing a list of non-empty words, add spaces in s to construct a senten...
//region Usings import "github.com/ravendb/ravendb-go-client" //endregion //region Demo //region Step_1 type Company struct { ID string Name string `json:"name,omitempty"` Phone string `json:"phone,omitempty"` Contact *Contact `json:"contact"` } //endregion //region Step_2 type Employ...
// +build linux package random import ( "errors" "fmt" "io/ioutil" "runtime" ) var ( ENoUUID = errors.New("Unable read uuid") ENoUUIDKernel = errors.New("Unable read uuid from kernel") ) func NewRandomUUID() string { s1 := NewRandomString(ModeHexLower, 8) s2 := NewRandomString(ModeHexLower, 4) s3 := ...
package powervs import ( "fmt" ) // Since there is no API to query these, we have to hard-code them here. // Region describes resources associated with a region in Power VS. // We're using a few items from the IBM Cloud VPC offering. The region names // for VPC are different so another function of this is to correl...
package ora2uml import ( "os" "text/template" ) const ( TemplPlantUML string = `@startuml sample !define Table(name,desc) class name as " + "\"desc\"" + @" << (T,#FFAAAA) >> !define primary_key(x) <b>x</b> !define unique(x) <color:green>x</color> !define not_null(x) <u>x</u> hide methods hide stereotypes ' T...
package storage import ( "context" "errors" "fmt" "github.com/hashicorp/go-hclog" ) // CacheableStorage is a wrapper storage used for providing a write-through cache. // This allows any storage type to be used on top, however, in-memory storage types are recommended to reduce latency. // Size and implementation ...
package db import ( "github.com/jinzhu/gorm" _ "github.com/jinzhu/gorm/dialects/mysql" "github.com/jlb0906/micro-movie/basic/config" "github.com/micro/go-micro/v2/logger" ) type db struct { Mysql mysqlConf `json:"mysql"` } // Mysql 配置 type mysqlConf struct { URL string `json:"url"` Enable bool `json:"ena...
/** * Definition for a binary tree node. * type TreeNode struct { * Val int * Left *TreeNode * Right *TreeNode * } */ package isBalanced type TreeNode struct { Val int Left *TreeNode Right *TreeNode } func isSymmetric(root *TreeNode) bool { return root == nil || checkChildIsSymmetric(root.L...
package service import ( "context" "testing" "github.com/gdotgordon/fibsrv/store" ) // Testing computing fibonacci values using a mock hash store. // This allows us to focus on the business logic of the service. func TestFib(t *testing.T) { ctx := context.Background() store := store.NewMap() svc, err := NewFib...
package main import "fmt" func displayStartup() { fmt.Println("Starting up...") }
package main import ( "fmt" "os" "github.com/weibocom/steem-rpc/client" "github.com/weibocom/steem-rpc/transports/websocket" ) func main() { tran, err := websocket.NewTransport([]string{"ws://52.80.76.2:8090"}) if err != nil { fmt.Println("failed to new transport:%s", err.Error()) os.Exit(-1) } defer tra...
package main import ( "fmt" "os" "strconv" ) func main() { numOfIterations, err := strconv.Atoi(os.Args[1]) if(err != nil) { fmt.Println("Error Converting Argument") } ch := make(chan float64) go countPositives(numOfIterations, ch) go countNegatives(numOfIterations, ch) ...
/* Copyright 2011 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 to in writing, software di...
package model // Authentication is the data structure used when "POST /check" handler's response type Authentication struct { Token string `json:"token"` IsValid bool `json:"isValid"` Platform string `json:"platform"` Admin bool `json:"admin"` } // LoginInformation respresents the data structure which is need...
package main import ( "bot/generator" "flag" "fmt" "github.com/thoj/go-ircevent" "log" "os" "strings" "time" ) const prefixlen = 2 // len of a prefix for the markov chain const cmdprefix = ":" // prefix of irc bot command const maxlinelen = 200 // max number of words in one line func asyncHandler(b *bot,...
// Copyright 2015 Walter Schulze // // 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 study import ( "bufio" "bytes" "fmt" "github.com/goquery" "golang.org/x/net/html" "io" "io/ioutil" "log" "net/http" url2 "net/url" "os" "path" "strings" "time" ) var htmlDocLinks []string //大数字加逗号 func comma(s string) string { var buf bytes.Buffer slen := len(s) for i := 1; i <= slen; i++ { ...
// DRUNKWATER TEMPLATE(add description and prototypes) // Question Title and Description on leetcode.com // Function Declaration and Function Prototypes on leetcode.com //115. Distinct Subsequences //Given a string S and a string T, count the number of distinct subsequences of S which equals T. //A subsequence of a str...
// Copyright (c) 2020, The Emergent Authors. All rights reserved. // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. // main for GUI interaction with Env for testing package main import ( "github.com/emer/etable/etview" _ "github.com/emer/etable/etview" // includ...
// Copyright (c) 2020 Xiaozhe Yao & AICAMP.CO.,LTD // // This software is released under the MIT License. // https://opensource.org/licenses/MIT package utilities import ( "io/ioutil" "net/http" "os" "time" ) var logger = NewDefaultLogger() // ReadFileContent returns the content of filename func ReadFileContent...