text
stringlengths
11
4.05M
package consecutivestrings import ( "strings" ) // Solution to: https://www.codewars.com/kata/56a5d994ac971f1ac500003e func BetterSolution(strarr []string, k int) string { // Own implementation of better solutions on codewars longest := "" for i := 0; i < len(strarr)-k+1; i++ { concat := strings.Join(strarr[i...
package mdtable import ( "bytes" "flag" "io/ioutil" "os" "path/filepath" "testing" "github.com/stretchr/testify/require" ) //go:generate go test . -write-golden func TestMain(m *testing.M) { var err error var writeGolden bool flag.BoolVar(&writeGolden, "write-golden", false, "write golden files") flag.Pa...
package fetch import ( "encoding/json" "net/http" "net/http/httptest" "testing" "github.com/gorilla/mux" "github.com/slotix/dataflowkit/storage" "github.com/spf13/viper" "github.com/stretchr/testify/assert" ) var st storage.Store func init() { viper.Set("SPLASH", "127.0.0.1:8050") viper.Set("SPLASH_TIMEOU...
package rabbitmq import ( "context" "io/ioutil" "time" . "github.com/onsi/ginkgo" . "github.com/onsi/gomega" "github.com/sirupsen/logrus" "github.com/streadway/amqp" "github.com/batchcorp/plumber-schemas/build/go/protos/args" "github.com/batchcorp/plumber-schemas/build/go/protos/opts" "github.com/batchcorp...
package client import ( "bufio" "crypto/ecdsa" "encoding/base64" "encoding/hex" "fmt" "io/ioutil" "log" "os" "github.com/ethereum/go-ethereum/crypto" "github.com/zbohm/lirisi/ring" ) // CreatePrivateKey creates private key and print it on stdout or save it into the filename. func CreatePrivateKey(output st...
package raftstore import ( "sync" "go.uber.org/atomic" "github.com/pingcap-incubator/tinykv/kv/tikv/raftstore/message" "github.com/pingcap-incubator/tinykv/proto/pkg/raft_serverpb" "github.com/pingcap/errors" ) // router routes a message to a peer. type router struct { peers sync.Map workerSenders [...
package sentence import ( "path/filepath" "runtime" ) const ( nounsFileName = "default_nouns.txt" adjectivesFileName = "default_adjectives.txt" ) var ( defaultNounsFilePath = filepath.Join(getCurrentDir(), nounsFileName) defaultAdjectivesFilePath = filepath.Join(getCurrentDir(), adjectivesFileName) )...
// Copyright 2020, Jeff Alder // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // // http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or a...
package intcode import "fmt" // Module is a module with an opcode and a ParamCount // which does something to an ic computer *Intcode using the next ParamCount memory locations. // Calling function can return an error if its params turns out to be invalid // e.g., accessing an invalid memory address. // // It is assu...
package main import ( "fmt" "path/filepath" "regexp" "strconv" "strings" "github.com/jraams/aoc-2020/helpers" ) func main() { // Load input from file inputPath, _ := filepath.Abs("input") lines := helpers.GetInputValues(inputPath) rules, messages := load(lines) // Part 1 a := solve(rules, messages, fals...
/* Copyright (C) 2016 Red Hat, 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, softwa...
// Package integration only contains integration tests package integration
package selector import ( "fmt" "golang.org/x/net/html" "os" "testing" ) func TestQuerySelector(t *testing.T) { file, err := os.Open("./test.html") if err != nil { t.Error(err) return } doc, err := html.Parse(file) if err != nil { t.Error(err) return } node := NewNode(doc) query := &Query{ Id:...
package Auxiliar import "fmt" //Escrever registra uma mensagem na tela func Escrever() { fmt.Println("Writing the package auxiliary") escrever2() }
package main import ( "fmt" ) func calcCubes(num int, cuchan chan int) { sq := 0; for num!= 0 { digit := num%10 num = num/10 sq = sq + digit * digit * digit } cuchan <- sq } func calcSqares(num int, sqchan chan int) { sq := 0; for num!= 0 { digit := num%10 num = num/10 sq = sq + digit * digit } ...
// +build !windows package config func getSearchPaths() []string { return []string{ "./", "/etc/bitmaelum", } }
/* Copyright 2019 Dmitry Kolesnikov, All Rights Reserved Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law...
package service import ( "fmt" "github.com/TRON-US/soter-order-service/common/constants" "github.com/TRON-US/soter-order-service/common/errorm" "github.com/TRON-US/soter-order-service/logger" "github.com/TRON-US/soter-order-service/model" "github.com/TRON-US/soter-order-service/utils" "github.com/TRON-US/chao...
package api import ( "math" "net/http" "strconv" "strings" "gopkg.in/gographics/imagick.v3/imagick" "onikur.com/text-to-img-api/conf" "onikur.com/text-to-img-api/utils" ) var extansion = "png" // Options ... type Options struct { Font string FontSize float64 FontColor string LineMaxChar int }...
package routers import ( "net/http" "github.com/gabriel70g/twittor/bd" "github.com/gabriel70g/twittor/models" ) /*BajaRalacion dar de baja la relacion */ func BajaRalacion(w http.ResponseWriter, r *http.Request) { ID := r.URL.Query().Get("id") var t models.Relacion t.UsuarioID = IDUsuario t.UsuarioRelacionID...
package blockmanager import ( "fmt" "github.com/reed/blockchain/config" "github.com/reed/blockchain/store" "github.com/reed/crypto" "github.com/reed/database/leveldb" "github.com/reed/types" dbm "github.com/tendermint/tmlibs/db" "math/big" "math/rand" "strconv" "testing" "time" ) func TestBlockManager_cal...
package main import "fmt" /*声明全局变量*/ var g int = 200 func main() { //声明局部变量 var a, b int a = 100 b = 200 g = a + b fmt.Printf("g= %d", g) }
package main import ( "flag" "log" "os" "os/signal" "net/url" "github.com/gorilla/websocket" "fmt" "time" "encoding/json" ) func one(combo string, flag_name string)(){ var addr = flag.String(flag_name, "api.hitbtc.com", "http service address") flag.Parse() log.SetFlags(0) interrupt := make(chan os.Sign...
package api import ( "bytes" "encoding/json" utils "github.com/kevinbarbary/go-lms/utils" "io/ioutil" "log" "net/http" "strings" "time" ) // @todo - Time.Unix ? type Timestamp int64 type JsonDate time.Time type JsonDateTime time.Time type Params map[string]interface{} func MergeParams(a, b Params) Params {...
package main import ( "embed" "encoding/json" "fmt" "github.com/docopt/docopt-go" "github.com/fatih/color" "github.com/joeljunstrom/go-luhn" "io/fs" "net/http" "os" "regexp" "strconv" ) var buildNumber = "21.05" type card struct { Number string Valid bool Issuer string MII string PAN s...
package guard import ( "math/rand" "testing" "time" ) func TestConstDeadline(t *testing.T) { const iterations = 100 for i := 0; i < iterations; i++ { tpl := time.Now().Add(time.Duration(rand.Int()) * time.Second) constFunc := ConstDeadline(tpl) result := constFunc(nil, nil) if result != tpl { t.Fata...
package strip import ( "awesome-dragon.science/go/goGoGameBot/pkg/format/transformer/tokeniser" ) // Transformer is a simple transformer that simply removes all intermediate form formatting codes it sees type Transformer struct{} // Transform strips all formatting codes from the passed string func (s Transformer) T...
package template import ( "net/http" "github.com/firefirestyle/engine-v01/oauth/twitter" "github.com/firefirestyle/engine-v01/prop" minisession "github.com/firefirestyle/engine-v01/session" "io/ioutil" userhundler "github.com/firefirestyle/engine-v01/user/handler" "golang.org/x/net/context" "google.golang.o...
package models import ( "bytes" "html/template" ) type EmailRequest struct { From string To []string Subject string Body string } type ConfirmEmailTemplate struct { Title string Name string URL string } func NewEmailRequest(to []string, subject, body string) *EmailRequest { return &EmailRequest...
package contracts import ( "errors" "math/big" "time" "github.com/smartcontractkit/integrations-framework/client" "github.com/smartcontractkit/integrations-framework/contracts/ethereum" "github.com/ethereum/go-ethereum/accounts/abi/bind" "github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethere...
package groups import ( "errors" "net/http" "strconv" "docktor/server/storage" "docktor/server/types" "github.com/labstack/echo/v4" log "github.com/sirupsen/logrus" ) // getAllWithDaemons find all groups with daemons func getAllWithDaemons(c echo.Context) error { user := c.Get("user").(types.User) db := c....
package services import ( "errors" "sub/app/helpers/dbhelper" "sub/app/models" ) // SaveMsg - to save hotel, room and rateplan object func SaveMsg(msgData *models.MsgData) error { conn, err := dbhelper.GetConnByHost("") if err != nil { return err } if msgData == nil { return errors.New("No data received"...
package validator import ( "testing" "github.com/stretchr/testify/assert" "github.com/authelia/authelia/v4/internal/configuration/schema" ) func TestValidatePrivacyPolicy(t *testing.T) { testCases := []struct { name string have schema.PrivacyPolicy expected string }{ {"ShouldValidateDefaultConf...
/* * Copyright (c) 2015, Yawning Angel <yawning at torproject dot org> * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * * Redistributions of source code must retain the above copyright ...
package caaa import ( "encoding/xml" "github.com/thought-machine/finance-messaging/iso20022" ) type Document01100103 struct { XMLName xml.Name `xml:"urn:iso:std:iso:20022:tech:xsd:caaa.011.001.03 Document"` Message *AcceptorBatchTransferV03 `xml:"AccptrBtchTrf"` } func (d *Document01100103) Add...
package main import "fmt" func main() { x := bar() fmt.Printf("%T\n", x) // x()Run func fmt.Println(x()) //More cleanup fmt.Println(goo()()) } func bar() func() int { return func() int { return 451 } } //More cleanup func goo() func() string { return func() string { return "Limbaroyati" } }
package platform import ( "io/ioutil" "os" "testing" "github.com/stretchr/testify/assert" ) func TestLoadConfigFromJSONFileShouldWorks(t *testing.T) { const json = "{ \"f1\": \"val1\", \"f2\": 1 }" file, err := ioutil.TempFile("", t.Name()) assert.Nil(t, err, "Error to create tempfile") defer os.Remove(file....
package main import ( "bytes" "crypto/md5" "encoding/base64" "encoding/xml" "github.com/aws/aws-sdk-go/aws" "github.com/aws/aws-sdk-go/aws/request" "github.com/aws/aws-sdk-go/aws/session" "github.com/aws/aws-sdk-go/service/s3" "io/ioutil" "log" "net/http" "strconv" "time" ) func main() { sess, err := se...
package main import "fmt" func main() { s := []int{1, 2, 3} d := make([]int, 2, 4) copy(d, s) fmt.Println(d) fmt.Println(len(d)) fmt.Println(cap(d)) }
package initializers_test import ( "testing" . "github.com/onsi/ginkgo" . "github.com/onsi/gomega" ) func TestInitializers(t *testing.T) { RegisterFailHandler(Fail) RunSpecs(t, "Initializers Suite") }
// Copyright (c) 2019 Chair of Applied Cryptography, Technische Universität // Darmstadt, Germany. All rights reserved. This file is part of go-perun. Use // of this source code is governed by a MIT-style license that can be found in // the LICENSE file. package memorydb import ( "testing" "perun.network/go-perun/...
package schoolmeal import ( "encoding/json" "errors" "fmt" "net/http" "github.com/buger/jsonparser" ) var ( client *http.Client ) func init() { client = &http.Client{} } // GetDayMeal 함수는 하루의 급식을 가져옵니다. func (s School) GetDayMeal(date string, mealType int) (m Meal, err error) { weekMeals, err := s.GetWeekM...
package main import ( "context" "fmt" "github.com/Highway-Project/highway/config" "github.com/Highway-Project/highway/internal/server" "github.com/Highway-Project/highway/logging" "github.com/creasty/defaults" "os" "os/signal" "syscall" "time" ) func main() { fmt.Println(` _ _ _ _ ...
// Package storage - служба хранения данных package storage import ( "go.core/lesson7/pkg/crawler" "go.core/lesson7/pkg/storage/bstree" ) type Interface interface { Create(docs []crawler.Document) Document(id int) (crawler.Document, bool) Add(d crawler.Document) } // New - конструктор службы хранения данных fun...
package html import ( "testing" ) func TestTidy(t *testing.T) { dest := "<div id='hello'><a onclick=\"window.location='aa'\" id=\"ss\"></a>" str := Tidy(dest) t.Error(str) }
package week11 type RuneStack []rune func (s *RuneStack) Push(r rune) { *s = append(*s, r) } func (s *RuneStack) Pop() rune { last := (*s)[len(*s)-1] *s = (*s)[:len(*s)-1] return last } // 20. 有效的括号 https://leetcode-cn.com/problems/valid-parentheses/ func isValid(s string) bool { stack := RuneStack{} for _, t...
// Copyright 2019 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 problem0441 import "testing" import "math" func TestArrangeCoins(t *testing.T) { for i := 0; i < 10; i++ { t.Log(arrangeCoins(i) == int(math.Sqrt(float64(i)))) } }
package main import ( "fmt" "math" ) type ( // Shapes interface Shapes interface { Area() float64 Perimeter() float64 } // Rectangle struct Rectangle struct { height, length int } // Circle struct Circle struct { radius float64 } // Triangle struct Triangle struct { sideA float64 sideB float6...
package s3fs // Credentials store sensitive strings that should not be marshalled to JSON type Credentials string // MarshalJSON implementation that ensures credentials are never returned from the API func (c Credentials) MarshalJSON() ([]byte, error) { if len(c) > 0 { return []byte(`"[redacted]"`), nil } return...
package multiples3or5 import ( "fmt" "testing" ) func TestMultiple3And5(t *testing.T) { tests := []struct { arg int want int }{ {arg: 10, want: 23}, } for _, tt := range tests { t.Run(fmt.Sprintf("Multiple3And5(%d)", tt.arg), func(t *testing.T) { if got := Multiple3And5(tt.arg); got != tt.want { ...
package main import "strconv" type Position struct { Latitude float64 Longitude float64 } func (p Position) String() string { return strconv.FormatFloat(p.Latitude, 'f', -1, 64) + "," + strconv.FormatFloat(p.Longitude, 'f', -1, 64) }
package types import ( "fmt" "go/ast" "go/token" "regexp" "strings" goast "go/ast" "strconv" "github.com/elliotchance/c2go/program" "github.com/elliotchance/c2go/util" ) func CastExpr(p *program.Program, expr ast.Expr, fromType, toType string) ast.Expr { fromType = ResolveType(p, fromType) toType = Reso...
package factory type Config struct { Period int `yaml:"period"` Delta float64 `yaml:"delta"` Granularity float64 `yaml:"granularity"` Host string `yaml:"host"` GnbIp string `yaml:"gnbIp"` DnIp string `yaml:"dnIp"` UpfInfos []UpfInfo `yaml:"upfInfos"` EdgeInfos []EdgeInfo `yaml:"edgeInfos"` Logger Logg...
package array import ( "reflect" "github.com/spf13/cast" ) // Keys array_keys() func Keys(input interface{}) (result []interface{}) { v := reflect.ValueOf(input) if (v.Kind() != reflect.Map) && (v.Kind() != reflect.Struct) { return } switch v.Kind() { case reflect.Map: if v.Len() <= 0 { return } re...
package imagekit import( "github.com/docker/distribution" "github.com/docker/distribution/reference" "github.com/docker/docker/image" ) // ImageKit represents toolset for manipulate docker image type ImageKit interface { Packer StaticBuilder ImageDescriptor } // Packer pack layers to generate a legal docker i...
package todo /** 这里是整个todo项目的配置中心 */ import ( "github.com/baotingfang/gomvc" "path" "runtime" "time" ) var ( // 数据库驱动类型:支持mymysql和mysql两种配置 DATABASE_Driver string = "mymysql" // mysql连接字符串: "user:password@/dbname?charset=utf8&keepalive=1" // mymysql连接字符串: tcp:localhost:3306*dbname/user/pwd DATABASE_DSN stri...
package main import ( "log" "sync" "time" cleverbot "github.com/ugjka/cleverbot-go" ) type ConversationCallback func(channel, nick, reply string, err error) // Conversation is a single conversation. type Conversation struct { // channel that the message should be posted to channel string // nick the bot is c...
package main import ( "BOOKS-LIST/models" "database/sql" "encoding/json" "fmt" "log" "net/http" "strconv" _ "github.com/go-sql-driver/mysql" "github.com/gorilla/mux" ) type Book struct { ID int `json:id` Title string `json:title` Author string `json:author` Year string `json:year` } var books...
package xendit import ( "fmt" "time" "github.com/imrenagi/go-payment" ) // EWalletPaymentStatus stores callback information for xendit ewallet type EWalletPaymentStatus struct { Event string `json:"event"` BusinessID string `json:"business_id"` Creat...
package vibely import ( "encoding/json" "io" "io/ioutil" "log" "net/http" "net/url" "os" "time" "github.com/gorilla/mux" "github.com/joho/godotenv" ) const baseUrl = "https://genius.com" func search(w http.ResponseWriter, r *http.Request) { vars := mux.Vars(r) query := vars["value"] url := baseUrl + "/...
// Copyright 2018 Lars Hoogestraat // Use of this source code is governed by a MIT-style // license that can be found in the LICENSE file. package models import ( "database/sql" "errors" "fmt" "net/http" "strings" "time" "git.hoogi.eu/snafu/go-blog/crypt" "git.hoogi.eu/snafu/go-blog/httperror" "git.hoogi.eu...
/* Given two numbers arr1 and arr2 in base -2, return the result of adding them together. Each number is given in array format: as an array of 0s and 1s, from most significant bit to least significant bit. For example, arr = [1,1,0,1] represents the number (-2)^3 + (-2)^2 + (-2)^0 = -3. A number arr in array, form...
package amazonmwsapi import ( "bytes" "context" "encoding/csv" ) // GetReportRequest requests a single amzMWS report for download type GetReportRequest struct { amazonRequest } // Do sends request to amazonMWS reports API and returns report data maps func (r *GetReportRequest) Do(ctx context.Context) ([]map[stri...
package minnow type Hook interface { MatchesBytes([]byte) bool Matches(Properties) bool } type BasicPropertiesMatchHook struct { match Properties } func NewBasicPropertiesMatchHookFromFile(path Path) (BasicPropertiesMatchHook, error) { hookProperties, err := PropertiesFromFile(path) if err != nil { return Ba...
package schedules import ( "sub_account_service/order_server/db" "sub_account_service/order_server/entity" "sub_account_service/order_server/handlers" "github.com/golang/glog" "time" ) //add order schedule func StartAddOrderSchedule() { go func(){ for { addOrderSchedule() time.Sleep(20 * time.Second) ...
/* * Copyright © 2018-2022 Software AG, Darmstadt, Germany and/or its licensors * * SPDX-License-Identifier: Apache-2.0 * * 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://...
package config const MongoDBEndpoint = "mongodb+srv://nocnocAdmin:Nocnoc2021@cluster0.o70ui.mongodb.net" const DatabaseName = "todo"
package pipeline import ( "time" "github.com/pkg/errors" "gopkg.in/guregu/null.v4" ) type ( Spec struct { ID int32 `gorm:"primary_key"` DotDagSource string CreatedAt time.Time } TaskSpec struct { ID int32 `gorm:"primary_key"` DotID string PipelineSpecID int32 Ty...
/* Copyright (c) 2017 Simon Schmidt 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, publish, distribute, s...
package baidu import ( "github.com/funxdata/baidu/core" "github.com/funxdata/baidu/face" "github.com/funxdata/baidu/nlp" "github.com/funxdata/baidu/ocr" "github.com/funxdata/baidu/speech" ) type Baidu struct { *core.Core } func New(apiKey, apiSecret string) *Baidu { return &Baidu{core.NewCore(apiKey, apiSecre...
package index type Index struct { InvertIndex InvertIndex StorageIndex StorageIndex } func NewIndex() *Index { return &Index{} }
package main import ( "bytes" "encoding/gob" "encoding/json" "errors" "fmt" //"github.com/filecoin-project/go-state-types/abi" "io/ioutil" "log" ) //定义一个结构体 type Monster struct { Name string Age int Birthday string Sal float64 Skill string } type Student struct { Name string Age uint8...
/* Copyright 2015 Crunchy Data Solutions, 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 股票问题 // ------------------ 单调栈法 ------------------ // 使用单调递减栈,找 A[:i]从右到左第一个小于A[i]的数 // 优化: 单调栈可以优化掉... func maxProfit(prices []int) int { minStack := make([]int, 0) maxProfitResult := 0 for i := 0; i < len(prices); i++ { if len(minStack) != 0 && minStack[len(minStack)-1] <= prices[i] { maxProfitResult...
package redis import ( "errors" "github.com/go-redis/redis" "github.com/spf13/viper" ) const ( Sentinel = "sentinel" Cluster = "cluster" DefaultPoolSize = 100 DefaultReadTimeout = 1000 DefaultWriteTimeout = 1000 ) var ( ErrorMissingRedisAddress = errors.New("missing redis address") ) type Connection...
package sw import ( "crypto/rsa" "crypto/x509" "fmt" "crypto/sha256" "errors" "encoding/asn1" "math/big" "github.com/HNB-ECO/HNB-Blockchain/HNB/bccsp" ) type rsaPublicKeyASN struct { N *big.Int E int } type rsaPrivateKey struct { privKey *rsa.PrivateKey } func (k *rsaPrivateKey) Bytes() (raw []byte, ...
package api import ( "encoding/json" "fmt" "net/http" "strings" ldap "gopkg.in/ldap.v2" "github.com/compsoc-edinburgh/bi-provider/pkg/config" "github.com/gin-gonic/gin" "github.com/qaisjp/gosign" "github.com/sirupsen/logrus" ) var outNotLoggedIn = gin.H{ "status": "error", "message": "not logged in", } ...
package main // QueryGenerator describes a generator of queries, typically according to a // use case. type QueryGenerator interface { Dispatch(int, *Query, int) }
package main import "log" var ( minTurnover float64 = 2 // 最少成交额 2 亿 minChangehands float64 = 2 // 最低换手 2% minTurnoverToCirculation float64 = 0.02 // 成交占比流通最少 万2 minMainP float64 = 5 // 主力流入占比最低 5% mainMainV float64 = 0.1 // 主力流入最少 0.1 亿 // 其实换手率就...
package logging import "github.com/sirupsen/logrus" //The LogrusLogger is the default logger for quacktors. //As the name implies, it uses logrus under the hood. type LogrusLogger struct { Log *logrus.Logger } //Init initializes the LogrusLogger with the default config (ForceColors=true, LogLevel=Trace) func (l *Lo...
package controllers import ( "github.com/astaxie/beego" ) type MainController struct { beego.Controller } type UserController struct { beego.Controller } func (this *MainController) Get() { this.Data["Website"] = "beego.me" this.Data["Email"] = "astaxie@gmail.com" this.TplName = "index.tpl" } // 登录 func (thi...
package tmpl1 import ( "github.com/sko00o/leetcode-adventure/queue-stack/queue/bfs" ) // BFS return the length of the shortest path between root and target node. func BFS(root, target *bfs.Node) int { // store all nodes which are waiting to be processed var queue bfs.NodeQueue // number of steps needed from root...
package accdownload_test import( "testing" "download/accdownload" "fmt" ) func Test_Account_GetBalanceData(t *testing.T){ d := accdownload.NewAccountDownloader() res := d.GetBalanceData("600001") fmt.Println(res) } func Test_Account_GetIncomeData(t *testing.T){ d := accdownload.NewAccount...
package logger import ( "reflect" "testing" "github.com/rifflock/lfshook" "github.com/sirupsen/logrus" ) func Test_setLogDirectoryPath(t *testing.T) { tests := []struct { name string }{ // TODO: Add test cases. } for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { setLogDirectoryPath() ...
// DRUNKWATER TEMPLATE(add description and prototypes) // Question Title and Description on leetcode.com // Function Declaration and Function Prototypes on leetcode.com //679. 24 Game //You have 4 cards each containing a number from 1 to 9. You need to judge whether they could operated through *, /, +, -, (, ) to get t...
package azure import ( "fmt" "strings" ) // aro is a setting to enable aro-only modifications var aro bool // OutboundType is a strategy for how egress from cluster is achieved. // +kubebuilder:validation:Enum="";Loadbalancer;NatGateway;UserDefinedRouting type OutboundType string const ( // LoadbalancerOutboundT...
// Copyright 2016-2021, Pulumi Corporation. package schema import ( jsschema "github.com/lestrrat-go/jsschema" ) // FlattenJSSchema recursively flattens a schema containing AnyOf or OneOf into a list of schemas // Note: this only performs a shallow copy, don't use in situations where schema fields may be mutated. /...
package provider import ( "fmt" "strconv" "strings" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" "github.com/mrparkers/terraform-provider-keycloak/keycloak" ) func resourceKeycloakSamlClientScope() *schema.Resource { return &schema.Resource{ Create: resourceKeycloakSamlClientScopeCreate, Re...
package proof import ( "github.com/filecoin-project/go-state-types/abi" "github.com/ipfs/go-cid" ) /// /// Sealing /// // Information needed to verify a seal proof. type SealVerifyInfo struct { SealProof abi.RegisteredSealProof abi.SectorID DealIDs []abi.DealID Randomness abi.SealRando...
package main import ( "encoding/json" "fmt" "net/http" "strconv" "github.com/julienschmidt/httprouter" ) func main() { router := httprouter.New() router.GET("/", index) router.GET("/testString", testString) router.GET("/testMap", testMap) router.GET("/test2", test2Index) router.GET("/test2/:size", test2) ...
package rules import ( "fmt" "log" "os" ) func GetRulesFiles() { file, err := os.Open("/home/artem/hello-sql") if err != nil { log.Fatalf("failed opening directory: %s", err) } defer file.Close() list, _ := file.Readdirnames(0) for _, name := range list { fmt.Println(name) } }
package main func longestCommonPrefix(strs []string) string { if len(strs) == 0 { return "" } res := strs[0] resRunes := []rune(res) minL := len(resRunes) for i := 1; i < len(strs); i++ { iRunes := []rune(strs[i]) //fmt.Println(string(iRunes), string(resRunes)) minL = min14(minL, len(iRunes)) for index...
package main import "fmt" func main() { // sliceChan := make(chan []int, 3) // 切片的值会受到影响 sliceChan := make(chan [3]int, 3) // 数组中的值不会收到影响 // srcSlice := []int{1, 2, 3} srcSlice := [3]int{1, 2, 3} fmt.Printf("srcSlice %v\n", srcSlice) sliceChan <- srcSlice dstSlice := <-sliceChan dstSlice[1] = 512 fmt.Pri...
package test import ( "fmt" "gengine/base" "gengine/builder" "gengine/context" "gengine/engine" "github.com/sirupsen/logrus" "testing" "time" ) const rule_not = ` rule "test not" "test" begin if !(10 < -10 + 6*100 - 10) && !false { println("hello") } end ` func exec_not(){ dataContext := context.NewDa...
package main import "fmt" // Channels are the pipes that connect concurrent goroutines. You // can send values into channels from one goroutine and receive // those values into another goroutine. func main() { // Create a new channel messages := make(chan string) // Send a value into a channel using the channel...
package onlinestore import ( "github.com/feast-dev/feast/go/internal/feast/registry" "testing" "github.com/stretchr/testify/assert" ) func TestNewRedisOnlineStore(t *testing.T) { var config = map[string]interface{}{ "connection_string": "redis://localhost:6379", } rc := &registry.RepoConfig{ OnlineStore: ...
package leetcode import ( "reflect" "testing" ) func TestCommonChars(t *testing.T) { if !reflect.DeepEqual(commonChars([]string{"bella", "label", "roller"}), []string{"e", "l", "l"}) { t.Fatal() } }
package ipfsaddr import ( "strings" "testing" ma "gx/ipfs/QmNTCey11oxhb1AxDnQBRHtdhap6Ctud872NjAYPYYXPuc/go-multiaddr" peer "gx/ipfs/QmPJxxDsX2UbchSHobbYuvz7qnyJTFKvaKMzE2rZWJ4x5B/go-libp2p-peer" ) var good = []string{ "/ipfs/5dru6bJPUM1B7N69528u49DJiWZnok", "/ipfs/kTRX47RthhwNzWdi6ggwqjuX", "/ipfs/QmUCseQWXC...
package glog import ( "log" ) //输出信息到console 使用log库来实现 type consoleTarget struct { name string //只读 minLevel LogLevel //只读 maxLevel LogLevel //只读 } func (ct *consoleTarget) Name() string { return ct.name } func (ct *consoleTarget) MinLevel() LogLevel { return ct.minLevel } func (ct *consoleTarget) MaxL...