text
stringlengths
11
4.05M
package service import ( "github.com/facebookgo/inject" ) //s依赖注入 func AppService() *Object { var g inject.Graph baseService := BaseService{} g.Provide(&inject.Object{Value: baseService}) g.Populate() return &Object{ AppService: &baseService, } } type Object struct { AppService *BaseService }
package adapter import "github.com/case2912/go-curd-clean-architecture/domain" type UserController interface { CreateUser(domain.User) domain.User }
package majiangserver import ( cmn "common" "logger" ) func InitGlobalConfig() { logger.Info("init........config") //初始化全局变量--翻对应的颗数 cfg := cmn.GetDaerGlobalConfig("551") if cfg != nil { KeAmount[0] = cfg.IntValue } else { logger.Error("GetDaerGlobalConfig return nil") } cfg = cmn.GetDaerGlobalConfig("5...
package services import ( "goscrum/server/models" "github.com/jinzhu/gorm" ) type ParticipantService struct { db *gorm.DB } func NewParticipantService(db *gorm.DB) ParticipantService { return ParticipantService{db: db} } func (service *ParticipantService) GetParticipantByUserId(userId string) (*models.Particip...
package accounts import ( "context" "github.com/CMedrado/DesafioStone/pkg/domain/entities" "github.com/google/uuid" ) func (a *Storage) ReturnAccountID(id uuid.UUID) (entities.Account, error) { var account entities.Account statement := `SELECT * FROM accounts WHERE id=$1` err := a.pool.QueryRow(context.Backgrou...
/* 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...
/* @File : httpServer.go @Time : 2022/02/08 10:13:42 @Author : lpp @Version : 1.0.0 @Contact : golpp@qq.com @Desc : RESTFUL 服务 */ package httpServer import ( "grpc-rest/protos" "net/http" "github.com/gin-gonic/gin" "github.com/golang/protobuf/jsonpb" ) // RestServer 为订单服务实现了一个 REST 服务。 typ...
// Copyright (c) 2020 - for information on the respective copyright owner // see the NOTICE file and/or the repository at // https://github.com/hyperledger-labs/perun-node // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may...
package main import ( "fmt" "os" ) type Piece struct { allowed map[string]([]string) } type Direction struct { modx int mody int out string } var pieces = make(map[int]Piece) var directions = make(map[string]Direction) func main() { var x, y, ex int fmt.Scanf("%d %d", &x, &y) var cmap = make([][]int, y)...
// 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 firmware import ( "context" "strconv" "time" "chromiumos/tast/common/servo" "chromiumos/tast/errors" "chromiumos/tast/remote/firmware" "chromiumos/tast/remot...
package errors // cause.go contains interface and unwrap func for the deprecated causer interface we adopted from pkg/errors // causer returns the underlying error, a error without cause should return itself. // It is based on the private `causer` interface in pkg/errors, so errors wrapped using pkg/errors can also b...
package client import ( "errors" "fmt" "github.com/prometheus/client_golang/prometheus" push "github.com/prometheus/client_golang/prometheus/push" ) var ( promNamespace = "nemesis" // Prometheus metrics // Total resources scanned totalResourcesCounter = prometheus.NewCounter( prometheus.CounterOpts{ Na...
package main import ( "log" "github.com/spf13/cobra" ) func install(cmd *cobra.Command, args []string) { log.Println("tbd") }
package client import ( "fmt" "net/http" "net/http/httptest" "net/url" "strings" "testing" ) func TestAddsGivenParameters(t *testing.T) { testServer := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { fmt.Fprintln(w, fmt.Sprintf("%s", r.URL)) })) parameters := map[string...
package main import ( "fmt" "strconv" "strings" ) func main() { seed := "1113122113" fmt.Println("------- Part 1 -------") after40 := LookAndSayMultipleTimes(seed, 40) fmt.Printf("After 40 rounds, the result has length %d\n\n", len(after40)) fmt.Println("------- Part 2 -------") after50 := LookAndSayMultip...
package text import ( "testing" "github.com/stretchr/testify/assert" ) func TestReleaseNotes(t *testing.T) { expected := "\n\n## Features :rocket:\n\n- 0000000 ci test\n\n## Bug fixes :bug:\n\n- 0000000 huge bug\n\n## Chores and Improvements :wrench:\n\n- 0000000 testing\n- 0000000 this should end up in chores\n\...
//go:build e2e package setup import ( "github.com/Dynatrace/dynatrace-operator/test/csi" "github.com/Dynatrace/dynatrace-operator/test/dynakube" "github.com/Dynatrace/dynatrace-operator/test/kubeobjects/manifests" "github.com/Dynatrace/dynatrace-operator/test/oneagent" "github.com/Dynatrace/dynatrace-operator/te...
package openstacknfv import ( "io/ioutil" ) func GetSriovStatus() (bool){ fileName := "/etc/puppet/hieradata/service_names.json" fileContent, err := ioutil.ReadFile(fileName) if err != nil { var data map[string]interface{} if err := json.Unmarshal([]byte(filecontent), &data); e...
// 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 handlefunc import ( "os" "time" "sync" "strconv" "net/http" "net/url" "fmt" "html/template" "strings" "encoding/json" . "DesertEagleSite/bean" ) var iconHandler http.Handler = http.FileServer(http.Dir("html/image")) var urlFuncMap map[string] func(w http.ResponseWriter, r *http.Request) func init()...
// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved. // See LICENSE.txt for license information. // package api_test import ( "bytes" "fmt" "net/http" "net/http/httptest" "testing" "time" "github.com/gorilla/mux" "github.com/mattermost/mattermost-cloud/internal/api" "github.com/mattermost/mat...
package xsd import ( "encoding/xml" "strings" "github.com/iancoleman/strcase" ) // Attribute defines single XML attribute type Enumeration struct { XMLName xml.Name `xml:"http://www.w3.org/2001/XMLSchema enumeration"` Value string `xml:"value,attr"` } // Public Go Name of this struct item func (e *Enumerat...
package main import ( "encoding/json" "io" "strings" "github.com/asim/go-micro/plugins/client/grpc/v3" _ "github.com/asim/go-micro/plugins/registry/etcd/v3" "github.com/asim/go-micro/plugins/server/http/v3" "github.com/asim/go-micro/v3" "github.com/asim/go-micro/v3/client" "github.com/asim/go-micro/v3/logger...
package data func Get(search string) string { return search }
package main import ( "encoding/json" "fmt" "io/ioutil" "net/http" "net/url" "strconv" "strings" ) const jotformKey = "jotformApiKey" const jotformCache = "jotform.json" // /form/{formID}/submissions?apiKey={apiKey}" const jotformURL = "https://api.jotform.com" // TODO get this programmatically via /user/for...
/* Copyright 2020 Docker Compose CLI 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 a...
package toggl import ( "encoding/json" "fmt" "io/ioutil" "net/http" "net/url" ) // This should change according to environment const APIURL = "https://toggl.com/" type TogglAPIError struct { status int message string endpoint string } func (t TogglAPIError) Error() string { return fmt.Sprintf("endpoint ...
// Copyright 2020 cloudeng llc. All rights reserved. // Use of this source code is governed by the Apache-2.0 // license that can be found in the LICENSE file. package cloudpath_test import ( "testing" "cloudeng.io/path/cloudpath" ) func TestGoogleCloudStorage(t *testing.T) { data := []matcherTestSpec{ { "g...
package main import "fmt" func main(){ //var deck string = "Ace of card" deck := "Ace of card" fmt.Println(deck) }
// Copyright 2018 Google Inc. All Rights Reserved. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // // http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable...
package base import ( "gonum.org/v1/gonum/stat" "math" ) // FuncSimilarity computes the similarity between a pair of vectors. type FuncSimilarity func(a, b *SparseVector) float64 // Cosine computes the cosine similarity between a pair of vectors. func CosineSimilarity(a, b *SparseVector) float64 { m, n, l := .0, ...
package management import ( "context" "github.com/golang/protobuf/ptypes/empty" "github.com/caos/zitadel/internal/api/authz" "github.com/caos/zitadel/pkg/grpc/management" ) func (s *Server) SearchUserGrants(ctx context.Context, in *management.UserGrantSearchRequest) (*management.UserGrantSearchResponse, error) ...
package main import ( "fmt" "io" "net/http" "os" "strings" ) var buildOrder = []string{ // or else it will end weird... "Body", "Eyes", "Shirts", "Hair", "Glasses", "Hats_and_Hair_Accessories", "Extras", } const input = "" var guard = make(chan struct{}, 5) func main() { words := strings.Split(input, ...
//Copyright 2019 Chris Wojno // // Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated // documentation files (the "Software"), to deal in the Software without restriction, including without limitation // the rights to use, copy, modify, merge, publish, distribut...
package stack import ( "github.com/docker/cli/opts" "github.com/docker/docker/api/types" "github.com/docker/docker/api/types/swarm" "github.com/docker/docker/client" "golang.org/x/net/context" ) type ServicesOptions struct { quiet bool format string filter opts.FilterOpt namespace string } func Li...
package main import ( "fmt" "sync" ) // worker_pool 概念,下面 的写法 就是 工作池 模式 // 目标 1个gorotuine 生产 100 个数据放入ch01,2个goroutine 消费 ch01数据 平方 操作后,放入 到 ch02 中,完成后,才再被读出来 var wg sync.WaitGroup var ch01,ch02 chan int var once sync.Once // 在 goroutine 中 指执行 1次 func f01(ch01 chan int){ defer wg.Done() defer close(ch01)...
package main import ( "bytes" "flag" "fmt" "io/ioutil" "os" "strings" "time" ) /* Урок №6 пакет ioutil Доп. задание: попробуйте передавать путь к файлу через аргумент, c которым запускаете программу. Подсказка - можно это сделать с помощью пакета flag) go run task12.go -filename=task12.txt -path=./task11 */ ...
/* * Convert a PDF to grayscale in a vectorized fashion, including images and all content. * * This advanced example demonstrates some of the more complex capabilities of UniPDF, showing the capability to process * and transform objects and contents. * * Run as: go run pdf_grayscale_transform.go color.pdf output....
package main import ( fiber "github.com/gofiber/fiber/v2" "github.com/gofiber/fiber/v2/middleware/cors" "github.com/gofiber/fiber/v2/middleware/logger" "github.com/pagongamedev/go-dd/example/ex003_repo_switcher/notexample" "github.com/pagongamedev/go-dd/example/ex003_repo_switcher/repo01" "github.com/pagongamed...
package middle type User struct { User string `form:"user" json:"user" binding:"required"` Pwd string `form:"pwd" json:"pwd" binding:"required"` }
package geoip import ( "errors" "fmt" "log" "net" "net/http" "strconv" "strings" "github.com/caddyserver/caddy/v2" "github.com/caddyserver/caddy/v2/caddyconfig/caddyfile" "github.com/caddyserver/caddy/v2/caddyconfig/httpcaddyfile" "github.com/caddyserver/caddy/v2/modules/caddyhttp" "github.com/mmcloughlin...
package log import "time" // Line is log data type Line struct { Level Level Fields Fields Source Source Time time.Time Args []interface{} } func NewLine(lvl Level, fields Fields, src Source, time time.Time, args []interface{}) Line { return Line{ Level: lvl, Fields: fields, Source: src, Time: ...
package LeetCode import ( "fmt" ) func Code526() { fmt.Println(countArrangement(4)) } /** 假设有从 1 到 N 的 N 个整数,如果从这 N 个数字中成功构造出一个数组,使得数组的第 i 位 (1 <= i <= N) 满足如下两个条件中的一个,我们就称这个数组为一个优美的排列。条件: 第 i 位的数字能被 i 整除 i 能被第 i 位上的数字整除 现在给定一个整数 N,请问可以构造多少个优美的排列? 示例1: 输入: 2 输出: 2 解释: 第 1 个优美的排列是 [1, 2]: 第 1 个位置(i=1)上的数字是1,1...
//this is storage for oath modules package mgostore import ( "encoding/json" "fmt" "github.com/idobn/osin" "gopkg.in/mgo.v2" "gopkg.in/mgo.v2/bson" ) var _ = fmt.Printf //some collection name const ( CLIENT_COL = "clients" AUTHORIZE_COL = "authorizations" ACCESS_COL = "accesses" ) const REFRESHTOKEN ...
/* Copyright 2023 Gravitational, 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 writin...
package tx import ( "encoding/json" "github.com/transmutate-io/cryptocore/types" ) var ( _ Tx = (*TxBCH)(nil) _ TxUTXO = (*TxBCH)(nil) ) type TxBCH struct{ txBTC } func (tx *TxBCH) ID() types.Bytes { return tx.txBTC.ID } func (tx *TxBCH) Hash() types.Bytes { return tx.txBTC.Hash } func (tx *TxBCH) BlockH...
package gg import ( "fmt" "testing" ) func _(t *testing.T) { fmt.Println("x_x") } func TestBasic(t *testing.T) { a := Quadtree{B, nil, nil, nil, nil} b := Quadtree{W, nil, nil, nil, nil} if a.Color != B || b.Color != W { t.Fail() } c := NewQuadtreeLeaf(B, B, W, W) if c.NW.Color != B || c.NE.Color != B ...
package main import ( "bufio" "fmt" "os" "sort" ) func main() { if len(os.Args) != 2 { os.Exit(1) } file, err := os.Open(os.Args[1]) check(err) var wrap int var ribbon int scanner := bufio.NewScanner(file) for scanner.Scan() { var l, w, h int n, err := fmt.Sscanf(scanner.Text(), "%dx%dx%d", &l, &w...
package main import ( "encoding/xml" "mime/multipart" "reflect" "strings" "golang.org/x/net/context" "github.com/PuerkitoBio/goquery" "github.com/golang/glog" ) type EldoradoFeedParser struct { FeedReader } func (e EldoradoFeedParser) ParseFeed(ctx context.Context, feedFile multipart.File) { e.waitGroup.A...
/* * User Services Platform - Controller API * * This is the REST API for the User Services Platform (USP) Controller. This is how an external entity can interact with a USP Controller to retrieve information from or configure a USP Agent. * * API version: 1.0.0 * Contact: info@broadband-forum.org * Generated b...
package main import "fmt" import "golang-book/ques3/sleep" func main() { c1 := make(chan string) c2 := make(chan string) go func() { for { c1 <- "from1" sleep.Sleep(2) } }() go func() { for { c2 <- "from2" sleep.Sleep(3) } }() go func() { for { select { case msg1 := <-c1: fmt.Pr...
package plugin import ( "fmt" "github.com/golang/protobuf/proto" "github.com/golang/protobuf/protoc-gen-go/descriptor" "github.com/golang/protobuf/protoc-gen-go/generator" valid "github.com/lanceryou/go-validator" "strings" ) func init() { generator.RegisterPlugin(new(validator)) } type validator struct { ge...
package main import ( "runtime" ) func main() { a1 := []int{4,3,4} b1 := len(a1) print(runtime.GOOS, b1) }
// 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 filemanager import ( "context" "strings" "time" "chromiumos/tast/common/action" "chromiumos/tast/ctxutil" "chromiumos/tast/local/drivefs" "chromiumos/tast/te...
package go_implement_c import "fmt" //void SayHello(char *name); import "C" //export SayHello func SayHello(s *C.char){ fmt.Println(C.GoString(s)) } func BasicApp() { SayHello(C.CString("Implement C")) }
package logx_test import ( "bytes" "fmt" "io" "os" "testing" "github.com/stretchr/testify/assert" "github.com/socialpoint-labs/bsk/logx" ) func TestDefaultAndLogstashLogging(t *testing.T) { t.Parallel() a := assert.New(t) rec := make(recorder, 1) defaultLogger := logx.New(logx.WriterOpt(rec), logx.Witho...
package main import ( "bufio" "bytes" "fmt" "math" "os" "strconv" ) /** * Wishing you Godspeed * https://www.hackerearth.com/practice/data-structures/arrays/1-d/practice-problems/algorithm/speed-7/ */ func main12() { fmt.Print(SolveSpeed(bufio.NewScanner(os.Stdin))) } func SolveSpeed(scanner *bufio.Scanner...
package configcommands import ( "errors" "fmt" "github.com/vmwarepivotallabs/cf-mgmt/config" ) type GlobalConfigurationCommand struct { ConfigManager config.Manager BaseConfigCommand EnableDeleteIsolationSegments string `long:"enable-delete-isolation-segments" description:"Enable removing isolati...
// Copyright 2020 The Moov Authors // Use of this source code is governed by an Apache License // license that can be found in the LICENSE file. package wire import ( "encoding/json" "strings" "unicode/utf8" ) // FIBeneficiaryFI is the financial institution beneficiary financial institution type FIBeneficiaryFI s...
package ravendb import ( "net/http" "reflect" ) var ( _ IOperation = &GetCompareExchangeValueOperation{} ) type GetCompareExchangeValueOperation struct { Command *GetCompareExchangeValueCommand _key string _clazz reflect.Type } func NewGetCompareExchangeValueOperation(clazz reflect.Type, key string) (*GetC...
package main import ( "./undity" "fmt" "os" ) import ( "github.com/lxn/walk" . "github.com/lxn/walk/declarative" ) const ( AppName = "unkarApp" Version = "1.0.0.8" TitleBase = AppName + " " + Version ) /** * アプリケーションのアイコン */ func GetApplicationIcon() *walk.Icon { // アイコン //icon, iconErr := walk.Res...
package main import "fmt" func update(p *int) { b := 2 *p = b } func main() { var ( a = 1 p = &a ) fmt.Println(*p) update(p) fmt.Println(*p) }
package conf import ( "fmt" "io/ioutil" "strings" "github.com/teamhephy/builder/pkg/sys" ) const ( storageCredLocation = "/var/run/secrets/deis/objectstore/creds/" minioHostEnvVar = "DEIS_MINIO_SERVICE_HOST" minioPortEnvVar = "DEIS_MINIO_SERVICE_PORT" gcsKey = "key.json" ) // BuilderKey...
package bitwire import ( "encoding/base64" "encoding/json" "fmt" "github.com/stretchr/testify/assert" "io/ioutil" "testing" "time" ) func TestClient(t *testing.T) { client, err := New("test") assert.Nil(t, client) assert.NotNil(t, err) assert.Equal(t, err.Error(), "Invalid mode") } func TestAll...
package compute_test import ( "errors" "github.com/genevieve/leftovers/gcp/compute" "github.com/genevieve/leftovers/gcp/compute/fakes" . "github.com/onsi/ginkgo" . "github.com/onsi/gomega" ) var _ = Describe("Network", func() { var ( client *fakes.NetworksClient name string network compute.Network )...
package stringutil var Name = "GoatMan of Alcatraz"
package files import ( "fmt" "io" "os" ) // Move file from src to dst. func Move(src, dst string) (int64, error) { // TODO srcFile, err := os.Open(src) if err != nil { return 0, err } defer srcFile.Close() srcFileStat, err := srcFile.Stat() if err != nil { return 0, err } if !srcFileStat.Mode().IsRe...
package rollback import "github.com/usvc/go-config" const ( FlagMigrationsTableName = "table-name" FlagSteps = "steps" ) var ( conf = &config.Map{ FlagMigrationsTableName: &config.String{ Default: "migrations", Shorthand: "n", Usage: "defines the name of the table used to store migr...
package lumps import ( "bytes" "encoding/binary" "log" ) /** Lump 12: Edge */ type Edge struct { LumpGeneric data [][2]uint16 // MAX_MAP_EDGES = 256000 } func (lump *Edge) FromBytes(raw []byte, length int32) { lump.data = make([][2]uint16, length/4) err := binary.Read(bytes.NewBuffer(raw), binary.LittleEndian...
package banners import ( "context" "errors" "fmt" "io/ioutil" "mime/multipart" "sync" ) //Service . Это сервис для управления баннерами type Service struct { mu sync.RWMutex items []*Banner } //NewService . функция для создания нового сервиса func NewService() *Service { return &Service{items: make([]*B...
// Provides HMAC Request Verification Via a Signature Header package middleware import ( "bytes" "crypto/hmac" "crypto/sha256" "encoding/base64" "fmt" "io/ioutil" "net/http" log "github.com/Sirupsen/logrus" "github.com/spf13/viper" "github.com/zenazn/goji/web" ) // Ensures only certain requests are valid ...
package lastfm import ( "bytes" "encoding/json" "fmt" "io/ioutil" "log" "net/http" "net/url" "os" "xiamiToLastfm/musicbrainz" "xiamiToLastfm/xiami" ) // QuitChan: an empty channel used to signal main channel to stop. var ( domain, apiUrl, sharedSecret, apiKey string QuitChan c...
package mesh import ( "fmt" "github.com/layer5io/meshery/mesheryctl/internal/cli/root/config" "github.com/layer5io/meshery/mesheryctl/pkg/utils" "github.com/pkg/errors" log "github.com/sirupsen/logrus" "github.com/spf13/cobra" "github.com/spf13/viper" ) var ( removeCmd = &cobra.Command{ Use: "remove", ...
// 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 fixtures contains fixtures useful for Kiosk mode tests. package fixtures import ( "context" "encoding/json" "io/ioutil" "path/filepath" "time" "github.com/...
package jago func Startup(initialClassName string) { thread := THREAD_MANAGER.NewThread("main") //systemClass := BOOTSTRAP_CLASSLOADER.CreateClass("java/lang/System").(*Class) //systemClass.Link() //systemClassClinits := systemClass.Initialize() //for _, clinit := range systemClassClinits { thread.enqueueFrame(N...
package main import ( "fmt" "github.com/gin-gonic/gin" "github.com/luckydog8686/logs" "net/http" "reflect" ) type SS struct { Name string } func main(){ r := GenRunc(TestGen) router := gin.Default() router.POST("/ping",r) router.Run("127.0.0.1:80") } func GenRunc(fun interface{}) gin.HandlerFunc { t :...
package calc import "bytes" type Expression interface { String() string } // 整数求值 type IntegerLiteralExpression struct { Token Token Value int64 } func (il *IntegerLiteralExpression) String() string { return il.Token.Literal } // 前缀 1+ -1 type PrefixExpression struct { Token *Token Operator string Right Exp...
package middleware import ( "bytes" "encoding/json" "github.com/gin-gonic/gin" "mockman/di" ) type bodyLogWriter struct { gin.ResponseWriter body *bytes.Buffer } func (w bodyLogWriter) Write(b []byte) (int, error) { w.body.Write(b) return w.ResponseWriter.Write(b) } func RespLogMiddleware() gin.HandlerFunc {...
package src //最小区间 func smallestRange(nums [][]int) []int { for }
package admin import ( db "github.com/JieeiroSst/LapTRWeb/config" ) type Profile struct { UserID int `json:"userid"` UserName string `json:"username"` Address string `json:"address"` Password string `json:"password"` } func ShowListProfile() []Profile { db := db.DbConn() selDB, err := db.Query("select *...
// 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, ...
package main import ( "bytes" "database/sql" "encoding/hex" "errors" "math/big" "path/filepath" "sort" "sync" "github.com/hectorchu/gonano/rpc" "github.com/hectorchu/gonano/wallet" "github.com/hectorchu/nano-token-protocol/tokenchain" _ "github.com/mattn/go-sqlite3" "github.com/mitchellh/go-homedir" "gi...
package main import ( "strings" "git.apache.org/thrift.git/lib/go/thrift" "fmt" "log" "echo-server/thrift-example-with-go/example" ) type FormatDataImpl struct{} func (fdi *FormatDataImpl) DoFormat(data *example.Data) (r *example.Data, err error) { var rData example.Data fmt.Println("receive:=>", data.Text) ...
package validator_test import ( "fmt" "testing" "github.com/stretchr/testify/assert" "github.com/darren-west/app/utils/validator" ) type Foo struct { Bar Bar Item string Something int } type Bar struct { Item string Another int } func (f Foo) IsValid() (err error) { if f.Bar == (Bar{}) { ...
package helpers_test import ( "testing" "github.com/go-jstmpl/go-jstmpl/helpers" ) func TestAdd(t *testing.T) { type Input struct { a int b int } type Case struct { Input Input Expected int } cases := []Case{ { Input: Input{ a: 2, b: 1, }, Expected: 3, }, { Input: Input{ ...
// Copyright (C) 2021 Storj Labs, Inc. // See LICENSE for copying information package storj import ( "testing" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" "storj.io/common/storj/location" ) func TestPlacement_Geofencing(t *testing.T) { cases := []struct { name string c...
package main import ( "golang.org/x/net/webdav" "log" "net/http" ) func main() { h := &webdav.Handler{ // 在内存中的文件系统,重启应用后就消失 // FileSystem: webdav.NewMemFS(), // 挂载本地文件系统 FileSystem: webdav.Dir("."), LockSystem: webdav.NewMemLS(), // 设置log Logger: func(r *http.Request, err error) { log.Printf("[d...
package main import ( "fmt" "time" ) func main() { c1 := make(chan string) c2 := make(chan string) go func() { for { c1 <- "from 1" time.Sleep(time.Second * 2) } }() go func() { for { c2 <- "from 2" time.Sleep(time.Second * 3) } }() go func() { for { /* select picks the first ...
// // 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 packer import ( "encoding/binary" "fmt" "github.com/golang/snappy" "io" "io/ioutil" "log" "os" "path/filepath" ) const ( // The original qvm-copy uses LongMax (9223372036854775807 = 9223 PB) as // max. I choose something smaller, 1TB ought to suffice MaxTransfer = 1e12 ) type Receiver struct { in...
// Copyright © 2020. All rights reserved. // Author: Ilya Stroy. // Contacts: qioalice@gmail.com, https://github.com/qioalice // License: https://opensource.org/licenses/MIT package ekatyp type ( NoCopy struct {} ) func (*NoCopy) Lock() {} func (*NoCopy) Unlock() {}
package util import ( "fmt" "github.com/latam-airlines/crane/logger" "strings" ) type KeyValue struct { Key string Value string } func (kv KeyValue) ToString() string { return fmt.Sprintf("%s=%s", kv.Key, kv.Value) } func AddOrReplaceKv(key string, value string, kvs []KeyValue) []KeyValue { replace := fals...
package main import ( "fmt" "github.com/aws/aws-sdk-go/aws" "github.com/aws/aws-sdk-go/service/s3" "log" "strings" "time" ) func loadS3Files(svc *s3.S3, bucket, path string, debug *log.Logger) chan map[string]*File { out := make(chan map[string]*File) // s3 doesn't like the key to start with / path = strin...
/* Copyright 2020 Huawei Inc. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software dis...
/** * * Author: Robert Skelton * Date 2.4.14 * Filename: structTest.go * Email: robertjskelton@gmail.com * Description: Basic structs in go testing. * */ package main import "fmt" type Rectangle struct { width, height int } func (r *Rectangle) area() float64 { return float64(r.height * r.width) } func ...
package configsort import ( "sort" "github.com/warrenharper/restapi/configuration" ) type Orderer func(i, j int) bool // Sorter sorts functions based on it's Order type Sorter struct { Configs []configuration.Configuration Order Orderer } // Sort sorts the configs according to the order that was given. func ...
package main import ( "fmt" "net/http" "time" "github.com/gorilla/mux" ) func main(){ // var num int router := mux.NewRouter() router.HandleFunc("/",index) http.ListenAndServe(":4000",router) } func index(res http.ResponseWriter,req *http.Request) { fmt.Println("Hello Go..") fmt.Println(time.Now()) }
package main import ( "github.com/typical-go/typical-go/pkg/typgo" ) var descriptor = typgo.Descriptor{ ProjectName: "hello-world", ProjectVersion: "1.0.0", Tasks: []typgo.Tasker{ // compile &typgo.GoBuild{}, // run &typgo.RunBinary{ Before: typgo.TaskNames{"build"}, }, }, } func main() { typg...
package main import ( "fmt" ) /** go的条件语句 */ func main() { condition1() fmt.Println("--------------") condition2() fmt.Println("--------------") condition3() fmt.Println("--------------") condition4() fmt.Println("--------------") condition5() } /** select语句:TODO select { case communication clau...
package kata import ( "strings" ) func duplicate_count(s1 string) int { var res int counts := make(map[string]int) for _, s := range s1 { counts[strings.ToLower(string(s))]++ } for _, count := range counts { if count > 1 { res++ } } return res }