text
stringlengths
11
4.05M
package schema import ( "github.com/facebook/ent/dialect" "github.com/facebook/ent" "github.com/facebook/ent/schema/field" ) // PhoneAccount holds the schema definition for the PhoneAccount entity. type PhoneAccount struct { ent.Schema } // Mixin of the PhoneAccount. func (PhoneAccount) Mixin() []ent.Mixin { r...
/* Package collectors defines collectors for app Copyright © 2020 Vishnu Rajendran vishnraj@umich.edu 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 ...
package dbl import ( //"fmt" "github.com/espebra/filebin2/ds" "testing" //"time" ) func TestGetByBin(t *testing.T) { dao, err := tearUp() if err != nil { t.Error(err) } defer tearDown(dao) binID := "1234567890" bin := &ds.Bin{} bin.Id = binID err = dao.Bin().Insert(bin) if err != nil { t.Error(err) ...
package go1broker import ( "github.com/ZandorZ/go1broker/api" "github.com/go-resty/resty" ) const basePath string = "https://1broker.com/api/v2" //OneBrokerClient ... type OneBrokerClient struct { hclient *resty.Client basePath string user *api.User order *api.Order position *api.Position market *a...
package services import ( "blog/app/common" "blog/app/models" "blog/app/repositories" "errors" "github.com/mlogclub/simple" ) type UserService interface { SignIn(username, password string) (*models.User, error) } func NewUserService() UserService { return &userService{ userRepository: repositories.NewUserRe...
// Package steward - package steward import ( "log" "time" ordone "github.com/shanehowearth/concurrency_in_go/ordonechannel" ) // StartGoroutineFn - type StartGoroutineFn func( done <-chan interface{}, pulseInterval time.Duration, ) (heartbeat <-chan interface{}) // NewSteward - // Ignore the non-exported type...
// Go support for Protocol Buffers RPC which compatiable with https://github.com/Baidu-ecom/Jprotobuf-rpc-socket // // Copyright 2002-2007 the original author or authors. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // Yo...
package main import ( "bytes" "encoding/json" "net/http" "net/http/httptest" "net/url" "strconv" "testing" ) func TestGetDaysHandler(t *testing.T) { mockStore := InitMockStore() mockStore.On("GetDays").Return([]*Day{ {"1990-01-02", 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10,10}}, nil).Once() req,...
package main import ( "io" "log" "net/http" ) func myName(res http.ResponseWriter, req *http.Request) { io.WriteString(res, "Marvel") } func main() { http.HandleFunc("/marvel/", myName) err := http.ListenAndServe(":8080", nil) if err != nil { log.Fatalln("Server error:", err) } }
package filestoresql import ( "context" "errors" "fmt" "github.com/direktiv/direktiv/pkg/refactor/filestore" "github.com/google/uuid" "gorm.io/gorm" ) type sqlFileStore struct { db *gorm.DB } func (s *sqlFileStore) ForRootID(rootID uuid.UUID) filestore.RootQuery { return &RootQuery{ rootID: rootID, ...
package main import ( "bufio" "fmt" "os" ) func main(){ scanner:=bufio.NewScanner(os.Stdin) scanner.Scan() operacion:=scanner.Text() fmt.Println(operacion) }
package handler import ( "backend/src/constants" "backend/src/module" "backend/src/service" "github.com/gin-gonic/gin" "github.com/gin-gonic/gin/binding" ) // 登录 func Login(context *gin.Context) { var param module.UserVo _ = context.ShouldBindWith(&param, binding.Form) result := service.Login(param) WrapperR...
/* # -*- coding: utf-8 -*- # @Author : joker # @Time : 2021/7/12 9:47 上午 # @File : jz_29_最小的k个数.go # @Description : # @Attention : */ package offer func GetLeastNumbers_Solution(input []int, k int) []int { heap := make([]int, 0) for _, v := range input { if len(heap) < k { heap = append(heap, v) } else { i...
package main import ( "bufio" "fmt" "os" ) func check(e error) { if e != nil { panic(e) } } func main() { boxesWithTwo := 0 boxesWithThree := 0 f, err := os.Open("Day2/puzzle2.txt") check(err) scanner := bufio.NewScanner(f) for scanner.Scan() { letterCounter := map[rune]int{} // Go through the b...
package main import ( "context" "log" "os" "cloud.google.com/go/pubsub" ) var ( projectID = os.Getenv("GOOGLE_CLOUD_PROJECT") subsc = os.Getenv("PUBSUB_SUBSC") ) func main() { ctx := context.Background() client, err := pubsub.NewClient(ctx, projectID) if err != nil { panic(err) } defer client.Clos...
/* # -*- coding: utf-8 -*- # @Author : joker # @Time : 2020-08-10 09:54 # @File : tree.go # @Description : # @Attention : */ package base type TreeNode struct { Data int LeftNode *TreeNode RightNode *TreeNode }
package stuff import ( "fmt" "log" "os" "strings" "github.com/PuerkitoBio/goquery" ) // LineageOS has their shit WAY more together than previous generations of android/CM! // // All their data is actually available in YAML in GIT! // https://github.com/LineageOS/lineage_wiki/blob/master/_data/devices/bacon...
package server import ( "net" "net/http" "net/http/fcgi" "os" "runtime" "strings" "time" "webconsole/utils" ) var ( ABC_Conf, conf_err = utils.Get_Conf() ) func init() { runtime.GOMAXPROCS(runtime.NumCPU()) if nil != conf_err { utils.Log_Fatal(conf_err.Error()) } _ = ABC_Conf.Web.Addr } func GetPID()...
package operation import ( "log" "github.com/google/go-github/github" ) func AddComment(issueSvc *github.IssuesService, owner string, name string, issue int, body string) bool { _, _, err := issueSvc.CreateComment(owner, name, issue, &github.IssueComment{ Body: &body, }) if err != nil { log.Printf("info: co...
// Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. // Package i18n contains localized strings for user facing messages. package i18n
package bench import ( "sync" "testing" ) func BenchmarkCounterAdd(b *testing.B) { c := Counter{0, &sync.RWMutex{}} for n := 0; n < b.N; n++ { c.Add(1) } } func BenchmarkCounterRead(b *testing.B) { c := Counter{0, &sync.RWMutex{}} for n := 0; n < b.N; n++ { c.Read() } } func BenchmarkCounterAddRead(b *t...
/* go likes error very much and treats them as their gf that's why they have created a seperate data type "error" you can create yur own error message if you found that go error messages are not adequate. having an error is one thing but how you will react to that error is a different thing. some error needs program te...
package server import ( "net/http" "gopkg.in/doug-martin/goqu.v3" "github.com/empirefox/esecend/front" "github.com/gin-gonic/gin" ) func (s *Server) GetNews(c *gin.Context) { items, err := s.NewsResource.NewSearcher(c).FindMany() ResponseObject(c, items, err) } func (s *Server) GetOrders(c *gin.Context) { d...
package main import ( "errors" "fmt" "github.com/astaxie/beego/config" ) var ( appConfig *Config ) type Config struct{ LogLevel string LogPath string CollectConf []CollectConf } type CollectConf struct { LogPath string Topic string } func LoadConf(confType,fileName string)(err error){ conf,err:=config.NewCo...
package labeler import ( "k8s.io/apimachinery/pkg/labels" ) // Labeler can provide label sets that describe an object type Labeler interface { // LabelSetsFor returns label sets that describe the given object LabelSetsFor(obj interface{}) ([]labels.Set, error) } // Func is a function type that implements the Labe...
package httpcanvas import ( "fmt" "html/template" "log" "math/rand" "net/http" "net/url" "strings" "strconv" ) type mouseMovement struct { command string x float64 y float64 } type CanvasHandler func(*Context) type Canvas struct { handler CanvasHandler Width float64 Height float64 Uniq...
package response import ( "encoding/json" ) type Holder struct { Data interface{} `json:"data"` Error *Error `json:"error"` } func NewHolder(data interface{}, err *Error) *Holder { return &Holder{ Data: data, Error: err, } } func NewEncodedSuccessHolder(data interface{}) []byte { return NewHolder(d...
package Models import "go.mongodb.org/mongo-driver/bson/primitive" type DataModel struct { ID primitive.ObjectID `json:"_id" bson:"_id"` Device string `json:"device" bson:"device"` Date string `json:"date" bson:"date"` Value string `json:"value" bson:"value"` }
package main import ( "fmt" ) func main() { // test([]int{2, 1, 5, 6, 2, 3}, 10) test([]int{2, 1, 2}, 3) } func test(heights []int, r int) { if r != largestRectangleArea(heights) { fmt.Println(heights, r) } } func largestRectangleArea(heights []int) int { res := 0 stack := []int{} heights = append(heights...
package etw import "C" import ( "fmt" "syscall" "unsafe" ) const ( ERROR_INSUFFICIENT_BUFFER syscall.Errno = 122 ERROR_NOT_FOUND syscall.Errno = 23 ) var ( advapi = syscall.NewLazyDLL("advapi32.dll") tdh = syscall.NewLazyDLL("tdh.dll") ...
package main import ( "github.com/pauloaguiar/ces27-lab1/mapreduce" "hash/fnv" "strings" "strconv" "unicode" ) // mapFunc is called for each array of bytes read from the splitted files. For wordcount // it should convert it into an array and parses it into an array of KeyValue that have // all the words in the i...
/* * Copyright 2018, CS Systemes d'Information, http://www.c-s.fr * * 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 internal import ( "errors" "sync/atomic" "github.com/go-jwdk/jobworker" "github.com/go-stomp/stomp" ) const ( subStateActive = 0 subStateClosing = 1 subStateClosed = 2 ) func NewSubscription(name string, raw *stomp.Subscription) *Subscription { return &Subscription{ name: name, raw: raw, ...
package main import ( "errors" "fmt" "io/ioutil" "net/http" "strings" "time" "github.com/GoAdminGroup/go-admin/modules/utils" "github.com/mgutz/ansi" "github.com/GoAdminGroup/go-admin/modules/system" ) func cliInfo() { fmt.Println("GoAdmin CLI " + system.Version() + compareVersion(system.Version())) fmt....
package main import "fmt" import "time" func main() { //traditional channeling messages := make(chan string) //IIFE :)? go func() { messages <- "ping" }() //sends and passes back. allows us to get it at the end //without any syncs. msg := <-messages fmt.Println(msg) ...
package main import ( "errors" "fmt" "github.com/jpillora/opts" "github.com/wxio/tron-go/adl/vscode-ext/lsp" ) var ( Version = "dev" Date string Commit string ) type root struct{} func main() { r := root{} opts.New(&r).Name("adl-lsp"). EmbedGlobalFlagSet(). Version(Version). AddCommand(lsp.NewTc...
package notifier import ( "github.com/jouir/pgterminate/base" ) // Notifier generic interface for implementing a notifier type Notifier interface { Run() Reload() } // NewNotifier looks into Config to create a Console, File or Syslog notifier and pass it // the session channel for consuming sessions structs sent ...
package consulutil import ( "time" "github.com/hashicorp/consul/api" "github.com/sirupsen/logrus" "github.com/square/p2/pkg/logging" "github.com/square/p2/pkg/util/param" "github.com/square/p2/pkg/util/randseed" ) // SessionRetrySeconds specifies the base time to wait between retries when establishing a // se...
package hocon type MightBeObject interface { IsObject() bool GetObject() *Object } type Element interface { IsString() bool GetString() string IsArray() bool GetArray() []*Value }
package golayout import ( "github.com/gobuffalo/packr/v2" ) var TemplateBox *packr.Box const ( TemplateExt = ".ttpl" )
// Copyright 2018 Andrew Bates // // 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 repository import ( "database/sql" "fmt" "strconv" "todo-app/internal/data" _ "github.com/go-sql-driver/mysql" // import for driver ) // DBConnection initalizes a sql.DB instance func DBConnection(user string, password string, database string) (db *sql.DB, err error) { connString := fmt.Sprintf("%s:%s@...
// Copyright 2012 Chris Broadfoot (chris@chrisbroadfoot.id.au). All rights reserved. // Licensed under Apache 2. package geocell import "testing" const ( lat = 37.4 lng = -152.34 cell = Cell("8b274e45b9e19") ) var latlng = LatLng{lat, lng} func Test_Encode_1(t *testing.T) { encodeDecode(t, cell, latlng) enco...
package nes import ( "encoding/gob" "log" ) type Mapper3 struct { *Cartridge chrBank int prgBank1 int prgBank2 int } func NewMapper3(cartridge *Cartridge) Mapper { prgBanks := len(cartridge.PRG) / 0x4000 return &Mapper3{cartridge, 0, 0, prgBanks - 1} } func (m *Mapper3) Save(encoder *gob.Encoder) error { ...
package client import ( "encoding/json" "errors" "net/http" "time" log "github.com/sirupsen/logrus" ) const amountSuffix = "/v1/amounts" //GetTotalAmount calculate the total amount of Charges in SUCCESS status and the total amount of Refunds within a specific timeframe. func (client *Client) GetTotalAmount(sta...
package build import ( "bytes" "context" "encoding/json" "fmt" "io/ioutil" "os" "runtime" "strings" "sync" "time" "github.com/google/uuid" "github.com/werf/logboek" "github.com/werf/logboek/pkg/style" "github.com/werf/logboek/pkg/types" "github.com/werf/werf/pkg/build/stage" "github.com/werf/werf/pk...
package network const ( RegionWestCoast = "sjc" )
package sysinfo import "testing" func TestResolveNameFromVersion(t *testing.T) { for _, tt := range []struct { in string out string }{ {"10.9", "OS X Mavericks"}, {"10.10.3", "OS X Yosemite"}, {"10.11.1", "OS X El Capitan"}, {"10.12.6", "macOS Sierra"}, {"10.13", "macOS High Sierra"}, {"10.14.4", "...
package main import ( _ "flag" "strings" _ "github.com/axgle/mahonia" ) //var infile *string = flag.String("i", "", "输入文件") //var outfile *string = flag.String("o", "", "输出文件") //var redis_conf *string = flag.String("r", "", "Redis服务器IP及端口,默认:127.0.0.1:6379") //func main() { // flag.Parse() // content, err := r...
package contracts import ( "math/big" "sub_account_service/blockchain_server/arguments" "sub_account_service/blockchain_server/config" "sub_account_service/blockchain_server/lib" "sub_account_service/blockchain_server/lib/eth" "github.com/ethereum/go-ethereum/common" "github.com/golang/glog" ) var UseNonce = ...
// 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 chartrepotest import ( "errors" "fmt" "os/exec" "strings" "testing" ) // tChartMuseumReal starts a real ChartMuseum service on an available port, // running in a Docker container. Most tests should use a fake instead. // // The URL of the service and a cleanup func that should be called once the // servi...
package main import ( "errors" "fmt" "geektime/Go-000/Week02/dao" "geektime/Go-000/Week02/service" ) func main() { name := "test1" srv := &service.UserService{} res, err := srv.GetUser(name) //屏蔽掉底层的sql.ErrNoRows,使用自己的预定义错误 if errors.Is(err, dao.ErrDaoNotFound) { fmt.Printf("%+v\n", err) //或者使用mock数据返...
package keyvaluestore type Command struct { Operation string Operand1 interface{} Operand2 interface{} }
package tsmt import ( "encoding/xml" "github.com/thought-machine/finance-messaging/iso20022" ) type Document01800105 struct { XMLName xml.Name `xml:"urn:iso:std:iso:20022:tech:xsd:tsmt.018.001.05 Document"` Message *FullPushThroughReportV05 `xml:"FullPushThrghRpt"` } func (d *Document01800105) ...
package main import ( "fmt" "github.com/Cloud-Foundations/Dominator/imageunpacker/client" "github.com/Cloud-Foundations/Dominator/lib/log" ) func unpackImageSubcommand(args []string, logger log.DebugLogger) error { if err := client.UnpackImage(getClient(), args[0], args[1]); err != nil { return fmt.Errorf("err...
package handler import ( "fmt" "net/http" "github.com/agusbasari29/Skilltest-RSP-Akselerasi-2-Backend-Agus-Basari/entity" "github.com/agusbasari29/Skilltest-RSP-Akselerasi-2-Backend-Agus-Basari/helper" "github.com/agusbasari29/Skilltest-RSP-Akselerasi-2-Backend-Agus-Basari/request" "github.com/agusbasari29/Skil...
package main import ( "github.com/dolphinsboy/test-orchestrator/go/http" "github.com/go-martini/martini" "github.com/martini-contrib/render" "log" nethttp "net/http" ) func main() { m := martini.Classic() http.API.URLPrefix = "" http.Web.URLPrefix = "" http.API.RegisterRequests(m) http.Web.RegisterRequests(...
package user import ( "model" "strconv" "testing" ) func testAddDevice(t *testing.T) { base := "12345678541" for i := int64(1350); i < 1450; i++ { imei := base + strconv.FormatInt(i, 10) d := &model.User{ Id: int(i), IMei: imei, UserType: 1, PassWord: "123456", UserName: string(...
package main import ( "fmt" "os" "bufio" "strings" "strconv" ) const inputPath = "input.txt" type instruction struct{ op string reg string val string } func main() { ins,reg := parseInstructions(inputPath) sound := execInstructions(ins,reg) fmt.Println(reg,sound) } func convert(value string, reg map[stri...
package server import ( "encoding/json" "net/http" "time" "github.com/golang/protobuf/jsonpb" "github.com/gorilla/mux" "github.com/rs/cors" "github.com/sirupsen/logrus" "github.com/zaynjarvis/fyp/dc/api" ) func ListenConfig(addr string, getSvc func() []string) chan *api.CollectionConfig { ch := make(chan *a...
package waitgroupmap import "sync" // A named wait group mapping type WaitGroupMap struct { // The groups for this WaitGroupMap Groups map[string]*sync.WaitGroup // The mutex for Groups access GroupsMutex sync.Mutex // The finished handlers for this WaitGroupMap Handlers map[string][]func() // The mutex for...
package orm import ( "database/sql" ) type User struct { Id int64 `column:"id"` UserCode string `column:"user_code"` Password string `column:"password"` RealName sql.NullString `column:"real_name"` Mobile sql.NullString `column:"mobile"` Email sql.NullStrin...
package main import ( "fmt" "io" // "log" ) type Interpreter struct { tokens []Token stack []int r io.Reader w io.Writer } func New(p string, w io.Writer, r io.Reader) *Interpreter { _, ts := lex(p) tokens := make([]Token, 0) for t := range ts { tokens = append(tokens, t) } return &Interpr...
package command import ( "fmt" "math" "math/rand" "sort" "strconv" "strings" "time" "github.com/jixwanwang/jixbot/channel" ) const entryAmount = 1 type lottery struct { cp *CommandPool startComm *subCommand endComm *subCommand enterComm *subCommand entries map[string]int active bool } func...
package transformer import ( "github.com/guilhermesteves/go-todo-api/internal/pkg/core/model" "go.mongodb.org/mongo-driver/bson/primitive" ) func BsonToToDos(src primitive.A) []*model.ToDo { todos := []*model.ToDo{} if src != nil { for _, d := range src { todos = append(todos, BsonToToDo(d.(primitive.M))) ...
package main import ( "fmt" "golang.org/x/crypto/bcrypt" ) func main() { password := "testtest" hash, err := bcrypt.GenerateFromPassword([]byte(password), bcrypt.DefaultCost) if err != nil { panic(err) } fmt.Printf("Password: %s\nHash: %s\n", password, string(hash)) }
package main import "fmt" var ( message = "Hello World" ) func main() { fmt.Println(message) } func init() { message = "Hello GO!!!!" } type TestStruct struct { FirstName string LastName string Email string }
package main import "fmt" const p = "SOS" func main() { var s string fmt.Scanf("%s", &s) mismatchCount := 0 for x := range s { if s[x] != p[x%3] { mismatchCount++ } } fmt.Println(mismatchCount) }
package controller import ( "forum_Anpw/common" "forum_Anpw/model" "forum_Anpw/reps" "github.com/gin-gonic/gin" "github.com/jinzhu/gorm" "golang.org/x/crypto/bcrypt" ) //用户注册 func Register(c *gin.Context) { db:=common.GetDB() username:=c.PostForm("username") password:=c.PostForm("password") securityCode:=c...
package primitives import ( "github.com/go-gl/mathgl/mgl32" ) const POINT_FLAT_SIZE = VERTEX_SIZE type Vec2 = mgl32.Vec2 type Vec3 = mgl32.Vec3 type Vec4 = mgl32.Vec4 type Mat4 = mgl32.Mat4 type Point struct { Vertex DrawPrimitive } func XY(x, y float32) Vec4 { return Vec4{x, y, 0, 1} } func XYZ(x, y, z...
package main import ( "github.com/ScriptArts/DiscordTaskManagementBot/bot" "github.com/ScriptArts/DiscordTaskManagementBot/models" "github.com/ScriptArts/DiscordTaskManagementBot/utils" "log" "os" "os/signal" "syscall" ) func initialize() error { err := utils.LoadEnv() if err != nil { return err } retur...
package acdc import ( "fmt" ) func ExampleSum() { fmt.Println(Sum(1, 2, 3)) //Output: // 6 }
package handler import ( "im/engine" "log" ) type Login struct { } func (login *Login) ChannelRead(ctx *engine.Context) { log.Println("login") //ctx.Cancel() }
/* Copyright 2011 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 writing, software di...
package db import ( "time" "github.com/boltdb/bolt" ) type Interface interface { CreateBucket(name string) error DeleteBucket(name string) error Buckets() ([]string, error) UseBucket(name string) error CurrentBucket() string Put(key, value string) error Remove(key string) error Get(key string) (string, er...
/* * Tencent is pleased to support the open source community by making Blueking Container Service available. * Copyright (C) 2019 THL A29 Limited, a Tencent company. All rights reserved. * Licensed under the MIT License (the "License"); you may not use this file except * in compliance with the License. You may obtain a...
package main import "strings" func newAnnotation(comment string) *annotation { annotation := new(annotation) s := strings.TrimPrefix(comment, "//") s = strings.TrimSpace(s) if !strings.HasPrefix(s, "@") { return nil } tmp := strings.Split(s, "=") nameKey := strings.Split(tmp[0], "(") annotation.Name = stri...
package server import ( "encoding/json" "fmt" "net/http" "reflect" "github.com/ItsJimi/casa/logger" "github.com/ItsJimi/casa/utils" "github.com/labstack/echo" "github.com/lib/pq" ) type addAutomationReq struct { Name string Trigger []string TriggerKey []string TriggerValue []st...
package httpclient_test import ( "context" "encoding/json" "io" "net/http" "net/http/httptest" "net/url" "testing" "github.com/best-expendables/httpclient" "github.com/stretchr/testify/assert" ) type CustomResponseParser struct{} func (c *CustomResponseParser) Parse(r io.Reader, v interface{}) error { ret...
package worldx import ( "fmt" ) type City struct { name string alienId int // 0 means nobody! north string // empty means there is no way south string west string east string } func NewCity(name, n, s, w, e string) *City { return &City{ name: name, north: n, south: s, west: w, east: e, } } ...
package util type Node struct { children []*Node title string value string } func NewNode(title, value string) *Node { return &Node{ title: title, value: value, } } func (n *Node) AddChild(childNode *Node) { n.children = append(n.children, childNode) } func (n *Node) GetChildren() []*Node { return ...
package control import "github.com/labstack/echo" func LoginView(ctx echo.Context) error { return ctx.Render(200, "login.html", nil) } func AdminIndexView(ctx echo.Context) error { return ctx.Render(200, "index.html", nil) }
package corekit import ( "encoding/json" "net/http" "github.com/pkg/errors" "github.com/t-ksn/core-kit/apierror" ) // API Handler type APIHandler func(req *http.Request) (interface{}, error) func wrapAPIHandler(log func(format string, args ...interface{})) func(handler APIHandler) http.Handler { return func(ha...
// Copyright 2021 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 handler import ( "net/http" "github.com/nektro/mantle/pkg/db" "github.com/nektro/mantle/pkg/ws" "github.com/gorilla/mux" ) // UsersMe is handler for /api/users/@me func UsersMe(w http.ResponseWriter, r *http.Request) { _, user, err := apiBootstrapRequireLogin(r, w, http.MethodGet, true) if err != nil ...
// Copyright 2014 The Sporting Exchange Limited. All rights reserved. // Use of this source code is governed by a free license that can be // found in the LICENSE file. package nitro import ( "testing" ) func TestConnLimit(t *testing.T) { limit := make(connLimit, 2) limit.Wait() limit.Wait() limit.Done() limi...
package stateless import ( "context" aliceapi "github.com/yandex-cloud/examples/serverless/alice-shareable-todolist/app/alice/api" aliceauth "github.com/yandex-cloud/examples/serverless/alice-shareable-todolist/app/alice/auth" "github.com/yandex-cloud/examples/serverless/alice-shareable-todolist/app/errors" "git...
package constant type Behavior int const ( BehaviorNone Behavior = iota BehaviorPeng BehaviorGang BehaviorAnGang BehaviorBaGang BehaviorHu ) type DeskStatus byte const ( //创建桌子 DeskStatusCreate DeskStatus = iota //发牌 DeskStatusDuanPai //齐牌 DeskStatusQiPai //游戏 DeskStatusPlaying //单局正常完成 DeskSta...
/* * Prints out networking information for a given server. */ package main import ( "flag" "fmt" "os" "path" "github.com/grrtrr/clcv2" "github.com/grrtrr/clcv2/clcv2cli" "github.com/grrtrr/exit" "github.com/olekukonko/tablewriter" ) func main() { flag.Usage = func() { fmt.Fprintf(os.Stderr, "usage: %s [...
package goinsta import ( "encoding/json" "fmt" ) // Feed is the object for all feed endpoints. type Feed struct { inst *Instagram } // newFeed creates new Feed structure func newFeed(inst *Instagram) *Feed { return &Feed{ inst: inst, } } // Feed search by locationID func (feed *Feed) Loca...
package kintone type FieldType string const ( FieldSingleLineText = "SINGLE_LINE_TEXT" FieldMultiLineText = "MULTI_LINE_TEXT" FieldNumber = "NUMBER" ) func (ft FieldType) String() string { return string(ft) } type FieldCode string func (fc FieldCode) String() string { return string(fc) } type Field ...
package bigmux import ( "errors" "net" "testing" ) func TestIsTimeout(t *testing.T) { t.Parallel() err := errors.New("hello") if isTimeout(err) { t.Error("err is not a timeout") } } func TestIsTimeoutNil(t *testing.T) { t.Parallel() if isTimeout(nil) { t.Error("nil is not a timeout") } } func Te...
package api import ( "github.com/labstack/echo/v4" "github.com/vitor-amartins/webapi-auth-go/services" ) type Middlewares struct { AllowGeneralRoles func(next echo.HandlerFunc) echo.HandlerFunc AllowAdminRoles func(next echo.HandlerFunc) echo.HandlerFunc AllowMentorRoles func(next echo.HandlerFunc) echo.Handl...
package hive import ( "crypto/tls" "net/http" "reflect" "testing" "time" ) func TestOptions(t *testing.T) { tests := []struct { name string opt Option want options }{ {"WithURL", WithURL("http://test.host"), options{baseURL: "http://test.host"}}, {"WithCredentials", WithCredentials("user", "pass"), ...
package scache type Kind int const ( KindUnknown Kind = iota KindLRU )
package main import ( "fmt" "regexp" "strings" ) func main() { str := " data ONLINE 0 0 0 asdasdas das dads asd" fmt.Println(strings.Join(regexp.MustCompile(`\s+`).Split(str, 6), "|") + "$$$") }
package aoc2015 import ( "strconv" "github.com/antonholmquist/jason" "github.com/pkg/errors" ) // extractSum returns the sum of all numbers (Int64) in an arbitrary value. // If the value is an int64 it will return that immediately. // If the value is an Object it will return the extracted sum of its value // If t...
package app import ( "fmt" "net/http" "os" "time" "github.com/prometheus/client_golang/prometheus" "github.com/prometheus/client_golang/prometheus/promhttp" "github.com/spf13/cobra" flag "github.com/spf13/pflag" v1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/apimachinery/pkg/fields" coreinformer "k8s.io...
/***************************************************************** * Copyright©,2020-2022, email: 279197148@qq.com * Version: 1.0.0 * @Author: yangtxiang * @Date: 2020-08-14 15:47 * Description: *****************************************************************/ package gcontext import ( "bytes" "fmt" "github.com/g...