text
stringlengths
11
4.05M
package main import ( "fmt" ) // 349. 两个数组的交集 // 给定两个数组,编写一个函数来计算它们的交集。 // https://leetcode-cn.com/problems/intersection-of-two-arrays/ func main() { nums1 := []int{1, 2, 2, 1} nums2 := []int{2, 2} fmt.Println(intersection(nums1, nums2)) } // 法一:暴力法,O(m*n),m和n分别是nums1和nums2的长度 // 法二:使用一个额外的map进行统计,O(n) func int...
package mapreduce import ( "bufio" "encoding/json" "io" "os" "sort" ) func doReduce( jobName string, // the name of the whole MapReduce job reduceTask int, // which reduce task this is outFile string, // write the output here nMap int, // the number of map tasks that were run ("M" in the paper) reduceF func...
package mqtt import ( "io" "fmt" "github.com/eclipse/paho.mqtt.golang" "mqtt-adapter/src/config" ) const qos = 0 // Subscriber is an interface that describes behavior of a subscriber to MQTT type Subscriber interface { Subscribe(topic string, writer io.Writer) SubscribeBridge(topic string, msgChan chan<- stri...
package agent import ( "log" "strconv" "time" "github.com/google/uuid" zmq "github.com/pebbe/zmq4" "google.golang.org/protobuf/proto" "github.com/Project-Auxo/Olympus/pkg/mdapi" "github.com/Project-Auxo/Olympus/pkg/util" mdapi_pb "github.com/Project-Auxo/Olympus/proto/mdapi" ) /* broker ...
package leetcode /* * LeetCode T1704. 二分查找 * https://leetcode-cn.com/problems/binary-search/ * * 给定一个 n 个元素有序的(升序)整型数组 nums 和一个目标值 target , * 写一个函数搜索 nums 中的 target,如果目标值存在返回下标,否则返回 -1。 */ // 时间复杂度 O(logN) func binarySearch(nums []int, target int) int { l, r := 0, len(nums)-1 // 搜索区间 [0, len(nums)-1],循环结束条件 l ...
package operator import ( "context" "fmt" "time" operatorv1 "github.com/openshift/api/operator/v1" operatorclient "github.com/openshift/cluster-dns-operator/pkg/operator/client" operatorconfig "github.com/openshift/cluster-dns-operator/pkg/operator/config" operatorcontroller "github.com/openshift/cluster-dns-o...
package main // Everything is in terms of "per 100 g" (except for g, which is the amount of // that thing that you're eating). //////////////////////////////////////////////////////////////////////////////// type Grams float32 const ( kg = 1000 perPound = 0.220462 ) func (g Grams) Of(f *food) *food { r := ...
// +build !windows package asyncexec_test import ( "fmt" "os/exec" "github.com/aws-controllers-k8s/dev-tools/pkg/asyncexec" ) func ExampleCmd_Run_withNoStream() { cmd := asyncexec.New(exec.Command("echo", "Hello ACK"), 16) cmd.Run() cmd.Wait() fmt.Println(cmd.ExitCode()) // Output: 0 } func ExampleCmd_Run_...
package cmd_test import ( "bytes" "fmt" "io/ioutil" "testing" "github.com/google/uuid" "github.com/stretchr/testify/require" "github.com/provenance-io/provenance/cmd/provenanced/cmd" "github.com/provenance-io/provenance/x/metadata/types" ) func TestAddMetaAddressParser(t *testing.T) { scopeUUID := uuid.New...
package cmd import ( "github.com/spf13/cobra" "go.uber.org/zap" "os" ) var dbType string var dbHost string var dbPort int32 var dbUser string var dbPass string var dbName string var dbTable string var outputFolder string func init() { genAPI.Flags().StringVarP(&dbType, "type", "", "mysql", "db type: mysql, postg...
package main const ( // Created indicates the job has just been created Created = iota // ReceivingInputs means some inputs (>0) have been received ReceivingInputs // AllInputReceived means no further inputs will be received AllInputReceived // AllOutputReceived means all outputs have been received AllOutpu...
package algorithm import ( . "gopkg.in/check.v1" "testing" ) // Hook up gocheck into the "go test" runner. func Test(t *testing.T) { TestingT(t) } type MySuite struct{} var _ = Suite(&MySuite{}) func (s *MySuite) TestKMP(c *C) { k := New("AAADAAA") next := k.next res := []int{0, 1, 2, 0, 1, 2, 3} for i := ra...
// cap and pointer. package main import "fmt" func main() { ss := make([]string, 0, 1) add := func(str string) { fmt.Printf("append:%q\n", str) ss = append(ss, str) fmt.Printf("pointer:%p, len:%d, cap:%d\n\n", ss, len(ss), cap(ss)) } fmt.Printf("pointer:%p, len:%d, cap:%d\n\n", ss, len(ss), cap(ss)) add("...
package httpapi import ( "time" "github.com/pkg/errors" ) // Config defines the http configuration. type Config struct { ListenAddress string `json:"listen-address" yaml:"listen-address"` RequestTimeout time.Duration `json:"request-timeout" yaml:"request-timeout"` TLS ...
package eaptls import ( "encoding/binary" "errors" "github.com/titanous/weap/eap" ) type PacketFlag byte const ( FlagLength PacketFlag = 1 << 7 FlagMore PacketFlag = 1 << 6 FlagStart PacketFlag = 1 << 5 ) type PacketHeader struct { Outer eap.PacketHeader Flags PacketFlag Length uint32 } func (h *Pac...
package main import "testing" func TestMain(t *testing.T) { t.Log("teste") }
package task import ( "DataApi.Go/database/orm" "DataApi.Go/lib/common" "github.com/jinzhu/gorm" ) func QueryAdSenseReportList(db *gorm.DB, accountId []string, startDate int, endDate int) []common.JSON{ caAccountId := common.GetCaAccountIds(accountId) reportList := orm.SelectAdSenseReport(db, caAccountId, common...
package main import "fmt" /** Go does not have classes. However, you can define methods on types. A method is a function with a special receiver argument. The receiver appears in its own argument list between the func keyword and the method name. In this example, the getName method has a receiver of type Vertex na...
package img import ( log "github.com/sirupsen/logrus" "image" "image/color" "image/draw" "image/png" "os" ) const ( wRect = 200 hRect = 200 ) // hLine draws a horizontal line. func hLine(rectImg *image.RGBA, color color.RGBA, x, y, length , width int) { rectLine := image.NewRGBA(image.Rect(x, y, x+length, y...
package cmd import ( "fmt" "os" "github.com/dnephin/dobi/config" "github.com/dnephin/dobi/logging" "github.com/dnephin/dobi/tasks" "github.com/dnephin/dobi/tasks/client" docker "github.com/fsouza/go-dockerclient" log "github.com/sirupsen/logrus" "github.com/spf13/cobra" ) const ( // DefaultDockerAPIVersion...
package fuse import ( "os" "testing" "syscall" ) func TestOsErrorToFuseError(t *testing.T) { errNo := OsErrorToFuseError(os.EPERM) if errNo != syscall.EPERM { t.Errorf("Wrong conversion %v != %v", errNo, syscall.EPERM) } e := os.NewSyscallError("syscall", syscall.EPERM) errNo = OsErrorToFuseError(e) if e...
package lastpass import ( "io" "net/url" "strconv" "github.com/smartystreets/scanners/csv" ) // CSVScanner provides a clean interface // to scan LastPass exported CSV files. type CSVScanner struct { *csv.Scanner } // NewCSVScanner will construct a CSVScanner // that wraps the provided io.Reader. func NewCSVSca...
package LeetCode var CousinsInBinaryTreeInput1 = &TreeNode{ Val:1, Left:&TreeNode{ Val:2, Left:&TreeNode{ Val:4, }, }, Right:&TreeNode{ Val:3, }, } var CousinsInBinaryTreeInput2 = &TreeNode{ Val:1, Left:&TreeNode{ Val:2, Right:&TreeNode{ Val:4, }, }, Right:&TreeNode{ Val:3, Right:&Tre...
// Copyright 2023 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 "fmt" func main() { // Similar for loop syntax to other languages for i := 0; i < 5; i++ { fmt.Println("Hello!") } // There is no while loop keyword. The for construct can be used j := 1 for j < 9 || j%2 != 0 { fmt.Println("We are in a while loop this will loop for a bit") j++ } fm...
package main import ( "fmt" "time" ) func main() { fmt.Println("in main()") go longWait() go shortWait() fmt.Println("about to sleep in main()") time.Sleep(60 * 1e9) fmt.Println("At the end of time") } func longWait() { fmt.Println("beginning longwait") time.Sleep(30 * 1e9) fmt.Println("end of longWait") ...
package main import ( "go-package/demo/interface/productrepo" ) func main() { // 选择"aliCloud" env := "aliCloud" // 根据env新建一个repo repo := productrepo.New(env) // 在新建的repo上进行存储 repo.StoreProduct("HuaWei mate 40", 105) }
// Copyright 2017 by caixw, All rights reserved. // Use of this source code is governed by a MIT // license that can be found in the LICENSE file. // Package types 一些公用类型的定义 package types import ( "github.com/tanxiaolong/apidoc/locale" "github.com/tanxiaolong/apidoc/vars" ) // Sanitizer 配置项的检测接口 type Sanitizer int...
package topology import ( "path/filepath" "time" "github.com/Cloud-Foundations/Dominator/lib/log" "github.com/Cloud-Foundations/Dominator/lib/repowatch" hyper_proto "github.com/Cloud-Foundations/Dominator/proto/hypervisor" ) func watch(topologyRepository, localRepositoryDir, topologyDir string, checkInterval t...
//go:build !release // +build !release //go:generate go run assets_generate.go package data import ( "net/http" "os" ) // Assets contains project assets. var Assets http.FileSystem func init() { dir := os.Getenv("OPENSHIFT_INSTALL_DATA") if dir == "" { dir = "data" } Assets = http.Dir(dir) }
package main import ( "io/ioutil" "github.com/go-rod/rod" "github.com/go-rod/rod/lib/proto" "github.com/ysmood/kit" ) // This example demonstrates how to take a screenshot of a specific element and // of the entire browser viewport, as well as using `kit` // to store it into a file. func main() { browser := rod...
package fsm import ( "strconv" "math/rand" "time" "github.com/aws/aws-sdk-go/aws" "github.com/aws/aws-sdk-go/service/swf" . "github.com/sclasen/swfsm/sugar" ) //DecisionInterceptor allows manipulation of the decision task and the outcome at key points in the task lifecycle. type DecisionInterceptor interface ...
package models_test import ( "testing" "github.com/cloudfoundry-incubator/notifications/models" . "github.com/onsi/ginkgo" . "github.com/onsi/gomega" ) func TestModelsSuite(t *testing.T) { RegisterFailHandler(Fail) RunSpecs(t, "Models Suite") } func TruncateTables() { err := models.Data...
/* Your challenge is to make an infinite loading screen, that looks like this: Loading...\ Or, to be more specific: Take no input. Output Loading..., with a trailing space, but no trailing newline. Infinitely cycle through the chars |, /, - and \: every 0.25 seconds, overwrite the last one with the next...
func reverse(x int) int { if x == 0 { return 0 } if x < -2147483648 || x > 2147483647 { return 0 } minusFlag := 0 if x < 0 { minusFlag = 1 x = x * -1 } result := 0 temp := []int{} for x > 0 { lastDigit := x % 10 temp = append(t...
package entities // Players is a pool of players // with additionnal filters. type Players []*Player // Count returns the total number of players // as an unsigned number. // func (p Players) Count() uint { return uint(len(p)) } // Humans returns ONLY the players // who are considered as humans. // func (p Players)...
package server import ( "github.com/pantonshire/nlpewee/core" pb "github.com/pantonshire/nlpewee/proto" ) func serializeTokenizeResponse(sentences []core.Sentence) *pb.TokenizeResponse { sentenceMsgs := make([]*pb.Sentence, len(sentences)) for i, sentence := range sentences { sentenceMsgs[i] = serializeSentence...
package main import ( "os" "github.com/sirkon/message" ) func loggerr(err error) { if os.Getenv("COMPLETELOG") == "" { return } message.Error(err) }
package relay import ( "context" "encoding/base64" "fmt" "time" "unicode/utf8" skafka "github.com/segmentio/kafka-go" "google.golang.org/grpc" "github.com/batchcorp/collector-schemas/build/go/protos/records" "github.com/batchcorp/collector-schemas/build/go/protos/services" "github.com/batchcorp/plumber/ba...
// Copyright 2018 Diego Bernardes. All rights reserved. // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. package worker import ( "bytes" "context" "encoding/json" "fmt" "net/http" "net/url" "github.com/pkg/errors" "github.com/diegobernardes/flare" infr...
package controller import ( "coconut/middleware" "coconut/model" "coconut/util" "coconut/serializer" "net/http" "github.com/gin-gonic/gin" ) func CreateUser(c *gin.Context) { v := model.UserValidator{} if err := v.Bind(c); err != nil { c.JSON(http.StatusUnprocessableEntity, util.NewValidatorError(err)) r...
package sobjects var SObjectsImplementations = map[string]SObject { "AcceptedEventRelation": &AcceptedEventRelation{}, "Account": &Account{}, "AccountCleanInfo": &AccountCleanInfo{}, "AccountContactRole": &AccountContactRole{}, "AccountFeed": &AccountFeed{}, "AccountHistory": &AccountHistory{}, "AccountPartner...
package v1beta7 import ( "github.com/devspace-cloud/devspace/pkg/devspace/config/versions/config" "github.com/devspace-cloud/devspace/pkg/devspace/config/versions/util" next "github.com/devspace-cloud/devspace/pkg/devspace/config/versions/v1beta8" "github.com/devspace-cloud/devspace/pkg/util/log" ) // Upgrade upg...
package model func (i *InstanceStruct) IsMyName(name string) bool { if i.InstanceAlias != "" && name == i.InstanceAlias { return true } if i.InstanceName == name { return true } return false }
package admin import ( md "github.com/ebikode/eLearning-core/model" ) // ValidationFields struct to return for validation type ValidationFields struct { Phone string `json:"phone,omitempty"` FirstName string `json:"first_name,omitempty"` LastName string `json:"last_name,omitempty"` Email string `json:"e...
package controllers import ( "github.com/astaxie/beego" "BeegoTest/models" "fmt" "strconv" ) type ApplicationsController struct { beego.Controller } func (App *ApplicationsController) URLMapping(){ App.Mapping("List", App.List) } // @router /apps [get] func (App *ApplicationsController) Lis...
package main import ( "encoding/json" "fmt" "io/ioutil" "os" "github.com/gdhagger/go-buildkite/buildkite" joonix "github.com/joonix/log" log "github.com/sirupsen/logrus" flag "github.com/spf13/pflag" "gopkg.in/yaml.v1" ) var apiToken string var org string var configFile string var logLevel string var logFor...
package logger import ( "fmt" "io" "os" "sync" "time" "github.com/fatih/color" ) // LogLevel is The severity level of the logs // 0 is the lowest severity type LogLevel int // LogDispatcher dispatches logs to multiple Loggers type LogDispatcher interface { Log(level LogLevel, msg string) Register(name strin...
package msp import ( "github.com/HNB-ECO/HNB-Blockchain/HNB/bccsp" "github.com/HNB-ECO/HNB-Blockchain/HNB/bccsp/factory" "github.com/HNB-ECO/HNB-Blockchain/HNB/bccsp/secp256k1" "github.com/HNB-ECO/HNB-Blockchain/HNB/bccsp/sw" "bytes" "crypto/elliptic" "fmt" "strconv" ) const ( ECDSAP224 = 0 ECDSAP256 = 1 E...
package traefik_plugin_geoip2_test import ( "context" traefik_plugin_geoip2 "github.com/negasus/traefik-plugin-geoip2" "net/http" "net/http/httptest" "testing" ) func TestGeoIP2_WrongNew(t *testing.T) { cfg := traefik_plugin_geoip2.CreateConfig() ctx := context.Background() _, err := traefik_plugin_geoip2.New...
package _257_Binary_Tree_Paths import ( "fmt" "strings" ) /** * Definition for a binary tree node. * type TreeNode struct { * Val int * Left *TreeNode * Right *TreeNode * } */ func binaryTreePaths(root *TreeNode) []string { if root == nil { return []string{} } var ret []string binaryTreePat...
// +build nobootstrap package update import ( "archive/tar" "compress/bzip2" "io" "net/http" "os" "path" "core" ) const url = "https://bitbucket.org/squeaky/portable-pypy/downloads/pypy-5.6-linux_x86_64-portable.tar.bz2" // DownloadPyPy attempts to download a standalone PyPy distribution. // We use this to ...
package slack import ( "encoding/json" "fmt" "testing" "net/http" "github.com/stretchr/testify/assert" ) // Dialogs var simpleDialog = `{ "callback_id":"ryde-46e2b0", "title":"Request a Ride", "submit_label":"Request", "notify_on_cancel":true }` var simpleTextElement = `{ "label": "testing label", "name...
package check import ( "fmt" "github.com/MintegralTech/juno/debug" "github.com/MintegralTech/juno/document" "github.com/MintegralTech/juno/index" "github.com/MintegralTech/juno/marshal" ) type OrChecker struct { c []Checker aDebug *debug.Debug } func NewOrChecker(c []Checker) *OrChecker { if c == nil { ...
package boltdb import ( "bytes" bolt "go.etcd.io/bbolt" ) type Iterator struct { cursor *bolt.Cursor // boltDB 用于迭代遍历的游标 prefix []byte // 指定遍历的前缀,用于前缀搜索 start []byte // 指定遍历左区间,用于区间搜索 end []byte // 指定遍历右区间,用于区间搜索 valid bool // 遍历是否终止 key []byte // 遍历到当前位置的 key 值 val ...
package options // Options : options of this program type Options struct { Width int `short:"w" long:"width" description:"Field width" default:"160"` Height int `short:"h" long:"height" description:"Field height" default:"90"` AliveRate float64 `short:"a" long:"alive-rate" des...
package handler import ( "database/sql" "encoding/json" "net/http" "time" "github.com/seongminnpark/nooler-server/internal/pkg/model" "github.com/seongminnpark/nooler-server/internal/pkg/util" ) type DeviceHandler struct { DB *sql.DB } func (handler *DeviceHandler) GetDevice(w http.ResponseWriter, r *http.Re...
package chain import ( "strings" abci "github.com/hashrs/blockchain/core/consensus/dpos-pbft/abci/types" "github.com/hashrs/blockchain/core/consensus/dpos-pbft/libs/log" sdk "github.com/hashrs/blockchain/framework/chain-app/types" starter "github.com/hashrs/blockchain/framework/chain-starter" dbm "github.com/ha...
// ------------------------------------------------------------------- // // salter: Tool for bootstrap salt clusters in EC2 // // Copyright (c) 2013-2014 Orchestrate, Inc. All Rights Reserved. // // This file is provided to you under the Apache License, // Version 2.0 (the "License"); you may not use this file // exce...
package atcoder import ( "fmt" "github.com/PuerkitoBio/goquery" "io" "strings" ) func ParseTasksPage(r io.Reader) ([]string, error) { doc, err := goquery.NewDocumentFromReader(r) if err != nil { return nil, err } selector := doc.Find("tbody > tr > td:first-child > a") paths := make([]string, selector.Leng...
package main import ( "bufio" "fmt" "log" "os" "strconv" "strings" ) const () func checkErr(err error) { if err != nil { log.Fatalf("Error: %v", err) } } func cyclePos(movePos int, pivot int) int { if movePos > pivot { return movePos - 2 * (movePos - pivot) } else { return movePos } } func collisi...
// Package tlit is a package for encoding russian and ukrainian letters with latin ones. package tlit // import "github.com/blackalegator/tlit"
package main import ( "github.com/fatih/color" "os" ) type mlCLI struct { printColor [6]*color.Color server string verbose bool silence bool debug bool } var currentColorTheme = "default" var ( colRegular = 0 colInfo = 1 colWarn = 2 colError = 3 colSuccess = 4 colDebug = 5 ) fu...
package main //暴力dfs,会超时 //func canJump(nums []int) bool { // if len(nums) == 0 { // return false // } // return dfs(nums, 0) //} // //func dfs(nums []int, now int) bool { // if now >= len(nums) - 1 { // return true // } // if nums[now] == 0 { // return false // } // for i := nums[now]; i >= 1; i-- { // if dfs(num...
// Copyright (c) 2015 Klaus Post, released under MIT License. See LICENSE file. // +build go1.7 package shutdown import ( "context" "fmt" "testing" "time" xcontext "golang.org/x/net/context" ) // otherContext is a Context that's not one of the types defined in context.go. // This lets us test code paths that ...
package kube import ( "testing" "github.com/google/go-cmp/cmp" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/apimachinery/pkg/runtime" sfv1alpha1 "github.com/openshift/splunk-forwarder-operator/api/v1alpha1" ) const ( instanceName = "test" instanceNamespace = "openshift-test" image ...
package main import ( "bitbucket.org/tebeka/selenium" "flag" "fmt" "gopkg.in/mgo.v2" "gopkg.in/mgo.v2/bson" "log" "net/http" "strconv" ) type Screenshot struct { Url string Data []byte } func main() { mongoHost := flag.String("mongo-host", "127.0.0.1", "mongo host") httpPort := flag.Int("port", 8080, "h...
package s3 import ( "context" "io" "github.com/aws/aws-sdk-go/aws" "github.com/aws/aws-sdk-go/service/s3" "github.com/sirupsen/logrus" "github.com/yunify/qscamel/constants" "github.com/yunify/qscamel/model" "github.com/yunify/qscamel/utils" ) // Deletable implement destination.Deletable func (c *Client) Del...
package models import ( "errors" "time" "github.com/badoux/checkmail" "github.com/jinzhu/gorm" ) type User struct { ID uint32 `gorm:"primary_key;auto_increment" json:"id"` Username string `gorm:"size:255;not null;unique" json:"username"` Email string `gorm:"size:100;not null;unique" json:...
/* Copyright © 2023 SUSE LLC 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 dist...
package main import ( "flag" "fmt" "os" "sync" "text/tabwriter" "github.com/mayflower/docker-ls/cli/docker-ls/response" "github.com/mayflower/docker-ls/cli/util" "github.com/mayflower/docker-ls/lib" ) type repositoriesCmd struct { flags *flag.FlagSet cfg *Config } func (r *repositoriesCmd) execute(argv ...
package postal import ( "encoding/json" "github.com/cloudfoundry-incubator/notifications/cf" "github.com/cloudfoundry-incubator/notifications/models" "github.com/pivotal-cf/uaa-sso-golang/uaa" ) const ( EmailFieldName = "email" RecipientsFieldName = "recipient" EmptyIDForNonUser = ...
package main import ( "fmt" "net" "strings" ) func main() { //创建监听套接字 //listener,err:=net.Listen("tcp","127.0.0.1:8000") listener,err:=net.Listen("tcp","172.18.2.34:8000") if err!=nil{ fmt.Println("Net.Listen err",err) return } defer listener.Close() //监听客户端请求 for{ fmt.Println("正在监听客户端连接...") con...
package first import ( "go/ast" "github.com/bunniesandbeatings/go-flavor-parser/architecture" "github.com/davecgh/go-spew/spew" ) type TypeSpecVisitor struct { Context TypeSpec *ast.TypeSpec } func NewTypeSpecVisitor(context Context, typeSpec *ast.TypeSpec) *TypeSpecVisitor { return &TypeSpecVisitor{ contex...
package main import ( "fmt" "syscall" ) func getSecrets() (string, string, string) { var accessKey string var secretKey string var warn string if a, ok := syscall.Getenv("AWS_ACCESS"); ok { accessKey = a } else { warn += fmt.Sprintf("AWS_ACCESS env var is nil in operator deployment. Please set up AWS_ACCE...
package rpcd import ( "github.com/Cloud-Foundations/Dominator/lib/errors" "github.com/Cloud-Foundations/Dominator/lib/srpc" "github.com/Cloud-Foundations/Dominator/proto/fleetmanager" ) func (t *srpcType) PowerOnMachine(conn *srpc.Conn, request fleetmanager.PowerOnMachineRequest, reply *fleetmanager.PowerOnMachi...
package testhandler import ( "bytes" "context" "fmt" "log" "os" "strconv" "time" "github.com/modeckrus/firebase/firebasestorage" "cloud.google.com/go/firestore" cstorage "cloud.google.com/go/storage" gstorage "cloud.google.com/go/storage" firebase "firebase.google.com/go" Auth "firebase.google.com/go/au...
package main import ( "bufio" "os" "strconv" "fmt" "strings" ) func main() { reader := bufio.NewReader(os.Stdin) p_string, _ := ReadLine(reader) p, err := strconv.Atoi(p_string) check(err) q_string, _ := ReadLine(reader) q, err := strconv.Atoi(q_string) check(err) var kaprekars []int for i := q; i >= p;...
package rsi import ( "github.com/charlesfan/go-api/repository/user" "github.com/charlesfan/go-api/utils/log" ) type EmailLoginBody struct { Email string `json:"email" binding:"required"` Password string `json:"password" binding:"required"` } type loginService struct { // ---Repository--- user user.Repositor...
package transform import "testing" func TestInstall(t *testing.T) { install() }
/* Copyright 2019 The Knative 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, soft...
package main import ( "fmt" "time" ) func main() { var t = time.Now() // PROCURA ALGUM CASE QUE FOR TRUE switch { case t.Hour() < 12: fmt.Println("Bom dia") case t.Hour() < 18: fmt.Println("Boa tarde") default: fmt.Println("Boa noite") } }
package git import ( "path" "runtime" "strings" "testing" ) func TestDescribeCommit(t *testing.T) { t.Parallel() repo := createTestRepo(t) defer cleanupTestRepo(t, repo) describeOpts, err := DefaultDescribeOptions() checkFatal(t, err) formatOpts, err := DefaultDescribeFormatOptions() checkFatal(t, err) ...
package util import ( "fmt" "github.com/mndrix/tap-go" rspec "github.com/opencontainers/runtime-spec/specs-go" "github.com/opencontainers/runtime-tools/cgroups" ) // ValidateLinuxResourcesNetwork validates linux.resources.network. func ValidateLinuxResourcesNetwork(config *rspec.Spec, t *tap.T, state *rspec.Stat...
package valexa import ( "net/http" "io" "fmt" "net/url" "path" "strings" "bytes" "io/ioutil" "os" "encoding/pem" "encoding/base64" "encoding/json" "crypto" "crypto/sha1" "crypto/x509" "crypto/rsa" "time" ) //https://developer.amazon.com/public/solutions/alexa/alexa-skills-kit/docs/developing-an-al...
package api import ( "InkaTry/warehouse-storage-be/internal/http/admin/dtos" "InkaTry/warehouse-storage-be/internal/pkg/http/responder" "InkaTry/warehouse-storage-be/internal/pkg/stores" "context" "encoding/json" "errors" "github.com/gorilla/mux" "github.com/stretchr/testify/assert" "net/http" "net/http/http...
package mongo import ( "encoding/binary" "flag" "fmt" "time" . "../../base" "../../store" "github.com/golang/glog" "gopkg.in/mgo.v2" "gopkg.in/mgo.v2/bson" ) var mongo string func init() { flag.StringVar(&mongo, "mongo", "mongodb://127.0.0.1/stock", "mongo uri") store.Register("mongo", &Mongo{}) } func...
package bot import ( "fmt" "log" "time" "github.com/anihouse/bot/config" "github.com/bwmarrin/discordgo" "github.com/robfig/cron" "github.com/sirupsen/logrus" ) type modules map[string]Module // build variables var ( Version string ) var ( logger *logrus.Logger ) // bot instanses var ( Session *discordg...
// +build remoteclient package adapter import ( "context" "encoding/json" "fmt" "io" "strings" "time" "github.com/containers/image/types" "github.com/containers/libpod/cmd/podman/varlink" "github.com/containers/libpod/libpod" "github.com/containers/libpod/libpod/image" "github.com/opencontainers/go-digest...
package main import ( "crypto/rsa" "encoding/json" "errors" "flag" "fmt" "io" "io/ioutil" "net/http" "os" "os/signal" "runtime/debug" "syscall" "time" "github.com/go-kit/kit/log" "github.com/go-kit/kit/log/level" kitprometheus "github.com/go-kit/kit/metrics/prometheus" "github.com/gorilla/handlers" ...
package config import ( "context" "sync" "github.com/pomerium/pomerium/internal/log" ) // The LogManager configures logging based on options. type LogManager struct { mu sync.Mutex } // NewLogManager creates a new LogManager. func NewLogManager(ctx context.Context, src Source) *LogManager { mgr := &LogManager{...
package dynamic_programming import ( "fmt" "testing" ) func Test_isScramble(t *testing.T) { res := isScramble("great", "rgeat") res2 := isScramble("abcde", "caebd") fmt.Println(res, res2) }
package functions import "math" // ReLU For activation function // f(x) = max(0,x) for All x in R. func ReLU(x float64) float64 { const ( Overflow = 1.0239999999999999e+03 Underflow = -1.0740e+03 NearZero = 1.0 / (1 << 28) // 2**-28 ) switch { case math.IsNaN(x) || math.IsInf(x, 1): return x case math...
package main import ( "fmt" "io/ioutil" "os" "os/exec" "strings" log "github.com/sirupsen/logrus" "github.com/Luzifer/rconfig/v2" ) var ( cfg = struct { CleanEnv bool `flag:"clean" default:"false" description:"Do not pass current environment to child process"` EncryptionMethod string `flag:"en...
package main import ( "bytes" "fmt" "strconv" ) type IP uint32 func ParseIP(b []byte) IP { return IP(IP(b[0])<<24 + IP(b[1])<<16 + IP(b[2])<<8 + IP(b[3])) } func (ip IP) String() string { var bf bytes.Buffer for i := 1; i <= 4; i++ { bf.WriteString(strconv.Itoa(int((ip >> ((4 - uint(i)) * 8)) & 0xff))) if...
package virtual_security import ( "errors" "reflect" "testing" ) func Test_marginPosition_exitable(t *testing.T) { t.Parallel() tests := []struct { name string position *marginPosition arg float64 want error }{ {name: "保有数不足でエグジットできないなら、エラーを返す", position: &marginPosition{OwnedQuantity:...
// Copyright 2017 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...
// for, switch, break. package main import ( "fmt" ) func canNotBreakLoop() { fmt.Println("--- can not break the for loops ---") for i := 0; i < 10; i++ { switch i { case 3: fmt.Printf("%d hello\n", i) case 4: fmt.Printf("%d expected break the loop but can not\n", i) break default: fmt.Println(...
package utils import ( "bytes" "container/list" "crypto/rand" "encoding/base32" "encoding/json" "fmt" "io" "io/ioutil" mrand "math/rand" "net/http" "net/url" "regexp" "strings" "time" _const "github.com/IcanFun/utils/const" goi18n "github.com/nicksnyder/go-i18n/i18n" "github.com/pborman/uuid" ) con...
package tax import ( "errors" "strconv" ) type TableInput struct { TableCount int // 4 digits PeriodCount int // 1 digit TypeCount int // 1 digit Salary int // 5 digits Tax int // 5 digits } func convert(str string) (*TableInput, error) { if len(str) != 16 { return &TableInput{}, errors.Ne...