text
stringlengths
11
4.05M
package ecc import ( "fmt" "math/big" ) // var Curves = map[string] Curve{ func (C *Curve) GetCurve(name string) *Curve { switch name { case "secp112r1": return C.load_curve_hex("secp112r1", "DB7C2ABF62E35E668076BEAD208B", "DB7C2ABF62E35E668076BEAD2088", "659EF8BA043916EEDE8911702B22", "0948723999...
// Copyright 2017 PingCAP, Inc. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // // http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed to i...
package humanize import ( "testing" . "github.com/smartystreets/goconvey/convey" ) var st = ` package test type STAR *int var x *int var y *int ` func TestStartType(t *testing.T) { Convey("Star test", t, func() { var p = &Package{} f, err := ParseFile(st, p) So(err, ShouldBeNil) p.Files = append(p.F...
// Copyright 2020 Kuei-chun Chen. All rights reserved. package mdb import ( "bytes" "context" "errors" "fmt" "net/url" "os" "strings" "sync" "time" "go.mongodb.org/mongo-driver/bson" "go.mongodb.org/mongo-driver/x/mongo/driver/connstring" "github.com/simagix/gox" "go.mongodb.org/mongo-driver/mongo" ) ...
package domain type BasketItems []BasketItem func (this BasketItems) CountCodes(codes []string) map[string]int { result := make(map[string]int) for _, code := range codes { val, ok := result[code] if !ok { val = 0 } val++ result[code] = val } return result } func (this BasketItems) DistinctProducts(...
package main import ( "encoding/json" "fmt" "io/ioutil" cli "gopkg.in/urfave/cli.v2" "github.com/johnwyles/vrddt-reboot/pkg/config" "github.com/johnwyles/vrddt-reboot/pkg/reddit" ) // InsertJSONToQueueCommand will take whatever garbage or valid URLs you throw in a // JSON file formatted with unmarshaled Reddi...
package steam // Friends related responses type FriendList struct { Friends []*Friend `json:"friends"` } type FriendResponse struct { FriendList FriendList `json:"friendslist"` } type Friend struct { Steamid string `json:"steamid"` Relationship string `json:"relationship"` FriendSince int `json:"friend...
package main import ( "crypto/tls" "flag" "github.com/FrankSantoso/go-hydra-login-consent/internal/cfg" "github.com/FrankSantoso/go-hydra-login-consent/internal/errutil" "github.com/FrankSantoso/go-hydra-login-consent/internal/log" "github.com/FrankSantoso/go-hydra-login-consent/internal/platform/mw" "github.co...
// Copyright 2021 BoCloud // // 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 wri...
package model import ( "context" "fmt" "log" "time" "Users/pingjing/docker/goPractice/owning/database" "go.mongodb.org/mongo-driver/bson" "go.mongodb.org/mongo-driver/bson/primitive" "go.mongodb.org/mongo-driver/mongo/options" ) type Shopping struct { Accounts []User `bson:"accounts" json:"accounts"` } ty...
/** * @Author: korei * @Description: * @File: init.go * @Version: 1.0.0 * @Date: 2020/11/17 下午12:05 */ package config import "github.com/BurntSushi/toml" var GlobalConfig Config type Config struct{ DBConfig DBConfig AdminConfig AdminConfig MachineConfig MachineConfig } type AdminConfig struct { Pass...
package main import ( "fmt" ) func main() { ch := make(chan int, 1) for i := 0; i < 10; i++ { select { case x := <-ch: fmt.Printf(" ch -> x is %d\n", x) case ch <- i: fmt.Printf(" i->ch is %d\n", i) } } }
package unittest import ( "encoding/json" g8sv1alpha1 "github.com/giantswarm/apiextensions/pkg/apis/cluster/v1alpha1" "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/apimachinery/pkg/runtime" cmav1alpha1 "sigs.k8s.io/cluster-api/pkg/apis/cluster/v1alpha1" "github.com/giantswarm/aws-operator/pkg/annotation" "gi...
package downloader import ( "io" ) // Updater will take care about everything related to updates. type Updater interface { io.Closer Update(target string) error }
package teams // Conferences maps team abbreviations to conferences var Conferences = map[string][]string{ "east": []string{"atl", "chi", "clb", "dc", "fcc", "mtl", "ner", "nyc", "nyrb", "orl", "phi", "tfc"}, "west": []string{"dal", "hou", "col", "lag", "lafc", "min", "por", "rsl", "sj", "sea", "kc", "van"}, } // C...
package main import ( "errors" "flag" "fmt" "io/ioutil" "os" "github.com/sirupsen/logrus" "github.com/ti-community-infra/tichi/internal/pkg/externalplugins" "sigs.k8s.io/yaml" ) // options specifies command line parameters. type options struct { externalPluginConfigPath string } func (o *options) DefaultAn...
package middleware import ( "net/http" "github.com/gorilla/mux" "github.com/root-gg/plik/server/context" ) // User middleware for all the /user/{userID} routes. func User(ctx *context.Context, next http.Handler) http.Handler { return http.HandlerFunc(func(resp http.ResponseWriter, req *http.Request) { if ctx....
package main var father []int // 初始化并查集 func initUFS(length int) { father = make([]int, length) for i := 0; i < length; i++ { father[i] = i } } // 合并并查集 func unionUFS(a, b int) { father1, father2 := findFather(a), findFather(b) father[father1] = father2 } // 找爸爸 func findFather(a int) int { if a == father[a]...
/* * dagdig * * PFN 2019 Internship Challenge * * API version: 1.0.0 * Generated by: OpenAPI Generator (https://openapi-generator.tech) */ package openapi type Error struct { // Error code Code int32 `json:"code"` // Error message Message string `json:"message"` }
package sensorcollection import ( "testing" "fmt" ) func TestConnection(t *testing.T){ getStationResponse := GetSensorServiceGetStationsResponse() for _,s := range getStationResponse.Stations { for _, p := range s.Parameters { fmt.Printf("%v\n", p.Devices) } } }
package ventilator import ( "github.com/Mvilstrup/mosquito/communication/errors" "github.com/Mvilstrup/mosquito/communication/messages" zmq "github.com/alecthomas/gozmq" ) type Ventilator struct { // ZeroMQ specific variables context *zmq.Context // Context sender *zmq.Socket // sender for clients & workers...
package api import( "log" "net/http" "encoding/json" //"github.com/gorilla/mux" "github.com/acmakhoa/smsapp/worker" "github.com/acmakhoa/smsapp/device" ) type DeviceAPI struct{} type DeviceSelectRequest struct{ Name string `json:"name"` } func (_ *DeviceAPI) ListHandler(w http.ResponseWriter, r *http.Request)...
package loader import ( "fmt" "path/filepath" "github.com/pkg/errors" yaml "gopkg.in/yaml.v2" "github.com/devspace-cloud/devspace/pkg/devspace/config/versions/latest" "github.com/devspace-cloud/devspace/pkg/devspace/deploy/deployer/helm/merge" "github.com/devspace-cloud/devspace/pkg/util/yamlutil" ) // Valid...
package main import "fmt" func main() { nums := []int{2,7,11,15} fmt.Println(twoSum(nums, 9)) fmt.Println(twoSum1(nums, 9)) } func twoSum(nums []int, target int) []int { hashmap := make(map[int]int) for i, v := range nums{ another_num := target - v if _, ok := hashmap[another_num]; ok { return []int{has...
/* Copyright © 2022 SUSE LLC Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distri...
package controllers import ( "net/http" "github.com/gin-gonic/gin" "github.com/jinzhu/gorm" "github.com/ranggarifqi/go-ecommerce-api/models" ) // RoleController struct type RoleController struct { DB *gorm.DB } // GetAll Role func (rc *RoleController) GetAll(c *gin.Context) { var roles []models.Role var resu...
package leetcode /*Given two binary trees and imagine that when you put one of them to cover the other, some nodes of the two trees are overlapped while the others are not. You need to merge them into a new binary tree. The merge rule is that if two nodes overlap, then sum node values up as the new value of the merge...
package main import "fmt" /* 指针作为参数: 引用传递 值传递 其实本质上来说 都是值传递, 传递指针 其实也是传递一个值,只是这个值 是一个地址而已。 数组是值类型 , 直接拷贝一份数据 */ func main() { a := 1 var arr = [4]int{1, 2, 3, 4} fun1(a) fmt.Println("fun1() 调用后,a=", a) fun2(&a) fmt.Println("fun2() 调用后,a=", a) fun3(arr) fmt.Println("fun3() 调用后,arr=", arr) fun4(&...
package flags import ( "testing" "github.com/10gen/realm-cli/internal/utils/test/assert" ) func TestArg(t *testing.T) { t.Run("should print only name when value is nil", func(t *testing.T) { arg := Arg{Name: "test"} assert.Equal(t, " --test", arg.String()) }) t.Run("should print name and value when set", f...
package user import ( "context" "encoding/json" "net/http" "github.com/julienschmidt/httprouter" ) type Controller struct { Service *Service } func (c *Controller) RegisterUser(w http.ResponseWriter, r *http.Request, _ httprouter.Params) { username, password, ok := r.BasicAuth() if !ok || !LoginAdmin(usernam...
package day2 import ( "fmt" "log" ) var puzzleInput = []int{ 1, 12, 2, 3, 1, 1, 2, 3, 1, 3, 4, 3, 1, 5, 0, 3, 2, 10, 1, 19, 1, 5, 19, 23, 1, 23, 5, 27, 2, 27, 10, 31, 1, 5, 31, 35, 2, 35, 6, 39, 1, 6, 39, 43, 2, 13, 43, 47, 2, 9, 47, 51, 1, 6, 51, 55, 1, 55, 9, 59, 2, 6, 59, 63, 1, 5, 63, 67, 2, 6...
package view import ( "bytes" "io/ioutil" "strings" "github.com/aimof/yomuRSS/domain" "github.com/mattn/godown" "github.com/rivo/tview" ) type View interface { AddArticles(a domain.Articles) Run() error } type view struct { flex *tview.Flex list *tview.List textview *tview.TextView app *tvi...
package main import "fmt" //channel //複数のゴルーチン間でのデータ受け渡しをする為に設計されたデータ構造。 //キュー(先入先出) //宣言、操作 func main() { //宣言 //双方向 var ch1 chan int //受信専用 //var ch2 <- chan int //送信専用 //var ch3 -> chan int ch1 = make(chan int) ch2 := make(chan int) //バッファサイズを調べる fmt.Println(cap(ch1)) fmt.Println(cap(ch2)) //バッファサイ...
// +build integration package imintegration_test import "testing" func Test(t *testing.T) { t.Error("found error in 'Integration Test'") }
// Copyright 2023 Google LLC. 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 applica...
package dao import ( _ "github.com/go-sql-driver/mysql" "github.com/jinzhu/gorm" "ssq-spider/configure" ) type MysqlDB struct { dbUrl string dbClient *gorm.DB } var mysqlDB MysqlDB func init() { mysqlDB.dbUrl = configure.GlobalConfig.Mysql.Url mysqlDB.dbClient = nil } func NewMysqlDBClient() (*gorm.DB, e...
package api import "time" type ReportID int64 type ReportStorage interface { Save(*Report) error ByWebsite(WebsiteID) (*Report, error) } type Report struct { ID ReportID `db:"id"` UserID UserID `db:"user_id"` WebsiteID WebsiteID `db:"website_id"` Matches []*Match `...
package crs import ( "runtime" "sync" ) // New ... func New(size uint) *LFU { list := &LFU{ limit: size, } list.ClearSoft() return list } type LFU struct { sync.RWMutex items []LFUItem table map[Snowflake]int nilTable []int limit uint // 0 == unlimited size uint misses uint64 // opposi...
package main import ( "bytes" "encoding/binary" "errors" "log" "os" "os/signal" "syscall" "github.com/cilium/ebpf/link" "github.com/cilium/ebpf/ringbuf" "github.com/cilium/ebpf/rlimit" "golang.org/x/sys/unix" ) // $BPF_CLANG and $BPF_CFLAGS are set by the Makefile. //go:generate go run github.com/cilium/e...
// +build !race package consulutil import ( "bytes" "reflect" "sync" "testing" "time" . "github.com/anthonybishopric/gotcha" "github.com/hashicorp/consul/api" ) // PairRecord is a record of a single update to the Consul KV store type PairRecord struct { // "create", "update", "delete", or "close" Change st...
package servers type StartMaintenanceModeReq struct { ServerIds []string }
/* Copyright 2018 Intel Corporation. SPDX-License-Identifier: Apache-2.0 */ package oimcsidriver import ( "context" "fmt" "github.com/kubernetes-csi/csi-test/pkg/sanity" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" "io/ioutil" "os" "path/filepath" "testing" "time" "google.go...
package MySQL import "time" type Admin struct { Id int `gorm:"column:id; primary_key ; AUTO_INCREMENT" json:"id"` Name string `gorm:"column:name" json:"name"` Email string `gorm:"column:email" json:"email"` Password string `gorm:"column:password" json:"password"` Created_a...
// Copyright 2014, Truveris Inc. All Rights Reserved. // Use of this source code is governed by the ISC license in the LICENSE file. package main import ( "encoding/json" "errors" "os" "github.com/jessevdk/go-flags" ) type Cmd struct { ConfigFile string `short:"c" description:"Configuration file" default:"/etc...
package main type Node struct { maxScore int ways int } func pathsWithMaxScore(board []string) []int { dp := [105][105]Node{} m, n := len(board), len(board[0]) mod := 1000000007 dp[m-1][n-1] = Node{0, 1} for i := m - 1; i >= 0; i-- { for t := n - 1; t >= 0; t-- { ch := board[i][t] if ch == 'X' { ...
package singleton import ( "github.com/stretchr/testify/assert" "sync" "testing" ) func TestGetInstance(t *testing.T) { for i := 0; i < 1000; i++ { repository1, repository2, repository3, repository4 := create() assert.Same(t, repository1, repository2) assert.Same(t, repository1, repository3) assert.Same(t...
// +build acceptance compute flavors package v2 import ( "testing" "github.com/gophercloud/gophercloud/acceptance/clients" "github.com/gophercloud/gophercloud/openstack/compute/v2/flavors" ) func TestFlavorsList(t *testing.T) { client, err := clients.NewComputeV2Client() if err != nil { t.Fatalf("Unable to c...
package handler import ( "context" "fmt" "path/filepath" corepb "github.com/jinmukeji/proto/v3/gen/micro/idl/partner/xima/core/v1" sempb "github.com/jinmukeji/proto/v3/gen/micro/idl/partner/xima/sem/v1" smspb "github.com/jinmukeji/proto/v3/gen/micro/idl/partner/xima/sms/v1" subscriptionpb "github.com/jinmukeji...
package montecarlo // ActionBuilder is a type that can sets of possible actions. type ActionBuilder interface { BuildActions(defaultState State) ActionSet } // MasterBuilder builds all actions, based on a list of other ActionBuilders type MasterBuilder struct { SubBuilders []ActionBuilder } // BuildActions builds ...
package test import ( "errors" "github.com/mkj-gram/go_email_service/internal/emailprovider" "github.com/mkj-gram/go_email_service/internal/emailsender" "github.com/stretchr/testify/assert" "testing" ) type TestProvider struct { send func(m emailprovider.Email) error } func (t TestProvider) Send(m emailprovide...
package main import ( "fmt" ) type iTable interface { GetName() string } type table struct{} func (t table) GetName() string { return "11" } func t1(it iTable) { fmt.Printf(it.GetName()) } type Vertex struct { X int Y int } func main1() { /**names := []string{"1", "2", "45"} //a := "n" // := &a p := &nam...
package main type InputData struct { Data []string `json:"data"` } type OutputData struct { Data []Output `json:"YashOju"` } type Output struct { Text string `json:"text"` Entity string `json:"entity"` Types string `json:"types"` }
package http import ( "fmt" "github.com/gin-gonic/gin" "github.com/tiagorlampert/CHAOS/internal/environment" "github.com/tiagorlampert/CHAOS/internal/utils/template" ) func NewRouter() *gin.Engine { router := gin.Default() router.Use(gin.Recovery()) router.Static("/static", "web/static") router.HTMLRender = t...
package main import "fmt" func addP(c *int) int { *c = *c + 1 return *c } func main() { x := 10 fmt.Println(x) fmt.Println(addP(&x)) fmt.Println(x) }
// Example of internal unit test // all public & private variables / types / functions etc... visable to test logic package pool import ( "fmt" "strings" "sync" "testing" ) func TestWorker(t *testing.T) { wg := &sync.WaitGroup{} todo := make(chan Work) result := make(chan Work) stop := make(chan struct{}) w ...
package example import "fmt" // Numbered test constants const ( T0 int = iota T1 T2 ) // Something is a test string used in various scenarios. const Something = "word" // DefaultName is a mutable variable used to store a string used in various default scenarios when an override is // not provided. var DefaultNam...
package main import ( "encoding/json" "errors" "net/http" ) type EstimatedFees struct { Opening *int `json:"opening"` MutualClose *int `json:"mutual_close"` UnilateralClose *int `json:"unilateral_close"` DelayedToUs *int `json:"delayed_to_us"` HTLCResolution *int `json:"htlc_resolution"` Pen...
package models import ( "errors" "mall/utils" "strconv" "github.com/astaxie/beego/orm" ) // PmsProductCategory 商品分类结构体 type PmsProductCategory struct { Id int `json:"id"` ParentId int `description:"上级分类的编号:0表示一级分类" json:"parent_id"` Name string `description:"分类名称" orm:"size(64)" js...
package schema import ( "fmt" "reflect" "strings" "testing" "time" "github.com/EverythingMe/bson/bson" "golang.org/x/text/language" ) var mockSchema = ` # Mock Schema schema: mock tables: users: engines: - redis columns: name: comment: "The name of...
package model import ( "fmt" ) type ( User struct { // User Unique ID. Generated by snowflake. UserID uint64 `json:"user_id,string" db:"user_id"` // Mail Address used to log in to the service. Email string `json:"email" db:"email"` // password stored with bcrypt salt hash. Password stri...
package wordcount import ( "regexp" "strings" ) type Frequency map[string]int func WordCount(s string) Frequency { c := make(Frequency) s = strings.ToLower(s) s = strings.Replace(s, ",", " ", -1) reg, _ := regexp.Compile("[^a-zA-Z0-9' ]+") s = reg.ReplaceAllString(s, "") words := strings.Fields(s) if len(...
package validate import ( "bufio" "encoding/json" "errors" "fmt" "net" "os" "path/filepath" "reflect" "regexp" "runtime" "strings" "unicode" "unicode/utf8" "github.com/blang/semver/v4" "github.com/hashicorp/go-multierror" rspec "github.com/opencontainers/runtime-spec/specs-go" osFilepath "github.com/...
package main import ( "fmt" "strings" ) func main0101() { //查找一个字符串在另一个字符串中是否出现 str1 := "hello world" str2 := "g" //Contains(被查找的字符串,查找的字符串) 返回值 bool //一般用于模糊查找 b := strings.Contains(str1,str2) //fmt.Println(b) if b { fmt.Println("找到了") }else { fmt.Println("没有找到") } } func main0102() { //字符串切片 ...
package database import ( "context" "fmt" "os" "time" "github.com/joho/godotenv" "go.mongodb.org/mongo-driver/mongo" "go.mongodb.org/mongo-driver/mongo/options" "go.mongodb.org/mongo-driver/mongo/readpref" ) func GetDatabase() (*mongo.Database, *mongo.Client) { godotenv.Load() uri := fmt.Sprintf("mongodb+s...
package service import ( "mobingi/ocean/pkg/tools/machine" ) func NewRunControlPlaneJobs(ips []string, etcdServers, advertiseAddress string) ([]*machine.Job, error) { apiserverJobs, err := NewRunAPIServerJobs(ips, etcdServers, advertiseAddress) if err != nil { return nil, err } controllerManagerJob, err := Ne...
package main import ( "testing" "exer10" ) func BenchmarkFibonacci1(b *testing.B){ for n := 0; n < b.N; n++ { exer10.Fibonacci(1) } } func BenchmarkFibonacci5(b *testing.B){ for n := 0; n < b.N; n++ { exer10.Fibonacci(5) } } func BenchmarkFibonacci10(b *testing.B){ for n := 0; n < b.N; n++ { exer10.Fi...
package main import ( "github.com/prometheus/client_golang/prometheus" "github.com/socketplane/libovsdb" "flag" "github.com/Sirupsen/logrus" "net/http" "github.com/joatmon08/ovs_exporter/openvswitch" ) const ( namespace = "openvswitch" // For Prometheus metrics. ) var ( up = prometheus.NewDesc( prometheus....
// Copyright 2021 BoCloud // // 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 wri...
package commands import ( "flag" "fmt" "net/http" "strconv" "time" "github.com/opentable/sous/core" "github.com/opentable/sous/tools/cli" "github.com/opentable/sous/tools/docker" "github.com/opentable/sous/tools/ports" ) var contractsFlags = flag.NewFlagSet("contracts", flag.ExitOnError) var timeoutFlag = ...
package criteria import ( "github.com/open-policy-agent/opa/ast" "github.com/pomerium/pomerium/pkg/policy/parser" ) type httpPathCriterion struct { g *Generator } func (httpPathCriterion) DataType() CriterionDataType { return CriterionDataTypeStringMatcher } func (httpPathCriterion) Name() string { return "ht...
/** This exercise will reinforce our understanding of method sets: create a type person struct - attach a method speak to type person using a pointer receiver *person create a type human interface - to implicitly implement the interface, a human must have the speak method create func “saySomething” ...
package di import ( "github.com/golobby/container" "github.com/profiralex/go-bootstrap-redis/pkg/config" ) func RegisterDependencies() { //Config container.Singleton(func() config.Config { return config.GetConfig() }) } func UnregisterDependencies() { container.Reset() } func Make(receiver interface{}) { c...
package eventdata import ( "bytes" "encoding/json" "io/ioutil" "net/http" "os" "strconv" "time" "github.com/elastic/beats/libbeat/common" "github.com/elastic/beats/libbeat/common/cfgwarn" "github.com/elastic/beats/metricbeat/mb" ) // init registers the MetricSet with the central registry as soon as the pro...
package main import ( "github.com/beego/beego/v2/client/orm/migration" ) // DO NOT MODIFY type User_20210713_191340 struct { migration.Migration } // DO NOT MODIFY func init() { m := &User_20210713_191340{} m.Created = "20210713_191340" migration.Register("User_20210713_191340", m) } // Run the migrations fun...
package handlers import ( "encoding/xml" "log" "net/http" "github.com/matscus/Hamster/Mock/rkk_tomsk/structs" ) func CreditClaimAcceptHandler(w http.ResponseWriter, r *http.Request) { var res structs.CreditClaimAcceptResponse res.ReturnCode = 0 res.InstitutionId = 500058 res.ContractReqId = 441014 res.CardR...
package task import ( "encoding/json" "tcc_transaction/constant" "tcc_transaction/global/various" "tcc_transaction/log" "tcc_transaction/model" "tcc_transaction/store/data" "tcc_transaction/util" "time" ) func taskToRetry(needRollbackData []*data.RequestInfo) { log.Infof("start to retry, data is : %+v", len(...
package pipeline import ( "context" "encoding/base64" "fmt" ) // Encode takes plain text as int // and returns "string => <base64 string encoding> // as out func (w *Worker) Encode(ctx context.Context) { for { select { case <-ctx.Done(): return case val := <-w.in: w.out <- fmt.Sprintf("%s => %s", val,...
package bylog import ( "github.com/hashicorp/go-syslog" ) type BySysLogger struct { logger gsyslog.Syslogger } func NewSysLogger(fac,name string) (ByLogger,error) { logger,err:=gsyslog.NewLogger(gsyslog.LOG_DEBUG,fac,name) if err!=nil{ //fmt.Println("Create Logger failed ",err) return nil,err } return &ByS...
package containers import ( "github.com/exproletariy/pip-services3-containers-examples/app-aws-lambda-example-go/build" cproc "github.com/pip-services3-go/pip-services3-aws-go/container" ) type AppExampleLambdaFunction struct { cproc.CommandableLambdaFunction } func NewAppExampleLambdaFunction() *AppExampleLambda...
package tracks type Track struct { Id uint `json:"id"` User_id uint `json:"user_id"` Name string `json:"name"` Url string `json:"url"` }
// Copyright 2020 PingCAP, Inc. Licensed under Apache-2.0. package summary import ( "testing" "time" "github.com/stretchr/testify/require" "go.uber.org/zap" ) func TestSumDurationInt(t *testing.T) { fields := []zap.Field{} logger := func(msg string, fs ...zap.Field) { fields = append(fields, fs...) } col ...
package web_controller import ( "2021/yunsongcailu/yunsong_server/common" "2021/yunsongcailu/yunsong_server/param/web_param" "2021/yunsongcailu/yunsong_server/web/web_model" "fmt" "github.com/gin-gonic/gin" "github.com/gin-gonic/gin/binding" "math/rand" "os" "path/filepath" "strconv" "time" ) // 上传更新头像 fun...
package misc_test import ( "testing" parser "github.com/romshark/llparser" "github.com/romshark/llparser/misc" "github.com/stretchr/testify/require" ) func TestLexerRead(t *testing.T) { lex := misc.NewLexer(&parser.SourceFile{ Name: "test.txt", Src: []rune("abc\r\n\t defg,!"), }) tk1, err := lex.Read() ...
package main import ( "github.com/labstack/echo" "github.com/labstack/echo/middleware" "graphql-golang/common" "graphql-golang/handler" ) func main() { e := echo.New() e.Use(middleware.CORS()) e.Use(middleware.Logger()) e.Use(middleware.Recover()) e.GET("/hello", handler.Hello()) e.POST("/login", handler....
package main import ( "crypto/tls" "fmt" "io/ioutil" "log" "net/http" "net/url" "os" "path" "github.com/osbuild/osbuild-composer/internal/common" "github.com/osbuild/osbuild-composer/internal/distro" "github.com/osbuild/osbuild-composer/internal/upload/koji" "github.com/osbuild/osbuild-composer/internal/w...
package main import ( "git.apache.org/thrift.git/lib/go/thrift" "github.com/lnhote/hello-thrift/gen-go/bill" "context" "log" ) func main() { sock, err := thrift.NewTSocket("localhost:9090") if err != nil { panic(err) } defer sock.Close() transportFactory := thrift.NewTFramedTransportFactory(thrift.NewTTran...
// Copyright 2015 PingCAP, Inc. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // // http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed to i...
package main import ( _ "github.com/lingdor/glog2midlog" "github.com/lingdor/midlog-examples/library1" ) func init() { } func main() { library1.DumpLog("rootlog pring") }
/* # -*- coding: utf-8 -*- # @Author : joker # @Time : 2021/8/23 9:47 下午 # @File : lt_24_删除有序数组的重复项.go # @Description : # @Attention : */ package offer // 关键 // 题目特点: 有序+重复 // 解题关键: 快慢指针,慢指针充当不重复的元素个数,快指针快速过滤 func removeDuplicates(nums []int) int { if len(nums) < 2 { return len(nums) } slow, fast := 0, 1 for ; f...
package game_map import ( "fmt" "github.com/steelx/go-rpg-cgm/combat" ) type CEFlee struct { Scene *CombatState Character *Character owner *combat.Actor name string countDown float64 finished bool FleeParams CSMoveParams CanFlee bool Storyboard *Storyboard } func CEFleeCreate(scene ...
package main import ( "fmt" "io/ioutil" "net/http" "strings" ) var port string var name string func handler(w http.ResponseWriter, r *http.Request) { cont, err := ioutil.ReadFile("index.php") if err != nil { fmt.Println("Error") } aob := len(cont) s := string(cont[:aob]) fmt.Fprint(w, s) } func readCon...
package p2p import ( "math" "sort" "sync/atomic" "time" "github.com/qlcchain/go-qlc/common" "github.com/qlcchain/go-qlc/common/types" "github.com/qlcchain/go-qlc/ledger" "github.com/qlcchain/go-qlc/log" "github.com/qlcchain/go-qlc/p2p/protos" "go.uber.org/zap" ) var ( headerBlockHash types.Hash openB...
package main import ( "bytes" "embed" "github.com/Masterminds/sprig" "go/format" "text/template" ) //go:embed *.tpl var templateFiles embed.FS var templates *template.Template func Templates() (*template.Template, error) { if templates == nil { //sub, err := fs.Sub(templateFiles, "template") //if err != n...
package users import ( "io" "io/ioutil" "log" "github.com/google/uuid" "github.com/pkg/errors" . "2019_2_IBAT/pkg/pkg/models" ) func (h *UserService) CreateEmployer(body io.ReadCloser) (uuid.UUID, error) { bytes, err := ioutil.ReadAll(body) defer body.Close() if err != nil { log.Printf("error while read...
package fin_test import ( "io" "net/http" "testing" "github.com/xsymphony/fin" ) func TestNewRouter(t *testing.T) { r := fin.New() r.ANY("/hello", func(ctx *fin.Context) { ctx.WriteString("hello") }) go func() { r.Run(":8080") }() resp, err := http.Get("http://127.0.0.1:8080/hello") if err != nil { ...
package app import ( "glsamaker/pkg/app/handler/authentication/totp" "glsamaker/pkg/config" "glsamaker/pkg/database/connection" "glsamaker/pkg/logger" "glsamaker/pkg/models/users" ) func defaultAdminPermissions() users.Permissions { return users.Permissions{ Glsa: users.GlsaPermissions{ View: ...
package main func minSumSubArray(nums []int) int { const IntMax = int(^uint(0) >> 1) const IntMin = -int(^uint(0)>>1) - 1 MinInt := func(args ...int) int { if len(args) == 0 { return IntMin } r := IntMax for _, e := range args { if e < r { r = e } } return r } n := len(nums) if n == 0 {...
package eventmanager import ( "context" cluster "github.com/bsm/sarama-cluster" "github.com/lovoo/goka" "github.com/lovoo/goka/kafka" "log" "microservices_template_golang/payment_processing/src/models" "microservices_template_golang/payment_processing/src/utils" "os" "os/signal" "syscall" ) var storageTopic...
package main import "fmt" func main() { printEveryThirdInRange(10, 35) } func printEveryThirdInRange(n int, m int) { for i := n ; i <= m ; i += 3 { fmt.Println(i) } }
package main // 3. 无重复字符的最长子串 // 来源:力扣(LeetCode) // 链接:https://leetcode-cn.com/problems/longest-substring-without-repeating-characters /* 题目描述 给定一个字符串,请你找出其中不含有重复字符的 最长子串 的长度。 示例 1: 输入: "abcabcbb" 输出: 3 解释: 因为无重复字符的最长子串是 "abc",所以其长度为 3。 示例 2: 输入: "bbbbb" 输出: 1 解释: 因为无重复字符的最长子串是 "b",所以其长度为 1。 示例 3: 输入: "pwwkew" 输...