text
stringlengths
11
4.05M
package day2 import ( "reflect" "testing" ) func Test_calculate(t *testing.T) { tests := []struct { name string in []int out []int }{ {"In: 1,0,0,0,99", []int{1, 0, 0, 0, 99}, []int{2, 0, 0, 0, 99}}, {"In: 2,3,0,3,99", []int{2, 3, 0, 3, 99}, []int{2, 3, 0, 6, 99}}, {"In: 2,4,4,5,99,0", []int{2, 4, ...
// Copyright 2017 // Author: catlittlechen@gmail.com package nexus import ( "errors" ) var ( // RootIndex the index of root RootIndex = 0 ) var ( // ErrConfFormat the format of configuration is wrong ErrConfFormat = errors.New("wrong conf format") // ErrConf bad configuration ErrConf = errors.New("wrong conf...
package argo import "testing" /* -------- */ /* Flags. */ /* -------- */ func TestFlagEmpty(t *testing.T) { parser := NewParser() parser.NewFlag("bool") parser.ParseArgs([]string{}) if parser.Found("bool") != false { t.Fail() } if parser.Count("bool") != 0 { t.Fail() } } func TestFlagMissing(t *testing...
package numtoword import "testing" func TestKuConverter(t *testing.T) { samples := []struct { in uint out string }{ {0, "zero"}, {1, "one"}, {6, "six"}, {9, "nine"}, {15, "fifteen"}, {25, "twenty and five"}, {22, "twenty and two"}, {40, "forty"}, {36, "thirty and six"}, {71, "seventy and o...
package benchmark import ( "sync" "benchmark/connection" "benchmark/report" "benchmark/suite" "time" "fmt" "os" "strings" ) type BenchmarkOptions struct { Connection connection.Connector Reporter report.Reporter Keepalive bool Clients int Requests uint64 Flush bool } func Run(tests map[string]suite.Run...
package usecases import ( "fmt" "os" "path/filepath" "time" "github.com/GomuGomuMan/go-cleanup/internal/config" ) const ( defaultTTL = -time.Hour * 24 * 30 ) type Directory struct { Path config.Path `json:"path"` TTL config.Duration `json:"ttl,omitempty"` } func (d Directory) Clean() error { var base...
package models type Order struct { Data string `bson:"data"` Items []Item `bson:"items"` }
// Copyright 2020 The Amadeus 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 agre...
package common import ( "encoding/json" "fmt" "os" ) type sidebarMenu struct { Sidebar *[]sidebarTitle `json:"sidebar,omitempty"` } type sidebarTitle struct { Title string `json:"title,omitempty"` Items *[]sidebarItems `json:"items,omitempty"` } type sidebarItems struct { Label string `json...
package main import ( "bufio" "os" "path/filepath" "strconv" "strings" ) var ( filename string = "gophermap" ) // Gophermap parses the given file 'fn' and returns a proper gopher list of items func Gophermap(fn string) List { var l List f, err := os.Open(fn) defer f.Close() if err != nil { return Error(...
package main import ( "github.com/edaniels/golinters/fatal" "golang.org/x/tools/go/analysis/singlechecker" ) func main() { singlechecker.Main(fatal.Analyzer) }
package Problem0375 import ( "fmt" "testing" "github.com/stretchr/testify/assert" ) // tcs is testcase slice var tcs = []struct { n int ans int }{ {12, 21}, {5, 6}, {1, 0}, {2, 1}, {3, 2}, {5, 6}, {6, 8}, {7, 10}, {8, 12}, {9, 14}, {10, 16}, {12, 21}, {20, 49}, {100, 400}, {300, 1640}, // ๅฏไปฅ...
package lecimg import ( "image" "image/color" "image/draw" "github.com/mitchellh/mapstructure" ) // ---------------------------------------------------------------------------- // ---------------------------------------------------------------------------- type WatermarkOption struct { Text string Locatio...
package basics import ( "github.com/google/go-cmp/cmp" "github.com/spf13/pflag" "net" "testing" ) //go:generate ../../configuration --parseTests --out basics.gen_test.go Basics type Basics struct { // address:port to listen on Listen string FileCount int Files []string Things map[string]string `config:"-"` ...
package pgsql import ( "testing" ) func TestJSONArray(t *testing.T) { B := func(s string) []byte { return []byte(s) } testlist2{{ valuer: JSONArrayFromByteSliceSlice, scanner: JSONArrayToByteSliceSlice, data: []testdata{ {input: [][]byte(nil), output: [][]byte(nil)}, {input: [][]byte{}, output: [][]b...
package main type J interface { Method() } type ( U16 uint16 U32 uint32 U64 uint64 U128 [2]uint64 F32 float32 F64 float64 C128 complex128 S string B []byte M map[int]int C chan int Z struct{} ) func (U16) Method() {} func (U32) Method() {} func (U64) Method()...
package main import "fmt" func imprimirResultado(nota float64) { // O bloco sempre รฉ representado com chaves ainda que seja apenas uma instruรงรฃo if nota >= 7 { fmt.Println("Aprovado") } else { fmt.Println("Reprovado") } } func main() { imprimirResultado(5.6) imprimirResultado(9.5) }
package main import ( "github.com/kyokomi/emoji/v2" ) func main() { // :face: not support emoji.Println("Hello, world, :smile: ") }
package factories import ( "github.com/barrydev/api-3h-shop/src/common/connect" "github.com/barrydev/api-3h-shop/src/connections" "github.com/barrydev/api-3h-shop/src/model" ) func FindCategory(query *connect.QueryMySQL) ([]*model.Category, error) { connection := connections.Mysql.GetConnection() queryString :=...
package extensions import ( "encoding/json" "io/ioutil" "log" "sort" ) //ะ“ะตะฝะตั€ะธั‚ ัะฟะธัะพะบ ะบะพั‚ะพั€ั‹ะน ั€ะฐะทั€ะตัˆะฐะตั‚ ัะบะฐะฝะธั€ะพะฒะฐะฝะธะต ะฒัะตั… //ั‚ะธะฟะพะฒ ั„ะฐะนะปะพะฒ func GetDefaultAllowList()[]Extension{ var exts = make([]Extension,len(IncludeExtension)) for i := 0; i < len(IncludeExtension);i++{ exts[i].Ext = IncludeExtension[i] ...
package osutils import ( "os" "github.com/hacdias/fileutils" ) func MoveFile(src, dst string) error { err := os.Rename(src, dst) if err != nil { err = fileutils.CopyFile(src, dst) if err != nil { return err } err = os.Remove(src) if err != nil { _ = os.Remove(dst) return err } } return n...
package services import ( "context" "errors" "fmt" "log" "github.com/go-ldap/ldap/v3" "github.com/mrzack99s/mrz-identity-management/ent" "github.com/mrzack99s/mrz-identity-management/ent/groupbandwidth" "github.com/mrzack99s/mrz-identity-management/ent/groups" ) func CreateGroup(data ent.Groups) (res *ent.Gr...
package main import ( "crypto/rand" "fmt" ) func random() int { var b [1]byte rand.Read(b[:]) return int(b[0])%3 + 1 } func rem(p []int, x int) []int { r := []int{} for _, y := range p { if x == y { continue } r = append(r, y) } return r } func sel(p []int, x int, swap bool) int { if !swap { re...
package ntp import ( "testing" "time" "github.com/stretchr/testify/assert" "github.com/authelia/authelia/v4/internal/utils" ) func TestNtpIsOffsetTooLarge(t *testing.T) { maxOffset, _ := utils.ParseDurationString("1s") assert.True(t, ntpIsOffsetTooLarge(maxOffset, time.Now(), time.Now().Add(time.Second*2))) ...
// Copyright 2021 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 data import ( "os" "strings" "bufio" "strconv" "math/rand" "log" ) type Point struct { Id string Features []float32 Weight float32 } type Dataset struct { Rows int VecLen int Points []*Point Index map[string]int } func NewDatasetWithHeader(filename string, idField string, colField string) (*Dat...
// nolint package types import ( sdk "github.com/irisnet/irishub/types" ) var ( ActionRequestRand = []byte("request_rand") TagAction = sdk.TagAction TagReqID = "request-id" TagRandHeight = "rand-height" TagRand = "rand" )
package cli import ( "fmt" "github.com/ColorPlatform/color-sdk/client/context" "github.com/ColorPlatform/color-sdk/codec" sdk "github.com/ColorPlatform/color-sdk/types" "github.com/ColorPlatform/color-sdk/x/mint" "github.com/spf13/cobra" ) // GetCmdQueryParams implements a command to return the current minting...
package constants const ( ContentType = "Content-Type" ContentTypeDefault = "Application/json; charset=UTF-8" )
package oauth2state import ( "testing" ) func TestCryptoValueGenerator_String(t *testing.T) { generator := CryptoValueGenerator{} got1 := generator.String() if len(got1) == 0 { t.Error(`CryptoValueGenerator.String() returned empty string`) } got2 := generator.String() if len(got2) == 0 { t.Error(`CryptoVa...
package dynamic import( "testing" ) func TestGetStepNum(t *testing.T){ n := 10 t.Log(GetStepNum(n)) } func TestGetStepNumWithClosure(t *testing.T){ n := 10 t.Log(GetStepNumWithClosure(n)) }
/* (C) Copyright 2019 Joe Ellsworth MIT LICENSE */ // Package stringutil contains utility functions for working with strings. // Include this package using: // import "github.com/joeatbayes/GOPackaging/sample_library" // Download the package with import // go get -u "github.com/joeatbayes/GoPackaging/sample_...
package sploit import ( "bytes" "testing" ) func TestPackUint64LE(t *testing.T) { if bytes.Compare(PackUint64LE(0xf00bdeadbeeff00b), []byte{0x0b, 0xf0, 0xef, 0xbe, 0xad, 0xde, 0x0b, 0xf0}) != 0 { t.Fatal("Return bytes != expected") } } func TestPackUint32LE(t *testing.T) { if bytes.Compare(PackUint32LE(0xf00b...
package definitions import ( "context" "github.com/itsmeadi/cart/src/entities/models" ) type Cart interface { UpdateCart(ctx context.Context, userId, productId, qty int64) error AddToCart(ctx context.Context, userId, productId, qty int64) error GetCart(ctx context.Context, userId int64) (models.CartDetail, error...
// Copyright 2019-present 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 agr...
package main import ( "bufio" "flag" "fmt" "net" "os" "strings" "sync" ) type Domain struct { name string spf_records []string dmarc_records []string } func get_spf(domain string) []string { potential_spf, _ := net.LookupTXT(domain) var spf_records []string for _, record := range potential_sp...
package users import ( "crypto/hmac" "crypto/rand" "crypto/sha256" "encoding/base64" "time" ) // FIXME something ? var secret = []byte("This is the password secret key !") type User struct { ID string `json:"id"` DisplayName string `json:"displayName"` Login string `...
package kube import ( "reflect" "testing" sfv1alpha1 "github.com/openshift/splunk-forwarder-operator/api/v1alpha1" "github.com/openshift/splunk-forwarder-operator/config" corev1 "k8s.io/api/core/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" ) func TestGetVolumeMounts(t *testing.T) { type args struct { i...
package home import ( "html/template" "log" "net/http" . "reunion/announcement" . "reunion/configuration" ) type HomePage struct { name, Title, Description, Image, Link string Announcements []Announcement } func GetPage(writer http.ResponseWriter, request *http.Request) { tmpl := temp...
/**********************************************************\ | | | hprose | | | | Official WebSite: http://www.hprose.com/ | | ...
package main import ( "github.com/improbable-eng/grpc-web/go/grpcweb" "golang.org/x/net/context" "google.golang.org/grpc" "log" "golang.org/x/net/http2" "net/http" ) type chatService struct { } func (s *chatService) Join(c context.Context, r *JoinRequest) (*JoinResponse, error) { log.Printf("join: %s", r.Get...
package main import ( "database/sql" "encoding/json" "fmt" "log" "net/http" "strconv" "strings" _ "github.com/go-sql-driver/mysql" ) type User struct { ID int `"json:id"` Name string `"json: name"` } func UserHandler(w http.ResponseWriter, r *http.Request) { sid := strings.TrimPrefix(r.URL.Path, "/u...
package component import ( "github.com/sherifabdlnaby/prism/pkg/config" "go.uber.org/zap" ) // Base defines the basic prism component. type Base interface { // Init Initializes Base's configuration Init(config.Config, zap.SugaredLogger) error // start starts the component Start() error // Stop shutdown down ...
/* * @lc app=leetcode.cn id=1619 lang=golang * * [1619] ๅˆ ้™คๆŸไบ›ๅ…ƒ็ด ๅŽ็š„ๆ•ฐ็ป„ๅ‡ๅ€ผ */ // @lc code=start package main import ( "sort" ) type intList []int func (s intList) Len() int { return len(s) } func (s intList) Swap(i, j int) { s[i], s[j] = s[j], s[i] } func (s intList) Less(i, j int) bool { return s[i] < s[j] } fu...
package child import ( "log" hooks "github.com/setecrs/wekan-hooks/hooks" ) func Creation(act string, cardId string, ops hooks.Operations) error { if act != hooks.ActCreateCard { return nil } card, err := ops.FindCard(cardId) if err != nil { return err } if card.ParentID == "" { return nil } log.Prin...
package youtube import ( "errors" "net/url" "os" "strings" "time" "gopkg.in/mgo.v2/bson" "github.com/johnwyles/vrddt-reboot/pkg/util" ) // TODO (IMPORTANT): Finish var ( // KnownYoutubeDomains are all of the known Youtube Domains prefixed with a "." so // that we do not process any requests for domains wh...
/* Below is a (schematic) Digital timing diagram, for the XNOR logic gate. โ”Œโ”€โ” โ”Œโ”€โ” โ”Œโ”€โ”€โ”€โ”€โ”€โ” โ”Œโ”€โ” โ”Œโ”€โ” โ”Œโ”€โ”€โ”€โ” A โ”€โ”€โ”˜ โ””โ”€โ”˜ โ””โ”€โ”˜ โ””โ”€โ”˜ โ””โ”€โ”˜ โ””โ”€โ”˜ โ””โ”€โ”€ โ”Œโ”€โ”€โ”€โ” โ”Œโ”€โ”€โ”€โ” โ”Œโ”€โ” โ”Œโ”€โ”€โ”€โ”€โ”€โ” โ”Œโ”€โ” โ”Œโ”€โ” B โ”˜ โ””โ”€โ”˜ โ””โ”€โ”˜ โ””โ”€โ”˜ โ””โ”€โ”€โ”€โ”˜ โ””โ”€โ”˜ โ”” โ”Œโ”€โ”€โ”€โ”€โ”€โ” โ”Œโ”€โ” โ”Œโ”€โ” โ”Œโ”€โ”€โ”€โ” X โ”€โ”€โ”˜ โ””โ”€โ”€โ”€โ”˜ โ””โ”€โ”€โ”€โ”˜ โ””โ”€โ”€โ”€โ”˜ โ””โ”€โ”€โ”€โ”€ Your goal is to reproduce it exac...
package connect import ( "testing" ) func Test_insertMysql(t *testing.T) { mysqlUrl := "mysql://b08738ff9fff5e:e79a1d81@us-cdbr-iron-east-01.cleardb.net/heroku_e16926abf051efd?reconnect=true" db := MysqlDB{} db.New(mysqlUrl) connection := db.GetConnection() stmt, err := connection.Prepare("INSERT `users` SE...
package services import ( "github.com/gin-gonic/gin" "net/http" "fmt" ) func WrongPostData(c *gin.Context) { c.JSON(http.StatusBadRequest, gin.H{ "ok": false, "message": "Wrong post data", }) c.Abort() } func WrongUrlParams(c *gin.Context) { c.JSON(http.StatusBadRequest, gin.H{ "ok": false, "message":...
package config import ( "errors" "github.com/askovpen/goated/pkg/types" "gopkg.in/yaml.v2" "io/ioutil" "os" "runtime" "strings" ) type configS struct { Username string AreaFile struct { Path string Type string } Areas []struct { Name string Path string Type string BaseType string ...
package main import ( "github.com/shurcooL/vfsgen" "log" "net/http" ) func main() { err := vfsgen.Generate(http.Dir("test/locale"), vfsgen.Options{ PackageName: "generator", VariableName: "Locale", Filename: "test/bundle/locale_bundle_build.go", }) if err != nil { log.Fatalln(err) } }
package main import ( "os" "fmt" "flag" "strings" "math/big" "crypto/rand" "github.com/atotto/clipboard" ) var ( length, charsLength int useUpper, useLow, useSpecial, useNumbers, outToClipboard bool ) const ( charsLow = "abcdefghijklmnopqrstuvwxyz" charsUpper = "ABCDEFGHIJKLMNOPQRSTUVWXYZ" charsSpecial =...
package main import ( log "github.com/sirupsen/logrus" "os" "github.com/dispatchlabs/disgo_commons/types" ) func main() { // Setup log. formatter := &log.TextFormatter{ FullTimestamp: true, ForceColors: false, } log.SetFormatter(formatter) log.SetOutput(os.Stdout) log.SetLevel(log.InfoLevel) address...
package main import ( "flag" "github.com/bborbe/log" "github.com/bborbe/www/server_configuration" ) var logger = log.DefaultLogger const DEFAULT_PORT int = 8002 const DEFAULT_ROOT string = "." func main() { portnumberPtr := flag.Int("port", DEFAULT_PORT, "int") documentRootPtr := flag.String("root", DEFAULT_R...
/* 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 not use this fi...
package main const ( PORT = "8080" ) func main() { r := registerRoutes() r.Run(":" + PORT) }
package models import ( "encoding/json" "io/ioutil" "testing" ) func BenchmarkCreateModQueueListing(b *testing.B) { data, _ := ioutil.ReadFile("./tests/modqueue.json") modQueueListingExampleJson := string(data) for i := 0; i < b.N; i++ { sub := ModQueueListing{} json.Unmarshal([]byte(modQueueListingExampleJ...
package repository import ( "RelationshipMatch/model" log "github.com/Sirupsen/logrus" "github.com/go-pg/pg" ) const ( CreateUserSQL = `insert into users (id,name,type) values (?,?,?)` UserIsExistSQL = `select * from users where id=?` ) func IsUserExist(pg *pg.DB, user_id string) (bool, error) { var u model....
/* # -*- coding: utf-8 -*- # @Author : joker # @Time : 2021/6/17 9:13 ไธŠๅˆ # @File : lt_ไบŒ่ฟ›ๅˆถ_0ๅˆฐnumber็š„1่ฎก็ฎ—.go # @Description : # @Attention : */ package v2 func countBits(n int) []int { r := make([]int, 0) count(n,&r) // for i := 0; i <= n; i++ { // count(i, &r) // } return r } func count(n int, r *[]int) { if n =...
package jwt import ( "encoding/base64" "encoding/json" "fmt" "io/ioutil" "strings" "k8s.io/client-go/rest" "github.com/argoproj/argo/server/auth/jws" ) func ClaimSetFor(restConfig *rest.Config) (*jws.ClaimSet, error) { username := restConfig.Username if username != "" { return &jws.ClaimSet{Sub: username...
package main import ( "fmt" "os" "github.com/therecipe/qt/core" "github.com/therecipe/qt/quick" "github.com/therecipe/qt/widgets" ) type QmlBridge struct { core.QObject //from golang to qml's onAddItem _ func(title string, author string, famous bool) `signal:"addItem"` //from golang to qm...
package main import ( "encoding/json" "errors" "fmt" "io/ioutil" "log" "net/http" "net/url" "strings" ) func handleMsg(msg *Message, logger *log.Logger) (bool, *Message) { //getMedia from weixin resource if strings.EqualFold(msg.ToType, TERMINAL_ADMIN) { if strings.EqualFold(msg.Source, MSG_SOURCE_WX) { ...
package id import ( "github.com/emersion/go-imap" ) // An ID command. // See RFC 2971 section 3.1. type Command struct { ID ID } func (cmd *Command) Command() *imap.Command { return &imap.Command{ Name: commandName, Arguments: []interface{}{formatID(cmd.ID)}, } } func (cmd *Command) Parse(fields []inte...
package csvutil import ( "encoding/csv" "io" "regexp" "strings" "github.com/gocarina/gocsv" "golang.org/x/text/encoding/charmap" ) var replaceNewlineSemicolon = strings.NewReplacer("\n;", ";") var regexRemoveBrackets = regexp.MustCompile(`[\s]*\([^\)]*\)`) // NewSemicolonReader is a stdlib CSV reader, but wit...
package cliutil import ( "context" "encoding/json" kjson "github.com/koinos/koinos-proto-golang/encoding/json" "github.com/koinos/koinos-proto-golang/koinos/contract_meta_store" "github.com/koinos/koinos-proto-golang/koinos/contracts/token" "github.com/koinos/koinos-proto-golang/koinos/protocol" "github.com/ko...
package main import ( "encoding/xml" "fmt" "io/ioutil" "os" "strconv" "strings" ) // //type SConfig struct { // XMLName xml.Name `xml:"config"` // ๆŒ‡ๅฎšๆœ€ๅค–ๅฑ‚็š„ๆ ‡็ญพไธบconfig // SmtpServer string `xml:"smtpServer"` // ่ฏปๅ–smtpServer้…็ฝฎ้กน๏ผŒๅนถๅฐ†็ป“ๆžœไฟๅญ˜ๅˆฐSmtpServerๅ˜้‡ไธญ // SmtpPort int `xml:"smtpPort"` // Sende...
package main import ( "context" "fmt" "github.com/stretchr/testify/assert" "github.com/testcontainers/testcontainers-go" "io" "log" "net/http" "os" "sync" "testing" "time" "github.com/testcontainers/testcontainers-go/wait" ) var mu = sync.Mutex{} var counterOutput int var counterTotal = 5 func TestFlu...
// srvcl_test project main.go package main import ( "log" "strconv" "time" ) const ( //ideally these shall be read as parameters buffer_size = 32 //buffer size working_day = 3 //max # clients max_requests = 3 //max # requests per client waiting_time = time.Minute port = ":2704" network = "tc...
package hill_test import ( "testing" "github.com/mkamadeus/cipher/cipher/hill" ) func TestEncrypt(t *testing.T) { cipher := "ABCDEF" key := "bcef" encrypted, err := hill.Encrypt(cipher, key) expected := "CFIXOP" if err != nil { t.Fatalf("error on hill encryption: %v", err) } else if encrypted != expected ...
// Copyright 2017 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 dlinkclient import ( "github.com/iikira/BaiduPCS-Go/baidupcs/pcserror" "github.com/json-iterator/go" "io" ) func handleJSONParse(op string, data io.Reader, info interface{}) (dlinkError pcserror.Error) { var ( d = jsoniter.NewDecoder(data) err = d.Decode(info) errInfo = info.(pcserror.Erro...
package main import ( "fmt" "log" "github.com/shanghuiyang/rpi-devices/dev" "github.com/stianeikeland/go-rpio" ) const ( p12 = 26 // led ) func main() { if err := rpio.Open(); err != nil { log.Fatalf("failed to open rpio, error: %v", err) return } defer rpio.Close() led := dev.NewLed(p12) var op str...
package osbuild2 // The commits to fetch indexed their checksum type OSTreeSource struct { Items map[string]OSTreeSourceItem `json:"items"` } func (OSTreeSource) isSource() {} type OSTreeSourceItem struct { Remote OSTreeRemote `json:"remote"` } type OSTreeRemote struct { // URL of the repository. URL string `js...
package lsof import ( "github.com/stretchr/testify/assert" "os" "testing" ) func TestGetUserPids(t *testing.T) { // Check that this pid is found as part of the user's pids pid := os.Getpid() result, err := getUserPids() if err != nil { t.Fatal(err) } assertionResult := false for _, v := range result { i...
package config import ( "fmt" "io/ioutil" "os" "strings" "gopkg.in/yaml.v2" ) type Config struct { Imap struct { Server string Username string Password string } GitHub struct { Username string } CIRobot struct { Enabled bool } MergeRobot struct { Enabled bool } RobotCommands struct { En...
package partner import ( "fmt" "github.com/APTrust/exchange/util/fileutil" "os/user" "path/filepath" ) var Version string = "2.1" var ConfigHelp string = ` Your config file should include the following name-value pairs, separated by an equal sign. The file may also include comment lines, which begin with a hash ...
// Copyright 2015 The Chromium 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 archiver import ( "bytes" "fmt" "io/ioutil" "log" "net/http/httptest" "os" "path/filepath" "testing" "github.com/luci/luci-go/client/in...
/* Given a boolean expression with the following symbols. Symbols 'T' ---> true 'F' ---> false And following operators filled between symbols Operators & ---> boolean AND | ---> boolean OR ^ ---> boolean XOR Count the number of ways we can parenthesize the expression so that the value of ...
package htlc import ( "encoding/hex" "testing" "github.com/irisnet/irishub/app/v1/auth" "github.com/irisnet/irishub/app/v1/bank" "github.com/irisnet/irishub/codec" "github.com/irisnet/irishub/store" sdk "github.com/irisnet/irishub/types" "github.com/stretchr/testify/require" abci "github.com/tendermint/tende...
package rp_kit import "github.com/tricobbler/rp-kit/cast" //ๆŸฅ่ฏขๅ€ผๆ˜ฏๅฆๅœจๅˆ‡็‰‡ๅญ˜ๅœจ func InSlice(value interface{}, list interface{}) bool { slice, err := cast.ToSliceE(list) if err != nil { panic(err) } for k := range slice { if slice[k] == value { return true } } return false }
package goee // ๅฎšไน‰็‰ˆๆœฌๅท const VERSION string = "v0.1.2"
package randutil import ( "regexp" "testing" ) func TestGenerateRandomString(t *testing.T) { forbiddenCharsRegex := regexp.MustCompile("[^a-zA-Z0-9]") for i := 0; i < 10000; i++ { randString, err := GenerateRandomString(1) if err != nil { t.Error("Unexpected Error Occurred: " + err.Error()) t.Fail()...
package metric import ( "os" "path" ) // ่Žทๅ–ๆŒ‡ๅฎš่ทฏๅพ„(ๆ–‡ไปถๆˆ–็›ฎๅฝ•)็š„็ฃ็›˜็ฉบ้—ดไฝฟ็”จๆƒ…ๅ†ต func TotalSize(filepath string) (tsize int64, err error) { var stat os.FileInfo stat, err = os.Lstat(filepath) if err != nil { return } tsize += stat.Size() if !stat.IsDir() { return } fp, err := os.Open(filepath) if err != nil { return...
package database import ( "io/ioutil" "log" ) // Parse parses dictd configuration file format in a tree. As it is not used at the moment, // it is useless. But it will be used as a boilerplate for further // development. func Parse(text string) []*ListNode { t := NewTree() t.Lex = Lex(text) t.Root = t.NewLis...
package stringsupport import ( "bytes" "io/ioutil" "golang.org/x/text/encoding" "golang.org/x/text/encoding/japanese" "golang.org/x/text/transform" ) // StringConverter is a small helper for encoding/decoding strings. type StringConverter struct { Encoding encoding.Encoding } // Decode decodes the given bytes...
package server import ( "fmt" "log" "net" "net/http" "time" "github.com/gorilla/handlers" "github.com/harnash/watcher/logging" "github.com/rs/xaccess" "github.com/rs/xhandler" "github.com/rs/xlog" "github.com/rs/xmux" "github.com/rs/xstats" "github.com/rs/xstats/telegraf" "golang.org/x/net/context" ) /...
package localutils import ( "fmt" ) // Render ๆ‰“ๅฐๆ‰€ๆœ‰็ฑปๅž‹ๅฎžไพ‹ func Render(instance interface{}, nested ...int) { // ็ฑปๅž‹่ฝฌๆข if b, result := instance.(bool); result { fmt.Printf("bool: %v", b) } else if s, result := instance.(string); result { fmt.Printf("string: '%v'", s) } else if i, result := instance.(int); result ...
// Copyright 2019 John Papandriopoulos. All rights reserved. // Use of this source code is governed by a MIT-style // license that can be found in the LICENSE file. package zydis // ElementType is an enum of processor element types. type ElementType int // ElementType enum values const ( ElementTypeInvalid Element...
package controllers import ( "github.com/devplayg/ipas-mcs/models" "github.com/devplayg/ipas-mcs/objs" log "github.com/sirupsen/logrus" "strconv" "strings" "time" ) type EventReportController struct { baseController } func (c *EventReportController) CtrlPrepare() { // ๊ถŒํ•œ ๋ถ€์—ฌ c.grant(objs.User) } func (c *Ev...
package plain import ( "sync" "github.com/toms1441/urlsh/internal/repo" "github.com/toms1441/urlsh/internal/shortener" ) // This package is a mock that implements all repositories. // It's meant to be used in tests mainly. type shortenerRepository struct { mtx sync.Mutex db map[string]shortener.Model } func ...
/* Copyright SecureKey Technologies Inc. All Rights Reserved. SPDX-License-Identifier: Apache-2.0 */ package csl import ( "encoding/json" "errors" "fmt" "strconv" "strings" "github.com/hyperledger/aries-framework-go/pkg/doc/verifiable" "github.com/trustbloc/edge-core/pkg/storage" vccrypto "github.com/trust...
package task // ๅฐฑ็ปช๏ผŒๅ‡†ๅค‡ๅˆ†ๅ‘ const READY_TO_DISPATCH = "d" // ๅฐฑ็ปช๏ผŒๅ‡†ๅค‡ๆ‰ง่กŒ const READY_TO_EXECUTE = "e" const CLOSE = "c" /*type boss chan string type data chan interface{} type dispatch func(d data) error*/
package two_sums import ( "reflect" "testing" ) type testStruct struct { values []int target int result []int } var tests = []testStruct{ {[]int{2, 7, 11, 15}, 9, []int{1, 1}}, {[]int{4, 8, 0, 7, 2, 5}, 7, []int{2, 3}}, {[]int{1, 4, 6, 7, 10, 47, 4, 6, 7, 10, 47, 4, 6, 7, 10, 47, 4, 6, 7, 10, 47, 4, 6, 7, 10...
package sample import "fmt" func init() { fmt.Println(111) }
package backend import ( "forum/pkg/res" "net/http" "github.com/gin-gonic/gin" ) func Hello(c *gin.Context) { c.JSON(http.StatusOK, res.JsonSuccess()) }
// Copyright 2022 PingCAP, Inc. Licensed under Apache-2.0. package stream_test import ( "context" "testing" backuppb "github.com/pingcap/kvproto/pkg/brpb" "github.com/pingcap/tidb/br/pkg/storage" "github.com/pingcap/tidb/br/pkg/stream" "github.com/pingcap/tidb/br/pkg/streamhelper" "github.com/stretchr/testify...
package handler import ( "fmt" log "github.com/sirupsen/logrus" "github.com/wneessen/sotbot/api" "github.com/wneessen/sotbot/user" "net/http" ) // Just a test handler func GetSotSeasonProgress(h *http.Client, u *user.User) (string, error) { l := log.WithFields(log.Fields{ "action": "handler.GetSotSeasonProgre...
package digicert import "encoding/json" // NewOrganizationRequest represents that creating new organization in CertCentral. type NewOrganizationRequest struct { Address string `json:"address"` Address2 string `json:"address2"` AssumedName string `json:"assumed_name"` City string `json:"city"` // Co...
package main import ( // "syscall/js" // "syscall/js" "encoding/json" "strconv" "strings" "sync" "syscall/js" "github.com/wangbin/jiebago" ) var x jiebago.Segmenter func init() { x.LoadDictionary("777.txt") } func cut(this js.Value, args []js.Value) interface{} { resultChan := x.Cut(args[0].String(), ...
package main import ( "time" ) const ( Delimiter = " โ”‚ " Unknown = "?" UpdatePeriod = 5 * time.Second ) var Items = []statusFunc{ netStatus("wlp3s0", "enp0s25"), batteryStatus("BAT0", "BAT1"), alsaAudioStatus("-M"), // defaults to non-padding and 12-hour time timeStatus("1/2/2006", "3:04"), }