text
stringlengths
11
4.05M
package function import ( "fmt" "log" "net/http" "os" ) var ( stdLogger = log.New(os.Stdout, "", 0) ) func TestDeployment(w http.ResponseWriter, r *http.Request) { BuildHash := os.Getenv("BUILD_HASH") stdLogger.Printf("BuildHash: %s", BuildHash) RegularEnvVar := os.Getenv("REGULAR_ENV_VAR") stdLogger.Print...
package main import ( "fmt" "unsafe" ) func main() { caller() } func caller() { var a int64 = 1 var b int64 = 2 c := callee(a, b) fmt.Println(c) var struct1 = struct{}{} var int1 = 12 var chstruct = make(chan struct{}, 10) fmt.Println(unsafe.Sizeof(struct1)) fmt.Printf("%p\n", &struct1) fmt.Printf("%p\...
/* * Copyright (c) 2013 Landon Fuller <landonf@mac68k.info> * All rights reserved. */ /* Select-based polling support for the pcap API */ package pcap /* #include <pcap/pcap.h> #include <sys/select.h> #include <stdlib.h> #include <unistd.h> #include <string.h> #include <stdint.h> // Indirection required to use ...
package flow import ( "math" "sync" "testing" "time" ) func TestBasic(t *testing.T) { var wg sync.WaitGroup wg.Add(100) for i := 0; i < 100; i++ { go func() { defer wg.Done() ticker := time.NewTicker(40 * time.Millisecond) defer ticker.Stop() m := new(Meter) for i := 0; i < 100; i++ { m.M...
package connect import ( "encoding/binary" "errors" "io" "github.com/xgheaven/localmap/logger" ) const ( HEL = iota HELRLY REQCON REQRLY CLOSE HEART ) const ( BLOCKREADSIZE = 1024 ) type ( BlockHeader struct { Type uint8 Flag uint8 Len uint16 } Block struct { *BlockHeader Data []byte } ...
// DRUNKWATER TEMPLATE(add description and prototypes) // Question Title and Description on leetcode.com // Function Declaration and Function Prototypes on leetcode.com //68. Text Justification //Given an array of words and a width maxWidth, format the text such that each line has exactly maxWidth characters and is ful...
// Copyright 2019-present 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 agr...
package config import ( "os" "sync" "github.com/DATA-DOG/go-sqlmock" "github.com/jmoiron/sqlx" "github.com/subosito/gotenv" ) type BbbxConfig struct { DB *sqlx.DB Mock sqlmock.Sqlmock } var ( bbbxConfig *BbbxConfig once sync.Once ) func GetInstanceWithEnv(env string) *BbbxConfig { once.Do(func() ...
package adapter import "fmt" type INonBattery interface { Use() } type IReBattery interface { Use() Charge() } type NonA struct { } func (NonA) Use() { fmt.Println("NonA using") } //适配可充电电池使用接口 type AdapterNonToYes struct { INonBattery } func (AdapterNonToYes) Charge() { fmt.Println("AdapterNonToYes Cha...
package config import ( "code.cloudfoundry.org/cli/plugin" "errors" "fmt" "github.com/pivotal-cf/spring-cloud-services-cli-plugin/cfutil" "github.com/pivotal-cf/spring-cloud-services-cli-plugin/httpclient" "github.com/pivotal-cf/spring-cloud-services-cli-plugin/serviceutil" ) type Refresher interface { Refresh...
package data import ( "database/sql" "fmt" "log" "os" "reflect" "strings" _ "github.com/mattn/go-sqlite3" ) const ( dbName = "./mediaWebServerDatabase.db" driver = "sqlite3" create = "CREATE TABLE IF NOT EXISTS" asterisk = "*" colon ...
package main import ( "flag" "fmt" "gopkg.in/headzoo/surf.v1" ) var ( link = flag.String("url", "http://m.newsmth.net", "url to get") ) func main() { flag.Parse() bow := surf.NewBrowser() err := bow.Open(*link) if err != nil { panic(err) } fmt.Println(bow.Title()) fmt.Println(bow.Body()) }
package main import ( "github.com/gin-gonic/autotls" "github.com/gin-gonic/gin" ) func main(){ r:=gin.Default() r.GET("/test", func(c *gin.Context) { c.String(200, "hello test") }) // 自动化证书配置: 调用证书下载的包,然后就是https的过程:1、生成本地密钥,2、然后用这个密钥去证书颁发机构获取私钥,3、进行本地私钥验证,验证成功把私钥保存,下次再有请求,用这个私钥加密 autotls.Run(r, "www.itpp.tk"...
/** * @author liangbo * @email liangbogopher87@gmail.com * @date 2017/10/22 18:21 */ package model import ( "time" "pet/utils" ) // 文章 type Article struct { Id int64 `gorm:"primary_key"; sql:"AUTO_INCREMENT"` Title string `sql:"type:varchar(128)"` ...
package rrdp import ( "github.com/cpusoft/goutil/belogs" "github.com/cpusoft/goutil/ginserver" "github.com/gin-gonic/gin" model "rpstir2-model" ) // start to rrdp from sync func RrdpRequest(c *gin.Context) { belogs.Debug("RrdpRequest(): start") syncUrls := model.SyncUrls{} err := c.ShouldBindJSON(&syncUrls) ...
package nv4 import ( "context" "github.com/filecoin-project/go-state-types/big" init0 "github.com/filecoin-project/specs-actors/actors/builtin/init" cid "github.com/ipfs/go-cid" cbor "github.com/ipfs/go-ipld-cbor" "golang.org/x/xerrors" init2 "github.com/filecoin-project/specs-actors/v2/actors/builtin/init" )...
package chapter2 import "fmt" func init() { fmt.Println("=== Function Variadic ===") var d1 = "A1 Auto" var d2 = "Discount AUto" var d3 = "Riverside Automart" var dealers = []string {d1, d2, d3} printDealers(dealers...) } /** input parameter : dealers 가변 변수 */ func printDealers(dealers ... string) { // 배열요...
package integration_test import ( "fmt" "os" "os/exec" "time" "github.com/cloudfoundry/libbuildpack/cutlass" . "github.com/onsi/ginkgo" . "github.com/onsi/gomega" ) var _ = Describe("CF Staticfile Buildpack", func() { var ( app *cutlass.App createdServices []string dynatraceAPI *cutlass...
package bean import ( "bytes" "encoding/binary" "errors" "github.com/HNB-ECO/HNB-Blockchain/HNB/p2pNetwork/common" ) type Ping struct { Height uint64 } //Serialize message payload func (this Ping) Serialization() ([]byte, error) { p := bytes.NewBuffer([]byte{}) err := binary.Write(p, binary.LittleEndian, &(th...
// Copyright 2019 GoAdmin Core Team. All rights reserved. // Use of this source code is governed by a Apache-2.0 style // license that can be found in the LICENSE file. package dialect type sqlite struct { commonDialect } func (sqlite) GetName() string { return "sqlite" } func (sqlite) ShowColumns(table string) s...
package config import ( "errors" "fmt" "github.com/spf13/viper" "os" "path/filepath" "strings" "gopkg.in/yaml.v2" ) // ErrUnknownCfg is thrown when the provided config doesn't match anything known, be it in "kind" or the version of it. var ErrUnknownCfg = errors.New("unknown framework configuration") // Meta...
package main import ( "log" "net" "github.com/iheanyi/grpc-phonebook/api" "github.com/iheanyi/grpc-phonebook/server" "google.golang.org/grpc" ) func main() { lis, err := net.Listen("tcp", ":50051") if err != nil { log.Fatalf("failed to listen: %v", err) } srv := grpc.NewServer() svc := server.New() a...
package vips import ( "fmt" "github.com/sherifabdlnaby/bimg" cfg "github.com/sherifabdlnaby/prism/pkg/config" "github.com/sherifabdlnaby/prism/pkg/payload" ) type flip struct { Raw flipRawConfig `mapstructure:",squash"` direction cfg.Selector } type flipRawConfig struct { Direction string } func (o *f...
package controller import ( "github.com/gin-gonic/gin" "net/http" "myzone/utils" ) func GotoHome(c *gin.Context){ user := utils.GetSession(c,"user") if user == nil { c.HTML(http.StatusOK, "login.html", gin.H{ "msg": "请登录!", }) }else { c.HTML(http.StatusOK, "home.html", gin.H{ "msg": "Home", "user...
package main import ( "bufio" "log" "os" "sync" "unsafe" "github.com/go-redis/redis" "github.com/google/flatbuffers/go" cli "gopkg.in/urfave/cli.v1" "github.com/transactional-cloud-serving-benchmark/tcsb/serialization_util" "github.com/transactional-cloud-serving-benchmark/tcsb/serialized_messages" ) func...
package main import ( "fmt" "image/color" "io" "strconv" "strings" "time" "fyne.io/fyne/v2" "fyne.io/fyne/v2/app" "fyne.io/fyne/v2/canvas" "fyne.io/fyne/v2/container" "fyne.io/fyne/v2/data/binding" "fyne.io/fyne/v2/dialog" "fyne.io/fyne/v2/theme" "fyne.io/fyne/v2/widget" "github.com/archon/backend" "g...
package v1 import ( "bytes" "encoding/json" "io/ioutil" "net/http" "net/http/httptest" "testing" api "github.com/motonary/Fortuna/api/v1" "github.com/motonary/Fortuna/entity" ) type Response struct { Status int `json:"status"` User *entity.User `json:"user,omitempty"` Token string `json:...
package main import "fmt" //输出小写得a-z和大写得Z-A func main() { for i := 0; i < 26; i++ { fmt.Printf("%c ", 'a'+i) } fmt.Println() for i := 0; i < 26; i++ { fmt.Printf("%c ", 'Z'-i) } }
// This file was generated for SObject LoginGeo, API Version v43.0 at 2018-07-30 03:47:32.50817275 -0400 EDT m=+18.851486547 package sobjects import ( "fmt" "strings" ) type LoginGeo struct { BaseSObject City string `force:",omitempty"` Country string `force:",omitempty"` CountryIso ...
package model import "time" type Users struct { Id int `json:"id" gorm:"column:id"` Name string `json:"name" gorm:"column:name"` Email string `json:"email" gorm:"column:email"` EmailVerified time.Time `json:"email_verified_at" gorm:"column:email_verified_at"` Passw...
package libRestful import ( "github.com/bb-orz/gt/utils" "io" "text/template" ) func NewFormatterGinEngine() *FormatterGinEngine { return new(FormatterGinEngine) } type FormatterGinEngine struct { FormatterStruct } func (f *FormatterGinEngine) Format(name string) IFormatter { f.PackageName = "restful" f.Stru...
package testcase import goplvalidator "github.com/go-playground/validator/v10" var v = goplvalidator.New() func init() { if err := v.RegisterValidation("adult", func(fl goplvalidator.FieldLevel) bool { return fl.Field().Int() >= 18 }); err != nil { panic(err) } } type Options struct { amount int `option:"ma...
// Copyright 2017 Google Inc. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // // http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed to in...
package main import ( "bytes" "fmt" "net" "net/http" "os" "strconv" "sync" "time" "./shared" "github.com/ant0ine/go-json-rest/rest" "github.com/jinzhu/gorm" _ "github.com/jinzhu/gorm/dialects/postgres" ) // var payload = bytes.NewBuffer([]byte(`{"message":"Buy cheese and bread for breakfast."}`)) type R...
package singleton var hungryInstance = &HungrySingleton{} // 单例模式-饿汉式 type HungrySingleton struct { } func GetHungryInstance() *HungrySingleton { return hungryInstance }
package tsin import ( "encoding/xml" "github.com/thought-machine/finance-messaging/iso20022" ) type Document01200101 struct { XMLName xml.Name `xml:"urn:iso:std:iso:20022:tech:xsd:tsin.012.001.01 Document"` Message *PartyRegistrationAndGuaranteeAcknowledgementV01 `xml:"Pty...
package http import ( "context" "crypto/tls" "database/sql" "fmt" "log" "net/http" "os" "os/signal" "syscall" "time" "github.com/javiercbk/jayoak/files" "github.com/javiercbk/jayoak/api/sound" "github.com/gin-contrib/sessions" "github.com/gin-contrib/sessions/redis" "github.com/gin-gonic/gin" "github...
package main import ( "fmt" "math" ) // the way to signal an error is to return it func sqrt(n float64) (float64, error) { if n < 0 { return 0.0, fmt.Errorf("Sqrt og negative value (%f)", n) } return math.Sqrt(n), nil // null in Golang } func testMain() { s1, err := sqrt(2.0) if err != nil { fmt.Printf(...
package middleware import ( "net/http" ) type Adapter func(http.HandlerFunc) http.HandlerFunc type GoMiddleware struct { } func InitMidleware() *GoMiddleware { return &GoMiddleware{} } func (gm *GoMiddleware) Method(m string) Adapter { return func(f http.HandlerFunc) http.HandlerFunc { return func(w http.Resp...
package pagination import ( "math" ) // Pagination is a general purpose pagination type, it knows how to calculate // offset and number of pages. It also contains some utility functions // that helps common tasks. One special utility is the PagesStream method // that returns a channel to range over for presenting a ...
package infrastructure import ( "github.com/golobby/container" "github.com/morteza-r/flexdb" "github.com/morteza-r/flexdb-server/app/application" ) func SetUp() { container.Singleton(func() application.DbService { var db *flexdb.Database db = flexdb.NewDb() return application.DbService{ Db: db, } })...
package wallet import ( "fmt" "github.com/textileio/go-textile/keypair" "github.com/tyler-smith/go-bip39" ) var ErrInvalidWordCount = fmt.Errorf("invalid word count (must be 12, 15, 18, 21, or 24)") type WordCount int const ( TwelveWords WordCount = 12 FifteenWords WordCount = 15 EighteenWords WordC...
package main import "fmt" func main() { var party = map[string]bool{ "Calisca": true, "Heodan": true, } fmt.Println(party["Calisca"]) for name, value := range party { fmt.Println(name, value) } }
package main import "fmt" type fruits struct { fruit []string } func (f *fruits) input(num int) { var fruit string for i := 0; i < num; i++ { fmt.Print("fruit[", i, "]:") fmt.Scanln(&fruit) f.fruit = append(f.fruit, fruit) } } func (f *fruits) print() { for _, fruit := range f.fruit { fmt.Println(fruit...
package sql type Order struct { Column Column Direction Direction } type Direction string const Ascending Direction = "ASC" const Descending Direction = "DESC"
package models import ( "errors" "labix.org/v2/mgo/bson" ) /* * 单个实体查找 */ func (d *CateDal) FindByID(id int) Cate { result := []Cate{} uc := d.session.DB(DbName).C(CateCollection) err := uc.Find(bson.M{"categoryID": id}).All(&result) if err != nil { panic(err) } if len(result)>0 { retur...
package port import ( "context" "github.com/mirzaakhena/danarisan/domain/repository" "github.com/mirzaakhena/danarisan/domain/service" ) // KocokUndianOutport ... type KocokUndianOutport interface { repository.FindOneArisanRepo repository.FindOneUndianRepo repository.FindAllSlotNotWinYetRepo repository.FindAl...
package camt import ( "encoding/xml" "github.com/thought-machine/finance-messaging/iso20022" ) type Document04200104 struct { XMLName xml.Name `xml:"urn:iso:std:iso:20022:tech:xsd:camt.042.001.04 Document"` Message *FundDetailedEstimatedCashForecastReportV04 `xml:"FndDtldEstmtd...
package main import ( "fmt" "github.com/soniakeys/graph" ) // node represents a node in a directed graph. It represents directed edges // from the node with the handy DijkstraNeighbor type from the graph package. type node struct { nbs []graph.DijkstraNeighbor // directed edges as DijkstraNeighbors name string...
package models import ( "encoding/json" "log" ) type Post struct { Id int `json:"id"` UserId int `json:"userId"` Title string `json:"title"` Body string `json:"body"` } func (p *Post) MarshalBinary() ([]byte, error) { if p == nil { return nil, nil } return json.Marshal(p) } func (p *Post) Un...
/* This challenge has been divided into parts. Your goal is to convert a sentence into a form of 'short-hand' For Part 1 these are the rules Take in 1 word Remove all vowels, except the ones at the beginning and the end If a letter is repeated more than once consecutively, reduce it to only one (e.g. Hello -> Hlo) Cr...
package game import ( "life/engine" "os" "github.com/hajimehoshi/ebiten/v2" ) const ( screenWidth = 320 screenHeight = 240 title = "micuffaro's Game of life" ) func newGame() *game { u := engine.NewUniverse(screenWidth, screenHeight) return &game{ universe: u, pixels: make([]byte, screenWidth*...
package datastore import ( "errors" "github.com/RicardoCampos/goauth/oauth2" ) type inMemoryReferenceTokenRepository struct { tokens map[string]oauth2.ReferenceToken } func (r inMemoryReferenceTokenRepository) AddToken(token oauth2.ReferenceToken) error { if token == nil { return errors.New("you cannot add an...
// Model // The Model component corresponds to all the data-related // logic that the user works with. This can represent either // the data that is being transferred between the View and Controller // components or any other business logic-related data. // For example, a Customer object will retrieve the customer inf...
package certgen import ( "bytes" "crypto/rand" "encoding/base64" "regexp" "strings" "text/template" "path/filepath" "os" "io" "github.com/Azure/acs-engine/pkg/certgen/templates" "github.com/Azure/acs-engine/pkg/filesystem" ) // PrepareMasterFiles creates the shared authentication and ...
/** * Copyright 2019 Comcast Cable Communications Management, 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 requir...
package version import ( "database/sql" "errors" "github.com/gin-gonic/gin" _ "github.com/go-sql-driver/mysql" _ "github.com/wangfmD/rvs/log" "github.com/wangfmD/rvs/setting" "github.com/wangfmD/rvs/sshv" "log" "net/http" ) func QueryVersionById(c *gin.Context) { id := c.Param("versionid") pVersMap := sqlQ...
package storage import ( "fmt" "time" "github.com/gofrs/uuid" "github.com/sasha-s/go-deadlock" ) type CropEventStorage struct { Lock *deadlock.RWMutex CropEvents []CropEvent } type CropReadStorage struct { Lock *deadlock.RWMutex CropReadMap map[uuid.UUID]CropRead } func CreateCropReadStorage()...
package rados import ( "io" ) const ( objectReaderBufferSize = 16 * 1024 ) // Object reader. type objectReader struct { ctx *Context key string size uint64 read uint64 buf []byte fill int ofs int } // Open Rados object for reading at a specific offset with a given size. // // This does not test if the file...
package handler import ( "encoding/json" "errors" "fmt" "github.com/golang/protobuf/ptypes" "github.com/jinmukeji/jiujiantang-services/analysis/aws" "github.com/jinmukeji/jiujiantang-services/pkg/rpc" "github.com/jinmukeji/jiujiantang-services/service/auth" "github.com/jinmukeji/jiujiantang-services/service/m...
/* The MIT License (MIT) Copyright (c) 2019 Microsoft 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, pu...
package main import ( pb "github.com/ihippik/grpc-test/protocol" "golang.org/x/net/context" "net" "fmt" "google.golang.org/grpc" ) type server struct{} func (s *server) Get(ctx context.Context, in *pb.GetUserRequest)(*pb.User, error){ fmt.Println(in.Id) switch in.Id{ case 1: return &pb.User{Name:"Вася", Ema...
/* * Copyright 2018- The Pixie 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 ag...
/* It is well known that if the square root of a natural number is not an integer, then it is irrational. The decimal expansion of such square roots is infinite without any repeating pattern at all. The square root of two is 1.41421356237309504880..., and the digital sum of the first one hundred decimal digits is 475...
package tasks import ( "log" "net/http" db "github.com/AnthuanGarcia/RestApiGo/db" model "github.com/AnthuanGarcia/RestApiGo/src/models" "github.com/gin-gonic/gin" ) // HandleGetTasks - EndPoint Todas las tareas func HandleGetTasks(c *gin.Context) { loadedTasks, err := db.GetAllTasks() if err != nil { c.JS...
package models import ( "fmt" "os" "path/filepath" ) type FinderEntity struct { os.FileInfo `json:"-"` Name string `json:"name"` Size int64 `json:"-"` HumanReadableSize string `json:"humanReadableSize"` Path string `json:"path"` LastModifiedAt string `json:"la...
package services import ( "strings" "time" "github.com/ne7ermore/gRBAC/common" "github.com/ne7ermore/gRBAC/plugin" ) type roleMap map[string]*Role type User struct { Id string `json:"id"` UserId string `json:"user_id"` Roles roleMap `json:"roles"` CreateTime time.Time `json:"createT...
// Copyright (c) 2014 The btcsuite developers // Use of this source code is governed by an ISC // license that can be found in the LICENSE file. /* Package walletdb provides a namespaced database interface for btcwallet. Overview A wallet essentially consists of a multitude of stored data such as private and public ...
package j2rpc import ( "context" "reflect" ) type callback struct { server *server methodName string //receiver object of method, set if fn is method rcv reflect.Value //the function fn reflect.Value //input argument types argTypes []reflect.Type //method's first argument is a context (not included in ...
package tmp const HandlerMQTTTmp = `package {{printf "%v_handler" (index . 0)}} import ( "encoding/json" "fmt" "strings" {{printf "\"%v/handlers/%v_handler/%v_helper\"" (index . 1) (index . 0) (index . 0)}} {{printf "\"%v/helper\"" (index . 1)}} {{printf "\"%v/hub/hub_helper\"" (index . 1)}} mqtt "github.com...
package config // BUFFERSIZE is the size of max packet size const BUFFERSIZE = 1024 // PORT the default port for communication const PORT = "4242" const SERVER_ADDR = "100.0.0.1:" + PORT
package backservice import ( "context" "fmt" calc "github.com/flexera/calc/back_service/gen/calc" "github.com/flexera/calc/back_service/services/dynamo" "github.com/flexera/micro/log" ) // calc service example implementation. // The example methods log the requests and return zero values. type calcsrvc struct {...
// 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 handlers_test import ( "encoding/json" "errors" "net/http" "net/http/httptest" "github.com/cloudfoundry-incubator/notifications/models" "github.com/cloudfoundry-incubator/notifications/postal" "github.com/cloudfoundry-incubator/notifications/web/handlers" "github.com/cloudfound...
package sys import ( "easyctl/constant" "easyctl/util" "fmt" "log" "os" ) const ( aliBaseEL7WriteErrMsg = "阿里云base镜像源配置失败..." localWriteErrMsg = "local.repo文件写失败..." nginxRepoFileWriteErrMsg = "nginx.repo文件写失败..." aliEpelEL7WriteErrMsg = "阿里云epel镜像源配置失败..." setAliMirrorSuccessful = "阿里云镜像源配置成功..."...
package azure import ( "github.com/openshift/installer/pkg/terraform" "github.com/openshift/installer/pkg/terraform/providers" "github.com/openshift/installer/pkg/terraform/stages" typesazure "github.com/openshift/installer/pkg/types/azure" ) // PlatformStages are the stages to run to provision the infrastructure...
package filestore import ( "context" "io" "strings" "time" "github.com/google/uuid" ) // RevisionTags is a comma separated string of tags that refers to the revision. type RevisionTags string // AddTag adds a new tag to the tags string. func (tags RevisionTags) AddTag(tag string) RevisionTags { tag = strings....
package client import ( "bytes" "context" "fmt" "io/ioutil" "golang.org/x/net/context/ctxhttp" "github.com/terra-money/terra.go/msg" sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" "github.com/cosmos/cosmos-sdk/types/rest" feeutils "github.com/terra-money/core/custom/auth/client/utils" ) // Estimat...
package solr const ( VERSION = "0.5" )
// Copyright 2015-2018 trivago N.V. // // 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 ...
package main import ( "fmt" ) func main() { defer fmt.Println("...1...") fmt.Println("...2...") defer fmt.Println("...3...") a := 10 b := 20 // 无参的匿名函数 defer func() { fmt.Printf("func(): a = %d, b = %d\n", a, b) }() // 有参的匿名函数 defer func(a, b int) { fmt.Printf("func(a, b): a = %d, b = %d\n", a, b)...
package main import ( "fmt" "time" ) type Address struct { HouseNumber uint32 Street string HouseNumberAddOn string POBox string ZipCode string City string Country string } type VCard struct { BirtDate time.Time FirstName string LastName string N...
package main import ( "log" "math/rand" "testing" ) func TestDoTransactionSuccess(t *testing.T) { system := NewSystem() users := []*User{ { ID: 1, Name: "Tom", Cash: 10, }, { ID: 2, Name: "Jerry", Cash: 10, }, } transcation := &Transcation{ TranscationID: 1, FromID: 1,...
package core import ( "er" "fwb" "sgs" ) type prtData struct { hotIndex int timer int turn int } func prtInit(me *gameImp) *er.Err { me.lg.Dbg("Enter Round Turns phase") pd := &prtData{ hotIndex: len(me.app.GetPlayers()) - 1, timer: -1, turn: 0, } me.pd = pd me.setDCE(fwb.CMD_ACTION...
// Copyright 2018 Andreas Pannewitz. All rights reserved. // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. package core import ( "time" ) func testanyType() (string, []anyType) { name := "any" data := []anyType{ int(4), Cardinal(7), time.Monday, time....
package main import ( "context" "flag" "fmt" "log" "net" "path/filepath" pb "nekonenene/hello/pb" "google.golang.org/grpc" "google.golang.org/grpc/credentials" "google.golang.org/grpc/reflection" ) var ( tls *bool = flag.Bool("tls", false, "Connection uses TLS if true, else plain TCP") certFile *...
// Package fftypes contains core types used throughout the functions framework // (ff) implementation. package fftypes import ( "cloud.google.com/go/functions/metadata" ) // BackgroundEvent is the incoming payload to functions framework to trigger // Background Functions (https://cloud.google.com/functions/docs/writ...
package raft import ( "log" "net" "net/http" "net/rpc" "sync" ) type ClientEnd struct { addr string rpcClient *rpc.Client sync.Mutex } func (end *ClientEnd) call(method string, args interface{}, reply interface{}) error { var client *rpc.Client var err error end.Lock() client = end.rpcClient end.Un...
package spotty import ( "os" ) var SPOTIFY_ID = os.Getenv("SPOTIFY_ID") var SPOTIFY_SECRET = os.Getenv("SPOTIFY_SECRET") var SPOTIFY_USER_ID = os.Getenv("SPOTIFY_USER_ID") var SPOTIFY_PLAYLIST_ID = os.Getenv("SPOTIFY_PLAYLIST_ID")
package admin import ( "cwengo.com/models" /*"fmt"*/ /*"reflect"*/ /*"encoding/base64"*/ "github.com/astaxie/beego" "strconv" "strings" ) type TopicController struct { beego.Controller } func (this *TopicController) Prepare() { userid := this.GetSession("userid") username := this.GetSession("username") if...
package main import ( "fmt" "os" "os/signal" "strings" "syscall" "exchanges" "github.com/bwmarrin/discordgo" ) const prefix = "!price" var token, secret string func init() { token = os.Getenv("APP_TOKEN") secret = os.Getenv("SECRET") } func main() { dg, err := discordgo.New("Bot " + token) if err != n...
package tdt import ( "fmt" "testing" ) func TestWithNoAttachedFunc(t *testing.T) { testCases := []struct { name string arg string want string }{ {"name1", "arg1", "want1"}, } for _, tc := range testCases { fmt.Errorf("Name: %v\nArg: %v\nWant: %v", tc.name, tc.arg, tc.want) } }
package main import ( "github/mariomang/catrouter" "io/mariomang/github/consts" "io/mariomang/github/controller" ) //The SnowFlake program enter func main() { app := catrouter.NewDefaultApp(consts.AppName, consts.Author, consts.Version, consts.Email) app.RegistController(catrouter.POST, "/primary/apply", control...
package apigen //API - This is api configuration type API struct { ModelName string `json:"model_name,omitempty"` Methods Method `json:"methods,omitempty"` } //Method - This is method type Method struct { Detail Detail `json:"detail,omitempty"` } //Detail - This is detail type Detail struct { Name str...
package middlewares import ( "fmt" "github.com/owenliang/myf-go-cat/cat" cat2 "github.com/owenliang/myf-go/client/cat" "github.com/owenliang/myf-go/conf" cronContext "github.com/owenliang/myf-go/cron/context" ) func Cat() cronContext.HandleFunc { // 初始化CAT if conf.MyfConf.CatConfig.IsOpen { if conf.MyfConf.D...
package main import ( "database/sql" DbModel "gowork/model/db" Config "gowork/utils" "log" "time" "github.com/go-xorm/xorm" "github.com/kataras/iris" _ "github.com/lib/pq" ) //Home o func Home(app *iris.Application, engine *xorm.Engine) { //./bombardier-linux-amd64 -c 100 -n 100 lfoteam.ddns.net:9001/test ...
package pie import ( "encoding/json" "golang.org/x/exp/constraints" ) // JSONStringIndent returns the JSON encoded array as a string with indent applied. // // One important thing to note is that it will treat a nil slice as an empty // slice to ensure that the JSON value return is always an array. See // json.Mars...
package pathfileops // DirTreeOp - Contains data fields used to store directory information // generated by type DirMgr. type DirTreeOp struct { CallingFunc string FileOps []FileOperationCode FileSelectCriteria FileSelectionCriteria SourceBaseDir DirMgr TargetBaseDir DirMgr Err...
package domain import . "meli/cmd/data" func GetLocation(distances ...float32) (x, y float32) { if len(distances) != 3 { return 0, 0 } radiusKenobi := distances[0] radiusSkywalker := distances[1] rediusSato := distances[2] S := (square(SATO_X) - square(SKYWALKER_X) + square(SATO_Y) - square(SKYWALKER_Y) + s...
// Package hybrid provides a hybrid FSDB implementation. // // A hybrid FSDB is backed by a local FSDB and a remote bucket. // All data are written locally first, then a background thread will upload them // to the remote bucket and delete the local data. // Read operations will check local FSDB first, // and fetch fro...