text
stringlengths
11
4.05M
package main import ( "github.com/snwfdhmp/errlog" ) func main() { errlog.PrintRawStack() }
package testdata import "github.com/jackc/pgtype" // 3 Checking incoming native parameters; checking outgoing composite parameters. // входные параметры: 1 шт нативный параметр // выходные параметры: режим template.QueryRow: 1 параметр составной, кроме ошибки // GoDao: generate type GoDao3 struct { // language=Post...
package avatar import ( "io/ioutil" "testing" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" ) func Test_RandomImage(t *testing.T) { avt := Avatar{ 290, 290, 4096, 4096, } img, err := avt.RandomImage([]byte("gogs@local")) require.NoError(t, err) assert.Equal(t, 290, img.Bound...
package gocube import "errors" // A Rotation is a way of rotating the entire // cube around the x, y, or z axes. // There are 9 total rotations, 0 through 8. // The first three rotation values are x, y, and z. // The next three are x', y', and z'. // The final three are x2, y2, and z2. type Rotation int // NewRotati...
package dnslb import ( crand "crypto/rand" "encoding/hex" "errors" "fmt" "strings" "time" "github.com/Cloud-Foundations/golib/pkg/log" ) type blockedType struct { IP string IpExpires time.Time OwnerId string OwnerExpires time.Time } func parseBlocked(txts []string) (*blockedType, error)...
package main import ( "fmt" "errors" "math/rand" ) type Character interface { getHp() int attack() int defend(dmg int) scream() init() } type Player struct { hp int damage int defense int phrase string healingPotions int } func (p *Player) scream() { fmt.Println(p.phrase) } func (p *Player) getHp() ...
// // Copyright (c) SAS Institute 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 agre...
package game import ( "c-server/model" "fmt" "reflect" uuid "github.com/satori/go.uuid" ) //用户中心 type Webcenter struct { Name string } type WebcenterActions interface { Login(interface{}) []byte Register(interface{}) interface{} } func (wb Webcenter) Login(req ClientMessage) { res := ResponseData{} fmt.Pr...
package feed import ( "net/http" "time" ) // Default HTTP client timeout. const timeout = 3 * time.Second func newHTTPClient() *http.Client { return &http.Client{Timeout: timeout} }
//nolint:scopelint,gosec // we don't care about these linters in test cases package serializer_test import ( "errors" "fmt" "math/rand" "sort" "testing" "github.com/stretchr/testify/assert" "github.com/iotaledger/hive.go/serializer/v2" ) const ( TypeA byte = 0 TypeB byte = 1 aKeyLength =...
// SPDX-License-Identifier: ISC // Copyright (c) 2014-2020 Bitmark Inc. // Use of this source code is governed by an ISC // license that can be found in the LICENSE file. package main import ( "fmt" "path/filepath" "github.com/bitmark-inc/bitmarkd/zmqutil" "github.com/bitmark-inc/exitwithstatus" ) const ( reco...
package main import ( "io" "log" "net/http" "path" "strings" ) // ShiftPath splits off the first component of p, which will be cleaned of // relative components before processing. `head` will never contain a slash and // `tail` will always be a rooted path without trailing slash. // Original: http://blog.meroviu...
// Copyright (C) 2016-Present Pivotal Software, Inc. All rights reserved. // This program and the accompanying materials are made available under the terms of the 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 Licen...
// Copyright 2019 Yunion // // 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 writi...
package main import ( "fmt" "net" "os/user" ) // type User string type Config struct { User *user.User TransientPath string StoragePath string } func HostIP() (string, error) { addrs, err := net.InterfaceAddrs() if err != nil { return "", err } for _, a := range addrs { if ipnet, ok := a.(...
package api import ( "github.com/cyberark/secretless-broker/bin/juxtaposer/timing" ) type OutputFormatter interface { ProcessResults([]string, map[string]timing.BackendTiming, int) error } type FormatterOptions map[string]string type FormatterConstructor func(FormatterOptions) (OutputFormatter, error)
// Package provider defines a built-in configuration providers that are // automatically registered by usrv. package provider import ( "os" "regexp" "strings" ) var ( invalidCharRegex = regexp.MustCompile(`[\s-\/]`) ) // EnvVars implements a configuration provider that fetches configuration values // from the en...
package main import ( "fmt" m "math" "github.com/MaxHalford/gago" ) // Rastrigin minimum is 0 reached in (0, ..., 0) // Recommended search domain is [-5.12, 5.12] func Rastrigin(X []float64) float64 { sum := 10.0 * float64(len(X)) for _, x := range X { sum += m.Pow(x, 2) - 10*m.Cos(2*m.Pi*x) } return sum } ...
package api import ( "github.com/antihax/optional" openapi "github.com/sapphi-red/go-traq" ) var ( allUsersCache []openapi.User currentUsersCache []openapi.User ) type NameUserMap map[string]*openapi.User func GetNameUserMap(includeSuspended bool, canUseCache bool) (NameUserMap, error) { users, err := GetU...
/* * @lc app=leetcode.cn id=623 lang=golang * * [623] 在二叉树中增加一行 */ type TreeNode struct { Val int Left *TreeNode Right *TreeNode } // @lc code=start /** * Definition for a binary tree node. * type TreeNode struct { * Val int * Left *TreeNode * Right *TreeNode * } */ ...
package app import ( "bytes" "context" "io" "net/http" "os" "path" "testing" "time" "github.com/google/go-cmp/cmp" "github.com/dikaeinstein/godl/internal/pkg/version" "github.com/dikaeinstein/godl/test" ) func TestListRemoteVersions(t *testing.T) { testClient := test.NewTestClient(test.RoundTripFunc(fun...
package main import ( "log" "github.com/LiveSocket/bot/service" "github.com/gammazero/nexus/v3/wamp" "github.com/gempir/go-twitch-irc/v2" ) func UserNoticeHandler(service *service.Service, client *Client) func(twitch.UserNoticeMessage) { return func(message twitch.UserNoticeMessage) { switch message.MsgID { ...
package bdd_spike_test import ( "encoding/json" "github.com/tebeka/selenium" "io/ioutil" "strings" "time" ) type Page struct { Wd selenium.WebDriver } func (p *Page) Refresh() error { return p.Wd.Refresh() } func (p *Page) WaitForNavigateToUrlContains(keyword string, timeout time.Duration) error { return p....
package main // 无重不可复选排列 func permute(nums []int) [][]int { res := make([][]int, 0) visited := make(map[int]bool, 0) // 注意:使用map表示visited path := make([]int, 0) // 注意:path的初始化长度为0 backtrace(nums, &path, &visited, &res) return res } func backtrace(nums []int, path *[]int, visited *map[int]bool, res *[][...
package smtpd import ( "fmt" "net" "net/smtp" "strings" "github.com/fitraditya/surelin-smtpd/config" "github.com/fitraditya/surelin-smtpd/data" "github.com/fitraditya/surelin-smtpd/log" ) var ( ports = []int{25, 2525, 587} ) type Mailer struct { Config config.SmtpConfig Store ...
// Copyright 2019 The Cockroach Authors. // // Licensed as a CockroachDB Enterprise file under the Cockroach Community // License (the "License"); you may not use this file except in compliance with // the License. You may obtain a copy of the License at // // https://github.com/cockroachdb/cockroach/blob/master/li...
package model // PathConfig represents the options available for the vault path template type PathConfig struct { Namespace string ContainerName string DeploymentName string }
package config // GetPlatformDefaultConfig gets the defaults for the platform func GetPlatformDefaultConfig() []byte { return []byte( `os: openCommand: 'cmd /c "start "" {{filename}}"' openLinkCommand: 'cmd /c "start "" {{link}}"'`) }
package view import ( "encoding/json" "fmt" "github.com/zput/innodb_view/log" "github.com/zput/innodb_view/mysql_define" "github.com/zput/innodb_view/print" "github.com/zput/ringbuffer" ) // ----------------- FspHeaderPage ------------------------------------// type FspHeaderPage struct { FileAllPage `yaml:"Fi...
package main import "fmt" func main() { numbers := []int{1, 2, 3, 4, 5, 6, 7, 8} for i := range numbers { fmt.Println("slice item", i, "is", numbers[i]) } countryCapitalMap := map[string]string{"flance": "paris", "italy": "rome", "japan": "tokyo"} for country := range countryCapitalMap { fmt.Println("capita...
package main import "fmt" func main() { var name string fmt.Print("input your name: ") fmt.Scan(&name) fmt.Printf("Hello %v", name) }
package orm import ( "github.com/jinzhu/gorm" ) // OrderDataStore is the order data store type OrderDataStore struct { DB *gorm.DB } // GetAll returns all the saved orders func (store *OrderDataStore) GetAll() (interface{}, int64, error) { orders := []Order{} connection := store.DB.Preload("CartItems.Product").F...
package leetcode import ( "reflect" "testing" ) func TestBank_Deposit(t *testing.T) { type fields struct { B []int64 } type args struct { account int money int64 } tests := []struct { name string fields fields args args want bool }{ { name: "testDeposit01", fields: fields{B: []...
package main import ( "fmt" "unicode" ) // unicode包提供数据和函数来测试Unicode代码点的一些属性 func main() { // 判断示例 exampleIs() // 对应示例 exampleSimpleFold() // 转换示例 exampleTo() } func exampleIs() { // constant with mixed type runes const mixed = "\b5Ὂg̀9! ℃ᾭG" for _, c := range mixed { fmt.Printf("For %q:\n", c) //...
package perceiving import ( "github.com/20zinnm/entity" "github.com/20zinnm/spac/client/physics" "github.com/20zinnm/spac/common/net/downstream" "github.com/faiface/pixel" "github.com/faiface/pixel/imdraw" "github.com/faiface/pixel/pixelgl" "github.com/google/flatbuffers/go" "github.com/jakecoffman/cp" "image...
package main import ( "flag" "fmt" "os" "bufio" "time" "github.com/nsf/termbox-go" "github.com/inazak/cpu3bit" ) const ( fgColor = termbox.ColorWhite bgColor = termbox.ColorBlack fgEmColor = termbox.ColorBlack bgEmColor = termbox.ColorWhite ) var display = []string{ //012345678901234567...
package main import "fmt" func main() { fmt.Println("here are more numbers... utF8") for z := 0; z < 200; z++ { fmt.Printf("%d \t %b \t %#x \t %q \n", z, z, z, z) } }
package bufferpool import ( "log" "os" "runtime" "sync/atomic" "unsafe" ) type BufferPool interface { Alloc(length int) ([]byte, error) Release(buffer []byte) } /* * array / map ~= 30 : 1 * integer assignment performace * num array map * 1000*1000 385us 11788 us * 1000*1000*1000 3...
package raft // specify a done channel for cancellation, ensures that only one goroutine that // sends to ch can be effective func sendWithCancellation(ch chan struct{}, done chan struct{}) { // for { // seems meaningless // select { // case <-done: // return // default: // select { // case ch <- struc...
package commands import ( "fmt" "strings" "time" "github.com/go-telegram-bot-api/telegram-bot-api" ) // GlobalCommand will handle a /global command from a chat, and give back the global scoreboard. type GlobalCommand struct { bot *tgbotapi.BotAPI } // SetBotAPI is used to make the bot api available for the han...
package main import ( "encoding/json" "fmt" "io/ioutil" "net/http" "os" "strings" "time" ) const ( TIMEOUT = 60 METHOD_POST = "POST" EXIT_CODE = -1 BODY_TYPE = "application/json" ZERO = 0 ) var client *HttpClient type HttpClient struct { Client *http.Client } func NewHttpClient(timeout ...
package main import ( "fmt" "gitgo/src/test/popcount" ) func main() { fmt.Println(popcount.PopCount(6)) fmt.Println(popcount.PopCountWithForLoop(6)) fmt.Println(popcount.PopCountWithBitMove(6)) fmt.Println(popcount.PopCountWithCleanLowest(6)) }
package controllers import ( "btcu-final/clientSDK" "btcu-final/server/models" "btcu-final/server/utils" "fmt" "github.com/astaxie/beego" "log" "time" ) type RegisterController struct { beego.Controller } func (this *RegisterController) Get() { this.TplName = "register.html" } //处理注册 func (this *RegisterCo...
package pkg import ( "context" "fmt" "github.com/machinebox/progress" "github.com/rylio/ytdl" "log" "net/http" "net/url" "os" "path" "strconv" "sync" "time" ) type worker struct { *State uri url.URL baseFileName string mp4File string mp3File string } type dispatcher struct { newT...
package main //309. 最佳买卖股票时机含冷冻期 //给定一个整数数组,其中第i个元素代表了第i天的股票价格 。​ // //设计一个算法计算出最大利润。在满足以下约束条件下,你可以尽可能地完成更多的交易(多次买卖一支股票): // //你不能同时参与多笔交易(你必须在再次购买前出售掉之前的股票)。 //卖出股票后,你无法在第二天买入股票 (即冷冻期为 1 天)。 //示例: // //输入: [1,2,3,0,2] //输出: 3 //解释: 对应的交易状态为: [买入, 卖出, 冷冻期, 买入, 卖出] //思路 单调递增 ,动态规划 //dp i 累计的当前最大钱数 状态:持有股票,不持有冻结中,不持有不...
package main import "fmt" type Element interface{} type vector struct { a []Element } func (p *vector) At(i int) Element { return p.a[i] } func (p *vector) Set(i int, e Element) { p.a[i] = e } func main() { v := new(vector) fmt.Println(*v) v.Set(1, "abc") fmt.Println(v) }
package main // User ... type User struct { ID int `json:"id"` Name string `json:"name"` } // RecipeCategory ... type RecipeCategory struct { ID int `json:"id"` ParentID int `json:"parent_id"` Name string `json:"name"` } // RecipeCategoryRecipe ... type RecipeCategoryRecipe struct { Recipe...
package oneagent_mutation import ( "testing" dynatracev1beta1 "github.com/Dynatrace/dynatrace-operator/src/api/v1beta1" "github.com/Dynatrace/dynatrace-operator/src/controllers/dynakube/deploymentmetadata" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" corev1 "k8s.io/api/core/v1" ) ...
package responder import ( "fmt" "github.com/family/translator" ) type _response int // Enum-like const declaration for supported response types const ( ChildAdditionSuccessful _response = iota ChildAdditionFailed _response = iota PersonNotFound _response = iota None _response ...
package main import ( "context" "flag" "fmt" "net/http" "os" "time" "golang.org/x/net/http2" "golang.org/x/net/http2/h2c" "github.com/dustin/go-humanize" _ "github.com/vicanso/diving/controller" "github.com/vicanso/diving/log" "github.com/vicanso/diving/router" _ "github.com/vicanso/diving/schedule" "g...
// Copyright 2021 The Perses 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 ...
// This is the setup file for this test suite. package main import ( "testing" "github.com/go-rod/rod" "github.com/ysmood/got" ) // test context. type G struct { got.G browser *rod.Browser } // setup for tests. var setup = func() func(t *testing.T) G { browser := rod.New().MustConnect() return func(t *tes...
package main import ( "log" "os" "text/template" ) type answer struct { Primary string Secondary string } func main() { ans := answer{Primary: "42", Secondary: "monkey"} tpl, err := template.ParseFiles("templates/answer.gotpl") if err != nil { log.Fatalln(err) } err = tpl.Execute(os.Stdout, ans) if e...
package operations // This file was generated by the swagger tool. // Editing this file might prove futile when you re-run the swagger generate command import ( "fmt" "github.com/go-openapi/runtime" strfmt "github.com/go-openapi/strfmt" ) // GetExportExecutionStatusObjectReader is a Reader for the GetExportExec...
package chance import ( "fmt" "math" "strings" ) // Float returns any valid floating point number in range [-MaxInt64..+MaxInt64] func (chance *Chance) Float() float64 { sign := 1 if chance.Bool() { sign = -1 } return float64(math.MaxInt64) * chance.r.Float64() * float64(sign) } // FloatN returns any floati...
// This work is subject to the CC0 1.0 Universal (CC0 1.0) Public Domain Dedication // license. Its contents can be found at: // http://creativecommons.org/publicdomain/zero/1.0 package vlc //#include <stdlib.h> //#include <vlc/vlc.h> import "C" import ( "syscall" "unsafe" ) type Media struct { ptr *C.libvlc_medi...
/* Упражнение: rot13Reader https://tour.golang.org/methods/23 */ package main import ( "io" "os" "strings" ) type rot13Reader struct { r io.Reader } func (rot13 rot13Reader) Read(b []byte) (int, error) { n, err := rot13.r.Read(b) var ( from = "NOPQRSTUVWXYZABCDEFGHIJKLMnopqrstuvwxyzabcdefghijklm" to ...
package event import ( "net/url" ) // GetEventSource gets the source to be used for CloudEvents originating from the dynatrace-service func GetEventSource() string { source, _ := url.Parse("dynatrace-service") return source.String() }
package utils import ( "testing" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" ) func TestSecureToken(t *testing.T) { t.Parallel() tok1 := SecureToken() assert.NotEmpty(t, tok1) tok2 := SecureToken() assert.NotEmpty(t, tok2) assert.NotEqual(t, tok1, tok2) } func TestHashPasswor...
package solutions type TrieNode struct { nodes [26]*TrieNode index int match map[int]bool } func palindromePairs(words []string) [][]int { var result [][]int root := &TrieNode{index: -1, match: make(map[int]bool)} for i, word := range words { addWord(root, word, i) } for i, w...
package main func twoSum(nums []int, target int) []int { valueToIdx := make(map[int][]int, 0) for i, v := range nums { valueToIdx[v] = append(valueToIdx[v], i) } for i := 0; i < len(nums); i++ { indexes := valueToIdx[target-nums[i]] if len(indexes) == 1 && i != indexes[0] { return []int{i, indexes[0]} ...
package main import ( "bytes" "encoding/gob" "errors" "fmt" "reflect" "strings" ) type Sslmeta struct { Ssl string User string } func main() { mList2 := map[string]interface{}{ "Ssl": "klp1", "User": "klpklp1", } var ssls *Sslmeta mapToStruct(mList2, &ssls) } func mapToStr...
package LRU import ( "fmt" "testing" ) func TestInit(t *testing.T) { lru := Init(3) if lru.dList.Capacity == 3 { t.Log("LRU Cache init success") } else { t.Error("LRU Cache init failed") } } func TestPut(t *testing.T) { lruCache := Init(3) lruCache.Put(2) lruCache.Put(3) lruCache.Put(2) lruCache.Put...
package main import ( "database/sql" "encoding/hex" //"encoding/json" "flag" //"fmt" _ "github.com/go-sql-driver/mysql" "github.com/olebedev/config" "github.com/shiyanhui/dht" "io" "log" // "net/http" _ "net/http/pprof" "os" "sort" "strings" //"code.google.com/p/go.text/encoding/charmap" //"code.googl...
package decoder import ( "bytes" "fmt" "go/ast" "go/parser" "go/token" "os" "os/exec" "path/filepath" "testing" "github.com/benbjohnson/megajson/generator/test" "github.com/stretchr/testify/assert" ) // Ensures a basic sanity check when generating the decoder. func TestWriteTypeGenerator(t *testing.T) { ...
// 183.Hands-on exercise#2 // fmt.Errorf() & errors.New() // 圖? package main import ( "encoding/json" "fmt" "log" ) type person struct { First string Last string Sayings []string } func main() { p1 := person{ First: "James", Last: "Bond", Sayings: []string{"Shaken, not stirred", "Any last wi...
package vkubelet import ( "context" "encoding/json" "fmt" "io" "net/http" "os" "strconv" "strings" "time" "github.com/Sirupsen/logrus" "github.com/gorilla/mux" "github.com/pkg/errors" "github.com/virtual-kubelet/virtual-kubelet/log" "k8s.io/kubernetes/pkg/kubelet/server/remotecommand" ) func loggingCon...
package indexing_test import ( "testing" "github.com/onsi/gomega" "github.com/sp0x/torrentd/bots" "github.com/sp0x/torrentd/indexer/search" . "github.com/sp0x/torrentd/storage/indexing" ) func TestKeyHasValue(t *testing.T) { g := gomega.NewWithT(t) item := &search.ScrapeResultItem{} chat := &bots.Chat{} it...
package ed25519 import ( "github.com/oasisprotocol/ed25519" "github.com/pkg/errors" ) const ( PublicKeySize = ed25519.PublicKeySize SignatureSize = ed25519.SignatureSize PrivateKeySize = ed25519.PrivateKeySize SeedSize = ed25519.SeedSize ) var ( ErrNotEnoughBytes = errors.New("not enough bytes") ) //...
package main import ( "encoding/json" "flag" "fmt" "io/ioutil" "net/http" "os" "strconv" "strings" ) type Resp struct { Code int64 Msg string Redirect string } type ResonseData struct { TaskId int64 UniqueSourceId string RenderUri string SensorName string Status int6...
package middleware import ( pb "github.com/jfeng45/grpcservice" "github.com/sony/gobreaker" "golang.org/x/net/context" "log" ) var cb *gobreaker.CircuitBreaker type CircuitBreakerCallGet struct { Next callGetter } func init() { var st gobreaker.Settings st.Name = "CircuitBreakerCallGet" st.MaxRequests = 2 st...
package main import ( netHttp "net/http" "sync" "time" "github.com/kelseyhightower/envconfig" "github.com/m-zajac/goprojectdemo/internal/adapter/github" "github.com/m-zajac/goprojectdemo/internal/api/grpc" "github.com/m-zajac/goprojectdemo/internal/api/http" "github.com/m-zajac/goprojectdemo/internal/api/http...
package main import ( "fmt" "strings" "testing" ) func TestCompress(t *testing.T) { tests := map[string]struct { str string want string }{ "1": { str: "aabcccccaaa", want: "a2b1c5a3", }, "2": { str: "abca", want: "abca", }, } for name, tt := range tests { t.Run(name, func(t *testin...
// Copyright [2015] [Ignazio Ferreira] // 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 ...
package model import ( "github.com/futurehomeno/fimpgo" "time" ) type MsgPipeline chan Message type FlowRunner func(ReactorEvent) type Message struct { AddressStr string Address fimpgo.Address Payload fimpgo.FimpMessage RawPayload []byte Header map[string]string CancelOp bool // if true , listen...
package services import ( "errors" "github.com/astaxie/beego/validation" "homework/models/datamodels" "homework/models/repositories" "log" ) type IProductService interface { GetProductByID(int64) (*datamodels.Product, error) GetAllProduct(int, int) ([]datamodels.Product, int, error) GetAllProductInfo(int, int...
package structs import ( "fmt" "strconv" "time" ) // ConvertUserMessageToUser — parse UserMessage (from JSON) to User. func ConvertUserMessageToUser(u UserMessage) (User, error) { ID, err := strconv.Atoi(u.ID) if err != nil { return User{}, fmt.Errorf("convert string to int error: %w", err) } user := User{ ...
package models import ( "encoding/json" "log" "strconv" "os" "testing" "github.com/go-redis/redis" ) var raw = json.RawMessage(`{ "global_id": 1704691, "system_object_id": "161", "ID": 161, "Name": "Парковка такси по адресу Карачаровское шоссе, дом 15", "AdmArea": "Юго-Восточный административный округ", "Dist...
package outer import ( "context" "sync" "github.com/qyqx233/go-tunel/lib" "github.com/qyqx233/go-tunel/lib/proto" "github.com/rs/zerolog/log" ) const ( RegState int = iota ) type reqConnChanStru struct { reqID int64 ch *chan lib.WrapConnStru } type transportImpl struct { proxyStarted bool // 是否监听转发端口 ...
package main import ( "os" "text/template" ) func main() { repoRoot, _ := os.Getwd() //dir := repoRoot + "/Chapter 2/Video 14" tpl, _ := template.ParseGlob(repoRoot + "/onur.gohtml") team := []string{"Muslera", "Falcao", "Luyindama", "Onyekuru"} tpl.Execute(os.Stdout, team) }
package arrays import ( "strings" ) func removeSpaces(s string) string { var new_s []rune for _, c := range s { if c == ' ' { continue } new_s = append(new_s, c) } return string(new_s) } func reverse(s string) string { n := len([]rune(s)) new_s := make([]rune, n) for i, v := range s { new_s[n-1-i]...
package main import "fmt" func Numbers(c chan int) { for i := 1; ; i++ { c <- i } return } func main() { ch := make(chan int) go Numbers(ch) for i := range ch { fmt.Println("Number: ", i) if i == 10 { break } } }
package main import "testing" func TestSatisfyTime(t *testing.T) { var time mtime time = toTime("9:00") action := eq c := &constraint{} c.vars = []constraintVariable{time} checkvalue := mtime(time) got := satisfyTime(action, c, checkvalue) if !got { t.Errorf("satisfyTime failed") } }
/* Application modules are test permutations testing various rlog output modules. */ package main import ( "github.com/rightscale/rlog" "github.com/rightscale/rlog/console" "github.com/rightscale/rlog/file" "github.com/rightscale/rlog/syslog" "os" "strings" ) func main() { //Setup syslog module facility, err...
/* Copyright: PeerFintech. All Rights Reserved. */ package gohfc import ( "strconv" "github.com/zhj0811/gohfc/pkg/parseBlock" "github.com/golang/protobuf/proto" "github.com/hyperledger/fabric-protos-go/common" "github.com/pkg/errors" ) type LedgerClientImpl struct { *sdkHandler } // queryByQscc 根据系统智能合约Qscc...
package psa import ( "fmt" "net/url" "github.com/evcc-io/evcc/util" "github.com/evcc-io/evcc/util/request" "github.com/evcc-io/evcc/util/transport" "golang.org/x/oauth2" ) // https://developer.groupe-psa.io/webapi/b2c/api-reference/specification // BaseURL is the API base url const BaseURL = "https://api.grou...
package models type Abonemen struct { UserID string `json:"userID"` SubscriberID string `json:"subscriberID"` Notification bool `json:"notification"` }
// Copyright (c) 2016-2019 Uber Technologies, 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...
package main import ( "fmt" "os" "os/signal" "github.com/growse/pcap" "github.com/jinzhu/gorm" ) var ( snaplen = 65536 ) // OpenFile opens or creates a file for json logging func OpenFile(path string) *os.File { var fo *os.File var ferr error if _, err := os.Stat(path); err == nil { fo, ferr = os.OpenFi...
package adapter import ( "fmt" "strings" "github.com/CenturyLinkLabs/pmxadapter" "github.com/GoogleCloudPlatform/kubernetes/pkg/api" "github.com/GoogleCloudPlatform/kubernetes/pkg/api/errors" "github.com/GoogleCloudPlatform/kubernetes/pkg/util" ) func (a KubernetesAdapter) CreateServices(services []*pmxadapter...
// Copyright 2016 The Go Authors. All rights reserved. // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. package gcbench import ( "fmt" "regexp" "strconv" "strings" "time" ) type GCTrace []GCCycle type GCCycle struct { // N is the 1-based index of this GC ...
func findMedianSortedArrays(nums1 []int, nums2 []int) float64 { m, n := len(nums1), len(nums2) length := m + n left, right := -1, -1 x, y := 0, 0 for i := 0; i <= length/2; i++ { left = right if x < m && (y >= n || nums1[x] < nums2[y]) { right = nums1[x] x++ } else { right = nums2[y] ...
package cli import ( "bytes" "testing" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/cli-runtime/pkg/genericclioptions" "github.com/tilt-dev/tilt/pkg/apis" "github.com/tilt-dev/tilt/pkg/apis/core/v1alpha1" ) func TestWait(t *...
package main import ( "bufio" "container/heap" "fmt" "io" "math" "os" "strconv" "strings" ) func main() { solve(os.Stdin, os.Stdout) } type edge struct { to int cost int } type vertex struct { id int dist int } type priorityQueue []vertex func (p priorityQueue) Len() int { return le...
package main type pizza struct { Cells map[point]*Cell H, L, R, C int Slices map[slice]*sliceInfo } type slice struct { x0, y0, x1, y1 int //score int } type sliceInfo struct { nbChamp, nbTomate int score int used bool } type point struct { x, y int } type Cell struct { Ingr...
/* * Lean tool - hypothesis testing application * * https://github.com/MikaelLazarev/lean-tool/ * Copyright (c) 2020. Mikhail Lazarev * */ package marketing import ( "context" "github.com/MikaelLazarev/willie/server/core" "github.com/MikaelLazarev/willie/server/helpers" "github.com/stretchr/testify/assert" ...
package handlers import ( mdl "diaria/models" route "diaria/routes" sec "diaria/security" "html/template" "log" "net/http" "strconv" ) func CreateFoodHandler(w http.ResponseWriter, r *http.Request) { log.Println("Create Food") if r.Method == "POST" && sec.IsAuthenticated(w, r) { name := r.FormValue("Name")...
// Copyright 2021 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" "encoding/json" "strings" "time" "chromiumos/tast/common/policy" "chromiumos/tast/common/servo" "chromiumos/tast/ctxutil" "chromiu...
// Copyright (c) 2021 Target Brands, Inc. All rights reserved. // // Use of this source code is governed by the LICENSE file in this repository. package docker import ( "bytes" "context" "encoding/json" "errors" "fmt" "io" "io/ioutil" "strings" "time" "github.com/docker/docker/api/types" "github.com/docke...
package main import ( "fmt" "main/utils" ) /* 给定一个整数数组 nums 和一个目标值 target,请你在该数组中找出和为目标值的那 两个 整数,并返回他们的数组下标。 你可以假设每种输入只会对应一个答案。但是,你不能重复利用这个数组中同样的元素。 示例: 给定 nums = [2, 7, 11, 15], target = 9 因为 nums[0] + nums[1] = 2 + 7 = 9 所以返回 [0, 1] 来源:力扣(LeetCode) 链接:https://leetcode-cn.com/problems/two-sum 著作权归领扣网...