text stringlengths 11 4.05M |
|---|
/*
Copyright The containerd 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... |
package http
import (
"time"
"github.com/LavGo/lavp/model"
"net/http"
)
type HttpGet struct {
}
func (self *HttpGet) Run(url string,ch chan *model.HttpResult,cType string,body []byte){
timeStart:=time.Now()
_,err:=http.Get(url)
//fmt.Println(url,resp,err)
timeEnd:=time.Now()
var timeDua int=0
if timeDua=t... |
package app
import (
"bytes"
"mime/multipart"
"net/http"
"net/textproto"
"testing"
)
type testModel struct{}
func (tm *testModel) Learn(data [][]string) {}
func (tm *testModel) Predict(content string) (string, float64) {
return "", 0.0
}
func Test_parseInput(t *testing.T) {
content := []byte("this is test c... |
package storage
import (
"bytes"
"encoding/xml"
"errors"
"fmt"
"github.com/smartystreets/go-aws-auth"
"io"
"io/ioutil"
"net/http"
"os"
"strings"
"sync"
"time"
)
var signMu sync.Mutex
// requestBuilder is something that can sign and return a http.Request for S3.
type requestBuilder func(method, bucket, pa... |
// Copyright © 2016 Alan A. A. Donovan & Brian W. Kernighan.
// License: https://creativecommons.org/licenses/by-nc-sa/4.0/
// See page 156.
// Package geometry defines simple types for plane geometry.
//!+point
//package geometry
package main
import(
"math"
"fmt"
)
type Point struct{ x, y float64 }
// traditio... |
package main
import (
"errors"
"os"
"google.golang.org/api/sheets/v4"
"github.com/apex/log/handlers/text"
"github.com/hink/SquadSheets/internal/pkg/config"
"github.com/apex/log"
"github.com/urfave/cli"
)
// CLIOpts command line options
type CLIOpts struct {
ConfigPath string
LogPath string
Ver... |
package main
import (
"encoding/json"
"log"
"net/http"
"fmt"
"github.com/gorilla/mux"
"github.com/melvinmt/firebase"
)
type Url struct {
Count int `json:"count"`
ActualUrl string `json:"actualurl"`
Visits []Visit `json:"visits"`
}
type Visit struct {
Browser string... |
// Partition system mapping for collections
package dbcore
import (
"github.com/gophergala/echodb/dberr"
"sync"
)
// Partition associates a hash table with collection documents, allowing addressing of a document using an unchanging ID.
type Partition struct {
col *Collection
lookup *HashTable
updating map... |
package mocks
import (
"io/ioutil"
"net/http"
"strings"
)
type mockHTTPClient struct {
LastRequest *http.Request
response *http.Response
err error
}
func (m *mockHTTPClient) SetResponse(body string, code int, err error) {
r := ioutil.NopCloser(strings.NewReader(body))
var response *http.Response =... |
// Copyright 2017 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 server
import (
"context"
"github.com/go-kit/kit/endpoint"
v1 "github.com/turao/go-worker/api/v1"
)
func makeDispatchEndpoint(service Service) endpoint.Endpoint {
return func(ctx context.Context, request interface{}) (interface{}, error) {
req := request.(v1.DispatchRequest)
id, err := service.Dispat... |
package ontap
import (
"bytes"
"encoding/xml"
"fmt"
"github.com/go-xmlfmt/xmlfmt"
"net/http"
"strings"
)
type PerfCounter struct {
ObjectName string
Counter string
Value string
}
type PerfCounterInfo struct {
Name string
Desc string
Unit string
Deprecated string
}
func (c *Cli... |
// Copyright 2021 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, ... |
// Copyright 2017 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 ircdiscord
import (
"strings"
"unicode"
)
func ircUsername(s string) string {
return strings.Map(
func(r rune) rune {
if unicode.IsLetter(r) ||
unicode.IsNumber(r) {
return r
}
switch r {
case '_', '-', '{', '}', '[', ']', '\\', '`', '|':
return r
}
return -1
},
s)
}
|
package basic
import (
"sync"
"time"
"github.com/prometheus/client_golang/prometheus"
"github.com/prometheus/common/log"
"github.com/hellofresh/rds_exporter/config"
"github.com/hellofresh/rds_exporter/sessions"
)
//go:generate go run generate/main.go generate/utils.go
var (
scrapeTimeDesc = prometheus.NewDe... |
package cal
import (
"fmt"
"net/http"
"strings"
"crypto/md5"
"crypto/hmac"
"crypto/sha1"
"encoding/base64"
"time"
"io/ioutil"
)
//define for MQ
// md5
func contentMD5(content string) string{
byteContent := []byte(content)
mdContent := md5.Sum(byteContent)
s := fmt.Sprintf("%x",mdContent)
return s
}
//ca... |
package main
import (
"./undity"
//"./undity/golib/util"
//"./undity/golib/model"
"fmt"
"strings"
//"log"
"os"
)
import (
"github.com/lxn/walk"
. "github.com/lxn/walk/declarative"
)
////////////////////////////////////////////////////////////
// ThreadWin
////////////////////////////////////////////////////... |
package statement
import (
"bytes"
)
type Writer struct {
buff *bytes.Buffer
statements []*Statement
}
func NewWriter() *Writer {
return &Writer{
buff: bytes.NewBuffer(make([]byte, 0)),
statements: make([]*Statement, 0),
}
}
func (w *Writer) MarshalBinary() ([]byte, error) {
return w.buff.Byte... |
package structure
import (
"errors"
)
type RuleFunc func(validator *Validator, ruleDetails []interface{}, data map[string]interface{}, key string) error
var rulesFunc map[string]RuleFunc
func init() {
rulesFunc = make(map[string]RuleFunc)
rulesFunc["required"] = alwaysNil
rulesFunc["optional"] = alwaysNil
ru... |
package repositories
import (
"database/sql"
"errors"
"fmt"
"github.com/revel/revel"
"ringinginross.com/jross/www/app"
entities "ringinginross.com/jross/www/app/entities"
)
// GetGuestUUID performs a db lookup and returns a guest UUID
func GetGuestUUID(firstName, lastName string) (string, error) {
app.InitDB(... |
package core
import (
"github.com/evcc-io/evcc/api"
)
// setConfiguredPhases sets the default phase configuration
func (lp *Loadpoint) setConfiguredPhases(phases int) {
lp.Lock()
defer lp.Unlock()
lp.ConfiguredPhases = phases
// publish 1p3p capability and phase configuration
if _, ok := lp.charger.(api.Phase... |
package computer
import (
"bufio"
"fmt"
"os"
"strconv"
"strings"
)
type IntCodeComputer struct {
Opcodes []int
InputChannel chan int
OutputChannel chan int
RelativeBase int
Running bool
UseStdInput bool
WaitingForInput bool
}
func IntToIntSlice(num int) (res []int) {
numStr := strconv.Itoa(num)
digits ... |
package problem0137
func singleNumber(nums []int) int {
m := make(map[int]int)
for i := 0; i < len(nums); i++ {
m[nums[i]]++
}
ret := 0
for k, v := range m {
if v == 1 {
ret = k
}
}
return ret
}
|
package models
import "github.com/astaxie/beego/orm"
var TableNotes = "poetry_detail_notes"
//poetry_detail_notes 诗词详情内容表
type Notes struct {
Id int `orm:"column(id);auto"`
Title string `orm:"column(title)"`
Content string `orm:"column(content)"`
PlayUrl string `orm:"column(play_url)"`
Pla... |
package main
import "strings"
type player struct {
location string
haveItem map[string]bool
action map[string]func([]string) string
}
type room struct {
description string
events map[string]bool
havePathTo []string
placesWithItems [][]string
additionTo map[string]func([]string) string... |
// Copyright 2018 The gVisor 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 app
import (
"context"
"log"
"time"
"github.com/9d77v/go-pkg/cache/redis"
)
//ShortURL 短地址
type ShortURL struct {
ID uint `gorm:"primarykey"`
URL string `gorm:"size:500;NOT NULL;comment:长地址"`
ShortCode string `gorm:"size:10;NOT NULL;comment:短码"`
Deadline time.Time
CreatedAt time.Time... |
package engine
import (
"testing"
"time"
. "github.com/smartystreets/goconvey/convey"
)
var redis_host string = "dockerhost"
var redis_port int = 6379
var redis_db int = 0
var redis_que string = "abcdef"
func TestRedisGetSet(t *testing.T) {
r := NewRedis(redis_host, redis_port, redis_db)
Convey("Given a Redi... |
package console
import (
"oh-my-posh/color"
"oh-my-posh/platform"
"oh-my-posh/template"
)
type Title struct {
Env platform.Environment
Ansi *color.Ansi
Template string
}
func (t *Title) GetTitle() string {
title := t.getTitleTemplateText()
title = t.Ansi.TrimAnsi(title)
return t.Ansi.Title(title)
}... |
package sqsx_test
import (
"context"
"testing"
"time"
"github.com/aws/aws-sdk-go/aws"
"github.com/aws/aws-sdk-go/aws/request"
"github.com/aws/aws-sdk-go/service/sqs"
"github.com/aws/aws-sdk-go/service/sqs/sqsiface"
"github.com/stretchr/testify/assert"
"github.com/socialpoint-labs/bsk/awsx/sqsx"
)
func Test... |
package util
import (
"hash/fnv"
"log"
"strconv"
"github.com/xmliszt/e-safe/config"
)
func GetHash(s string) (uint32, error) {
config, err := config.GetConfig()
if err != nil {
return 0, err
}
var un uint32
for i := 0; i < config.NumberOfHashing; i++ {
h := fnv.New32a()
_, err := h.Write([]byte(s))
... |
/**
* All Rights Reserved
* This software is proprietary information of Akurey
* Use is subject to license terms.
* Filename: database.go
*
* Author: rnavarro@akurey.com
* Description: Handles mysql DB connection
*/
package database
import (
"database/sql"
"fmt"
_ "github.com/go-sql-driver/mysql"
)
const(
HOST ... |
/*
* traPCollection API
*
* traPCollectionのAPI
*
* API version: 1.0.0
* Generated by: OpenAPI Generator (https://openapi-generator.tech)
*/
package openapi
import (
"time"
)
// VersionDetails - ランチャーのバージョン詳細
type VersionDetails struct {
// ID
Id string `json:"id"`
// 名前
Name string `json:"name"`
// ア... |
package models
import (
"time"
"gorm.io/gorm"
)
// AuthCode type that extends gorm.Model
type AuthCode struct {
gorm.Model
Token string `gorm:"unique"`
AuthorizationCode string `gorm:"unique"`
Expiry *time.Time
}
func (a *AuthCode) IsExpired() bool {
timeLeft := a.Expiry.Sub(time.Now(... |
package base
import "bytes"
import "testing"
func TestGridSetup(t *testing.T) {
p := &Puzzle{}
p.MakeCells(9)
if p.Universe != 0x1FF {
t.Errorf("Universe is %v", p.Universe)
}
c := p.Cell(3, 4)
if c.X != 3 {
t.Errorf("Cell at [3, 4] has X of %d", c.X)
}
if c.Y != 4 {
t.Errorf("Cell at [3, 4] has Y of ... |
// Copyright 2021 The Cockroach Authors.
//
// Licensed as a CockroachDB Enterprise file under the Cockroach Community
// License (the "License"); you may not use this file except in compliance with
// the License. You may obtain a copy of the License at
//
// https://github.com/cockroachdb/cockroach/blob/master/li... |
/*
Copyright 2019-2020 vChain, 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
... |
// Copyright (C) 2019-2020 Zilliz. 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 l... |
// Copyright 2019 - 2022 The Samply Community
//
// 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 ... |
package controllers
import (
"beeapi/models"
"encoding/json"
"fmt"
"math/rand"
"time"
"github.com/astaxie/beego"
)
// EventsController Operations about Events.
type EventsController struct {
beego.Controller
}
// GetRandomString func
func GetRandomString(l int) string {
str := "0123456789abcdefghijklmnopqrs... |
/*
* @lc app=leetcode id=1295 lang=golang
*
* [1295] Find Numbers with Even Number of Digits
*
* https://leetcode.com/problems/find-numbers-with-even-number-of-digits/description/
*
* algorithms
* Easy (82.83%)
* Likes: 321
* Dislikes: 51
* Total Accepted: 113.5K
* Total Submissions: 137.1K
* Testcas... |
package main
import (
"flag"
"fmt"
"log"
"os"
"os/signal"
"syscall"
"reflect"
"github.com/coreos/pkg/flagutil"
"github.com/dghubble/go-twitter/twitter"
"github.com/dghubble/oauth1"
)
//func hello(w http.ResponseWriter, r *http.Request) {
// io.WriteString(w, "Hello world!")
//}
func main() {
... |
package routers
import (
"fmt"
"github.com/apulis/AIArtsBackend/services"
"github.com/apulis/AIArtsBackend/models"
"github.com/gin-gonic/gin"
)
func AddGroupVisualJob(r *gin.Engine) {
group := r.Group("/ai_arts/api/visual")
group.Use(Auth())
group.POST("/", wrapper(createVisualJob))
group.GET("/list", wrapp... |
package actions
import (
"github.com/driusan/de/demodel"
//"github.com/driusan/de/viewer"
)
func init() {
actions = make(map[string]func(string, *demodel.CharBuffer, demodel.Viewport))
// This needs to go here instead of in an init function where the Alias
// command is defined in order to make sure that the ab... |
package model
import (
"gamesvr/manager"
"shared/common"
"shared/protobuf/pb"
"shared/utility/errors"
"shared/utility/servertime"
)
const (
UpdateForNone int32 = 0
UpdateForDay int32 = 1
UpdateForWeek int32 = 2
UpdateForMonth int32 = 3
)
type StoreInfo struct {
*DailyRefreshChecker
Stores map[int32... |
package models
import (
"database/sql"
"fmt"
"github.com/coopernurse/gorp"
_ "github.com/lib/pq"
"log"
"os"
)
const maxContentLength = 140
var dbMap *gorp.DbMap
type Post struct {
Id int64 `json:"id"`
Content string `json:"content"`
}
type ValidationResult struct {
Errors map[string]string `json:"er... |
package main
import (
"encoding/json"
"fmt"
"github.com/plunder-app/plunder/pkg/parlay/parlaytypes"
)
const pluginInfo = `This plugin is used to managed kubeadm automation`
// This defines the etcd kubeadm file (should use the kubernetes packages to define at a later point)
const etcdKubeadm = `apiVersion: "kube... |
package leetcode_go
func combinationSum(candidates []int, target int) [][]int {
res := [][]int{}
helperP39(candidates, []int{}, target, 0, &res)
return res
}
func helperP39(candidates []int, curSum []int, target int, start int, res *[][]int) {
sum := sumInt(curSum)
if sum > target {
return
} else if sum == ta... |
package colors
import "fmt"
// Color represents the various color formats that ASCII escape codes use for text-colorization.
type Color interface {
// Compress condenses the color down into a string format that we can append to the end of an escape character.
Compress() string
}
// DefaultColor represents the buil... |
package dingtalk
const ROOTURL = "https://oapi.dingtalk.com"
var (
// 身份验证
GetUserInfoBycode = ROOTURL + "/sns/getuserinfo_bycode"
GetUserInfo = ROOTURL + "/user/getuserinfo"
GetToken = ROOTURL + "/gettoken"
SSOGetToken = ROOTURL + "/sso/gettoken"
SSOGetUserInfo = ROOTURL + "/sso/getuser... |
// Copyright 2021 The ChromiumOS Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
package appsplatform
import (
"context"
"io/ioutil"
"net/http"
"time"
"chromiumos/tast/common/android/ui"
"chromiumos/tast/ctxutil"
"chromiumos/tast/errors"
"chromi... |
package main
import (
"net/http"
"github.com/gin-gonic/gin"
"github.com/micro/go-micro/registry"
"github.com/micro/go-micro/web"
"github.com/micro/go-plugins/registry/consul"
)
func main() {
// 添加consul地址
cr := consul.NewRegistry(
registry.Addrs("120.78.167.190:8500"))
// 使用gin作为router
router := gin.Defa... |
package cine
import (
"strconv"
"strings"
"testing"
"github.com/go-errors/errors"
)
type TestActor struct {
Actor
t *testing.T
x int
y int
// For BenchmarkChannel test
in chan AddXRequest
// For TestPanic test
shouldStopNormally bool
}
// For BenchmarkChannel test
type AddXRequest struct {
x int
o... |
package colors
import (
"fmt"
)
// textMode is the mode that the text is going to be rendered in.
type textMode uint8
const (
// text modes
Normal textMode = 0
Bold textMode = 1
Dim textMode = 2
Underlined textMode = 4
Blink textMode = 5
rgbForeground textMode = 38
rgbBackground t... |
package sysmodel
import (
"errors"
"log"
"time"
"github.com/tianye3017/gin-admin-backend/db"
)
// SysUser 用户表
type SysUser struct {
Id uint `json:"id" xorm:"pk autoincr"`
Username string `json:"username" xorm:"notnull unique"`
Password string `json:"password" xorm:"notnull"`
NickName str... |
package main
import (
goflag "flag"
"fmt"
"gitlab.com/minorhacks/bazeldeps/bazel"
"gitlab.com/minorhacks/bazeldeps/git"
"github.com/golang/glog"
flag "github.com/spf13/pflag"
)
var (
diffChanges = flag.String("diff_changes", "local",
"Changes to compare for affected target. Options are:\n"+
" `local`: ... |
package main
import "fmt"
type person1 struct {
id int
name string
age int
sex string
}
type student1 struct {
*person1 // 指针作为匿名字段
class int
score int
}
func main() {
var stu student1
stu.class = 301
stu.score = 90
//stu.person1是一个指针类型 默认值为nil 0x0
//需要对指针进行创建空间 new(person1)
//stu.person1=new(... |
// Unless explicitly stated otherwise all files in this repository are licensed
// under the Apache License Version 2.0.
// This product includes software developed at Datadog (https://www.datadoghq.com/).
// Copyright 2016-present Datadog, Inc.
package merger
import (
"fmt"
"github.com/DataDog/datadog-operator/co... |
// SPDX-License-Identifier: ISC
// Copyright (c) 2014-2020 Bitmark Inc.
// Use of this source code is governed by an ISC
// license that can be found in the LICENSE file.
package zmqutil
import (
"encoding/hex"
"io/ioutil"
"os"
"strings"
zmq "github.com/pebbe/zmq4"
"github.com/bitmark-inc/bitmarkd/fault"
"gi... |
package api
import (
"context"
"errors"
"net/http"
"os"
"os/signal"
"time"
"github.com/gorilla/mux"
"go.mongodb.org/mongo-driver/bson"
"go.mongodb.org/mongo-driver/bson/primitive"
"go.mongodb.org/mongo-driver/mongo"
"go.mongodb.org/mongo-driver/mongo/options"
"go.mongodb.org/mongo-driver/mongo/readpref"
... |
package base
import "shared/utility/glog"
type ConfigManager struct {
CfgActionUnlockConfig *CfgActionUnlockConfig
CfgActivityConfig *CfgActivityConfig
CfgActivityFuncConfig *CfgActivityFuncConfig
CfgBattleLevelConfig *CfgBattleLevelConfig
CfgBattleNpcConfig ... |
package main
import (
"fmt"
"math"
)
type Shape interface {
area() float64
}
type Circle struct {
x, y, radius float64
}
type Rectangle struct {
width, height float64
}
func (circle Circle) area() float64 {
return math.Pi * circle.radius * circle.radius
}
func (rect Rectangle) area() float64 {
return rect.... |
package mapbson
import (
"fmt"
"reflect"
"go.mongodb.org/mongo-driver/bson/bsoncodec"
"go.mongodb.org/mongo-driver/bson/bsonrw"
"go.mongodb.org/mongo-driver/bson/bsontype"
)
func newCustomMapCoder(
mapType reflect.Type,
keyEnc func(reflect.Value) (string, error),
keyDec func(string) (reflect.Value, error),
)... |
package internal_test
import (
"fmt"
"net/http"
"net/http/httptest"
"os"
"path/filepath"
"strings"
"testing"
"github.com/paketo-buildpacks/packit/cargo/jam/internal"
"github.com/sclevine/spec"
. "github.com/onsi/gomega"
)
func testImage(t *testing.T, context spec.G, it spec.S) {
var (
Expect = NewWithT... |
// 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 leetcode
func moveZeroes(nums []int) {
var n int
for i := 0; i < len(nums); i++ {
if nums[i] != 0 {
nums[n] = nums[i]
n++
}
}
for n < len(nums) {
nums[n] = 0
n++
}
}
|
package artifacts
import (
"github.com/staffano/crazy-build/artifact"
"github.com/staffano/crazy-build/examples/example2/build/services"
)
// PrintArtifact is the artifact built from this directory
type PrintArtifact struct {
artifact.BaseArtifact
S1 services.Service1API `requirement:"target=x86_64-pc-linux-gnu, ... |
package cavitymap
// https://www.hackerrank.com/challenges/manasa-and-stones
// Stones - implements the solution to the problem
func Stones(n int32, a int32, b int32) []int32 {
result := make([]int32, 0)
if a > b {
exchange := a
a = b
b = exchange
}
current := a * (n - 1)
delta := b - a
result = append(re... |
package rotateimage
import (
"image"
"image/png"
"log"
"net/http"
"os"
)
func rotateImageBy90(imageURL string) {
response, err := http.Get(imageURL)
if err != nil {
log.Fatal(err)
}
defer response.Body.Close()
imageObject, _, err := image.Decode(response.Body)
if err != nil {
log.Fatal(err)
}
ima... |
package mapreduce
import (
"fmt"
"sync"
"sync/atomic"
)
//
// schedule() starts and waits for all tasks in the given phase (mapPhase
// or reducePhase). the mapFiles argument holds the names of the files that
// are the inputs to the map phase, one per map task. nReduce is the
// number of reduce tasks. the regist... |
package Binary_Tree_Preorder_Traversal
import "container/list"
type TreeNode struct {
Val int
Left *TreeNode
Right *TreeNode
}
func preorderTraversal(root *TreeNode) []int {
results := make([]int, 0)
stack := list.New()
p := root
for p != nil || stack.Len() != 0 {
for p != nil {
results = append(resu... |
package cashttpclient
import (
"io/ioutil"
"net/http"
"net/http/httptest"
"os"
"strings"
"testing"
)
func TestNewMultipartRequest(t *testing.T) {
remotePath := "http://exampleurl:exampleport/cas/filename"
d1 := []byte("hello cas http client")
err := ioutil.WriteFile("text.txt", d1, 0644)
if err != nil {
... |
package socks
import (
"bufio"
"fmt"
"io"
)
// ConnectionHandler is the Serve method to handle connections
// from a local TCP listener of the standard library (net.Listener)
type ConnectionHandler interface {
Serve(io.ReadWriter) error
}
// StandardConnectionHandler is the base implementation of handling SOCKS5... |
package utils
import (
"github.com/itchyny/gojq"
"github.com/porter-dev/porter/internal/templater"
)
// NewQuery constructs a templater.TemplateReaderQuery by parsing the jsonpath
// query string
func NewQuery(key, query string) (*templater.TemplateReaderQuery, error) {
jquery, err := gojq.Parse(query)
if err !=... |
// package pgtypes contains sql.Scanners for postgres
package pgtypes
import (
"bytes"
"fmt"
"strconv"
"strings"
)
// a sql.Scanner for postgres text[] values
type StringArray []string
func (s *StringArray) Scan(src interface{}) error {
switch v := src.(type) {
case nil:
s = nil
return nil
case []byte:
... |
package endpoint
import (
"app/todo-api/app/domain/model"
"app/todo-api/component/endpoint/request"
"fmt"
"github.com/gin-gonic/gin"
"net/http"
"strconv"
)
/* Start function for todos */
func (p *Endpoint) GetTodo(ctx *gin.Context) {
// Get params from url
page, _ := strconv.Atoi(ctx.Request.URL.Query()["pag... |
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may ... |
package exec
import (
"errors"
"fmt"
"github.com/spf13/cobra"
cfg "github.com/cloudposse/atmos/pkg/config"
u "github.com/cloudposse/atmos/pkg/utils"
)
// ExecuteHelmfileGenerateVarfileCmd executes `helmfile generate varfile` command
func ExecuteHelmfileGenerateVarfileCmd(cmd *cobra.Command, args []string) error... |
package planar
import (
"math"
"testing"
"github.com/paulmach/orb"
)
var epsilon = 1e-6
func TestDistanceFromSegment(t *testing.T) {
a := orb.Point{0, 0}
b := orb.Point{0, 10}
cases := []struct {
name string
point orb.Point
result float64
}{
{
name: "point in middle",
point: orb.Point{1,... |
package node
import (
"context"
"fmt"
"regexp"
"strconv"
"strings"
dockertypes "github.com/docker/docker/api/types"
"github.com/docker/docker/api/types/container"
"github.com/docker/docker/api/types/filters"
"github.com/docker/docker/api/types/network"
"github.com/docker/docker/api/types/strslice"
"github.... |
package app
import (
"context"
"net/http"
"time"
"github.com/didip/tollbooth"
"github.com/didip/tollbooth/limiter"
"github.com/gorilla/csrf"
log "github.com/sirupsen/logrus"
)
//These middlewares protect the server's router and therefore apply to all routes.
//NewLimiter sets up tollbooth rate limiter
func (... |
package browsermain
import (
"zenhack.net/go/tempest/capnp/external"
"zenhack.net/go/tempest/internal/common/types"
"zenhack.net/go/util/exn"
)
var _ pusherHooks[types.GrainID, external.UiView] = grainPusher{}
type grainPusher struct {
}
func (gp grainPusher) Upsert(id types.GrainID, view external.UiView) (Msg, ... |
package dao
import (
"fmt"
"mall/app/service/main/member/model"
"mall/lib/time"
"github.com/jinzhu/gorm"
)
func (d *Dao) CreateMember(member model.EweiShopMember) (*model.EweiShopMember, error) {
member.Createtime = time.Now()
err := d.orm.Create(&member).Error
return &member, err
}
func (d *Dao) QueryMember... |
package server
import (
"fmt"
"io/ioutil"
"net"
"os"
"strconv"
"sync"
"time"
)
type Info struct {
ID string `json:"server_id"` // NATS服务器的ID
Version string `json:"version"` // NATS的版本
GoVersion string `json:"go"` // NATS用的go版本
Host st... |
package model
import (
_ "github.com/mattn/go-sqlite3"
"log"
"github.com/jmoiron/sqlx"
)
type Question struct {
Id int `db:"id"`
TargetUser string `db:"targetUser"`
Text string `db:"text"`
Reply *string `db:"reply"`
}
func ShowQuestionsList(userName string) (questions []Question) {
db, err := sqlx.Conne... |
package tor
import (
"conf"
"testing"
)
func TestGetTor(t *testing.T) {
path := "."
id := "SET014"
err := GetTor(path, id, conf.TOR_URL_TEMPLATES[1])
if err != nil {
t.Errorf("%s", err.Error())
}
}
|
package domain
// LogEntry represents an alb log entry in s3
type LogEntry struct {
AlbName string
Minute int
Host string
Port string
RequestProcessingTime float64
Status int
TotalBytes int64
IsError bool
}
|
package icws
// License describes a PureConnect License
type License struct {
Name string `json:"name"`
IsAssigned bool `json:"isAssigned"`
}
type LicenseProperties struct {
Active bool `json:"licenseActive"`
HasClientAccess bool `json:"hasClientAccess"`
Media... |
package solutions
func uniquePaths(m int, n int) int {
result := make([]int, m)
for i := 0; i < m; i++ {
result[i] = 1
}
for j := 1; j < n; j++ {
for i := 1; i < m; i++ {
result[i] = result[i] + result[i - 1]
}
}
return result[m - 1]
}
|
package terraform
import (
"github.com/gruntwork-io/terratest/modules/terraform"
"os"
"testing"
)
type TerraformTestScaffold struct {
terraformOptions *terraform.Options
t *testing.T
ExoscaleKey string
ExoscaleSecret string
}
func New(t *testing.T, dir string) *TerraformTestScaffold {
v... |
package common
import "reflect"
func InterSlice(data interface{}) []interface{} {
v := reflect.ValueOf(data) //使用断言机制判断当前传入类型
if v.Kind() != reflect.Slice {
panic("方法体需要接收一个切片类型")
}
if data == nil {
panic("集合数据为空")
}
l := v.Len()
ret := make([]interface{}, l) //开始将传入切片转换为[]interface{}类型
for i := 0; i < l;... |
package main
import (
"fmt"
"github.com/grpc-ecosystem/grpc-opentracing/go/otgrpc"
pb "github.com/jfeng45/grpcservice"
"github.com/jfeng45/grpcservice/server/middleware"
"github.com/jfeng45/grpcservice/server/service"
"github.com/opentracing/opentracing-go"
openzipkin "github.com/openzipkin/zipkin-go-opentracin... |
// Copyright 2018 The Cori Cloud 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
//
// https://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or a... |
package site
import (
"net/http"
)
func ResourcesSetup() {
http.Handle("/public/",http.StripPrefix("/public/",http.FileServer(http.Dir("site/public"))))
}
|
package http
import (
"log"
"net/http"
)
type Server struct {
Port string
Handler http.Handler
}
func (s *Server) Run() error {
log.Println("http.Server: running on port " + s.Port)
return http.ListenAndServe(s.Port, s.Handler)
}
|
package tyTlsPacketDebugger
import (
"encoding/binary"
"encoding/hex"
"fmt"
)
type record struct {
ContentType string
Length int
ProtocolList []handshakeProtocol
}
type handshakeProtocol struct {
HandshakeType string
Length int
}
func Dump(logPrefix string, packet []byte) {
records := GetReco... |
package util
import (
"time"
)
func GetDefaultLocation() *time.Location {
location, _ := time.LoadLocation("America/Sao_Paulo")
return location
}
func DateParse(layout string, data string) (time.Time, error) {
return time.ParseInLocation(layout, data, GetDefaultLocation())
}
func DateNow() time.Time {
return t... |
package usecase
import (
"errors"
"fmt"
"marketplace/accounts/domain"
"github.com/go-pg/pg/v10"
)
type UpdateBalanceByIdCmd func(db *pg.DB, userId int64, deltaBalance float64) (error)
func UpdateBalanceById() UpdateBalanceByIdCmd {
return func(db *pg.DB, userId int64, deltaBalance float64) (error) {
acc :=... |
package eth
import (
"context"
"crypto/ecdsa"
"math/big"
"sync"
"github.com/ethereum/go-ethereum/accounts/abi/bind"
"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/crypto"
"github.com/ethereum/go-ethereum/ethclient"
"github.com/pkg/errors"
store "github.com/lillilli/geth_contract/... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.