text
stringlengths
11
4.05M
package services import ( "fmt" "time" "github.com/Volkov-D-A/vk-stitch-bot/pkg/config" "github.com/Volkov-D-A/vk-stitch-bot/pkg/models" "github.com/Volkov-D-A/vk-stitch-bot/pkg/repository" ) type MessagingService struct { repos *repository.Repository config *config.Config } func NewMessagingService(repos *...
// Copyright (C) 2023 Storj Labs, Inc. // See LICENSE for copying information. package sync2 import ( "context" ) // ReceiverClosableChan is a channel with altered semantics // from the go runtime channels. It is designed to work // well in a many-producer, single-receiver environment, // where the receiver consume...
package server import ( "context" "encoding/json" "fmt" "io" "net/http" "github.com/gempir/gempbot/internal/api" "github.com/gempir/gempbot/internal/log" "github.com/gempir/gempbot/internal/store" ) func (a *Api) BotConfigHandler(w http.ResponseWriter, r *http.Request) { authResp, _, apiErr := a.authClient....
// Copyright 2019 Copyright (c) 2019 SAP SE or an SAP affiliate company. All rights reserved. This file is licensed under the Apache Software License, v. 2 except as noted otherwise in the LICENSE file. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in complian...
package main import ( "net/http" "encoding/json" "gomail-master" "crypto/tls" ) type MailSetting struct { From string `json:"from"` To string `json:"to"` Text string `json:"text"` SmtpServer string `json:"smtp_server"` SmtpPort int `json:"smtp_port"` UserName string `json:"user_name"` Password string `json...
// Copyright 2019 Google 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 // // https://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed to in ...
package kademlia import ( "fmt" "math/big" "net" "net/rpc" "sort" "time" ) type node struct { IP string ID *big.Int kBuckets [B]kBucket Data KVMap publishMap KVMap ON bool } type Node struct { O node Listen net.Listener } func (o *node) Init(port string) { o.IP = GetLocalAddress() + ":...
package main import ( "fmt" "net/http" "net/url" _ "github.com/hiromisuzuki/clean-arch-example/docs" // docs is generated by Swag CLI, you have to import it. "github.com/hiromisuzuki/clean-arch-example/app/infrastructure" "github.com/spf13/viper" "github.com/swaggo/http-swagger" ) func init() { //TODO:chan...
package middle import ( "time" jwtlib "github.com/dgrijalva/jwt-go" "github.com/labstack/echo/v4" "github.com/labstack/echo/v4/middleware" "github.com/shandysiswandi/echo-service/pkg/is" ) type ( UserJWT struct { ID int `json:"id"` Email string `json:"email"` CompanyID int `j...
package http import ( "github.com/gin-gonic/gin" "github.com/saxon134/workflow/controller" ) func initRoutes(group *gin.RouterGroup) { Post(group, "upload.file", controller.Upload, AuthSign) Post(group, "user.login", controller.UserLogin, AuthSign) Gett(group, "user.list", controller.UserList, AuthMs) Gett(gro...
package main import ( "flag" "fmt" "log" "os" "github.com/scjalliance/logmein" "gopkg.in/gcfg.v1" ) type config struct { RSS struct { ProfileID uint64 `gcfg:"profile"` Key string `gcfg:"key"` } `gcfg:"rss"` } var configFile = flag.String("c", "config.conf", "Config file") func main() { flag.Pars...
package path import ( "testing" ) var testTable = []struct { in []string out string }{ {[]string{}, ""}, {[]string{"foo"}, "foo"}, {[]string{"/foo/bar/.."}, "/foo"}, {[]string{"foo", "bar"}, ""}, {[]string{"home/khoiracle", "home/khoiracle/foo", "home/khoiracle/bar"}, "home/khoiracle"}, {[]string{"home/khoi...
package rdb import ( "bufio" "bytes" "encoding/json" "fmt" "github.com/dongmx/rdb" "io" "net" "strconv" "sync" "sync/atomic" "time" ) const ( byteLF = byte('\n') // 换行符 ) var ( bytesSpace = []byte(" ") psyncFullSyncCmd = []byte("*3\r\n$5\r\nPSYNC\r\n$1\r\n?\r\n$2\r\n-1\r\n") // 执行全量复制的命令 ) // In...
package cmd import ( "bytes" "context" b64 "encoding/base64" "encoding/json" "fmt" "os" "path/filepath" "sort" "time" "github.com/gridscale/gscloud/render" "github.com/gridscale/gscloud/runtime" "github.com/gridscale/gscloud/utils" "github.com/kardianos/osext" "github.com/spf13/cobra" "github.com/spf13...
package main import "strconv" type Sessions struct { SessionRequest chan chan Session nextSession int } func NewSessions() *Sessions { return &Sessions{ SessionRequest: make(chan chan Session), } } func (s *Sessions) Run() { for requestChan := range s.SessionRequest { s.handleSessionRequest(requestChan)...
/* * * Copyright 2020 gRPC 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 agree...
package tests import ( "reflect" "testing" ravendb "github.com/ravendb/ravendb-go-client" "github.com/stretchr/testify/assert" ) // Note: renamed to Item2 to avoid conflicts type Item2 struct { ID string Name string `json:"name"` Latitude float64 `json:"latitude"` Longitude float64 `json:"l...
package midec import ( "io" ) const tmpLength = 256 * 3 // ReadAdvancer is the struct that can skip some bytes reading. type ReadAdvancer struct { io.Reader tmp []byte } // NewReadAdvancer creates ReadAdvancer. func NewReadAdvancer(r io.Reader) *ReadAdvancer { var arr [tmpLength]byte return &ReadAdvancer{ Re...
// MIT License // // Copyright (c) 2019 Adrian Houghton // // 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, mo...
package LeetCode import ( "fmt" "math" ) func Code110() { head := InitTree() head = &TreeNode{1, nil, nil} head.Left = &TreeNode{2, nil, nil} head.Right = &TreeNode{2, nil, nil} head.Left.Left = &TreeNode{3, nil, nil} head.Left.Right = &TreeNode{3, nil, nil} head.Left.Left.Left = &TreeNode{4, nil, nil} head...
/* Ex 8 Implement a function that given a directed graph finds the strongly connected components. Author: Xiaoyan ZHANG */ package main import( "fmt" "strconv" "container/list" ) /* directed graph represented by adjacency list each index of the array represents a node each list of the node contains all the conn...
package schedulepayout import ( "errors" "time" "github.com/NodeFactoryIo/vedran/internal/configuration" "github.com/NodeFactoryIo/vedran/internal/repositories" "github.com/NodeFactoryIo/vedran/internal/script" "github.com/NodeFactoryIo/vedran/internal/ui" log "github.com/sirupsen/logrus" ) // StartScheduledP...
package controllers import ( "fmt" "encoding/json" "smartCity/models" "github.com/astaxie/beego" ) // Operations about Users type UserController struct { beego.Controller } // @Title CreateUser // @Description create users // @Param body body models.User true "body for user content" // @Success 200 {int} mo...
package account import ( "sync" "testing" "time" "github.com/jrapoport/gothic/api/grpc/rpc/account" "github.com/jrapoport/gothic/config" "github.com/jrapoport/gothic/core/context" "github.com/jrapoport/gothic/jwt" "github.com/jrapoport/gothic/mail/template" "github.com/jrapoport/gothic/test/tconf" "github.c...
package utils import ( "bytes" "runtime" "strconv" ) func TakeStacktrace(skip int) string { buffer := bytes.NewBuffer(make([]byte, 0, 1000)) programCounters := make([]uintptr, 10000) var numFrames int for { // Skip the call to runtime.Callers and takeStacktrace so that the // program counters start at the...
package main import ( "bufio" "errors" "fmt" "log" "math" "math/rand" "os" "regexp" "strings" "time" "unicode" "golang.org/x/text/runes" "golang.org/x/text/transform" "golang.org/x/text/unicode/norm" "gonum.org/v1/gonum/floats" "gonum.org/v1/gonum/mat" ) type neuralNet struct { config neuralNetConf...
package main type article struct { ID int json:"id" Title string json:"title" Content string json:"content" } var articleList = []article{ article{ID:1, Title:"Article 1", Content:"Article 1 body"}, article{ID:2, Title:"Article 2", Content:"Article 2 body"} } func getAllArticles() []article { return articleList ...
package payserver import ( "bytes" "centerclient" "common" "crypto/md5" "encoding/hex" "encoding/xml" "fmt" "io/ioutil" "logger" "math/rand" "net" "net/http" "proto" "rpc" "rpcplus" "runtime/debug" "strconv" "strings" "sync" "time" ) type PayService struct { pCachePool *common.CachePool sl ...
package util import "log" type DB_Config struct { Db_host string Db_port string Db_user string Db_password string Db_database string Db_max_open int Db_max_idle int } type Server_Config struct { SSO string SSO_Login string SSO_Service_Validate string OAuth ...
package service // import "yunion.io/x/onecloud/pkg/cloudid/service"
package backup import ( "time" snapshotv1 "github.com/kubernetes-csi/external-snapshotter/v2/pkg/apis/volumesnapshot/v1beta1" corev1 "k8s.io/api/core/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" harvesterv1 "github.com/harvester/harvester/pkg/apis/harvesterhci.io/v1beta1" ) func isBackupReady(backup *harv...
package common // LogoText is a text logo var LogoText = ` ____________ _____________ _____________ _ _____________ ___ _/ / / / / _________/ / / / ________/ _/ ____ / / /_________ /____ ____/ _ ___/ /_______ / / / ...
package main func (___Vtbm *_TtcpBufMachine) IRun(___Vidx int) { switch ___Vidx { case 1500101: if nil == ___Vtbm.tbmCBinit { go _FtcpBufMachine__1500101x__init(___Vtbm) } else { go ___Vtbm. tbmCBinit(___Vtbm) } case 1500201: go ___Vtbm. _FtcpBufMachine__1500201x__chan_rece__default() case 150...
package main import ( "log" "Week02/service" ) func main() { svr := service.New() userinfo, err := svr.GetUserInfo(1) if err != nil { log.Println("HTTP 500") return } log.Println(userinfo) }
package show import "store" func ShowEmployeeByID(id int, idEmpMap *map[int](store.Employee)){ empl := (*idEmpMap)[id] if empl.There == true {empl.PrintName()} }
// Copyright (c) 2018 The MATRIX Authors // Distributed under the MIT software license, see the accompanying // file COPYING or http://www.opensource.org/licenses/mit-license.php package matrixstate import ( "github.com/MatrixAINetwork/go-matrix/common" "github.com/MatrixAINetwork/go-matrix/log" "github.com/MatrixA...
package controller import ( "encoding/json" "fmt" "gin-use/configs" "gin-use/src/global" "gin-use/src/model/response" "gin-use/src/util/consul" "gin-use/src/util/snowflake" "net/http" "reflect" "time" "github.com/ddliu/go-httpclient" "github.com/gin-gonic/gin" ) var resp *response.Resp // Health 健康检查 //...
package webhook const ( // InjectionInstanceLabel can be set in a Namespace and indicates the corresponding DynaKube object assigned to it. InjectionInstanceLabel = "dynakube.internal.dynatrace.com/instance" // AnnotationDynatraceInjected is set to "true" by the webhook to Pods to indicate that it has been injecte...
package do import ( "database/sql" "time" ) type UserDo struct { ID string `ddb:"id"` Name string `ddb:"name"` Password sql.RawBytes `ddb:"password"` Email string `ddb:"email"` Version int `ddb:"version"` CTime time.Time `ddb:"ctime"` MTime time.Time `ddb:...
package models import "testing" func TestNewEntityIDFromString(t *testing.T) { str := "@user@cadmium.org" eid, err := NewEntityIDFromString(str) if err != nil { t.Fatal("error must be null") } if eid.Attr != "" || eid.Type != UsernameType || eid.ServerPart != "cadmium.org" || eid.LocalPart != "user" { t.Fai...
package spotifaux import "C" import "math" const SS_FFT_LENGTH = 800 const WindowLength = 400 const Hop = 160 const SAMPLE_RATE = 16000 type SoundSpotter struct { ChosenFeatures []int CqtN int // number of constant-Q coefficients (automatic) InShingles [][]float64 ShingleSize int } func (s *Sou...
package solutions type MaskPair struct { mask int length int } func maxProduct(words []string) int { masks := make([]MaskPair, len(words)) for i := 0; i < len(words); i++ { masks[i] = MaskPair{mask: getBitMask(words[i]), length: len(words[i])} } result := 0 for i := 0; i < len(m...
package Model type Referal struct { Id int `form:"id" json:"id"` ReferalCode string `form:"referal_code" json:"referal_code"` MuridID int `form:"murid_id" json:"murid_id"` Used bool `form:"used" json:"used"` } type ResponseReferal struct { Status int `json:"status"` Message st...
package hnsvc_test import ( stdlog "log" "testing" "github.com/stretchr/testify/assert" "github.com/wenerme/uo/pkg/hnsvc" ) func TestBasic(t *testing.T) { // os.Setenv("HTTP_PROXY", "socks5://127.0.0.1:8888") s := &hnsvc.HackerNewsService{} { it, err := s.GetItem(8863) assert.NoError(t, err) assert.Equ...
package routers import ( v1 "deepgo/download/api/v1" "deepgo/download/middleware" "deepgo/download/pkg/setting" "github.com/gin-gonic/gin" "net/http" ) func InitRouter() *gin.Engine { r := gin.New() r.Use(gin.Logger()) r.Use(gin.Recovery()) gin.SetMode(setting.RunMode) r.Use(middleware.Cors()) apiv1 :=...
package putils import ( "fmt" "os" "path/filepath" "time" "github.com/tkanos/gonfig" ) type Configuration struct { Delay int Type string Sensor string AITA string TOPIC string PORT int HOST string } func GetConfig() Configuration { configuration := Configuration{} dir, err := os.Getwd() if...
// Copyright 2019 Yunion // // 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 writi...
/* Copyright 2021 The Skaffold 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, sof...
package redis import ( "fmt" "session-sample/server/config" "github.com/go-redis/redis/v8" ) func Connection() *redis.Client { client := redis.NewClient(&redis.Options{ Addr: fmt.Sprintf("%s:%s", config.RedisHost, config.RedisPort), }) return client }
package forms_test import ( . "github.com/d11wtq/bijou/runtime" "github.com/d11wtq/bijou/test" "strings" "testing" ) func TestMacroReturnsAMacro(t *testing.T) { form := test.NewList(Symbol("macro"), test.NewList(Symbol("x"))) env := test.FakeEnv() v, err := form.Eval(env) if err != nil { t.Fatalf(`expected ...
package main // 结构体 // type identifier struct { // field1 type1 // field2 type2 // ... // } func main() { }
package main import ( "bytes" "context" "encoding/json" "fmt" "log" "net/http" "os" "os/signal" "path" "strings" "syscall" "time" "github.com/Clever/analytics-util/analyticspipeline" discovery "github.com/Clever/discovery-go" "github.com/Clever/s3-to-redshift/v3/logger" redshift "github.com/Clever/s3-...
package main import "fmt" func taumBirthday(b, w, bc, wc, z int) (output int) { var x, y int if bc > wc && z < bc-wc { x = w * wc y = b * (wc + z) } else if wc > bc && z < wc-bc { x = b * bc y = w * (bc + z) } else { x = b * bc y = w * wc } output = x + y return output } func main() { fmt.Println...
package leetcode import "fmt" /* * @lc app=leetcode id=443 lang=golang * * [443] String Compression */ // @lc code=start type BytePair struct { c byte count int } func compress(chars []byte) int { // Case1: empty chars if len(chars) <=1 { return len(chars) } // Case2: normal sentryIdx := 0 sentryCh...
package dappauth import ( "bytes" "context" "crypto/ecdsa" "encoding/hex" "errors" "fmt" "math/big" "strings" "github.com/ethereum/go-ethereum" ethAbi "github.com/ethereum/go-ethereum/accounts/abi" "github.com/ethereum/go-ethereum/common" ethCrypto "github.com/ethereum/go-ethereum/crypto" ) type mockCont...
package conversion import "fmt" import "strconv" import "strings" func Int2String(input chan int, output chan string) { for v := range input{ output <- strconv.Itoa(v) } close(output) } func String2Int(input chan string, output chan int) { for v := range input { i, err := strconv.Atoi(v) if err ...
package schemas import ( "testing" "github.com/stretchr/testify/require" ) func TestDecode(t *testing.T) { tests := []struct { name string data string want interface{} }{ { name: "post", data: `{ "id": "id-1", "source": { "id": "1", "name": "source name" }, "schemaType": "POST", ...
package main type _TloginGenerator struct { lgSrvDownInfoLX *_TsrvDownInfo // server Info seting , update by Github , try to connect lgCB850101init func(*_TloginGenerator) // if nil , use the default init procedure // _FudpDecode__800101x__init__tryUdpLogin__default lgCB850201chRece func(*_TloginG...
/* * aggro * * Functions for querying data from the RIPEstat API * * Copyright (c) 2017 Noora Halme - please see LICENSE.md * */ package main import ( "errors" "fmt" "net/http" "io/ioutil" "strings" "encoding/json" ) // fetch a list of prefixes associated with a country matching an ISO-3166 alp...
package main import ( "testing" "github.com/stretchr/testify/assert" ) func Test_pluralize(t *testing.T) { assert.Equal(t, "migration", pluralize("migration", 1)) assert.Equal(t, "migrations", pluralize("migration", 2)) assert.Equal(t, "migrations", pluralize("migration", 0)) }
package main import ( "/home/ubuntu/proj/helloworld/hello" "micode.be.xiaomi.com/systech/soa/thrift" ) func (p *HelloServiceHandler) HelloWorld(ctx *thrift.XContext, name string) (r *hello.Result_, errRet error) { return }
package historian_test // // Copyright (c) 2019 ARM Limited. // // SPDX-License-Identifier: MIT // // 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 wit...
package helper import ( "github.com/docker/cli/cli/streams" "github.com/docker/docker/pkg/idtools" "github.com/docker/docker/pkg/progress" "github.com/docker/docker/pkg/streamformatter" "github.com/loft-sh/devspace/pkg/devspace/build/builder/restart" "github.com/loft-sh/devspace/pkg/util/kubeconfig" logpkg "git...
/* Copyright (c) 2019 VMware, Inc. All Rights Reserved. SPDX-License-Identifier: Apache-2.0 */ package objectstore import ( "context" "github.com/pkg/errors" "go.opencensus.io/trace" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/apimachinery/pkg/apis/meta/v1/unstructured" "k8s.io/apimachinery/pkg/label...
package blockchain import ( "../block" "log" "testing" ) func TestGetBlock(t *testing.T) { blA := block.GetTestBlock() AddBlock(blA) blB, err := GetBlock(blA.BlHash) if err != nil { log.Fatal(err) } if blA.Timestamp != blB.Timestamp { log.Fatal("Timestamp blocks don't equals") } log.Printf("BlB: %x \...
package fod import ( "android/soong/android" "android/soong/cc" "strings" ) func deviceFlags(ctx android.BaseContext) []string { var cflags []string var config = ctx.AConfig().VendorConfig("XIAOMI_SDM710_FOD") var posX = strings.TrimSpace(config.String("POS_X")) var posY = strings.TrimSpa...
package io import ( "strconv" ) // PrintIntsLine returns integers string delimited by a space. func PrintIntsLine(A ...int) string { res := []rune{} for i := 0; i < len(A); i++ { str := strconv.Itoa(A[i]) res = append(res, []rune(str)...) if i != len(A)-1 { res = append(res, ' ') } } return string(...
package main import ( "fmt" "sync" ) //func main() { //} func main() { //使用mutex lock控制并发 var mutex sync.Mutex i := 6 mutex.Lock() go func() { fmt.Println(i) mutex.Unlock() }() mutex.Lock() //使用chan控制并发 done := make(chan bool, 1) go func() { fmt.Println("执行子线程") done <- true }() <-done fmt.Pri...
// A Pythagorean triplet is a set of three natural numbers, a < b < c, for which, // // a^2 + b^2 = c^2 // For example, 3^2 + 4^2 = 9 + 16 = 25 = 5^2. // // There exists exactly one Pythagorean triplet for which a + b + c = 1000. // Find the product abc. package main import ( "fmt" "math" ) func eq(a, b int)...
package piscine func ToUpper(s string) string { str := []rune(s) for index, letter := range str { if letter >= 'a' && letter <= 'z' { str[index] = str[index] - 32 } } upper := string(str) return upper }
package cmn import ( "bytes" "fmt" "io" "io/ioutil" "net/http" "strings" ) func SmartClose(c io.Closer) { err := c.Close() if err != nil { fmt.Printf("closing: %v\n", err) } return } // Plural returns "s" when there is more than one number n is given // and returns empty string otherwise. // It is meant ...
package acceptance import ( "context" "crypto/tls" "net/http" ms "github.com/cloudfoundry/metric-store-release/src/pkg/client" "github.com/cloudfoundry/metric-store-release/src/pkg/rpc/metricstore_v1" . "github.com/onsi/ginkgo" . "github.com/onsi/gomega" "google.golang.org/grpc" ) var _ = Describe("Metric St...
package config import ( "encoding/json" "github.com/iancoleman/orderedmap" flag "github.com/spf13/pflag" "github.com/iotaledger/hive.go/app/configuration" "github.com/iotaledger/hive.go/apputils/parameter" ) type parameterMapJSON struct { *orderedmap.OrderedMap } func newParameterMapJSON() *parameterMapJSON ...
package main import ( "fmt" "time" ) type Flag int64 func (f Flag) String() string { return fmt.Sprintf("0x%b", f) } func main() { fmt.Println("ok") fmt.Println(fmt.Sprintf("0x%b", 0xb)) fmt.Println(Flag(1)) time.Now() }
package wire_test import ( "errors" "testing" "github.com/hoistup/hoist-go/wire" "github.com/matryer/is" ) func TestEncode(t *testing.T) { type MyDetails struct { ServiceName string `json:"svc"` FuncName string `json:"fn"` } table := []struct { Name string Details interface{} ...
package database import ( "bufio" "encoding/json" "fmt" "os" "path/filepath" "time" ) // State used to control the state of the chain type State struct { Balances map[Account]uint txMempool []Tx dbFile *os.File latestBlockHash Hash } // NewStateFromDisk -> load all state information f...
package configuration import ( "io/ioutil" "log" "gopkg.in/yaml.v2" ) // DbConfiguration : conf pour la connexion PG type DbConfiguration struct { Host string Port int64 User string Password string Schema string } // HTTPConfiguration : la configuration pour le serveur http type HTTPConfigurat...
package mocks import ( "github.com/spothero/optimizely-sdk-go/api" "github.com/stretchr/testify/mock" ) // Client mocks out the OptimizelyAPI interface for use in testing type Client struct { mock.Mock } func (c *Client) GetDatafile(environmentName string, projectID int) ([]byte, error) { call := c.Called(enviro...
package server import ( "database/sql" "testing" "github.com/dhaifley/dlib" ) type MockDBSession struct{} func (m *MockDBSession) Close() error { return nil } func (m *MockDBSession) Exec(query string, args ...interface{}) (sql.Result, error) { return nil, nil } func (m *MockDBSession) Query(query string, ar...
package tsm /* #cgo pkg-config: libtsm */ import "C"
package utils import ( "fmt" "math/rand" "time" ) func init() { rand.Seed(time.Now().UnixNano()) } var numberRunes = []rune("0123456789") var charRunes = []rune("abcdefghijklmnopqrstuvwxyz0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ") // RandNumberString retuns rand string of number in length of the given length func R...
package middleware import ( "fmt" "net/http" "github.com/dgrijalva/jwt-go" ) var mySigningKey = []byte("top-secret-signin-value-key") // Auth validates all requests for a valid token func Auth(next http.HandlerFunc) http.HandlerFunc { return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { if r...
package replicatectl import ( "context" "errors" "path" "github.com/operator-framework/operator-lib/status" regv1 "github.com/tmax-cloud/registry-operator/api/v1" "github.com/tmax-cloud/registry-operator/internal/schemes" "github.com/tmax-cloud/registry-operator/internal/utils" "github.com/tmax-cloud/registry...
package middleware import ( "context" "strings" "go.opencensus.io/plugin/ocgrpc" "go.opencensus.io/trace" "google.golang.org/grpc" "google.golang.org/grpc/stats" "github.com/caos/zitadel/internal/api/http" "github.com/caos/zitadel/internal/tracing" ) type GRPCMethod string func TracingStatsServer(ignoredMe...
package mercedes import ( "time" "github.com/evcc-io/evcc/provider" ) // Provider implements the vehicle api type Provider struct { chargerG func() (EVResponse, error) rangeG func() (EVResponse, error) } // NewProvider creates a vehicle api provider func NewProvider(api *API, vin string, cache time.Duration) ...
// Copyright 2022 The ChromiumOS Authors // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. package telemetryextension import ( "context" "chromiumos/tast/local/bundles/cros/telemetryextension/dep" "chromiumos/tast/local/bundles/cros/telemetryextension/vendorut...
package http import ( "github.com/gin-gonic/gin" "github.com/saxon134/go-utils/saData" "github.com/saxon134/go-utils/saData/saHit" "github.com/saxon134/go-utils/saHttp" "github.com/saxon134/workflow/api" "github.com/saxon134/workflow/conf" "strings" ) type Handle func(c *api.Context) (res *api.Response, err er...
package timeparser import ( "testing" "time" ) func TestParseAtTime_Empty(t *testing.T) { got, err := ParseAtTime("", nil) if err != nil { t.Fatalf("err: %s", err) } TestTimeNearlyEqual(t, got, time.Now()) } func TestParseAtTime_UnixTime(t *testing.T) { got, err := ParseAtTime("100", nil) if err != nil { ...
// 189.godoc 離線 本地 文件說明書 // 確認有沒有裝 go get -v golang.org/x/tools/cmd/godoc // CMD >godoc -http=:8080 // 預覽器 > http://localhost:8080/pkg/ // ex // godoc fmt Printf // godoc -src fmt Printf // go doc fmt.Printf package mymath // Sum() 備註 func Sum(xi ...int) int { sum := 0 for _, v := range xi { sum += v } return...
package main /* On an N x N board, the numbers from 1 to N*N are written boustrophedonically starting from the bottom left of the board, and alternating direction each row. For example, for a 6 x 6 board, the numbers are written as follows: 36 35 34 33 32 31 25 26 27 28 29 30 24 23 22 21 20 19 13 14 15 16 17 18 12 11...
package array // 左闭右闭区间 func BinarySearch(arr []int, n int, target int) int { if n == 0 { return -1 } // 定义闭区间 [left, right],那么之后就是在这个闭区间中找 target left := 0 right := n - 1 for left <= right { // left == right 表示数组中还有一个元素 mid := left + (right-left)>>1 if arr[mid] == target { return mid } if arr[mi...
// Copyright (c) KwanJunWen // This source code is licensed under the MIT license found in the // LICENSE file in the root directory of this source tree. package estemplate import "fmt" // TokenizerUAXURLEmail Word Orientated Tokenizer which is like the standard tokenizer // except that it recognises URLs and email ...
package fmc import "github.com/unixpickle/gocube" // IsF2LMinus1Solved returns true if any F2L-1 is solved. It returns the face of // the F2L-1 cross and the corner index of the pair which is not solved. func IsF2LMinus1Solved(state gocube.CubieCube) (solved bool, face, corner int) { crossEdges := []int{ 0, 4, 5, ...
/* * traPCollection API * * traPCollectionのAPI * * API version: 1.0.0 * Generated by: OpenAPI Generator (https://openapi-generator.tech) */ package openapi import ( echo "github.com/labstack/echo/v4" ) func SetupRouting(e *echo.Echo, api *Api) { e.DELETE("/api/games/:gameID", DeleteGamesHandler(api.GameApi...
// Copyright 2015 The Cockroach Authors. // // Use of this software is governed by the Business Source License // included in the file licenses/BSL.txt. // // As of the Change Date specified in that file, in accordance with // the Business Source License, use of this software will be governed // by the Apache License, ...
package connection_manager import ( pb "github.com/1851616111/xchain/pkg/protos" ) type Connection interface { Send(*pb.Message) error Recv() (*pb.Message, error) }
package account import ( "encoding/json" domain2 "github.com/CMedrado/DesafioStone/pkg/domain" http2 "github.com/CMedrado/DesafioStone/pkg/gateways/http" "github.com/gorilla/mux" log "github.com/sirupsen/logrus" "net/http" ) func (s *Handler) GetBalance(w http.ResponseWriter, r *http.Request) { id := mux.Vars(...
// Copyright 2018 The ChromiumOS Authors // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. package example import ( "context" "math" "time" "chromiumos/tast/local/chrome" "chromiumos/tast/local/chrome/browser" "chromiumos/tast/local/chrome/browser/browserfi...
package main import ( "fmt" "log" "net/http" "os" ) func indexHandler(w http.ResponseWriter, req *http.Request) { f, err := os.Open("/home/liminghao/Dev/Golang/src/github.com/castermode/golang-test/web/html/form.html") if err == nil { defer f.Close() buf := make([]byte, 1024*16) if _, err := f.Read(buf);...
package organisations import ( "encoding/json" "fmt" "os" "testing" "github.com/Financial-Times/annotations-rw-neo4j/annotations" "github.com/Financial-Times/neo-utils-go/neoutils" "github.com/jmcvetta/neoism" "github.com/stretchr/testify/assert" ) const ( org1UUID = "0d99ab07-3b0a-4313-939e-ca...