text
stringlengths
11
4.05M
package api import ( "fmt" "github.com/johanhenriksson/edetalj-backend/views" ) type ViewService struct { } type UserViewService struct { ViewService Template *views.Template } func (srv ViewService) Path() string { return "/{name}" } func (srv ViewService) Routes() Routes { return Routes {...
package mempool import ( "testing" "github.com/meshplus/bitxhub-kit/types" "github.com/meshplus/bitxhub-model/pb" "github.com/stretchr/testify/assert" ) func TestStorage(t *testing.T) { ast := assert.New(t) mempool, _ := mockMempoolImpl() defer cleanTestData() txList := make([]*pb.Transaction, 0) txHashLis...
// +build !test package util func init() { loadConfig() }
package ch1 import ( "bytes" "testing" ) func TestEchoOSArgs(t *testing.T) { buf := bytes.NewBuffer(nil) if err := EchoOSArgs(buf, "\n"); err != nil { t.Error(err) } t.Logf("success,os.Args is\n%s", buf.String()) }
package main import "gopkg.in/mgo.v2/bson" type Task struct { Id bson.ObjectId `json:"id" bson:"_id,omitempty"` Name string `json:"name"` IsCompleted bool `json:"is_completed"` } type Tasks []Task
package actions import ( "crypto/md5" "encoding/hex" "errors" "strings" "time" "github.com/barrydev/api-3h-shop/src/common/connect" "github.com/barrydev/api-3h-shop/src/factories" "github.com/barrydev/api-3h-shop/src/helpers" "github.com/barrydev/api-3h-shop/src/model" "github.com/dgrijalva/jwt-go" ) func ...
package websocket_service import ( "ms/sun_old/base" "ms/sun/shared/helper" "ms/sun/servises/chat_service" "ms/sun/shared/x" "time" ) var syncChatPipePusher = make(chan *x.ChatSync, 100000) var lastSyncLoaded = helper.NextRowsSeqId() func syncChaFetcher() { defer helper.JustRecover() for { time.Sleep(tim...
package main import ( "context" "crypto/sha512" "encoding/hex" "errors" "flag" "fmt" "github.com/milaniez/teleportselftest/protojob" "github.com/milaniez/teleportselftest/util/mytls" "google.golang.org/grpc" "google.golang.org/grpc/credentials" "google.golang.org/grpc/peer" "google.golang.org/grpc/reflecti...
package pie import ( "golang.org/x/exp/constraints" "math/rand" ) // Random returns a random element by your rand.Source, or zero. func Random[T constraints.Integer | constraints.Float](ss []T, source rand.Source) T { n := len(ss) // Avoid the extra allocation. if n < 1 { return 0 } if n < 2 { return ss[...
package trident import ( pf "trident.li/pitchfork/lib" ) type TriGroupMember interface { pf.PfGroupMember GetVouchesFor() int GetVouchesBy() int GetVouchesForMe() int GetVouchesByMe() int } type TriGroupMemberS struct { pf.PfGroupMember VouchesFor int VouchesBy int VouchesForMe int VouchesByMe int }...
package cli import ( "context" "fmt" "io" "net/url" "os" "path/filepath" "runtime" "strings" "time" "github.com/google/uuid" "github.com/moby/buildkit/frontend/dockerfile/dockerfile2llb" "github.com/moby/buildkit/solver/pb" ocispecs "github.com/opencontainers/image-spec/specs-go/v1" log "github.com/siru...
package grammar import ( // "fmt" "strings" // "golang.org/x/tour/wc" ) // func main() { // var str string = "I am in baidu am am" // var re map[string]int = WordCount(str) // fmt.Println(re) // } func WordCount(s string) map[string]int { var strs []string = strings.Fields(s) var result map[string]int = make...
package gotoml import ( "fmt" "testing" "time" ) func TestStripLineComment(c *testing.T) { out := StripLineComment("should remain # should strip") expected := "should remain " if out != expected { fmt.Println(out) c.Error("should strip from # to end of string") } out = StripLineComment("key = \"\\\"conta...
package router import ( "github.com/google/uuid" "io/ioutil" "log" "mime" "net" "net/http" "net/url" "os" "path" "path/filepath" "reflect" "regexp" "strconv" "strings" "time" ) const ( CONNECT = "CONNECT" DELETE = "DELETE" GET = "GET" HEAD = "HEAD" OPTIONS = "OPTIONS" PATCH = "PATCH" P...
// Copyright (c) 2017 mgIT GmbH. All rights reserved. // Distributed under the Apache License. See LICENSE for details. package mqv import ( "crypto/elliptic" "io" "math/big" "github.com/pkg/errors" ) var genMask = []byte{0xff, 0x1, 0x3, 0x7, 0xf, 0x1f, 0x3f, 0x7f} // GenerateKey returns a public / private key...
/* Continued fractions are expressions that describe fractions iteratively. They can be represented graphically: a0 + 1/(a1 + 1/(a2 + 1/(a3 + ...))) Or they can be represented as a list of values: [a0;a1,a2,…,an] The challenge: take a base number: a0 and a list of denominator values: [a1,a2,…,an] and simplify the c...
// Copyright 2017 The go-darwin Authors. All rights reserved. // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. package hdiutil import "strconv" func boolFlag(name string, b bool) []string { if b { return []string{"-" + name} } return nil } func boolNoFlag(...
package upstream import ( "encoding/json" "errors" "fmt" "github.com/tal-tech/go-zero/core/logx" "strings" "tpay_backend/utils" ) const ( TopPayQuickSignUrl = "/quickSign" // 订单是否已支付 TopPayUnpaid = "成功" // 成功 TopPayPaid = "失败" // 失败 TopPayRefund = "已退款" // 已退款 ) type TopPay struct { upMerchantNo str...
package html import ( "github.com/elliotchance/gedcom" "github.com/elliotchance/gedcom/html/core" "io" ) type PlaceStatistics struct { document *gedcom.Document placesMap map[string]*place } func newPlaceStatistics(document *gedcom.Document, placesMap map[string]*place) *PlaceStatistics { return &PlaceStatist...
package bosh_test import ( "encoding/json" "errors" "fmt" "io" "io/ioutil" "os" "path/filepath" "github.com/cloudfoundry/bosh-bootloader/bosh" "github.com/cloudfoundry/bosh-bootloader/fakes" . "github.com/onsi/ginkgo" . "github.com/onsi/gomega" ) var _ = Describe("Executor", func() { Describe("JumpboxCr...
package controllers import ( "github.com/astaxie/beego" "nepliteApi/comm" "github.com/astaxie/beego/logs" "encoding/json" "nepliteApi/models" ) type GroupController struct { beego.Controller } func (group *GroupController) Add() { result := comm.Result{Ret: map[string]interface{}{"err": "", "num": 0, "result"...
// 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 flags provides frequently used kingpin flags for command-line tools // that connect to Consul. package flags import ( "io/ioutil" "log" "net" "net/http" "strings" "time" "github.com/square/p2/pkg/labels" "github.com/square/p2/pkg/store/consul" netutil "github.com/square/p2/pkg/util/net" "gopkg.in...
// DRUNKWATER TEMPLATE(add description and prototypes) // Question Title and Description on leetcode.com // Function Declaration and Function Prototypes on leetcode.com //598. Range Addition II //Given an m * n matrix M initialized with all 0's and several update operations. //Operations are represented by a 2D array, ...
package main import ( "strings" "fmt" "strconv" ) //strings strconv基本用法 func main() { str := " hello world abc " result := strings.Replace(str, "world", "you", 1) fmt.Println("replace:", result) count := strings.Count(str, "l") fmt.Println("count:", count) result = strings.Repeat(str, 3) fmt.Println("...
package stellar import ( "net/http" "time" "github.com/stellar/go/clients/horizon" "github.com/stellar/go/keypair" "github.com/stellar/go/services/bifrost/common" "github.com/stellar/go/support/errors" "github.com/stellar/go/support/log" ) // NewAccountXLMBalance is amount of lumens sent to new accounts const...
package main import ( "flag" "fmt" "time" "github.com/qixin1991/grpc-go-service-discover/sdk" "strconv" "github.com/qixin1991/grpc-go-service-discover/rpc" "golang.org/x/net/context" "google.golang.org/grpc" ) var ( serv = flag.String("service", "hello_service", "service name") reg = flag.String("reg",...
package model import ( "fmt" "time" "github.com/rodrigo-brito/ninjabot/pkg/series" ) type SideType string type OrderType string type OrderStatusType string var ( SideTypeBuy SideType = "BUY" SideTypeSell SideType = "SELL" OrderTypeLimit OrderType = "LIMIT" OrderTypeMarket OrderType = "MA...
package v1 import ( metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" ) // +genclient // +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object type SampleResource struct { metav1.TypeMeta `json:",inline"` metav1.ObjectMeta `json:"metadata,omitempty"` Spec SampleResourceSpec `json:"spec"` } type Sam...
package paperswithcode_go import ( "net/http" "regexp" "strings" "time" "github.com/codingpot/paperswithcode-go/v2/internal/transport" ) const ( BaseURL = "https://paperswithcode.com/api/v1" ) var whiteSpaceRegexp = regexp.MustCompile(`\s+`) // ClientOption can be used to swap the default http client or swap...
package harness import ( "context" "fmt" "io/ioutil" "log" "os" "os/exec" "path/filepath" "syscall" "time" ) const ( sdCfgDir = "sd_configs" ) type Harness struct { testDirectory string } func (h *Harness) GetSdCfgDir() string { return filepath.Join(h.testDirectory, sdCfgDir) } func NewHarness(testDire...
package controllers import ( "net/http" "strconv" "github.com/insisthzr/echo-test/cookbook/twitter/models" "github.com/insisthzr/echo-test/cookbook/twitter/utils" "github.com/dgrijalva/jwt-go" "github.com/labstack/echo" "gopkg.in/mgo.v2/bson" ) func CreatePost(c echo.Context) error { userID := utils.UserIDF...
package main import ( "os" "anime/controllers" "strconv" "fmt" "net/http" "github.com/go-martini/martini" "bufio" ) func main() { m := martini.Classic() canWork := false reader := bufio.NewReader(os.Stdin) fmt.Println("ALLOW ACESS? [y/n]") //ДА да, именно так в го пишется while(true) flag := tr...
package helpers import ( "fmt" "os" "strconv" gomail "gopkg.in/gomail.v2" ) // MailConfig to hold mail data type MailConfig struct { To string Subject string Body string } // SendHTMLMail to someone func (mc *MailConfig) SendHTMLMail() { port, _ := strconv.Atoi(os.Getenv("MAIL_PORT")) m := gomail...
package deposits import ( context "context" "time" ) type Usecase struct { Repo DomainRepository ContextTimeout time.Duration } func NewUsecase(repo DomainRepository, timeout time.Duration) *Usecase { return &Usecase{ Repo: repo, ContextTimeout: timeout, } } func (u *Usecase) GetAll(ct...
package phrasecounter import ( "reflect" "testing" ) func TestCountPhraseFrequency(t *testing.T) { scenarios := []struct { content string expected map[string]int }{ {"", map[string]int{}}, {"abc", map[string]int{}}, {"abc def ghi", map[string]int{"abc def ghi": 1}}, {"abc def ghi hij", map[string]int...
package models import ( "errors" "mall/utils" "strconv" "github.com/astaxie/beego/orm" ) // Comment 定义结构体 type Comment struct { Id int `json:"id"` Comment string `description:"描述" json:"comment"` User *User `orm:"rel(fk)" json:"user"` Monitor *Monitor `orm:"rel(fk)" json:"monitor"` } // Ta...
package routing import "github.com/valyala/fasthttp" func SetHeader(next fasthttp.RequestHandler) fasthttp.RequestHandler { return fasthttp.RequestHandler(func(ctx *fasthttp.RequestCtx) { ctx.SetContentType("application/json") next(ctx) }) }
/* Create a function that will build a staircase using the underscore _ and hash # symbols. A positive value denotes the staircase's upward direction and downwards for a negative value. Examples staircase(3) ➞ "__#\n_##\n###" __# _## ### staircase(7) ➞ "______#\n_____##\n____###\n___####\n__#####\n_######\n#######" ...
package handlers import ( "net/http" "net/http/httptest" "syscall" "testing" ) func TestShutdownHandler(t *testing.T) { req, err := http.NewRequest("PUT", "/shutdown", nil) if err != nil { t.Fatal(err) } rr := httptest.NewRecorder() handler := http.HandlerFunc(ShutdownHandler) handler.ServeHTTP(rr, req) ...
package main import ( "fmt" "strconv" ) func main() { var n, k, x int g := []int{1, 3, 4, 6, 4, 32, 4, 5, 40} fmt.Scan(&n, &k) fmt.Println(Potenza(n, k)) fmt.Println(Max(g)) fmt.Scan(&x) fmt.Println(Taglio(x)) for i, v := range Occo(x) { fmt.Println("numero", i, "è apparso", v, "volte") } //fmt.Println(...
package backend import ( "github.com/shirou/gopsutil/mem" ) // MemoryUsage = Struct of Memory Usages type MemoryUsage struct { Virtual *mem.VirtualMemoryStat `json:"virtual"` Swap *mem.SwapMemoryStat `json:"swap"` } // GetMemoryUsage = Get Memory Usage func (s *Stats) GetMemoryUsage() *MemoryUsage { MU := ...
package dorisloader import ( "context" "encoding/json" "io" "io/ioutil" "log" "net/http" "net/http/httputil" "net/url" "sync" ) var ( Version = "1.0.0" ) type Client struct { c Doer // e.g. a net/*http.Client to use for requests mu sync.RWMutex // guards the next bl...
package validator import ( "crypto/elliptic" "crypto/rsa" "testing" "github.com/stretchr/testify/assert" "github.com/authelia/authelia/v4/internal/configuration/schema" "github.com/authelia/authelia/v4/internal/oidc" ) func TestIsCookieDomainValid(t *testing.T) { testCases := []struct { domain string e...
package util import ( "context" "fmt" "io/ioutil" "net/http" "os" "strings" "time" "cloud.google.com/go/compute/metadata" secretmanager "cloud.google.com/go/secretmanager/apiv1" "google.golang.org/api/googleapi" "google.golang.org/api/run/v1" secretmanagerpb "google.golang.org/genproto/googleapis/cloud/se...
// Package hashdir contains methods for generating hashes of directories package hashdir import ( "crypto/md5" "io" "os" "path/filepath" "github.com/gobwas/glob" ) // GenerateString creates a new hash for a given path. The path is walked and a hash is // created based on all files found in the path. If a file m...
package main import ( "fmt" ) type movie struct { name string release int } func main() { dark := movie{ name: "Dark", release: 2017, } fmt.Println(dark) }
/* Copyright (c) 2017 GigaSpaces Technologies Ltd. All rights reserved Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable ...
/* This file run server web server app. Author: Igor Kuznetsov Email: me@swe-notes.ru (c) Copyright by Igor Kuznetsov. */ package main import ( "github.com/gorilla/websocket" "github.com/labstack/echo" "github.com/labstack/echo/middleware" "github.com/streadway/amqp" "net/http" "os" "simple-tracking/backend/h...
package download import ( "context" "fmt" "io" "net/http" ) type ( Option struct { Headers map[string]string } ) func Download( ctx context.Context, client *http.Client, uri string, option Option, ) (io.ReadCloser, error) { req, err := http.NewRequestWithContext(ctx, "GET", uri, nil) if err != nil { ret...
package model type InstallationData struct { Email string `json:"email"` Name string `json:"name"` EventList []EventList `json:"events"` }
package form import ( "bytes" "github.com/astaxie/beego/logs" "strings" "text/template" ) type SwitchInput struct { Name string Label string SwitchText string //属性lay-text可自定义开关两种状态的文本: ON|OFF 开|关 Option SelectOption } func (c *SwitchInput) String() string { html := `<input type="checkbox" na...
package main func main() { var a string = "string" var b []int b = append(b, 0) var c [5]int var r int r = len(c) }
package worker import ( "github.com/bearname/videohost/internal/common/caching" "github.com/bearname/videohost/internal/common/db" "github.com/bearname/videohost/internal/thumbgenerator/app/provider" "github.com/bearname/videohost/internal/thumbgenerator/app/subscriber" "github.com/bearname/videohost/internal/thu...
package service import "time" type MessageStatus struct { Message Message Error error } type Message struct { ID string Account Account Application Application CreatedAt time.Time Content string Emojis []Emoji InReplyToID string IsReblog bool Tags []Tag Visibility str...
package main_test import ( . "github.com/dcarley/swt-wifi-login" . "github.com/onsi/ginkgo" . "github.com/onsi/gomega" "net/http" "testing" "github.com/onsi/gomega/ghttp" ) func TestSwtWifiLogin(t *testing.T) { RegisterFailHandler(Fail) RunSpecs(t, "SwtWifiLogin Suite") } var _ = Describe("SwtWifiLogin", ...
package mod_test import ( "net/http" "os/exec" "path/filepath" "strconv" "strings" "sync" "testing" "time" "github.com/prometheus/common/expfmt" "github.com/robustirc/bridge/robustsession" "github.com/robustirc/internal/health" "github.com/robustirc/robustirc/internal/localnet" "github.com/robustirc/robu...
package rest import "github.com/gin-gonic/gin" var ( router = gin.Default() ) // SetRoutes ... func SetRoutes() { router.GET("/refresh", refresh) router.GET("/create", create) router.GET("/verify", verify) router.GET("/revoke", revoke) router.Run(":8080") }
package downloader import ( "fmt" "os" "os/exec" "github.com/andygrunwald/perseus/dependency" ) // Git represents an Updater and Downloader for the git protocol type Git struct { // workerCount is the number of worker that will be started workerCount int // Directory where to download the data into dir stri...
package internal import "github.com/sirupsen/logrus" // Reload will reload any configuration changes without restarting the server func Reload() { logrus.Info("Reloading configurations (not implemented)") }
package graph import ( "fmt" "sync" "bldy.build/build" "bldy.build/build/label" ) // NewNode takes a label and a rule and returns it as a Graph Node func NewNode(l label.Label, t build.Rule) Node { return Node{ Target: t, Type: fmt.Sprintf("%T", t)[1:], Children: make(map[string]*Node...
package server import ( "context" "fmt" uuid "github.com/satori/go.uuid" "github.com/sirupsen/logrus" "github.com/batchcorp/plumber-schemas/build/go/protos" "github.com/batchcorp/plumber-schemas/build/go/protos/common" "github.com/batchcorp/plumber-schemas/build/go/protos/opts" "github.com/batchcorp/plumber...
package model import ( "time" ) type AddTaskRQ struct { StudyUID string `json:"studyUID"` StudyName string `json:"studyName"` ContainerName string `json:"containerName"` SOPObjects []SOPObject `json:"sopObjects"` Steps []string `json:"steps"` File string ...
package ratelimit import ( "errors" "fmt" "math" "sync" "sync/atomic" "time" ) // todo timer 需要 stop type localCounterLimiter struct { limit Limit limitCount int32 // 内部使用,对 limit.count 做了 <0 时的转换 ticker *time.Ticker quit chan bool lock sync.Mutex newTerm *sync.Cond count int32 } func (lim *localCoun...
package vcli import "fmt" // CsvDataLoad - Load Funds, Voteplans and Proposals information into a SQLite3 ready file DB. // // vit-servicing-station-cli csv-data load // --db-url <db-url> URL of the vit-servicing-station database to interact with // --funds <funds> Path to the csv co...
package module type ChatMgr struct { moduleMgr *ModuleMgr //! 模块管理器指针 } //! 注册消息 func (self *ChatMgr) registerMsg() { } //! 初始化管理器 func (self *ChatMgr) Init(moduleMgr *ModuleMgr) { G_Dispatch.AddMsgRegistryToMap(new(Msg_Chat_Private)) //! 用户私聊消息 } //! 生成聊天管理器 func NewChatMgr(moduleMgr *ModuleMgr) *ChatMgr { chat...
package _45_Jump_Game_2 func jump(nums []int) int { if len(nums) <= 1 { return 0 } var ( distance = len(nums) - 1 step = 0 max = 0 i, idx = 0, 0 ) for i < len(nums) { if i+nums[i] >= distance { step++ return step } max = 0 idx = i + 1 for j := i + 1; j-i <= nums[i]; j++ { i...
package Voucher import ( "encoding/json" "fmt" "github.com/Shopify/sarama" "github.com/labstack/echo" "github.com/radyatamaa/loyalti-go-echo/src/api/host/Config" "github.com/radyatamaa/loyalti-go-echo/src/domain/model" "log" ) func PublishUpdateVoucher(c echo.Context) error { //var data model.Merchant data :...
package google import ( "math/rand" "runtime" "time" "gitgud.io/softashell/comfy-translator/translator" "github.com/hashicorp/go-retryablehttp" log "github.com/sirupsen/logrus" ) type inputChannel chan inputObject type outputChannel chan returnObject type BatchTranslator struct { inCh inputChannel // Dela...
package service import "github.com/henglory/Demo_Golang_v0.0.1/spec" type aRequestFn func(req spec.AReq) (spec.ARes, error) type bRequestFn func(req spec.BReq) (spec.BRes, error)
package librke import ( "context" "github.com/docker/docker/api/types" "github.com/rancher/norman/types/convert" "github.com/rancher/rke/cluster" "github.com/rancher/rke/hosts" "github.com/rancher/rke/k8s" "github.com/rancher/rke/pki" "github.com/rancher/types/apis/management.cattle.io/v3" ) type rke struct ...
package main import "fmt" func main() { sampleVarFunc(2, 2) } //variadic function test func sampleVarFunc(x ...int) { sum := 0 for _, v := range x { sum += v } fmt.Printf(`%T`, x) }
package models import ( "log" "os" ) //LogError logs all error to file func LogError(err error) { f, _ := os.OpenFile("logs/errors.log", os.O_APPEND|os.O_CREATE|os.O_WRONLY, 0644) defer f.Close() logger := log.New(f, "Error: ", log.LstdFlags) logger.Println(err.Error()) } //ValidResponse structures valid api ...
package tsmt import ( "encoding/xml" "github.com/thought-machine/finance-messaging/iso20022" ) type Document03700103 struct { XMLName xml.Name `xml:"urn:iso:std:iso:20022:tech:xsd:tsmt.037.001.03 Document"` Message *StatusReportV03 `xml:"StsRpt"` } func (d *Document03700103) AddMessage() *StatusReportV0...
package streams import ( "context" "encoding/json" "github.com/go-fed/activity/streams/vocab" "github.com/go-test/deep" "net/url" "testing" ) type serializer interface { Serialize() (map[string]interface{}, error) } // IsKnownResolverError returns true if it is known that an example from // GetTestTable will ...
package main import ( "fmt" "math" "strings" ) type particle struct { x, y, dx, dy int } func loaddata(input string) (result []particle) { for _, line := range strings.Split(input, "\n") { line = strings.TrimSpace(line) if line == "" { continue } p := particle{} fmt.Sscanf(line, "position=<%d, %d> ...
package peer import ( "bytes" "encoding/hex" "fmt" "github.com/perlin-network/noise/protobuf" ) // ID is an identity of nodes, using its public key and network address type ID protobuf.ID // CreateID is a factory function creating ID func CreateID(address string, publicKey []byte) ID { return ID{PublicKey: pub...
package main import ( "errors" "go/parser" "go/token" "os" "path/filepath" "strings" "github.com/gelidus/nogo/utils" "github.com/gelidus/nogo/visitors/example" "github.com/gelidus/nogo/visitors/govisitor" "github.com/gelidus/nogo/visitors/pointers" log "github.com/sirupsen/logrus" "github.com/urfave/cli...
package main import ( "fmt" "bufio" "os" "net/http" "log" "io/ioutil" "strings" ) func main() { reader := bufio.NewReader(os.Stdin) fmt.Print("Give me a number: ") num, _ := reader.ReadString('\n') num = strings.TrimSuffix(num, "\n") url := fmt.Sprintf("http://numbersapi.com/%s/math",num) response, err ...
package main import ( "fmt" facebook "github.com/madebyais/facebook-go-sdk" ) // BasicFeedPost will show you about // how to post a feed to your timeline func BasicFeedPost() { // initalize facebook-go-sdk fb := facebook.New() // set your access token // NOTES: Please exchange with your access token fb.SetAc...
package main import "sort" type ints [][]int func (s ints) Len() int { return len(s) } func (s ints) Less(i, j int) bool { return s[i][0] < s[j][0] } func (s ints) Swap(i, j int) { s[i], s[j] = s[j], s[i] } func merge(intervals [][]int) [][]int { var res [][]int if len(intervals) == 0 { return res } sort...
package linkedlist import ( "fmt" "strings" ) type Node struct { Value interface{} next *Node } func (node *Node) String() string { return fmt.Sprint(node.Value) } type LinkedList struct { head *Node len int } func (l *LinkedList) String() string { cur := l.head ret := strings.Builder{} for cur != nil ...
package data import ( "gobackend/chitChat/db" "gobackend/chitChat/models" ) func GetThreads() (ThreadList []*ThreadList, err error) { err = db.GetDB().Model(&models.Threads{}).Scan(&ThreadList).Error return } func GetThread(id int64) (Thread models.Threads, err error) { err = db.GetDB().Where("id = ?", id).Firs...
package images import ( "context" "fmt" "sync" "time" "github.com/dollarshaveclub/acyl/pkg/eventlogger" "github.com/dollarshaveclub/acyl/pkg/models" nitroerrors "github.com/dollarshaveclub/acyl/pkg/nitro/errors" "github.com/dollarshaveclub/acyl/pkg/nitro/metrics" "github.com/dollarshaveclub/acyl/pkg/persiste...
package cache import ( "strconv" "strings" "sync" "time" "github.com/lexesjan/go-web-proxy-server/pkg/http" "github.com/lexesjan/go-web-proxy-server/pkg/log" ) // Cache represents the proxy cache type Cache struct { cacheMap *sync.Map } // NewCache returns a new Cache func NewCache() (cache *Cache) { cache ...
package golang import ( "reflect" "testing" ) var tests = []struct { input []int output int }{ /* * {input: []int{1, 3, 5, 7, 9}, output: 4}, * {input: []int{1, 1, 1, 3, 3, 3, 7}, output: 15}, * {input: []int{149, 107, 1, 63, 0, 1, 6867, 1325, 5611, 2581, 39, 89, 46, 18, 12, 20, 22, 234}, output: 12}, *...
package field import ( "encoding/binary" "io" "github.com/tombell/go-serato/internal/decode" "github.com/tombell/go-serato/internal/trim" ) // Comment is the comment on the track. type Comment struct { header *Header data []byte } // Value returns the comment. func (f *Comment) Value() string { s := decode...
package tsin import ( "encoding/xml" "github.com/thought-machine/finance-messaging/iso20022" ) type Document01000101 struct { XMLName xml.Name `xml:"urn:iso:std:iso:20022:tech:xsd:tsin.010.001.01 Document"` Message *PartyRegistrationAndGuaranteeStatusV01 `xml:"PtyRegnAndGrntSts"` }...
package main import ( "fmt" "strconv" ) func sendWithBuffer(ch chan int) { count := 100 for count > 0 { ch <- count fmt.Println("send " + strconv.Itoa(count)) count-- } close(ch) } func receiveWithBuffer(ch chan int) { for { value, ok := <- ch if ok { fmt.Println("receive " + strconv.Itoa(value...
package service import ( "encoding/json" "errors" "fmt" "io" "krpc/codec" "krpc/conf" "log" "net" "reflect" "strings" "sync" "time" ) // Connection's message between client & server // | Option{..., CodeType: xxx} | Header..., Body ... | Header2, Body2, ... // |<------ Json En...
package main import "fmt" func Example_simple() { fmt.Println("this is not it") // Output: // this is it }
package main import ( "encoding/json" "os" "strings" "fmt" ) type person struct { Fname string Lname string Age int //start with caps to export and thus print data after using marshal } func main() { p1 :=person{"AMan","Patel",21} //p2 :=person{"acd","gupta",22,2} json.NewEncoder(os.Stdout)...
package util import ( "camp/lib" "errors" "github.com/globalsign/mgo/bson" ) func TokenToUid(base lib.IBase) (uid bson.ObjectId, err error) { if v, exists := base.GetParam("uid"); !exists { return bson.ObjectIdHex(""), errors.New("uid not exists") } else { uid = v.(bson.ObjectId) } return }
package publickey import ( "crypto/ecdsa" "crypto/x509" "encoding/hex" "encoding/pem" "errors" "github.com/SIGBlockchain/project_aurum/internal/hashing" ) // AurumPublicKey struct holds public key for user type AurumPublicKey struct { Key *ecdsa.PublicKey Bytes []byte Hex string Hash []byte } // NewF...
package core // BoolType express SQL boolean including Null type BoolType int const ( // True is true of BoolType True BoolType = iota // False is false of BoolType False // Null is null of BoolType Null ) type WildcardType int const ( Wildcard WildcardType = iota ) // ColType is a type of column type Col...
package main import ( "fmt" ) // https://leetcode-cn.com/problems/gray-code/ // 89. 格雷编码 | Gray Code //------------------------------------------------------------------------------ //------------------------------------------------------------------------------ // Solution // // 找规律 // i res | bit | xor res[i...
// Copyright 2017 // Author: catlittlechen@gmail.com package main import ( "encoding/json" "fmt" "github.com/catlittlechen/nexus" "github.com/garyburd/redigo/redis" "time" ) type config struct { Addr string `json:"addr"` DB int `json:"db"` PoolSize int `json:"poolsize"` Idle int `json...
package main import ( "encoding/json" "fmt" "net" "crypto/md5" "encoding/hex" "github.com/m4ttclendenen/basen" ) type Message struct { Code int Payload json.RawMessage } type Range struct { Start []byte End []byte } type User struct { ID int Pass int } type Job struct { Hash string Range Range } type ...
// Copyright 2020 PingCAP, Inc. Licensed under Apache-2.0. package export import ( "database/sql" "strings" "github.com/pingcap/errors" "github.com/pingcap/tidb/br/pkg/version" tcontext "github.com/pingcap/tidb/dumpling/context" "go.uber.org/zap" ) // rowIter implements the SQLRowIter interface. // Note: To c...
package usecase import ( "github.com/dkpeakbil/taskserver/domain" ) type UseCase interface { Register(*domain.RegisterRequest) *domain.RegisterResponse Auth(request *domain.AuthRequest) *domain.AuthResponse AuthGame(request *domain.AuthGameRequest) *domain.AuthGameResponse GetUsers(request *domain.GetUsersReques...