text
stringlengths
11
4.05M
package coremain const ( coreName = "CoreDNS" // CoreVersion is the current version of CoreDNS. CoreVersion = "1.0.4" serverType = "dns" )
// 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 certificate import ( "crypto/x509" "encoding/json" "encoding/pem" "reflect" "strings" "testing" "time" "chromiumos/tast/errors" ) func pemDecode(s string) ...
package main import ( "fmt" "time" ) func using_select() { fmt.Println("-------------- Multithreading select -------------------") c1 := make(chan string) c2 := make(chan string) go func() { for { time.Sleep(time.Second * 5) c1 <- "" } }() go func() { for { time.Sleep(time.Minute) c2 <- "...
/* Command line tool to try evaluating JSonnet. Demos: echo "{ a: 1, b: 2 }" | go run jsonnet_main/main.go /dev/stdin go run jsonnet_main/main.go test1.j go run jsonnet_main/main.go test2.j echo 'std.extVar("a") + "bar"' | go run jsonnet_main/main.go /dev/stdin a=foo */ package main import "github.com/strick...
package models type SSGAResponse struct { Data struct { FundType []struct { Key string `json:"key"` Name string `json:"name"` Size int `json:"size"` } `json:"fundType"` Funds struct { Etfs struct { ViewBy struct { Overview struct { Name string `json:"name"` } `json:"overview"...
package ifcli import ( "github.com/c-bata/go-prompt" ) var ( additionalSugKey = map[string]bool{} suggestions = []prompt.Suggest{ // A {Text: "ALTER", Description: "..."}, // B // C {Text: "CREATE", Description: "..."}, // D {Text: "DATABASE", Description: "..."}, {Text: "DATABASES", Descriptio...
package gemini import ( "net/http" "reflect" "testing" "time" ) func TestNewClient(t *testing.T) { tests := []struct { name string want *Client }{ { name: "valid", want: &Client{ BaseURL: "https://api.gemini.com", HTTPClient: &http.Client{ Timeout: 3 * time.Second, }, }, }, } ...
// 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 stmt import ( "reflect" "github.com/junhwong/goost/apm" "github.com/junhwong/goost/runtime" ) type ParamterFilter func(string, interface{}) (interface{}, error) type structedParams struct { names map[string]int val reflect.Value filters []ParamterFilter } var ( newParameterInvalidErr, Paramete...
package main import "fmt" func main() { s := "babad" fmt.Println(longestPalindrome(s)) } func longestPalindrome(s string) string { len := len(s) if len <= 1 { return s } // 回文起始位置 start := 0 // 回文串最大长度 max := 1 // 动态规划二维数组 dp := [][]bool{} for i := 0; i < len; i++ { dp = append(dp, make([]bool, len)) ...
/** * Copyright (c) 2018-present, MultiVAC Foundation. * * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. */ package sync import ( "github.com/multivactech/MultiVAC/configs/config" "github.com/multivactech/MultiVAC/model/shard" "github...
// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved. // See LICENSE.txt for license information. // package main import "github.com/spf13/cobra" func newCmdInstallationOperation() *cobra.Command { cmd := &cobra.Command{ Use: "operation", Short: "Manipulate installation operations managed by the...
package user import "time" type User struct { Username string `json:"username" pg:",use_zero"` DiscordId string `json:"discord_id" pg:",pk,use_zero"` Birthday time.Time `json:"birthday"` Anilist string `json:"anilist"` Waifu string `json:"waifu"` Admin bool `json:"admin" pg:",use_ze...
// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved. // See LICENSE.txt for license information. // package utility import ( "strings" "github.com/mattermost/mattermost-cloud/model" "github.com/pkg/errors" log "github.com/sirupsen/logrus" ) type cloudprober struct { cluster *model.Cluster...
package candyjs import ( "fmt" "reflect" "testing" "time" . "gopkg.in/check.v1" ) // Hook up gocheck into the "go test" runner. func Test(t *testing.T) { TestingT(t) } type CandySuite struct { ctx *Context stored interface{} } var _ = Suite(&CandySuite{}) func (s *CandySuite) SetUpTest(c *C) { s.ctx = ...
package api import ( "encoding/json" "io/ioutil" "log" "net/http" "github.com/def4ultx/mv-restapi/models" ) const httpURI = "https://s3-ap-southeast-1.amazonaws.com/ysetter/media/video-search.json" // RequestVideo get video metadata from httpURI and return SearchResponse func RequestVideo() (*models.SearchResp...
package main import ( "hello/handler" "hello/subscriber" "time" "github.com/micro/go-micro/v2/registry" "github.com/micro/go-micro/v2" log "github.com/micro/go-micro/v2/logger" "github.com/micro/go-micro/v2/registry/etcd" hello "hello/proto/hello" ) var etcdReg registry.Registry func init() { etcdReg = e...
package main import ( "fmt" ) func main() { var nome string = "Joao" switch nome { case "Ana": fmt.Println("É a Ana") case "Joao": fmt.Println("É o João") default: fmt.Println("Não conheço") } fmt.Println(nome) }
package leaderboard import ( "reflect" "testing" ) type testCase struct { name string scores []int32 alice []int32 ans []int32 } var testCases = []testCase{ {"1", []int32{100, 100, 50, 40, 40, 20, 10}, []int32{5, 25, 50, 120}, []int32{6, 4, 2, 1}}, {"2", []int32{100, 90, 90, 80, 75, 60}, []int32{50, 65...
package injector import ( "log" "strconv" "strings" corev1 "k8s.io/api/core/v1" ) const ( eventstoreEnabledKey = "eventstore/enabled" eventstorePortKey = "eventstore/port" eventstoreNames = "eventstore/names" evenstoreDefaultPort = 5600 ) func (i *injector) isEventstoreEnabled(pod *corev1.Pod) bool ...
package socketClient import ( "context" "fmt" "io" "net" ) // Request will send a request to the socket and return the bytes sent back. // It will close the socket at the end. // It takes a timeout value which will be used to wait for the output of the // socket. This is a read timeout. func Request(ctx context.C...
package httpsrv import ( "context" "github.com/k81/kate" ) type HelloHandler struct { BaseHandler } func (h *HelloHandler) ServeHTTP(ctx context.Context, w kate.ResponseWriter, r *kate.Request) { h.OKData(ctx, w, "hello world") }
// Package mailer contains a utility to send an smtp package mailer import ( "crypto/tls" "fmt" "log" "net/smtp" "strings" ) // Mail contains the information related to email. type Mail struct { SenderID string Password string ToIds []string CcIds []string BccIds []string Subject string Body ...
package controllers import ( "database/sql" "github.com/go-gorp/gorp" _ "github.com/mattn/go-sqlite3" r "github.com/revel/revel" "RecipeHosting/app/models" "fmt" "golang.org/x/crypto/bcrypt" ) // Global variable that stored the database object map var ( Dbm *gorp.DbMap ) // Initialize the Database by import...
// Copyright (c) 2017 Kuguar <licenses@kuguar.io> Author: Adrian P.K. <apk@kuguar.io> // // MIT License // // 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 //...
// 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 tokenizer provides encoding for tokens that can carry user data. // // Tokens are made up of base64url(iv,aes(pkcs7(ts,data)),hmac) // where the iv is random, and hmac signs iv,aes(...). package tokenizer
package lang import ( "reflect" "testing" ) func TestListToSlice(t *testing.T) { list := MakePair(MakeNumber(42), MakePair(MakeString("value"), Nil)) result := ListToSlice(list) expected := []Expr{MakeNumber(42), MakeString("value")} if len(result) != len(expected) { t.Errorf("Result has wrong length, expec...
/* * Copyright (c) 2019. * by Steve Brush, Iridium Developers */ // Iridium payments gateway JSON RPC API for golang package iridiumWalletdRPC // Version declaration module mame, version major, minor and patch func Version() (name string, major int, minor int, patch int) { return "iridiumdRPC", 0, 0, 1 }
package dmsg import ( "testing" "github.com/skycoin/skycoin/src/util/logging" "github.com/stretchr/testify/assert" "github.com/skycoin/dmsg/cipher" ) func TestNewTransport(t *testing.T) { log := logging.MustGetLogger("dmsg_test") tr := NewTransport(nil, log, cipher.PubKey{}, cipher.PubKey{}, 0, func(id uint16...
package uno import ( "fmt" "strconv" ) var ( NoCards = []int{} ) /* =========================================================== | 000 | ------- | | | 001~013 | Red | 1-9,skip,reverse,draw_two,0 | | 014~026 | Yellow | 1-9,skip,reverse,draw_two,0 ...
package main import ( "fmt" "strconv" ) func getQueensAttack(n int, k int, rQ int, cQ int, obstacles [][]int) (output int) { /* Args: n (int): [Chessboard Size Number. The Board will be nxn] k (int): [Number of obstacles on Chessboard.] rQ (int): [Row Number of Queen Position] ...
package main import ( "4d63.com/assets/exchangerates" "4d63.com/assets/portfolio" ) type Data struct { ExchangeRates exchangerates.ExchangeRates Portfolios []portfolio.Portfolio } func (d Data) Names() []string { names := []string{} for _, p := range d.Portfolios { names = append(names, p.Name) } return...
package main import ( "flag" "buffer" "time" "github.com/golang/glog" ) func init() { glog.MaxSize = 1024 * 1024 * 100 //最大100M flag.Set("alsologtostderr", "true") // 日志写入文件的同时,输出到stderr flag.Set("log_dir", "./log") // 日志文件保存目录 flag.Set("v", "1") // 配置V输出的等级。 flag.Parse() } func...
package requests import ( "encoding/json" "fmt" "io/ioutil" "net/http" "net/url" "strings" "time" "github.com/google/go-querystring/query" "github.com/atomicjolt/canvasapi" "github.com/atomicjolt/canvasapi/models" "github.com/atomicjolt/string_utils" ) // GetSISImportList Returns the list of SIS imports ...
package main import ( "fmt" "io/ioutil" "strings" ) // Reads all of the lines from the shia labeouf text file into memory func readFileIntoMem() []string { var filename = "shia-labeouf.txt" content, err := ioutil.ReadFile(filename) if err != nil { fmt.Println("Error Or Something") //Do something } lines ...
package handlers import ( "encoding/json" "fmt" "io/ioutil" "log" "net/http" "os" "path" "github.com/husobee/vestigo" "github.com/libgit2/git2go" "github.com/tmaesaka/cellar/config" ) // Repository type holds information about a repository. type Repository struct { Name string `json:"name"` // Unique name...
package main //hackerRank-Golang-test import ( "fmt" "net/http" "os" "hackerRank-Golang-test/driver" ph "hackerRank-Golang-test/handler/http" "github.com/go-chi/chi" "github.com/go-chi/chi/middleware" ) func main() { dbName := os.Getenv("DB_NAME") dbPass := os.Getenv("DB_PASS") dbHost := os.Getenv("DB_HO...
package main import ( "crypto/md5" "fmt" "encoding/hex" "crypto/des" "encoding/base32" ) func GetMD5Hash(text string) string { hasher := md5.New() hasher.Write([]byte(text)) return hex.EncodeToString(hasher.Sum(nil)) } func main() { str := "fweih...
package middlewares import ( "log" "github.com/dgrijalva/jwt-go" "gopkg.in/matryer/respond.v1" "net/http" "context" "os" ) func JwtMiddleware(next http.Handler) http.Handler { return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { tokenStr := r.Header.Get("Authorization") jwt_string :=...
package api import ( "context" "encoding/json" "fmt" "net/http" "strings" ) // CreateGithubActionRequest represents the accepted fields for creating // a Github action type CreateGithubActionRequest struct { ReleaseID uint `json:"release_id" form:"required"` GitRepo string `json:"git_...
package main import ( "fmt" "github.com/garyburd/redigo/redis" ) func main() { c, err := redis.Dial("tcp", "127.0.0.1:6379") if err != nil { fmt.Println("Connect to redis error", err) return } defer c.Close() _, err = c.Do("SET", "mykey", "sl") if err != nil { fmt.Println("redis set failed:", err) }...
/* Copyright 2017 The Kubernetes 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, ...
package user import ( internal "github.com/ernesto2108/AP_CreatyHelp/internal/storage/psql" "github.com/ernesto2108/AP_CreatyHelp/pkg/user/domain" ) type UsersStorageGateway interface { create(u *domain.CreateUserCmd) (*domain.User,error) update(u *domain.UpdateUserCmd) *domain.User getId(id int64) (*domain.User...
package test import ( "testing" "time" "github.com/muidea/magicOrm/orm" "github.com/muidea/magicOrm/provider" "github.com/muidea/magicOrm/provider/remote" ) func TestRemoteExecutor(t *testing.T) { orm.Initialize() defer orm.Uninitialize() config := orm.NewConfig("localhost:3306", "testdb", "root", "rootkit"...
package main import ( "context" "encoding/json" "errors" "fmt" "io/ioutil" "os" "regexp" "strings" "github.com/google/go-github/github" "golang.org/x/oauth2" ) var ( ghClient *github.Client ghCtx context.Context reHex = regexp.MustCompile("^#?([0-9a-fA-F]{3}|[0-9a-fA-F]{6})$") version = "master" ...
package dtoshoptrades import ( "github.com/tahmooress/motor-shop/internal/entities/models" "github.com/tahmooress/motor-shop/internal/pkg/query" "github.com/tahmooress/motor-shop/internal/pkg/server" ) type Request struct { ShopID models.ID `json:"shop_id"` server.Query } type Response struct { Data []models.S...
package closeflag import ( "errors" "sync" ) // CloseFlag is a simple object that has a close function that closes a channel and can be called many times type CloseFlag struct { mutex sync.Mutex closed bool closeChan chan (struct{}) // CloseFunc will be called the first time Close is called. It is allow...
// Copyright 2014 Marc-Antoine Ruel. All rights reserved. // Use of this source code is governed under the Apache License, Version 2.0 // that can be found in the LICENSE file. package main import ( "io/ioutil" "log" "os" "testing" "github.com/maruel/subcommands" "github.com/maruel/ut" ) // t.Parallel() canno...
/* Copyright 2022 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 read type repository interface { GetWidget(id uint) (Widget, error) GetAllWidgets() ([]Widget, error) } type Service interface { GetWidget(id uint) (Widget, error) GetAllWidgets() ([]Widget, error) } type service struct { r repository } func NewService(r repository) Service { return service{r: r} } f...
package main import ( "database/sql" "fmt" "os" ) // Up is executed when this migration is applied func Up_20170818120003(txn *sql.Tx) { databaseProvider := os.Getenv("DATABASE_PROVIDER") fmt.Printf("ENV is: %s, %s", databaseProvider, os.Getenv("MYSQL_ROOT_PASSWORD")) binaryDataType := "BYTEA" if databaseProv...
package main import "fmt" func main() { //no need for break statements //because by default there is no fallthrough in switches //which means if you forget a break the code won't continue //to check for matches after a case runs switch "Medhi" { case "Daniel": fmt.Println("Sup Daniel") case "Medhi": fmt.Pr...
package services import ( "context" "encoding/json" "errors" "fmt" "time" "traceip/internal/models" "traceip/internal/restclient" "github.com/go-redis/redis/v8" ) //CurrenciesService service to obtain information about currencies type CurrenciesService struct { RedisConn *redis.Client } //Sync allows us to...
package model import ( ) type CmsPrefrenceAreaProductRelation struct { AppId string `json:"appId" gorm:"type:bigint unsigned;"` // Id int `json:"id" gorm:"type:bigint;primary_key"` // PrefrenceAreaId string `json:"prefrenceAreaId" gorm:"type:bigint;"` // ProductId string `json:"p...
// generated by running "go generate" on project root package assets // Helper for rod var Helper = ` (frameId) => { // eslint-disable-line no-unused-expressions const rod = { element (selector) { return (this.document || this).querySelector(selector) }, elements (selector) { return (this.d...
package main import ( "fmt" "git.ronaksoftware.com/blip/server/internal/tools" "github.com/spf13/cobra" "io/ioutil" "os" ) /* Creation Time: 2019 - Oct - 16 Created by: (ehsan) Maintainers: 1. Ehsan N. Moosa (E2) Auditor: Ehsan N. Moosa (E2) Copyright Ronak Software Group 2018 */ func in...
package frvradn import ( "encoding/json" "errors" "fmt" "strings" "github.com/prebid/openrtb/v19/openrtb2" "github.com/prebid/prebid-server/adapters" "github.com/prebid/prebid-server/config" "github.com/prebid/prebid-server/errortypes" "github.com/prebid/prebid-server/openrtb_ext" ) type adapter struct { u...
package driver // type Migrator interface { // HasTable(table string) bool // }
package market import "github.com/shopspring/decimal" type GetAllSymbolsLast24hCandlesticksAskBidResponse struct { Status string `json:"status"` Ts int64 `json:"ts"` Data []SymbolCandlestick `json:"data"` } type SymbolCandlestick struct { Amount decimal.Decimal `json:"amount"` O...
// Copyright (C) 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 t...
package main import ( "fmt" "net/http" /* "os" "os/signal"*/ "strings" "time" ) func startServer() { http.Handle("/", TestHandle(".")) s := &http.Server{ Addr: ":8080", } s.ListenAndServe() } func main() { fmt.Println("before listen") go startServer() fmt.Println("after liste...
// Copyright (C) 2019 Storj Labs, Inc. // See LICENSE for copying information. package storj_test import ( "testing" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" "storj.io/common/storj" "storj.io/common/testrand" ) func TestNewKey(t *testing.T) { t.Run("nil humanReadableKey", fu...
package users import ( "fmt" "io" "net/http" "net/url" "mainapp/app/middleware" "io/ioutil" ) // DB_BASE_URL Database Address const DB_BASE_URL string = "http://cooper-database-api:8080" // Type is an HTTP content-type key const Type string = "Content-Type" // contentT is an HTT...
/* Copyright 2021 The KodeRover 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, s...
// Package errorutils provides helper functions for dealing with errors. package errorutils // First returns the first non-nil error in a set of errors. func First(errors ...error) error { for _, err := range errors { if err != nil { return err } } return nil }
package sql import ( "database/sql" // "log" "sort" "strings" "unicode" "golang.org/x/text/runes" "golang.org/x/text/transform" "golang.org/x/text/unicode/norm" "github.com/BestPrice/backend/bp" "github.com/shopspring/decimal" ) var _ bp.Service = &Service{} type Service struct { db *sql.DB } func make...
package bfrequence import ( "bufio" "fmt" "io/ioutil" "log" "os" "sort" "strconv" ) func BuffFileInfo(filename string) { //Open method, returnerer et File objekt file, err := os.Open(filename) if err != nil { log.Fatalf("Oh no") } scanner := bufio.NewScanner(file) scanner.Split(bufio.ScanLines) fil...
package module import ( "bytes" "reflect" "testing" ) func TestModuleHCL(t *testing.T) { hclInput := ` import { name = "base-module" } import { name = "some-other-module" } pacman "openssh" { state = "present" } pacman "tmux" { state = "present" } ` hclModule, err := Load("main", &Config{}, bytes.NewB...
// A RPC Node type for RPC call package chord import ( "math/big" "net" ) type RPCNode struct { O *Node Listen net.Listener } /* method used for rpc call: FindSuccessor Notify GetData GetValue GetPredecessor SetSuccessor SetPredecessor */ func (o *RPCNode) FindSuccessor(pos *Looku...
package azure import ( "context" "fmt" "strconv" "strings" "github.com/pkg/errors" "yunion.io/x/jsonutils" api "yunion.io/x/onecloud/pkg/apis/compute" "yunion.io/x/onecloud/pkg/cloudprovider" "yunion.io/x/onecloud/pkg/multicloud" ) // todo: 虚拟机规模集不支持 // 注: 因为与onecloud后端服务器组存在配置差异,不支持同步未关联的后端服务器组 // 应用型LB:...
// Copyright 2014 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 ( "fmt" "gitgo/src/test/geometry" "image/color" ) func main() { q := geometry.Point{1, 2} p := geometry.Point{4, 6} fmt.Println(geometry.Distance(p, q)) fmt.Println(p.Distance(q)) m := geometry.Point.Distance fmt.Println(m(q, p)) //三角形周长 perim := geometry.Path{ {1, 1}, {5, 1}, {5...
package matcher import ( jsonEnc "encoding/json" "errors" "sync" "github.com/antonmedv/expr" "github.com/antonmedv/expr/vm" "github.com/mylxsw/adanos-alert/internal/repository" "github.com/mylxsw/adanos-alert/pkg/helper" "github.com/mylxsw/adanos-alert/pkg/json" "github.com/mylxsw/adanos-alert/pkg/misc" ) /...
package main func main() { for ;;_ { } }
package main import ( "os" ) const Name = "gch" const Version = "0.1.1" func main() { cli := &CLI{ outStream: os.Stdout, errStream: os.Stderr, } os.Exit(cli.Run(os.Args)) }
package main import ( "bufio" "fmt" "os" "reflect" ) // main Manueller Test für den PO (Überprüfungstest) func main() { ui := Ui{} cfg := Cfg{ N: 3, Reizdauer: 2000, AnzahlReize: 10, Probant: "Peter", } onStart := func() { r := Reiz{ Buchstabe: "A", Index: 1, Anzahl: ...
package main import ( "net" "net/http" "net/url" "testing" "github.com/DonnchaC/oniongateway/util" ) func TestNewRedirect(t *testing.T) { listener, err := net.Listen("tcp", "127.0.0.1:0") defer listener.Close() if err != nil { t.Fatalf("Failed to create a listener: %s", err) } server, err := NewRedirect(...
package model // Author ... type Author struct { ID uint `db:"id"` Name string `db:"name"` Year string `db:"year"` }
package user import ( "database/sql" "errors" "time" "github.com/uw-thalesians/perceptia-servers/gateway/gateway/session" mssql "github.com/denisenkom/go-mssqldb" uuid "github.com/satori/go.uuid" ) type MsSqlStore struct { database *sql.DB } // NewMsSqltore constructs a new MsSqlStore. // If *sql.DB is nil...
package v1alpha1 import ( "github.com/kotalco/kotal/apis/shared" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" ) // NodeSpec defines the desired state of Node type NodeSpec struct { // Network is the Filecoin network the node will join and sync Network FilecoinNetwork `json:"network"` // Resources is node comput...
package main import ( "bufio" "fmt" "os" "unicode" ) func main() { in := bufio.NewReader(os.Stdin) input, _ := in.ReadString('\n') var alphabet = map[string]bool{ "a": false, "b": false, "c": false, "d": false, "e": false, "f": false, "g": false, "h": false, "i": false, "j": false, "k": ...
package experiment import "fmt" type experimentNotFoundError struct { experimentName string } func (err *experimentNotFoundError) Error() string { return fmt.Sprintf(`experiment: Experiment "%s" not found`, err.experimentName) } type taskRunError struct { experimentName string err error } func (err ...
package domain import ( "time" "github.com/jeansferreira/api-b2w-planetas/helpers" "gopkg.in/mgo.v2/bson" ) // The representation of a created planet type Planeta struct { ID bson.ObjectId `bson:"_id" json:"id,omitempty"` Nome string `bson:"nome" json:"nome,omitempty"` Clima...
package main import ( "fmt" "encoding/json" "io" "net/http" "net/http/httptest" "reflect" "testing" ) type StubPlayerStore struct { stores map[string]int winCalls []string league []Player } func (s *StubPlayerStore) GetPlayerScore(name string) int { score := s.stores[name] return score } fun...
//MIT License // //Copyright (c) 2020 targyz // //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, pub...
package main import( "fmt" "sort" ) type person struct { First string Last string age int } type ByFirst []person func (bn ByFirst) Len() int { return len(bn) } func (bn ByFirst) Swap(i, j int) { bn[i],bn[j] = bn[j], bn[i] } func (bn ByFirst) Less(i, j int) bool { return bn[i].First < bn[j].Firs...
// description : A read-write TCP client that takes command line arguments (like the real nc) // author : Tom Geudens (https://github.com/tomgeudens/) // modified : 2016/07/24 // package main import ( "io" "log" "net" "os" ) func mustCopy(dst io.Writer, src io.Reader) { _, err := io.Copy(dst, src) if er...
package SmartAuth import ( "bytes" "encoding/json" "errors" "fmt" "github.com/Tnze/go-mc/yggdrasil" "github.com/google/uuid" "github.com/spf13/viper" "net/http" "strings" "sync" "time" ) type Tokens struct { AccessToken string `json:"accessToken"` ClientToken string `json:"clientToken"` } var ( syncLoc...
// Package carbone provide an SDK to communicate with Carbone Render // Carbone is the most efficient report generator // It render from a JSON and template into PDF, DOCX, XLSX, PPTX, ODS and many more reports package carbone import ( "bytes" "crypto/sha256" "encoding/hex" "encoding/json" "errors" "fmt" "io" ...
package main import "fmt" // 001 Methods type person struct { first string last string } type secretAgent struct { person ltk bool } func (s secretAgent) speak() { fmt.Println("I am", s.first, s.last, " -ajan konuştu") } func (p person) speak() { fmt.Println("I am", p.first, p.last, " -insan konuştu") } // 0...
package main import "fmt" func main() { meetShortDeclaration() } func meetShortDeclaration() { // short declaration x := 42 // normal declaration var y = 48 // using package fmt to emit a message fmt.Println("y => ", y, ", x => ", x) }
// Copyright 2019 Google 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 w...
package main import ( "bufio" "fmt" "image" "image/color" "image/png" "log" "math" "math/rand" "os" "sort" "strings" "github.com/gonum/stat" "github.com/llgcode/draw2d/draw2dimg" ) const ( terminateThreshold = 0.01 maxIters = 10 expandCoeff = 2 contractCoeff = 0.5 shrinkCoeff ...
package main import ( "easyquery/examples/pkg/db" "easyquery/examples/pkg/user" ) func main() { // AutoMigrate db.InitDB() defer db.CloseDB() current := db.Postgres current.Migrator().DropTable(&user.User{}) current.AutoMigrate(&user.User{}) current.Migrator().DropTable(&user.Role{}) current.AutoMigrate(&us...
package router import ( "github.com/futurehomeno/fimpgo" log "github.com/sirupsen/logrus" "github.com/thingsplex/easee-ad/model" ) // SendChangerModeEvent sends fimp event func (fc *FromFimpRouter) SendChangerModeEvent(chargerID string, mode string, oldMsg *fimpgo.Message) error { msg := fimpgo.NewStringMessage("...
// Copyright 2019 The ChromiumOS Authors // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. package hardware import ( "context" "time" "github.com/shirou/gopsutil/v3/mem" "chromiumos/tast/local/bundles/cros/hardware/memtester" "chromiumos/tast/testing" ) fu...
package main import ( "bufio" "crypto/sha1" "errors" "flag" "fmt" "html/template" "io" "log" "net/http" "os" "path/filepath" "strconv" "strings" "time" ) var initial_days = flag.Int( "initial_days", 14, "How many days to display initially") var listen_address = flag.String( "listen_address", "", "L...
package dao import ( "sync" "math" "math/rand" "fmt" "log" _"os" model "service-monitor/models" mgo "gopkg.in/mgo.v2" "gopkg.in/mgo.v2/bson" ) type StreamsDAO struct { Server string Database string } var db *mgo.Database const ( COLLECTION = "streams" SLIDE = 1 MAXINT = 2147483647 MININT ...
package helper import "time" //DefaultLocation is default location of application timezone var DefaultLocation = time.FixedZone("UTC+7", 7 * 60 * 60) //DatetimeFormat is the default date time format to use var DatetimeFormat = "2006-01-02 15:04:05" //mysql datetime format (RFC3339)