text
stringlengths
11
4.05M
package main import ( "testing" ) func TestParseLine(t *testing.T) { if c := parseLine("#1 @ 829,837: 11x22"); c.id != 1 || c.x != 829 || c.y != 837 || c.w != 11 || c.h != 22 { t.Fatalf("Failed to parse: %v", c) } if c := parseLine("#583 @ 110,564: 10x23"); c.id != 583 || c.x != 110 || c.y != 564 ||...
package HumorChecker // "cirello.io/HumorChecker" import ( "bufio" "regexp" "strings" ) type Score struct { // Score is the sum of the sentiment points of the analyzed text. // Negativity will render negative points only, and vice-versa. Score float64 // Comparative establishes a ratio of sentiment per word ...
// Copyright 2019 Copyright (c) 2019 SAP SE or an SAP affiliate company. All rights reserved. This file is licensed under the Apache Software License, v. 2 except as noted otherwise in the LICENSE file. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in complian...
package parspack import ( "testing" "github.com/DataDrake/cuppa/version" "github.com/autamus/go-parspack/pkg" ) func TestEncode(t *testing.T) { packg := pkg.Package{ BlockComment: `# Copyright 2013-2020 Lawrence Livermore National Security, LLC and other # Spack Project Developers. See the top-level COPYRIGHT ...
package main import ( "fmt" ) type Errno uint var errors = [...]string{ 1: "operation not permitted", // EPERM 2: "no such file or directory", // ENOENT 3: "no such process", // ESRCH } func (e Errno) Error() string { if 0 <= int(e) && int(e) < len(errors) { return err...
package main import ( "fmt" "time" pg "github.com/test_go_pg/pg" "go.uber.org/zap" ) func main() { fmt.Println("Starting go-pg-migrations...") // Bootstrap check pg if err := pg.PGDBWrite.Ping(); err != nil { fmt.Println(pg.DBWriteConnectionError, zap.Error(err)) return } fmt.Println("PostgreSQL is ru...
// Copyright 2022 The ChromiumOS Authors // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. package example import ( "context" "fmt" "time" "chromiumos/tast/ctxutil" "chromiumos/tast/errors" "chromiumos/tast/local/chrome/ash" "chromiumos/tast/local/chrome/b...
package udwSqlite3Test import ( "github.com/tachyon-protocol/udw/udwSqlite3" "github.com/tachyon-protocol/udw/udwSync" "github.com/tachyon-protocol/udw/udwTest" ) func TestRangeCallback2() { db := udwSqlite3.MustNewMemoryDb() defer db.Close() num := udwSync.NewInt(0) db.MustGetRangeCallback(udwSqlite3.GetRange...
// +build all common pkg api proxy // Package api :: proxy_test.go package api import ( "bytes" "errors" "fmt" "io" "io/ioutil" "log" "net/http" "net/http/httptest" "testing" "github.com/stretchr/testify/assert" ) // MockProxyClient struct type MockProxyClient struct { Request *http.Request Respons...
package testing import ( "context" "time" "github.com/cloudfoundry/metric-store-release/src/pkg/persistence/transform" rpc "github.com/cloudfoundry/metric-store-release/src/pkg/rpc/metricstore_v1" "github.com/prometheus/prometheus/pkg/labels" "github.com/prometheus/prometheus/storage" ) type SpyDataReader stru...
package internal import ( "encoding/json" "fmt" "os" "os/exec" "path/filepath" "strconv" "strings" ) // ContainerUserName is the username of the user created in the container const ContainerUserName = "ahab" // Container contains all information regarding a container's configuration type Container struct { F...
package limiter import ( "context" "math" "net/http" "testing" "time" "github.com/m-zajac/goprojectdemo/internal/mock" ) func TestLimitedHTTPDoerRate(t *testing.T) { maxRate := 500.0 testTime := 200 * time.Millisecond doer := &mock.HTTPDoer{} limitedDoer := NewHTTPDoer(doer, maxRate) req, _ := http.NewR...
package hems import ( "errors" "strings" "github.com/evcc-io/evcc/core/site" "github.com/evcc-io/evcc/hems/ocpp" "github.com/evcc-io/evcc/hems/semp" "github.com/evcc-io/evcc/server" ) // HEMS describes the HEMS system interface type HEMS interface { Run() } // NewFromConfig creates new HEMS from config func ...
package machine import ( "errors" "fmt" "net/http" "sync" "time" "github.com/gorilla/websocket" //"github.com/aglyzov/log15" Log "github.com/sirupsen/logrus" ) //var Log = log15.New("pkg", "machine") type State byte type Command byte type ( Machine struct { URL string Headers http.Header Input ...
/* * OFAC API * * OFAC (Office of Foreign Assets Control) API is designed to facilitate the enforcement of US government economic sanctions programs required by federal law. This project implements a modern REST HTTP API for companies and organizations to obey federal law and use OFAC data in their applications. * ...
package main import "fmt" import "github.com/kovetskiy/lorg" import "github.com/kovetskiy/spinner-go" import "os" func getLogger() *lorg.Log { logger := lorg.NewLog() logger.SetFormat(lorg.NewFormat("${level:[%s]:left:true} %s")) return logger } func fatalf(format string, values ...interface{}) { if spinner.IsA...
package job import ( "context" "time" "github.com/mylxsw/adanos-alert/internal/repository" "github.com/mylxsw/adanos-alert/pkg/misc" "github.com/mylxsw/asteria/log" "github.com/mylxsw/glacier/infra" "go.mongodb.org/mongo-driver/bson/primitive" ) const RecoveryJobName = "recovery" type RecoveryJob struct { a...
package main import ( "errors" "fmt" "math" ) type Color int8 type Piece int8 type Direction int8 const ( BLACK_KING Piece = -2 BLACK_MAN Piece = -1 EMPTY Piece = 0 RED_MAN Piece = 1 RED_KING Piece = 2 RED Color = 1 BLACK Color = -1 NONE Color = 0 RED_FORWARD Direction = -1 BLACK_FORWA...
package Search_a_2D_Matrix func searchMatrix(matrix [][]int, target int) bool { if len(matrix) < 1 { return false } row, column := len(matrix), len(matrix[0]) pMin, pMax := 0, row*column-1 for pMin <= pMax { mid := (pMin + pMax) / 2 x := mid / column y := mid % column if matrix[x][y] == target { ...
// Tags handling // ================================================= package main import ( "gopkg.in/yaml.v2" // "fmt" "strings" "log" "io/ioutil" "path/filepath" ) type TagsData struct { Tags map[string][]string } var tagsData TagsData func populateTagsMap(foldersMap map[string]string) { ...
package models import ( "time" "github.com/juliotorresmoreno/unravel-server/db" ) // Profile modelo de usuario type Profile struct { Id uint `xorm:"bigint not null autoincr pk" json:"id"` Usuario string `xorm:"varchar(100) not null unique index" valid:"required" json:...
package controllers import ( "context" "time" . "github.com/onsi/ginkgo" . "github.com/onsi/gomega" corev1 "k8s.io/api/core/v1" "k8s.io/apimachinery/pkg/api/errors" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/apimachinery/pkg/types" "k8s.io/utils/pointer" "sigs.k8s.io/controller-runtime/pkg/client...
/* * Quay Frontend * * This API allows you to perform many of the operations required to work with Quay repositories, users, and organizations. You can find out more at <a href=\"https://quay.io\">Quay</a>. * * API version: v1 * Contact: support@quay.io * Generated by: Swagger Codegen (https://github.com/swagger...
package main import ( "flag" "log" "github.com/sahlinet/go-tumbo/pkg/app" "github.com/sahlinet/go-tumbo/pkg/client" "github.com/sahlinet/go-tumbo/pkg/config" ) func main() { var server = flag.Bool("server", false, "huhu") flag.Parse() log.Printf("Running as server: %t", *server) /*if *server { srv.Start(...
package DbService import ( "fmt" "ledger/DbDao" ) //func InsertRegister_PreExe(username string, password string, idNumber string, phoneNumber string) (bool, error) { // //admin WorkEntry admin // err := DbDao.InsertToDb_PreExe("INSERT INTO tb_User(username,password,idNumber,phoneNumber) VALUES (?,?,?,?)", username...
package lbricks type Event chan interface{} type Predicate func(interface{}) bool type Mapper func(interface{}) interface{} type MultiMapper func(...interface{}) interface{} type Reducer func(memo interface{}, element interface{}) interface{} type Subscriber func(interface{}) type Signal struct { event E...
package access import ( "context" "fmt" "net/http" "sync" "time" log "github.com/cihub/seelog" "github.com/jinzhu/gorm" httpr "github.com/julienschmidt/httprouter" "github.com/ok-borg/api/ctxext" "github.com/ok-borg/api/domain" ) type AccessKinds int type UserAccess struct { Update int Create int } // ...
package accounts import ( "testing" "github.com/acrossmounation/redpack/services" "github.com/go-spring/spring-boot" "github.com/segmentio/ksuid" "github.com/shopspring/decimal" . "github.com/smartystreets/goconvey/convey" ) type TestAccountServiceCreate struct { _ SpringBoot.JUnitSuite `export:""` ...
package main import ( "crypto/hmac" "crypto/md5" "crypto/sha1" "fmt" ) // 对字符串进行MD5哈希 func md5Str(data string) string { m := md5.New() m.Write([]byte(data)) my_md5 := m.Sum(nil) return fmt.Sprintf("%x", my_md5) } // 对字符串进行MD5哈希 func md5Str2(data string) string { my_md5 := md5.Sum([]byte(data)) return fmt.S...
package zy_logs import ( "bytes" "fmt" "runtime" ) type LogLevel int /*获取日志等级字符串*/ func getLevelText(level LogLevel) string{ switch level { case LogLevelAccess: return "ACCESS" case LogLevelDebug: return "DEBUG" case LogLevelTrace: return "TRACE" case LogLevelInfo: return "INFO" case LogLevelWarn: ...
package main import ( "os" "fmt" "github.com/spf13/cobra" //"github.com/sonataruby/smart-blockchain/cli" //"net/http" ) func main() { var smartCmd = &cobra.Command{ Use: "smart", Short: "The SMART Blockchain CLI", Run: func(cmd *cobra.Command, args []string) { }, } smartCmd.AddComma...
package main type CPUSpec struct { Request string Limit string }
package requests import ( "fmt" "net/url" "strings" "github.com/google/go-querystring/query" "github.com/atomicjolt/canvasapi" ) // RemoveUsageRightsGroups Removes copyright and license information associated with one or more files // https://canvas.instructure.com/doc/api/files.html // // Path Parameters: // ...
/* Copyright 2019 The Skaffold 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, sof...
package main import ( "fmt" "sync" ) //test 123 //test 123 //test 123 //test 123 //test 123 //test 123 //test 123 var ch1 chan int = make(chan int,1) //声明并 初始化channel 变量 var ch2 chan int = make(chan int,1) //声明并初始化channel变量 var chs = []chan int{ch1, ch2} var numbers = []int{1, 2, 3, 4, 5} ...
// SPDX-License-Identifier: Apache-2.0 // Copyright(c) 2018-2019 Saaras Inc. package webhttp import ( "bytes" "github.com/labstack/echo/v4" "github.com/saarasio/enroute/enroute-dp/saaras" "net/http" "github.com/sirupsen/logrus" ) type Proxy struct { Name string `json:"name" xml:"name" form:"name" query:"name...
// Copyright 2014 Dirk Jablonowski. All rights reserved. // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. package dualbutton import ( "fmt" "github.com/dirkjabl/bricker" "github.com/dirkjabl/bricker/device" "github.com/dirkjabl/bricker/net/packet" ) // GetBu...
// Copyright 2014 Dirk Jablonowski. All rights reserved. // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. package analogin import ( "fmt" "github.com/dirkjabl/bricker" "github.com/dirkjabl/bricker/device" "github.com/dirkjabl/bricker/net/packet" ) /* SetRang...
// Copyright 2017 The Cockroach Authors. // // Use of this software is governed by the Business Source License // included in the file licenses/BSL.txt. // // As of the Change Date specified in that file, in accordance with // the Business Source License, use of this software will be governed // by the Apache License, ...
package main import ( "flag" "io/ioutil" "os" "path/filepath" "sort" "strings" ) const tagSymbol string = "+" const indexFileName string = "_filetags.md" var whiteSpaceDelim = [...]string{" ", "_", ".", "[", "]"} type tagFiles struct { tag string file []string } type tags struct { tf []tagFiles } func i...
// Copyright 2018 The gVisor 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 agree...
package dynamodb import ( "bytes" "context" "encoding/binary" "fmt" "log" "math" "net/http" "time" "github.com/aws/aws-sdk-go/aws" "github.com/aws/aws-sdk-go/aws/awserr" "github.com/aws/aws-sdk-go/aws/credentials" "github.com/aws/aws-sdk-go/aws/request" "github.com/aws/aws-sdk-go/aws/session" godynamodb...
package leetcode /* 605. 种花问题 假设你有一个很长的花坛,一部分地块种植了花,另一部分却没有。可是,花卉不能种植在相邻的地块上,它们会争夺水源,两者都会死去。 给定一个花坛(表示为一个数组包含0和1,其中0表示没种植花,1表示种植了花),和一个数 n 。能否在不打破种植规则的情况下种入 n 朵花?能则返回True,不能则返回False。 示例 1: 输入: flowerbed = [1,0,0,0,1], n = 1 输出: True 示例 2: 输入: flowerbed = [1,0,0,0,1], n = 2 输出: False 注意: 数组内已种好的花不会违反种植规则。 输入的数组长度范...
package main import ( "fmt" "reflect" ) func main() { var nome = "Vitor" var idade = 25 // não precisa de var versao := 1.2 fmt.Println("String:", nome, " Idade :", idade, " Versão: ", versao) fmt.Println(reflect.TypeOf(nome)) fmt.Println(reflect.TypeOf(idade)) fmt.Println(reflect.TypeOf(versao)) }
package main /* Fetches several web pages simultaneously using the net/http package, and prints the URL of the biggest home page (defined as the most bytes in the response) */ import ( "fmt" "io/ioutil" "net/http" ) type HomePageSize struct { URL string Size int } func main() { urls := []string{ "http://ww...
package opsgenie import ( "bytes" "crypto/tls" "encoding/json" "fmt" "io/ioutil" "net" "net/http" "net/url" "time" log "github.com/Sirupsen/logrus" ) var timeout = time.Second * 30 var apiURL = "https://api.opsgenie.com" func startHeartbeatAndSend(args OpsArgs) { startHeartbeat(args) sendHeartbeat(args)...
package clicksend import ( "bytes" "encoding/base64" "encoding/json" "fmt" "io/ioutil" "net/http" ) var ( clicksendURL = `https://rest.clicksend.com/v3` ) type HttpClientAPI interface { Do(req *http.Request) (*http.Response, error) } type ClientAPI interface { SendSMS(s *SMS) (*SMSResponse, error) } // Cl...
// date: 2019-03-14 package balance type Node struct { nodeKey string spotValue uint32 } type nodesArray []Node func (p nodesArray) Len() int { return len(p) } func (p nodesArray) Less() { }
package main import ( "flag" "fmt" "io" "log" "net" "sync/atomic" "syscall" "github.com/514366607/reload" ) var ( port int isAccept int32 = 1 ) func main() { flag.IntVar(&port, "p", 8888, `端口`) flag.Parse() log.Printf("Actual pid is %d\n", syscall.Getpid()) listener, err := reload.GetListener(fm...
package main import "net/http" type Route struct { Name string Method string Pattern string HandlerFunc http.HandlerFunc } type Routes []Route var routes = Routes{ Route{ "Index", "GET", "/", Index, }, Route{ "Index", "HEAD", "/", Index, }, Route{ "Auth", "POST", "/aut...
package api import ( "encoding/json" "fmt" "io/ioutil" "net/http" "strings" "errors" "github.com/pborman/uuid" "log" ) type ContentDeliveryNetwork struct { Id string `json:"id"` Label string `json:"label"` Ips []string `json:"ips"` Hostnames []string `json:"hostnames"` } var db = m...
// SPDX-License-Identifier: MIT package core import ( "bytes" "fmt" "testing" "time" "github.com/issue9/assert/v3" "github.com/caixw/apidoc/v7/internal/locale" ) var _ fmt.Stringer = Erro func TestType_String(t *testing.T) { a := assert.New(t, false) a.Equal("ERRO", Erro.String()) a.Equal("SUCC", Succ.St...
//go:generate go get github.com/jteeuwen/go-bindata/go-bindata //go:generate go-bindata -o templates.go -pkg assets templates/... package assets
//go:build gofuzzbeta // +build gofuzzbeta package network import ( "context" "math/big" "testing" "time" "github.com/ethereum/go-ethereum/ethclient" abci "github.com/tendermint/tendermint/abci/types" tmjson "github.com/tendermint/tendermint/libs/json" "github.com/cosmos/cosmos-sdk/simapp" authtypes "gith...
package db import ( "context" "time" "go.mongodb.org/mongo-driver/mongo" "go.mongodb.org/mongo-driver/mongo/options" ) type DisconnectFunc func() func GetClient(uri string, username string, password string) (*mongo.Client, DisconnectFunc) { ctx, cancel := context.WithTimeout(context.Background(), 10*time.Secon...
package main import ( "bytes" "encoding/binary" "fmt" ) // every binary struct pack that google does seems to be in big endian /* SUBPROTOCOL_TAG_CONNECT_SUCCESS_SID = 0x0001 SUBPROTOCOL_TAG_RECONNECT_SUCCESS_ACK = 0x0002 SUBPROTOCOL_TAG_DATA = 0x0004 SUBPROTOCOL_TAG_ACK = 0x0007 return (struct.unpack(str('>H'...
/** * Copyright (c) 2016 Intel Corporation * * 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 ...
package client import ( "context" "net/url" "time" "github.com/go-kit/kit/endpoint" v1 "github.com/turao/go-worker/api/v1" ) // client wraps an http client and add a bunch of stuff to it type client struct { // dependencies // auth // server // logger (?) dispatch endpoint.Endpoint stop endpoint.Endp...
package errors import ( "encoding/json" "errors" "fmt" "testing" "github.com/stretchr/testify/suite" ) type Errors struct { suite.Suite } func TestErrors(t *testing.T) { suite.Run(t, new(Errors)) } func (s *Errors) TestStack() { // getPCs pcs := getPCs(0) if !s.True(len(pcs) > 0, "wrong pcs length") { ...
// Copyright 2019 The Cockroach Authors. // // Use of this software is governed by the Business Source License // included in the file licenses/BSL.txt. // // As of the Change Date specified in that file, in accordance with // the Business Source License, use of this software will be governed // by the Apache License, ...
// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved. // See LICENSE.txt for license information. // package api import ( "net/url" "strconv" "github.com/mattermost/mattermost-cloud/model" "github.com/pkg/errors" "github.com/sirupsen/logrus" ) func logSecurityLockConflict(resourceType string, lo...
// Copyright 2018 The Cockroach Authors. // // Use of this software is governed by the Business Source License // included in the file licenses/BSL.txt. // // As of the Change Date specified in that file, in accordance with // the Business Source License, use of this software will be governed // by the Apache License, ...
package models import ( "errors" "net/http" "strconv" "github.com/labstack/echo" ) // Product structure type Product struct { ID string `json:"id"` Name string `json:"name"` ListOrder int64 `json:"list_order"` OptionIDs []string `json:"option_ids"` CategoryID string `json:"category_...
package main import ( "math" ) func pp(n int) (a int, b int) { var fixn int = n var num, currentNear, currentNearTemp float64 var maxNo int var count int var flag bool = false for i := 2; i <= int(math.Floor(math.Log2(float64(n)))); i++ { num = math.Floor(math.Pow(float64(n), float64(1.0/float...
package diff import ( "testing" "github.com/containerum/kube-client/pkg/model" ) func TestDiff(t *testing.T) { var oldDepl = model.Deployment{ Containers: []model.Container{ { Name: "gateway", Image: "nginx", }, { Name: "feed", Image: "wordpress", }, }, } var newDepl = model.De...
package lc // Time: O(n) // Benchmark: 4ms 3.1mb | 89% 13% func minTimeToVisitAllPoints(points [][]int) int { max := func(x, y int) int { if x > y { return x } return y } abs := func(x int) int { if x < 0 { return x * -1 } return x } var dist int for i := 0; i < len(points)-1; i++ { x1 := ...
package clop import ( "bytes" "fmt" "go/format" "strings" ) func genStructName(k string) string { return k + "AutoGen" } func genVarName(varName string) string { return varName + "Var" } // 根据解析的函数名和参数, 生成结构体 func genStructBytes(p *ParseFlag) ([]byte, error) { var code bytes.Buffer var allCode bytes.Buffer...
// Copyright 2020 The ChromiumOS Authors // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. package policy import ( "context" "strings" "time" "chromiumos/tast/common/pci" "chromiumos/tast/common/policy" "chromiumos/tast/common/policy/fakedms" "chromiumos/t...
package commands import ( "github.com/brooklyncentral/brooklyn-cli/net" ) type CatalogEntity struct { network *net.Network } func NewCatalogEntity(network *net.Network) (cmd *CatalogEntity) { cmd = new(CatalogEntity) cmd.network = network return }
package weather import ( "encoding/json" "errors" "testing" "github.com/stretchr/testify/assert" ) type weatherProvider struct{} func (w weatherProvider) GetForecastData(country, state, city string, forecastDays uint, client httpClient) (map[string]interface{}, error) { data, err := getProviderTestDataJSON(tru...
package mondohttp import ( "net/http" "net/url" "strings" ) // NewAccountsRequest creates a request for a listing of the user's accounts. // https://getmondo.co.uk/docs/#list-accounts. func NewAccountsRequest(accessToken string) *http.Request { req, _ := http.NewRequest("GET", ProductionAPI+"accounts", nil) req....
package main import "fmt" func main() { } func isPalindrome(x int) bool { sX := fmt.Sprintf("%d", x) for i := 0; i < len(sX)/2; i++ { if sX[i] != sX[len(sX)-1-i] { return false } } return true }
package server import ( "errors" "github.com/asaskevich/govalidator" "github.com/sergeychur/avito_auto/internal/models" "net/http" "time" ) type Validator struct { TimeOut int } func NewValidator(timeOut int) *Validator { validator := new(Validator) validator.TimeOut = timeOut return validator } func (v *V...
package authlete import ( "fmt" "net/http" "time" "github.com/dodosuke/authlete-go/pkg/util" ) // AuthorizationRequest is a request to Authlete's /auth/authorization API. // // OAuth 2.0 authorization request parameters which are the // request parameters that the OAuth 2.0 authorization endpoint // of the servi...
package aggregatedprocessor import ( "context" "fmt" "strings" "sync" "go.opentelemetry.io/collector/component" "go.opentelemetry.io/collector/config/configmodels" "go.opentelemetry.io/collector/consumer" "go.opentelemetry.io/collector/processor/processorhelper" "go.uber.org/zap" ) type processorSettings st...
package main import( "database/sql" ) var db *sql.DB func main() { //user, port, database name db = getDB("root", "26257", "recipes") defer db.Close() initializeRoutes() }
package mypkg import "fmt" func PrintMe(s string) { fmt.Println(s) }
package main import "fmt" /* una variadic function es una funcion que admite un numero variable de parametros se especifica con 3 puntos antes del tipo, y se guarda en una slice */ func average(sliceFloat ...float64) { sum := 0.0 /* esta linea usa range para recorrer toda la slice e ir almacenando dos valores, el ...
// package main defines the executable for the bcc (bit code compiler) compiler. package main import ( "fmt" "os" "github.com/mkenney/8bit-cpu/cmp2/pkg/bcc" "github.com/bdlm/log/v2" ) func init() { //log.SetFormatter(&log.TextFormatter{DisableTTY: true}) log.SetLevel(log.DebugLevel) } func main() { var err ...
package main import ( //该包是用来使用框架接口的 "crypto/ecdsa" "crypto/sha256" "crypto/x509" "encoding/asn1" "encoding/base64" "encoding/json" "encoding/pem" "fmt" "math/big" shim "github.com/tjfoc/tjfoc/core/chaincode/shim" //该包是用来使用通信消息结构的 pb "github.com/tjfoc/tjfoc/protos/chaincode" ) const ( use_ecdsa = true ...
package main import ( "github.com/go-playground/validator" "go.uber.org/zap" "github.com/imouto1994/yume/internal/infra/config" httpProtocol "github.com/imouto1994/yume/internal/infra/http" "github.com/imouto1994/yume/internal/infra/migration" "github.com/imouto1994/yume/internal/infra/sqlite" "github.com/imou...
// package config holds the const of the configuration values // Right now it is just a thin wrapper around viper. If growing in // use or complexity it should probably have its own structs and // hide viper // also depending on the use, maybe more sources of config // TODO add tests package config import "github.com...
package customRoundrobin import ( "context" "google.golang.org/grpc/balancer/apis" "google.golang.org/grpc/metadata" "strings" "sync" "google.golang.org/grpc/balancer" "google.golang.org/grpc/balancer/base" "google.golang.org/grpc/grpclog" "google.golang.org/grpc/internal/grpcrand" ) const Name = "customRou...
package chart import ( "math" "sort" "github.com/wcharczuk/go-chart/drawing" ) // XAxis represents the horizontal axis. type XAxis struct { Name string Style Style ValueFormatter ValueFormatter Range Range Ticks []Tick } // GetName returns the name. func (xa XAxis) GetNa...
package createsubcommands import ( "fmt" snmpsimclient "github.com/inexio/snmpsim-restapi-go-client" "github.com/rs/zerolog/log" "github.com/spf13/cobra" "github.com/spf13/viper" "os" ) // CreateTagCmd represents the createTag command var CreateTagCmd = &cobra.Command{ Use: "tag", Args: cobra.ExactArgs(0),...
package main import ( "fmt" "os" "runtime" "github.com/rs/zerolog" "github.com/rs/zerolog/log" ) const ( defaultConfig = "config.yaml" exampleConfig = "config-example.yaml" myName = ` ✄╔════╗ ✄╚══╗═║ ✄──╔╝╔╝╔══╗╔╗╔╗╔══╗╔═╗╔══╗ ✄─╔╝╔╝─║║═╣║║║║║══╣║╔╝║╔╗║ ✄╔╝═╚═╗║║═╣║╚╝║╠══║║║─║╚╝║ ✄╚════╝╚══╝╚══╝╚══╝╚╝...
package gob import ( "reflect" "testing" ) func TestCodec(t *testing.T) { type Example struct { Field1 string Field2 int } example := &Example{ Field1: "field1", Field2: 128, } codec := Codec() marshal := codec.Marshaler() unmarshal := codec.Unmarshaler() data, err := marshal(example) if err != ...
package main import ( "crypto/md5" _ "expvar" "flag" "fmt" "io" "io/ioutil" "log" "net/http" _ "net/http/pprof" "os" "path/filepath" "sync" "time" humanize "github.com/dustin/go-humanize" "github.robot.car/cruise/swift-profiler/copier" ) const defaultGoroutineCount = 16 const defaultNumFiles = 120 con...
package controllers import ( "github.com/astaxie/beego" ) type Result struct { Response string } type MainController struct { beego.Controller } func (c *MainController) Get() { result := Result{Response: "OK"} c.Data["json"] = &result c.ServeJson() }
package main import ( "log" "github.com/cloudevents/sdk-go/pkg/cloudevents" keptn "github.com/keptn/go-utils/pkg/lib" ) /** * Here are all the handler functions for the individual event See https://github.com/keptn/spec/blob/0.1.3/cloudevents.md for details on the payload -> "sh.keptn.event.configuration.cha...
package golem import "crypto/rc4" type rc4ModeEcnryption struct { key []byte cipher *rc4.Cipher } // NewRc4Cipher returns a new rc4 cipher func NewRc4Cipher() Cipher { return &rc4ModeEcnryption{} } func (r *rc4ModeEcnryption) SetKey(key string) error { keylen := len([]byte(key)) if keylen < 1 || keylen > 2...
// Copyright 2020 The Cockroach Authors. // // Use of this software is governed by the Business Source License // included in the file licenses/BSL.txt. // // As of the Change Date specified in that file, in accordance with // the Business Source License, use of this software will be governed // by the Apache License, ...
package main import ( "bufio" "container/heap" "fmt" "log" "os" "sort" "strings" ) type ascend []visit func (s ascend) Len() int { return len(s) } func (s ascend) Less(i, j int) bool { return s[i].room < s[j].room } func (s ascend) Swap(i, j int) { s[i], s[j] = s[j], s[i] } func d2ts(d string) int { var h...
package codequalitybinding import ( "alauda.io/devops-apiserver/pkg/apis/devops/v1alpha1" devopsclient "alauda.io/devops-apiserver/pkg/client/clientset/versioned" "alauda.io/diablo/src/backend/api" "alauda.io/diablo/src/backend/errors" "alauda.io/diablo/src/backend/resource/common" "alauda.io/diablo/src/backend/...
package main import ( "fmt" "github.com/jwhett/gogo" ) func main() { var board gogo.Board fmt.Printf("Black: %d\nWhite: %d\n", gogo.BLACK, gogo.WHITE) board.PlayMove(gogo.BLACK, "d4") board.PlayMove(gogo.WHITE, "f3") board.PlayMove(gogo.BLACK, "c6") board.PlayMove(gogo.WHITE, "a19") board.PlayMove(gogo.BLAC...
package db import ( "context" "database/sql" "database/sql/driver" "errors" "fmt" "strings" "testing" "github.com/chadweimer/gomp/models" gomock "github.com/golang/mock/gomock" "github.com/samber/lo" ) func Test_postgres_GetSearchFields(t *testing.T) { type testArgs struct { fields []models.SearchField ...
package gsftp import ( "context" "fmt" "cloud.google.com/go/storage" "github.com/pkg/sftp" "google.golang.org/api/option" ) func GoogleCloudStorageHandler(ctx context.Context, bucketName string, opts ...option.ClientOption) (*sftp.Handlers, error) { client, err := storage.NewClient(ctx, opts...) if err != nil...
package pkg // PkgTemplate is the common template to generate encoded spack // package specs. var PkgTemplate = "" + `{{.BlockComment}} from spack import * class {{.Name}}({{.PackageType}}): {{if .Description}}"""{{.Description}}"""{{end}} {{if .Homepage}}homepage = "{{.Homepage}}"{{end}} {{if gt (len...
package pipelinetemplate import ( "log" "alauda.io/devops-apiserver/pkg/apis/devops/v1alpha1" devopsclient "alauda.io/devops-apiserver/pkg/client/clientset/versioned" "alauda.io/diablo/src/backend/api" ) // PreviewOptions used for render jenkinsfile type PreviewOptions struct { Source *v1alpha1.PipelineSource `...
package media import ( "fmt" ) type Multimedia interface { Mostrar() string } type ContenidoWeb struct { Multimedias []Multimedia } func (cw ContenidoWeb) Mostrar() { for _,i:= range cw.Multimedias{ fmt.Println(i) } } type Imagen struct { Titulo string Formato string Canales string } func (i *Imagen) Mo...