text
stringlengths
11
4.05M
package main import ( "io" "net/http" "strings" ) func hello(w http.ResponseWriter, r *http.Request) { listIP := strings.Split(r.Header.Get("X-FORWARDED-FOR"),",") io.WriteString(w, listIP[0] ) } func main() { http.HandleFunc("/", hello) http.ListenAndServe(":...
package keeper import ( "context" "encoding/hex" "google.golang.org/grpc/codes" "google.golang.org/grpc/status" sdk "github.com/cosmos/cosmos-sdk/types" "github.com/irisnet/irismod/modules/random/types" ) var _ types.QueryServer = Keeper{} // Random implements the Query/Random gRPC method func (k Keeper) Ra...
package AvatarGenerator import ( "os" "image/png" "image" "fmt" "crypto/sha256" "image/color" ) const ( IMAGE_DIMENSION = 256 ) func GenerateAvatar(email string, ip string, user string) { if email == "" || ip == "" || user == "" { print("You must provide an email, ip address and username \n") os.Exit(1)...
/* Package say provides an interruptible speaking service. The server will 'say' a user supplied quote. It breaks the quote into phrases, using punctuation as delimiters, running the espeak command for each phrase. This allows the sequence to be terminated at any point between phrases, but introduces a short pause at ...
package event import ( "gopkg.in/mgo.v2/bson" "time" mgo "gopkg.in/mgo.v2" ) type EventRepo struct { Collection *mgo.Collection } //MONGO FUNCTIONS func (repo EventRepo) create(item *Event) error { //check the family query := bson.M{ "child": item.Child, "name": item.Name, } exist, err := repo.exist(...
package common import ( "fmt" "regexp" "strings" "testing" "github.com/stretchr/testify/require" ) func getVersionRegex() string { return `^\d+\.\d+((\.\d+)?|(\-RC\d+))$` } func validateVersion(t *testing.T, version string, ok bool) { matched, err := regexp.Match(getVersionRegex(), []byte(version)) require....
package cmd import ( "fmt" "github.com/bb-orz/gt/libs/libService" "github.com/bb-orz/gt/utils" "github.com/urfave/cli/v2" "io" "os" ) func ServiceCommand() *cli.Command { return &cli.Command{ Name: "service", Usage: "Add Application Service", UsageText: "gt service [--name|-n=][ServiceName...
package reflection import ( "reflect" "testing" ) type TestStruct struct { ReflectTest string `test:"Test tag value"` } type TestMultiple struct { ReflectTest string `test:"Test tag value"` ReflectTest2 string `test:"Test tag value2"` } type TestUnexportedFails struct { unexportedTest string `test:"tester"` ...
package sese import ( "encoding/xml" "github.com/thought-machine/finance-messaging/iso20022" ) type Document02700105 struct { XMLName xml.Name `xml:"urn:iso:std:iso:20022:tech:xsd:sese.027.001.05 Document"` Message *SecuritiesTransactionCancellationRequestStatusAdv...
package main import ( "math" ) func abs(x int) int { if x < 0 { return -x } return x } func min(a, b int) int { if a <= b { return a } return b } func divide(dividend int, divisor int) int { sign := (dividend < 0) == (divisor < 0) a, b, res := abs(dividend), abs(divisor), 0 // if i -> int build error,...
package fysdk import ( "encoding/json" "fmt" "log" "net/http" "strings" pkgBean "webapi/bean" ) type ISkeleton interface { OnPaid(*pkgBean.AndroidPayment) } // 支付通知自定义字段 type FYSDKPaymentExt struct { SKU string `json:"sku"` } func PayNotify(skeleton ISkeleton, w http.ResponseWriter, r *http.Request) { r.P...
package syntax import ( "fmt" "testing" "time" ) func TestTimeoutSelect(t *testing.T) { c := make(chan int, 10) go func() { for i := 0; i < 30; i++ { if i < 10 { c <- i } fmt.Println("tick", i) time.Sleep(1 * time.Second) } }() for { timeout := false select { case <-time.After(10 * t...
package main import ( "bufio" "log" "os" "strconv" "strings" ) func main() { validPasswordsPart1 := 0 validPasswordsPart2 := 0 file, err := os.Open("input.txt") if err != nil { log.Fatal(err) } defer file.Close() scanner := bufio.NewScanner(file) for scanner.Scan() { validPasswordsPart1 = validPassw...
package utils import ( "encoding/base64" "log" "time" "gocv.io/x/gocv" ) func CaptureImg() string { webcam, err := gocv.OpenVideoCapture(0) if err != nil { log.Fatal(err) } defer webcam.Close() img := gocv.NewMat() time.Sleep(time.Millisecond * 100) webcam.Read(&img) data, err := gocv.IMEncode(".pn...
/* You are given the following information, but you may prefer to do some research for yourself. 1 Jan 1900 was a Monday. Thirty days has September, April, June and November. All the rest have thirty-one, Saving February alone, Which has twenty-eight, rain or shine. And on leap years, twen...
package webauthnutil import ( "testing" "github.com/google/uuid" "github.com/stretchr/testify/assert" "github.com/pomerium/pomerium/pkg/grpc/user" ) func TestGetUserEntity(t *testing.T) { t.Run("name as email", func(t *testing.T) { ue := GetUserEntity(&user.User{ Id: "test", Email: "test@example.com...
package main import ( "bytes" "flag" "fmt" "io" "log" "os" "os/exec" "sync" "time" ) var start = time.Now() var format = flag.String("format", "default", "timestamp format") var verbose = flag.Bool("verbose", false, "verbose output") var tabs = flag.Bool("tabs", false, "use tabs rather than spaces after the ...
package goauth import ( "crypto/rand" "encoding/base64" "encoding/json" "io" "strings" "time" ) // TokenType is the type of the token and defines how it // must be used in order to authenticate requests. type TokenType string const ( // TokenTypeBearer is the bearer token type. TokenTypeBearer TokenType = "b...
/* Copyright 2021 The KubeVela 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, so...
package pkg import ( "go.uber.org/zap" "go.uber.org/zap/zapcore" ) func NewSugaredLogger() *zap.SugaredLogger { // ログレベル level := zap.NewAtomicLevel() level.SetLevel(zapcore.InfoLevel) // コンフィグ myConfig := zap.Config{ Level: level, Development: false, DisableCaller: true, Disable...
package core import ( "fmt" "strings" "github.com/chirino/graphql" "github.com/chirino/graphql/resolvers" "github.com/chirino/graphql/schema" "github.com/dosco/graphjin/core/internal/sdata" "github.com/dosco/graphjin/core/internal/util" ) var typeMap map[string]string = map[string]string{ "smallint": ...
package mongodb import ( "context" "fmt" "time" "github.com/brigadecore/brigade/v2/apiserver/internal/api" "github.com/brigadecore/brigade/v2/apiserver/internal/lib/mongodb" "github.com/brigadecore/brigade/v2/apiserver/internal/meta" "github.com/pkg/errors" "go.mongodb.org/mongo-driver/bson" "go.mongodb.org/...
package databroker import ( "context" "sort" "sync" "time" "golang.org/x/exp/maps" "github.com/pomerium/pomerium/config" "github.com/pomerium/pomerium/internal/hashutil" "github.com/pomerium/pomerium/internal/log" "github.com/pomerium/pomerium/internal/telemetry/metrics" "github.com/pomerium/pomerium/inter...
package controller import ( "context" "github.com/labstack/echo" "mix/test/api/admin/common" codes "mix/test/codes" transaction "mix/test/pb/core/transaction" "mix/test/utils/api" ) func CreateHotWithdraw(c echo.Context) error { in := new(transaction.CreateHotWithdrawInput) if err := c.Bind(in); err != nil {...
package app import ( "fmt" api "github.com/Percona-Lab/percona-xtradb-cluster-operator/pkg/apis/pxc/v1alpha1" corev1 "k8s.io/api/core/v1" "k8s.io/apimachinery/pkg/api/resource" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" ) // PVCs returns the list of PersistentVolumeClaims for the pod func PVCs(name string, v...
package domain //Resource - structure to processing type Resource struct { ID uint `json:"id"` Payload string `json:"payload"` Pattern string `json:"pattern"` }
package runtimehelper import ( "runtime" ) func callerName(skip int) string { pc, _, _, ok := runtime.Caller(skip) if ok { return runtime.FuncForPC(pc).Name() } return "" } // CallerName returns name of its caller. func CallerName() string { return callerName(1) } // CallerCallerName returns name of caller ...
//+build test // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. package node import ( "context" "encoding/json" "log" "os/exec" "regexp" "strings" "time" "github.com/Azure/aks-engine/test/e2e/kubernetes/pod" "github.com/Azure/aks-engine/test/e2e/kubernetes/util...
// Copyright (C) 2021 Cisco Systems 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 agr...
package packet import ( "bytes" "github.com/cpusoft/goutil/asn1util" "github.com/cpusoft/goutil/belogs" model "rpstir2-model" ) func ExtractSiaOid(oidPackets *[]OidPacket, fileByte []byte) (subjectInfoAccess model.SiaModel, err error) { //oidRpkiManifestKey,oidRpkiNotifyKey,oidCaRepositoryKey,oidSignedObjectKey...
package envoyconfig import ( "encoding/json" "fmt" "net/url" "sort" "strings" envoy_config_core_v3 "github.com/envoyproxy/go-control-plane/envoy/config/core/v3" envoy_config_route_v3 "github.com/envoyproxy/go-control-plane/envoy/config/route/v3" envoy_type_matcher_v3 "github.com/envoyproxy/go-control-plane/en...
package jwt import ( "errors" "fmt" "log" "strconv" "strings" "testing" "time" "github.com/robbert229/jwt" ) func Test_jwt_gen(t *testing.T) { secret := "ThisIsMySuperSecret" algorithm := jwt.HmacSha256(secret) claims := jwt.NewClaim() claims.Set("Role", "Admin") claims.Set("UserName", "whr") claims.S...
package views import "time" type CreateUserRes struct { Name string `json:"name"` Username string `json:"username"` Age int64 `json:"age"` Contact string`json:"contact"` KycDetails string `json:"kyc_details"` } type CreateWalletRes struct { WalletName string `json:"wallet_name"` } type Wallets struct { W...
package repository import ( . "2019_2_IBAT/pkg/pkg/models" "fmt" "testing" "github.com/google/uuid" "github.com/jmoiron/sqlx" "github.com/stretchr/testify/require" "gopkg.in/DATA-DOG/go-sqlmock.v1" ) func TestDBUserStorage_SetTagsIDs_Correct(t *testing.T) { db, mock, err := sqlmock.New() defer db.Close() s...
package main import ( "context" "crudrpc/api/mcrsv" "encoding/json" "io/ioutil" "net/http" "github.com/gorilla/mux" "google.golang.org/grpc" ) var conn *grpc.ClientConn type Request struct { Idx int `json:"idx"` Username string `json:"username"` UserId string `json:"userid"` Password string `js...
package problem0240 import "testing" func TestSolve(t *testing.T) { t.Log(searchMatrix([][]int{ []int{1, 2, 3, 4, 5}, }, 4)) }
package repository import ( "fmt" "github.com/google/uuid" "github.com/pkg/errors" . "2019_2_IBAT/pkg/pkg/models" ) func (m *DBUserStorage) CreateFavorite(favVac FavoriteVacancy) bool { _, err := m.DbConn.Exec("INSERT INTO favorite_vacancies(person_id, vacancy_id)"+ "VALUES($1, $2);", favVac.PersonID, fav...
package asset // FileWriter interface is used to write all the files in the specified location type FileWriter interface { PersistToFile(directory string) error } // NewDefaultFileWriter create a new adapter to expose the default implementation as a FileWriter func NewDefaultFileWriter(a WritableAsset) FileWriter { ...
package cmd import ( "github.com/spf13/cobra" ) // Execute adds all child commands to the root command and sets flags appropriately. // This is called by main.main(). It only needs to happen once to the rootCmd. func Execute() { rootCmd := initRoot() rootCmd.AddCommand(initDoc(rootCmd)) cobra.CheckErr(rootCmd.Ex...
package p0001 import ( "reflect" "testing" ) func TestTwoSum(t *testing.T) { nums := []int{2, 7, 11, 15} target := 9 t.Logf(" Input: nums = %v, target = %d\n", nums, target) actual := twoSum(nums, target) t.Logf(" Output: %v\n", actual) expected := []int{0, 1} if !reflect.DeepEqual(expected, actual) { t.F...
/* * @lc app=leetcode.cn id=147 lang=golang * * [147] 对链表进行插入排序 */ package solution // @lc code=start func insertionSortList(head *ListNode) *ListNode { if head == nil || head.Next == nil { return head } dummy := &ListNode{Next: head} p, pre, q := dummy, head, head.Next for q != nil { if pre.Val <= q.Val...
package dao import ( "fmt" "github.com/xormplus/xorm" "go.uber.org/zap" "mix/test/codes" entity "mix/test/entity/core/transaction" mapper "mix/test/mapper/core/transaction" "mix/test/utils/status" ) func (p *Dao) CreateToken(logger *zap.Logger, session *xorm.Session, item *entity.Token) (id int64, err error) ...
package dvid import ( . "github.com/janelia-flyem/go/gocheck" "testing" ) // Hook up gocheck into the "go test" runner. func Test(t *testing.T) { TestingT(t) } type MySuite struct{} var _ = Suite(&MySuite{}) func (s *MySuite) TestVoxelCoord(c *C) { a := VoxelCoord{10, 21, 837821} b := VoxelCoord{78312, -200, 4...
// Copyright 2020 Thomas.Hoehenleitner [at] seerose.net // Use of this source code is governed by a license that can be found in the LICENSE file. // Package assert_test contains blackbox tests. package tst_test import ( "io/ioutil" "os" "testing" "github.com/stretchr/testify/assert" "github.com/rokath/trice/p...
package banner import ( "fmt" ) // Print prints the ASCII banner to the console func Print() { // Note: Generated ASCII banner online: http://patorjk.com/software/taag/#p=display&f=Big%20Money-nw fmt.Println(`-----------------------------------------------------------`) fmt.Println(` $$$$$$\ $$\ ...
package scanner import ( "bytes" "fmt" "regexp" "strconv" "strings" //"time" "github.com/PuerkitoBio/goquery" "github.com/purstal/go-tieba-base/misc" "github.com/purstal/go-tieba-base/simple-http" //"github.com/purstal/go-tieba-modules/operation-analyser/old/log" ) type OpType int const ( OpType_None ...
package structs import "testing" func TestPerimeter(t *testing.T) { rectangle := Rectangle{10.0, 3.0} got := Perimeter(rectangle) want := 26.0 if got != want { t.Errorf("got %.2f want %.2f", got, want) } } func TestArea(t *testing.T) { checkArea := func(t *testing.T, shape Shape, want float64) { t.Helper(...
package leetcode import "testing" func TestCommonPrefix(t *testing.T) { tests := []struct { a string b string cp string }{ { a: "a", b: "b", cp: "", }, { a: "a", b: "a", cp: "a", }, { a: "abc", b: "ab", cp: "ab", }, { a: "ab", b: "abc", cp: "ab", }...
//All variables on LHS of declaration has already been declared package main func pain () { //should be legal var x, y bool x, y, z := true, `false`, true != false; } func main () { //Illegal var x, y, z bool x, y, z := true, `false`, true == false; }
package model // Assessment a struct encapsulating payment type Assessment struct { BaseModel ApplicationID uint `json:"application_id" gorm:"not null;type:int(15)"` QuestionID string `json:"question_id" gorm:"not null;type:varchar(20)"` SelectedAnswer string `json:"selected_answer" gorm:"...
package main import ( "fmt" ) func main() { fmt.Println(predictPartyVictory("RD")) //fmt.Println(predictPartyVictory("DDRRR")) } func predictPartyVictory(senate string) string { bs := []byte(senate) r, d := true, true flag := 0 for r && d { r, d = false, false for i := 0; i < len(bs); i++ { switch bs...
package submerge import ( "bufio" "os" "strconv" "strings" ) func parseSubFile(file *os.File) ([]*subLine, error) { var lines []*subLine sc := bufio.NewScanner(file) nextLine := true for nextLine { line, notEmpty, err := parseSubLine(sc) if err != nil { return nil, err } nextLine = notEmpty if ...
package rabbitmq import ( "context" "regexp" "time" "github.com/pkg/errors" "github.com/streadway/amqp" "github.com/batchcorp/plumber-schemas/build/go/protos/opts" "github.com/batchcorp/plumber-schemas/build/go/protos/records" "github.com/batchcorp/rabbit" rtypes "github.com/batchcorp/plumber/backends/rabb...
package diff import ( "fmt" "os" "reflect" "testing" ) func TestListSubdirsPWD(t *testing.T) { // diff folder doesn't currently have subdirs got, err := listSubDirs() if err != nil { t.Errorf("error listing subdirs: %s", err) } want := []string{} if !reflect.DeepEqual(got, want) { t.Errorf("got %+v, w...
package models // Inventories data model for inventory type Inventories struct { Model ProductID int `gorm:"not null" json:"product_id"` Quantity int `json:"quantity"` }
package main import ( "fmt" "errors" ) func main(){ r, err := div(9, -10) if err != nil { fmt.Println(err.Error()) } else { fmt.Println(r) } } func div(x,y float64)(float64, error){ if y < 0 { return x/y, errors.New("jumlah nilai harus positif") } else { return x/y, nil ...
// +build !race package daemonsetstore import ( "context" "testing" "time" "github.com/square/p2/pkg/ds/fields" daemonsetstore_protos "github.com/square/p2/pkg/grpc/daemonsetstore/protos" "github.com/square/p2/pkg/grpc/testutil" "github.com/square/p2/pkg/logging" "github.com/square/p2/pkg/manifest" "github....
package vm import ( "fmt" "github.com/davecgh/go-spew/spew" installertypes "github.com/openshift/installer/pkg/types" vsphere "github.com/pulumi/pulumi-vsphere/sdk/v2/go/vsphere" "github.com/pulumi/pulumi/sdk/v2/go/pulumi" ) // InstanceType - Types of instances type InstanceType string //InstanceType enum cons...
package interpeter import ( "fmt" "github.com/fd/forklift/static/github.com/zhemao/glisp/interpreter" ) type Interperter struct { Env map[string]string env *glisp.Glisp } func (i *Interperter) SexpString() string { return "forklift" } func (i *Interperter) setup() { i.env.AddGlobal("forklift", i) i.env.Add...
package main import ( "bytes" "flag" "fmt" "html/template" "log" "math/rand" "net/http" "os" "runtime" "sync" "time" "golang.org/x/tools/godoc" "golang.org/x/tools/godoc/static" "golang.org/x/tools/godoc/vfs" "golang.org/x/tools/godoc/vfs/gatefs" "golang.org/x/tools/godoc/vfs/mapfs" "github.com/code...
package types import ( "fmt" bgpapi "github.com/osrg/gobgp/v3/api" "github.com/projectcalico/vpp-dataplane/v3/vpplink/generated/bindings/interface_types" "github.com/projectcalico/vpp-dataplane/v3/vpplink/generated/bindings/ip_types" "github.com/projectcalico/vpp-dataplane/v3/vpplink/generated/bindings/sr" "gi...
package main import "fmt" type Pet interface { Walk() } type Dog struct { name string } func (d *Dog) Walk() { fmt.Println("dog walk ...") } func main() { dog := Dog{"little dog"} // p 是接口类型变量,&dog 是 p 的动态值,Dog 是 p 的动态类型 var p Pet = &dog p.Walk() var p1 Pet fmt.Println(p1) // <nil> fmt.Println(p1...
package actions import "github.com/gopherjs/vecty/examples/todomvc/store/model" type ReplaceItems struct { Items []*model.Item } type AddItem struct { Title string } type DestroyItem struct { Index int } type SetTitle struct { Index int Title string } type SetCompleted struct { Index int Completed bool...
package p02 func addDigits(num int) int { if num == 0 { return 0 } res := num % 9 if res == 0 { return 9 } return res }
package authors import ( "emailSender/db" "github.com/gofiber/fiber/v2" "github.com/golang-jwt/jwt" ) type v struct { Id string `json:"id"` jwt.StandardClaims } func VerifyEmail(c *fiber.Ctx) error { vToken := c.Params("verification") token, err := jwt.ParseWithClaims(vToken, &v{}, func(token *jwt.Token) (in...
// 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 junehttp import ( "fmt" "net/http" ) func Servertest() { http.HandleFunc("/postpage", func(w http.ResponseWriter, r *http.Request) { //接受post请求,然后打印表单中key和value字段的值 if r.Method == "POST" { var ( key string = r.PostFormValue("key") value string = r.PostFormValue("value") ) fmt.Printf(...
package main import ( "bufio" "fmt" "io" "os" ) func main() { // os.Stdout.Close() //会把终端输出关闭, 下面的println就打印不出来了 fmt.Println("Are you OK?") os.Stdout.WriteString("Are you ok??? \n") //往终端屏幕上输出 // os.Stdin.Close() 关闭后就无法输入 var a int fmt.Println("please input a number") fmt.Scan(&a) fmt.Println("a = ", a...
package uhost import ( "github.com/xiaohui/goucloud/ucloud" ) // CreateUHostInstance will create instances type CreateUHostInstanceParams struct { ucloud.CommonRequest Region string ImageId string LoginMode string Password string KeyPair string CPU int Memory int DiskSpace int Name s...
package cbor import ( "bytes" "testing" "github.com/polydawn/refmt/tok/fixtures" ) func testBytes(t *testing.T) { t.Run("short byte array", func(t *testing.T) { seq := fixtures.SequenceMap["short byte array"] canon := bcat(b(0x40+5), []byte(`value`)) t.Run("encode canonical", func(t *testing.T) { checkE...
package main import ( "io" "net/http" "os" "path/filepath" "regexp" "strings" "sync" "gopkg.in/cheggaaa/pb.v1" ) var fileRegExp = regexp.MustCompile(`[0-9]`) func download(media string, wg *sync.WaitGroup, bar *pb.ProgressBar) { semaphore <- struct{}{} defer func() { <-semaphore }() defer wg.Done() if !...
package main import "fmt" func main() { //var chan1 chan int //读写 var chan2 chan<- int //只写 chan2 = make(chan int, 3) chan2 <- 2 var chan3 <-chan int //只读 chan3 = make(chan int, 3) num := <-chan3 fmt.Println(num) }
package tx import ( "fmt" "testing" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" "github.com/terra-money/terra.go/key" "github.com/terra-money/terra.go/msg" terraapp "github.com/terra-money/core/app" ) func Test_Sign(t *testing.T) { mnemonic := "essence gallery exit illegal na...
package g2util import ( "database/sql/driver" "fmt" "time" ) const ( //TimeZone ... TimeZone = "Asia/Shanghai" //Custom ... Custom = "2006-01-02 15:04:05" //DateLayout ... DateLayout = "2006-01-02" ) /*func init() { //设定时区,shanghai _ = SetTimeZone() }*/ // TimeNowFunc ... var TimeNowFunc = time.Now // T...
package cmd import ( "context" "fmt" "strings" "github.com/chaosblade-io/chaosblade-spec-go/spec" "github.com/spf13/cobra" ) type DestroyCommand struct { baseCommand exp *expCommand } func (dc *DestroyCommand) Init() { dc.command = &cobra.Command{ Use: "destroy UID", Short: "Destroy a chaos exper...
package main import ( "fmt" ) func main() { x := 15 a := &x fmt.Println(a) //adress fmt.Println(*a) //pointer value *a = 5 //change pointer value fmt.Println(x) //print new x value *a = *a * *a //change value again fmt.Println(a) //new adress fmt.Println(*a) //new value 25 }
// Copyright 2019 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 ( "bytes" "encoding/json" "fmt" "net/http" "os" "time" "github.com/nicholasjackson/bench" "github.com/nicholasjackson/bench/output" "github.com/nicholasjackson/bench/util" "github.com/nicholasjackson/building-microservices-in-go/chapter6/vanilla_http/entities" ) func main() { fmt.Print...
// Copyright (c) 2020 Hirotsuna Mizuno. All rights reserved. // Use of this source code is governed by the MIT license that can be found in // the LICENSE file. package speedio import ( "time" ) // MeterConfig indicates the configuration parameter of bit rate measurement. // // Resolution is how often the bitrate i...
// Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. package engine import ( "github.com/Azure/azure-sdk-for-go/services/network/mgmt/2018-08-01/network" "github.com/Azure/go-autorest/autorest/to" ) // CreatePublicIPAddressForNodePools returns public ipv4 address resource...
package repository import ( "backend/src/constants" "backend/src/global" "backend/src/module" ) // 获取父节点权限 func GetEnableParentPrivilege(allEnableParent interface{}) { global.DataBase.Where(&module.Privilege{IsForbidden: constants.PrivilegeEnable, IsLeaf: constants.NotLeaf}).Order("parent_path, label").Find(allEn...
// // Copyright (C) 2019-2021 vdaas.org vald team <vald@vdaas.org> // // 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 // // https://www.apache.org/licenses/LICENSE-2.0 // // Unless requir...
package series type Series []float64 func (s Series) Values() []float64 { return s } func (s Series) Last(position int) float64 { return s[len(s)-1-position] } func (s Series) LastValues(size int) []float64 { if l := len(s); l > size { return s[l-size:] } return s } func (s Series) Crossover(ref Series) boo...
package cloud const ( Pending = "创建中" LaunchFailed = "创建失败" Running = "运行中" Stopped = "关机" Starting = "开机中" Stopping = "关机中" Rebooting = "重启中" ShutDown = "停止销毁" Terminating = "销毁中" Unknow = "未知" ) type Instance struct { Key string UUID string Name ...
package goevent import "fmt" // EventNotDefined is an error indicationg that the event has not been defined. type EventNotDefined struct { eventName string } func newEventNotDefined(name string) *EventNotDefined { return &EventNotDefined{ eventName: name, } } func (e *EventNotDefined) Error() string { return ...
// Copyright 2020 Ant Group. All rights reserved. // // SPDX-License-Identifier: Apache-2.0 package converter import ( "context" "strings" "testing" "github.com/dragonflyoss/image-service/contrib/nydusify/pkg/utils" "github.com/opencontainers/go-digest" ocispec "github.com/opencontainers/image-spec/specs-go/v1...
// Copyright 2012 the u-root Authors. All rights reserved // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. //Wget reads one file from the argument and writes it on the standard output. package main import ( "io" "log" "net/http" "os" ) func wget(arg string, ...
package gofinancial import ( "errors" "time" "github.com/razorpay/go-financial/enums/paymentperiod" "github.com/razorpay/go-financial/enums/interesttype" "github.com/razorpay/go-financial/enums/frequency" ) // Config is used to store details used in generation of amortization table. type Config struct { Star...
package main import "fmt" func main() { var key = "" var loop = true var balance float64 = 0 var money float64 = 0 var flag = false var note = "" var detail = "类型\t金额\t余额\t说明" for { fmt.Println("收入支出登记") fmt.Println("1:查看明细") fmt.Println("2:登记收入") fmt.Println("3:登记支出") fmt.Println("4:退出") fmt.Prin...
package primitives import ( "encoding/xml" "github.com/plandem/ooxml/ml" ) //FontVAlignType is a type to encode XSD ST_VerticalAlignRun type FontVAlignType ml.Property //MarshalXML marshal FontVAlignType func (t *FontVAlignType) MarshalXML(e *xml.Encoder, start xml.StartElement) error { return (*ml.Property)(t).M...
package apple1 import ( "github.com/KaiWalter/go6502/pkg/mc6821" "github.com/veandco/go-sdl2/sdl" ) type keyMap struct { unmodified byte shifted byte ctrl byte } var ( keyboardMapping map[sdl.Keycode]keyMap ) func initKeyboardMapping() { // DE! keyboardMapping = map[sdl.Keycode]keyMap{ 0x08: {un...
package main /** 309. 最佳买卖股票时机含冷冻期 给定一个整数数组,其中第 i 个元素代表了第 i 天的股票价格 。​ 设计一个算法计算出最大利润。在满足以下约束条件下,你可以尽可能地完成更多的交易(多次买卖一支股票): - 你不能同时参与多笔交易(你必须在再次购买前出售掉之前的股票)。 - 卖出股票后,你无法在第二天买入股票 (即冷冻期为 1 天)。 示例: ``` 输入: [1,2,3,0,2] 输出: 3 解释: 对应的交易状态为: [买入, 卖出, 冷冻期, 买入, 卖出] ``` */ /** 又没写出来 ERROR */ func MaxProfit(prices []int) int { ...
package rds import ( "fmt" "testing" set "github.com/deckarep/golang-set" xds_route "github.com/envoyproxy/go-control-plane/envoy/config/route/v3" "github.com/golang/mock/gomock" proto "github.com/golang/protobuf/ptypes" "github.com/google/uuid" tassert "github.com/stretchr/testify/assert" "github.com/opens...
package main import ( "fmt" "html/template" "net/http" ) func index(w http.ResponseWriter, r *http.Request) { t := template.Must(template.ParseFiles("index.html")) t.Execute(w, nil) } func main() { http.Handle("/css/", http.StripPrefix("/css/", http.FileServer(http.Dir("css/")))) http.Handle("/fonts/", http.S...
package write import ( "os" "fmt" "encoding/binary" //"bufio "log" ) type WriteChannel interface { WritePair(k []byte, v []byte) int WriteDeleteMarker(k []byte) int } type DiskWriteChannel struct { segment_file *os.File } func NewDiskWriteChannel(segment_file *os.File) *DiskWriteChannel { return &DiskWrite...
// 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 domain import ( "errors" "time" uuid "github.com/satori/go.uuid" "golang.org/x/crypto/bcrypt" ) type User struct { ID uuid.UUID `db:"id" json:"id"` Name string `db:"name" json:"name"` Email string `db:"email" json:"email"` Password string `db:"password" json:"-"` CreatedAt tim...
package manifests import ( "errors" "fmt" "os" "os/exec" "testing" "github.com/golang/mock/gomock" "github.com/stretchr/testify/assert" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" aiv1beta1 "github.com/openshift/assisted-service/api/v1beta1" "github.com/openshift/assisted-service/models" "github.com/ope...
package coreos import ( "github.com/bernardolins/vandame/metadata" ) func Config(name string, config metadata.Config) *CoreOs { coreos := new(CoreOs) coreos.Etcd.MachineName = name configureEtcd2(coreos, config) return coreos } func configureEtcd2(coreos *CoreOs, config metadata.Config) { coreos.Etcd.Initial...
package main import( "../core" // "strconv" // "fmt" ) func main(){ // bc:=core.NewBlockchain() // bc.SendData("Send 1 BTC to fox1"); // bc.SendData("Send 1 ETH to fox2"); // bc.Print() // getSumAndSub(1,2); // fmt.Println("hello start!") // bcc:=core.NewBlockchain() //创建区块链 // bcc.AddBlock("Send 1 BTC to...