text stringlengths 11 4.05M |
|---|
package main
import (
"fmt"
"time"
"net"
"golang.org/x/net/icmp"
"golang.org/x/net/ipv4"
)
func (p* Packet) IPv4() {
//fmt.Println("Protocol",p.protocol)
//fmt.Println("Count to send",p.count)
//fmt.Println("ttl",p.ttl)
//fmt.Println("address",p.address)
//fmt.Println("delay",p.delay)
conn, err :... |
package timeseries
import (
"bytes"
"fmt"
"log"
"github.com/pascaldekloe/metrics"
"gitlab.com/thorchain/midgard/event"
)
// Double Depth Counting
var (
addPerPoolAndAsset = metrics.Must2LabelCounter("midgard_event_add_E8s_total", "pool", "asset")
errataPerPoolAndAsset = metrics.Must2LabelCounter("midgar... |
package rules
import (
"github.com/bonjourmalware/melody/internal/config"
"github.com/bonjourmalware/melody/internal/events"
)
// Match is the entry point of the Rule matching proc
// It attempt to match every supported rules to the given event after the rules filters have been applied
func (rl *Rule) Match(ev even... |
package worldx
import (
"fmt"
)
type Alien struct {
id int
cityName string
steps int
}
func (a Alien) String() string {
return fmt.Sprintf("alien{#%v, city=%v, steps=%v}", a.id, a.cityName, a.steps)
}
|
package main
import "fmt"
func main() {
nums := []int{10,9,2,5,3,7,101,18}
fmt.Println(lengthOfLIS(nums))
}
func lengthOfLIS(nums []int) int {
n := len(nums)
if n <= 1 {
return n
}
tail := make([]int, n)
tail[0] = nums[0]
end := 0
for i := 1; i < n; i++ {
if nums[i] > tail[end] {
end++
tail[end] =... |
package c19_break_fixed_nonce_ctr
import (
"bufio"
"bytes"
"math/rand"
"os"
"testing"
"time"
"github.com/vodafon/cryptopals/set1/c1_hex_to_base64"
"github.com/vodafon/cryptopals/set1/c2_fixed_xor"
"github.com/vodafon/cryptopals/set3/c18_ctr_stream_mode"
)
func TestExploit(t *testing.T) {
key := make([]byte... |
package shakespeare
import (
"context"
"encoding/json"
"fmt"
"net/http"
"net/url"
"strings"
"time"
)
type convertTextResponse struct {
Success struct {
Total int `json:"total"`
} `json:"success"`
Content struct {
Translated string `json:"translated"`
Text string `json:"text"`
Translation str... |
// Copyright (c) 2014 James Wendel. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
package auth
import (
"encoding/json"
"net/http"
"regexp"
)
var (
proxyAuthRegex *regexp.Regexp
tokenRegex *regexp.Regexp
)
// Webapi represents t... |
// 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 synth
import (
"sync"
"buddin.us/eolian/module"
lua "github.com/yuin/gopher-lua"
)
func Preload(mtx sync.Locker) lua.LGFunction {
return func(state *lua.LState) int {
fns := map[string]lua.LGFunction{}
for _, name := range module.RegisteredTypes() {
fns[name] = constructor(name, mtx)
}
mod := ... |
package handler
import (
"context"
proto "github.com/jinmukeji/proto/v3/gen/micro/idl/partner/xima/core/v1"
)
// WechatCheckWxSignature 验证微信接入的 Signature
func (j *JinmuHealth) WechatCheckWxSignature(ctx context.Context, req *proto.WechatCheckWxSignatureRequest, resp *proto.WechatCheckWxSignatureResponse) error {
... |
package config
import (
"bufio"
"encoding/base64"
"fmt"
"io/ioutil"
"log"
"os"
"os/exec"
"strings"
"syscall"
"golang.org/x/crypto/ssh/terminal"
"github.com/imdario/mergo"
"github.com/zefhemel/kingpin"
yaml "gopkg.in/yaml.v2"
"github.com/egnyte/ax/pkg/backend/common"
"github.com/egnyte/ax/pkg/backend/... |
package coda
import (
"encoding/json"
"fmt"
"net/http"
)
type ErrorResponse struct {
StatusCode int `json:"statusCode"`
StatusMessage string `json:"statusMessage"`
Message string `json:"message"`
}
func buildError(resp *http.Response) error {
var errResp ErrorResponse
err := json.NewDecoder(resp.... |
package lecimg
import "math"
// Max returns max value
func Max(x, y int) int {
if x > y {
return x
}
return y
}
// Min returns min value
func Min(x, y int) int {
if x < y {
return x
}
return y
}
// Minf32 returns min value
func Minf32(x, y float32) float32 {
if x < y {
return x
}
return y
}
// Maxf3... |
package users
import (
"encoding/json"
"github.com/gorilla/mux"
"github.com/The-Music-Network/TMN-API/database"
"github.com/The-Music-Network/TMN-API/errs"
"github.com/jinzhu/gorm"
"log"
"net/http"
"net/http/httptest"
"strconv"
"strings"
)
/*******************************************************************... |
package pdl
import (
"fmt"
"github.com/go-xe2/x/os/xstream"
)
type FileDataField struct {
Id int16 `json:"id"`
Name string `json:"name"`
FieldType *FileDataType `json:"fdType"`
Summary string `json:"summary"`
Limit ProtoFieldLimit `json:"limit"`
Rule string... |
package chapter3
type Truck struct {
numberOfDoors int
bedSize string
weightByTon weight
}
type weight string
const (
oneTon weight ="One Ton"
twoTon weight = "Two Ton"
)
func (t *Truck) getDoors()(int) {
return t.numberOfDoors
} |
package logging
import (
"github.com/google/uuid"
"github.com/jpurdie/authapi"
"github.com/jpurdie/authapi/pkg/api/project"
"github.com/jpurdie/authapi/pkg/utl/model"
"github.com/labstack/echo"
"time"
)
func New(svc project.Service, logger authapi.Logger) *LogService {
return &LogService{
Service: svc,
log... |
/*
Copyright 2022 The KubeVela 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, softw... |
package cmd
import "github.com/spf13/cobra"
var versionCmd = &cobra.Command{
Use: "version",
Short: "v1.0.0",
}
|
package main
import (
"fmt"
"net/http"
)
func serverTest(w http.ResponseWriter, r *http.Request) {
fmt.Println("Server is up and running")
}
|
package user
import (
"ego/src/commons"
"encoding/json"
"net/http"
)
func UserHandler() {
commons.Router.HandleFunc("/login",loginController)
}
//登陆
func loginController(w http.ResponseWriter,r *http.Request) {
username :=r.FormValue("username")
password :=r.FormValue("password")
er :=loginService(username,p... |
package routers
import (
ctx "context"
"hw6/controllers"
"log"
"github.com/astaxie/beego"
"go.mongodb.org/mongo-driver/mongo"
"go.mongodb.org/mongo-driver/mongo/options"
)
func init() {
db, err := mongo.NewClient(options.Client().ApplyURI("mongodb://localhost:27017"))
if err != nil {
log.Fatal(err)
}
er... |
// Copyright 2016 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 main
import (
"bytes"
"encoding/binary"
"math"
)
//packet120 with game state to be read by the server
type packet120 struct {
clientPlayerState uint8 //Packet number 1
xPosition float32
yPosition float32
xVelocity float32
yVelocity float32
}
//ServerPacket with game st... |
package main
import (
"fmt"
"log"
"math"
)
type Point struct{ X, Y float64 }
// A Path is a journey connecting the points with straight lines
type Path []Point
// traditional function
func Distance(p, q Point) float64 {
return math.Hypot(q.X-p.X, q.Y-p.Y)
}
// same thing, but as a method of the Point type
func... |
package envoyconfig
import (
"context"
envoy_config_core_v3 "github.com/envoyproxy/go-control-plane/envoy/config/core/v3"
envoy_extensions_http_header_formatters_preserve_case_v3 "github.com/envoyproxy/go-control-plane/envoy/extensions/http/header_formatters/preserve_case/v3"
envoy_extensions_upstreams_http_v3 "g... |
/*****************************************************************
* Copyright©,2020-2022, email: 279197148@qq.com
* Version: 1.0.0
* @Author: yangtxiang
* @Date: 2020-07-30 17:10
* Description:
*****************************************************************/
package xthrift
import "github.com/apache/thrift/lib/go/... |
package cmd
import (
"bufio"
"fmt"
"io"
"strconv"
"strings"
)
func GetOption(stdin io.Reader) (int, error) {
fmt.Println("1 - Start monitoring")
fmt.Println("2 - Show logs")
fmt.Println("0 - Exit program")
reader := bufio.NewReader(stdin)
input, err := reader.ReadString('\n')
input = strings.TrimSpace(inp... |
package tracing
import (
"context"
"io"
"github.com/opentracing/opentracing-go"
"github.com/opentracing/opentracing-go/ext"
tracinglog "github.com/opentracing/opentracing-go/log"
"github.com/uber/jaeger-client-go"
jaegercfg "github.com/uber/jaeger-client-go/config"
jaegerlog "github.com/uber/jaeger-client-go/... |
package main
import (
"encoding/json"
"fmt"
"net/url"
"sort"
"strconv"
"strings"
"time"
)
type Entry struct {
Name string
Hours uint
Date time.Time
Organization string
ContactName string
ContactEmail string
ContactPhone uint
Description string
LastModified time.Time
Flagged ... |
package main
import "fmt"
func reverse(s []byte) {
for i, j := 0, len(s)-1; i<j; i, j = i+1, j-1 {
s[i], s[j] = s[j], s[i]
}
}
func main() {
str := "ABCDEFG"
input := []byte(str)
fmt.Println(input)
reverse(input[:])
fmt.Println(input)
}
|
package conclusion
import (
"fmt"
"testing"
"github.com/sko00o/leetcode-adventure/queue-stack/conclusion/stack-using-queue/impl1"
"github.com/sko00o/leetcode-adventure/queue-stack/conclusion/stack-using-queue/impl2"
"github.com/sko00o/leetcode-adventure/queue-stack/conclusion/stack-using-queue/impl3"
"github.c... |
package main
import "fmt"
func foo(a int, b int)int{
return a + b
}
func bar(a,b int)int{
return a +b
}
func main(){
fmt.Println(foo(1,2))
fmt.Println(bar(3,4))
}
|
/*
Given a list of (key, value) pairs, determine whether it represents a function, meaning that each key maps to a consistent value. In other words, whenever two entries have equal keys, they must also have equal values. Repeated entries are OK.
For example:
# Not a function: 3 maps to both 1 and 6
[(3,1), (2,5), (3... |
package dhcp
import (
"bytes"
"crypto/rand"
"encoding/binary"
"errors"
"fmt"
"io"
"log"
"math"
"math/big"
"net"
"os"
"time"
"unicode/utf8"
)
const MaxUDPPacketSize = 1024
var PayloadError = errors.New("Payload error")
type UDPPacket struct {
RemoteAddr *net.UDPAddr
Payload []byte
Size int
}... |
func largeGroupPositions(S string) [][]int {
if len(S) < 3 {
return [][]int{}
}
res := [][]int{}
var end int
for i := 0; i < len(S); i++ {
end = i
for end < len(S) - 1 && S[end] == S[end + 1] {
end++
}
if (end - i + 1 >= 3) {
res = appe... |
// This file was generated for SObject ApexClass, API Version v43.0 at 2018-07-30 03:47:23.946271246 -0400 EDT m=+10.289263767
package sobjects
import (
"fmt"
"strings"
)
type ApexClass struct {
BaseSObject
ApiVersion float64 `force:",omitempty"`
Body string `force:",omitempty"`
Bo... |
package main
import "testing"
func TestCamelCase(t *testing.T) {
testCases := []struct {
input, want string
}{
{"", ""},
{"abc", "abc"},
{"MyWWW", "myWww"},
{"HTMLBody", "htmlBody"},
{"UserID", "userId"},
{"totalMBUploaded", "totalMbUploaded"},
}
for _, tc := range testCases {
t.Run(tc.input, func... |
package c41_unpadded_rsa
import (
"crypto/sha256"
"errors"
"time"
"github.com/vodafon/cryptopals/set5/c39_rsa"
)
var AccessError = errors.New("Access denied")
type Server struct {
rsa *c39_rsa.RSA
db map[[32]byte]time.Time
}
func NewServer() *Server {
rsa, err := c39_rsa.Generate(1024)
if err != nil {
p... |
package legolegends
import (
"fmt"
)
type MatchList struct {
TotalGames int `json:"totalGames"`
StartIndex int `json:"startIndex"`
EndIndex int `json:"endIndex"`
Matches []MatchReference `json:"matches"`
}
type MatchReference struct {
Timestamp int... |
package public
import (
"context"
"errors"
"fmt"
"github.com/tal-tech/go-zero/core/logx"
"strings"
"tpay_backend/merchantapi/internal/svc"
"tpay_backend/model"
)
// 代付API路径
const PayApiTransferPath = "/system/transfer"
// 批量代付API路径
const PayApiBatchTransferPath = "/system/transfer-batch"
type FuncLogic struc... |
//author xinbing
//time 2018/8/28 14:18
//数字工具
package utilities
import (
"fmt"
"strconv"
"math"
)
var fmtStrings = []string{
//第一个是补位
"%0.0f","%0.1f","%0.2f","%0.3f","%0.4f","%0.5f","%0.6f","%0.7f","%0.8f","%0.9f","%0.10f",
}
func Round(f float64, precision int) float64 {
if precision <= 0 {
return math.Rou... |
package main
import "fmt"
//这两就是创建分配类型内存
func main(){
//要想声明变量直接var i int就行了,这时候默认值为0
var i *int
//这个是引用类型
i = new(int)
//对于引用类别的变量,不光要声明,还要分配内容空间
//new返回的是指针,指向内存地址
*i = 10
fmt.Println(*i)
}
//make也差不多,但是只用于slice,map以及channel的初始化
//其实new都没人用,直接:=就行了 |
package main
import (
"fmt"
"strings"
)
type coord struct {
x, y, z int
}
type nanobot struct {
loc coord
radius int
}
func abs(val int) int {
if val < 0 {
return -val
}
return val
}
func manhattandistance(a coord, b coord) int {
return abs(a.x-b.x) + abs(a.y-b.y) + abs(a.z-b.z)
}
func loaddata(inpu... |
package _968_Binary_Tree_Cameras
import (
"fmt"
"testing"
)
func TestMinCameraCover(t *testing.T) {
root := &TreeNode{
Left: &TreeNode{
Left: &TreeNode{
Left: &TreeNode{
Left: nil,
Right: &TreeNode{},
},
Right: nil,
},
Right: nil,
},
Right: nil,
}
count := minCameraCover(roo... |
package random
import (
"math/big"
"testing"
"github.com/stretchr/testify/assert"
)
func TestCryptographical(t *testing.T) {
p := &Cryptographical{}
data := make([]byte, 10)
n, err := p.Read(data)
assert.Equal(t, 10, n)
assert.NoError(t, err)
data2, err := p.BytesErr()
assert.NoError(t, err)
assert.Len... |
package common
import (
"database/sql"
"fmt"
"log"
_ "github.com/go-sql-driver/mysql"
)
var Db *sql.DB
func initDatabase() {
prepareDatabase()
}
func closeDatabase() {
Db.Close()
}
func prepareDatabase() {
connectionString := fmt.Sprintf(
"%s:%s@tcp(%s:%d)/%s?parseTime=true",
AppConfig.Database.User,
... |
package airflow_test
import (
"bytes"
"context"
"fmt"
"io/ioutil"
"net/http"
"path/filepath"
"testing"
"time"
"github.com/odpf/optimus/ext/scheduler/airflow2"
"github.com/google/uuid"
"github.com/odpf/optimus/ext/scheduler/airflow"
"gocloud.dev/blob"
"gocloud.dev/blob/memblob"
"github.com/odpf/optimu... |
package main
/**
167. 两数之和 II - 输入有序数组
给定一个已按照升序排列 的有序数组,找到两个数使得它们相加之和等于目标数。
函数应该返回这两个下标值 index1 和 index2,其中 index1 必须小于 index2。
说明:
返回的下标值(index1 和 index2)不是从零开始的。
你可以假设每个输入只对应唯一的答案,而且你不可以重复使用相同的元素。
示例1:
```
输入: numbers = [2, 7, 11, 15], target = 9
输出: [1,2]
解释: 2 与 7 之和等于目标数 9 。因此 index1 = 1, index2 = 2 。
```
*/
... |
package public
import (
"net/http"
"tpay_backend/adminapi/internal/common"
"github.com/tal-tech/go-zero/rest/httpx"
logic_ "tpay_backend/adminapi/internal/logic/public"
"tpay_backend/adminapi/internal/svc"
)
func GetOtherConfigHandler(ctx *svc.ServiceContext) http.HandlerFunc {
return func(w http.ResponseWrite... |
package provider
import (
"github.com/chapterzero/gomposer/composer"
)
type Provider interface {
GetApiUrl(string) string
GetCommitsUrl(string, string) string
GetBranchesUrl(string, string) string
GetTagsUrl(string) string
GetDownloadUrl(string, string) string
GetComposerJson(str... |
package ackhandler
import (
"time"
"github.com/golang/mock/gomock"
. "github.com/onsi/ginkgo"
. "github.com/onsi/gomega"
"gx/ipfs/QmU44KWVkSHno7sNDTeUcL4FBgxgoidkFuTUyTXWJPXXFJ/quic-go/internal/congestion"
"gx/ipfs/QmU44KWVkSHno7sNDTeUcL4FBgxgoidkFuTUyTXWJPXXFJ/quic-go/internal/mocks"
"gx/ipfs/QmU44KWVkSHno7sN... |
package main
import "fmt"
type AnimalCategory struct {
kingdom string
phylum string
class string
order string
family string
genus string
species string
}
func (ac AnimalCategory) String() string {
return fmt.Sprintf("%s%s%s%s%s%s%s",
ac.kingdom, ac.phylum, ac.class,
ac.order, ac.family, ac.genus,... |
package schema
import (
"fmt"
"log"
"github.com/graphql-go/graphql"
"github.com/jjg-akers/docker-sql-graphql/cmd/resolvers"
"github.com/jjg-akers/docker-sql-graphql/cmd/types"
)
var Schema graphql.Schema
func init() {
Query := graphql.NewObject(graphql.ObjectConfig{
Name: "Query",
Fields: graphql.Fields{
... |
// BSD 3-Clause License
//
// Copyright (c) 2020, Kingsgroup
// All rights reserved.
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are met:
//
// 1. Redistributions of source code must retain the above copyright notice, thi... |
package main
import (
"fmt"
"gin_blog/pkg/setting"
)
func main() {
fmt.Println(setting.HTTPPort)
}
|
/*
Copyright 2018 Planet Labs 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 main
import "fmt"
func main() {
nums :=[]int{1,2}
fmt.Println(maxSubArray(nums))
}
func maxSubArray(nums []int) int {
n := len(nums)
if n < 2 {
return nums[0]
}
dp := nums[0]
res := dp
for i := 1; i < n; i++ {
if nums[i] < nums[i]+dp {
dp = nums[i] + dp
} else {
dp = nums[i]
}
if dp >... |
package releaseversion
import (
"fmt"
"testing"
)
// Testre ...
// func TestRe(t *testing.T) {
// SqlAddversion()
// }
func TestQuery(t *testing.T) {
// res := queryTagVers("V4.020")
res := queryVersByIps("10.1.41.56")
fmt.Println(res)
}
|
// Copyright 2023 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
// Outyet is a web server that announces whether or not a particular Go version
// has been tagged.
package main
import (
"expvar"
"flag"
"fmt"
"html/templ... |
package config
import (
"github.com/gin-gonic/gin"
"github.com/goboilerplates/micro-websocket/middleware"
)
// SetMiddleWares setups middlewares.
func SetMiddleWares(router *gin.Engine) {
router.Use(middleware.Cors())
router.Use(middleware.Gzip())
router.Use(middleware.Static())
}
|
package utils
var (
TwilioAccountSid = ""
TwilioAuthToken = ""
)
|
package chunkserver
import (
"io"
"os"
)
// Note: Can't handle concurrent read and write.
func WriteDataAt(path string, offset int64, bytes []byte) (int, error) {
offset += ChunkHeaderLength // Take metadata into account.
file, err := os.OpenFile(path, os.O_WRONLY | os.O_CREATE, 0666)
if err != nil {
re... |
package main
import(
"fmt"
"time"
)
func main() {
ticker := time.NewTicker(time.Second)
i := 0
for tickTime := range ticker.C {
i++
fmt.Println("step", i, "time", tickTime)
if i >= 5 {
//must initiate stop
ticker.Stop()
break
}
}
fmt.Println("total", i)
// return
// time.Tick is an alias fo... |
package Delivery
import (
"Lab1/internal/pgk/Person"
"Lab1/internal/pgk/model_of_person"
"encoding/json"
"fmt"
"github.com/gorilla/mux"
"io/ioutil"
//"log"
"net/http"
"strconv"
)
type PersonHandler struct {
ForPersonUsecase Person.ForUsecase
}
func NewPersonHandler(forPersonUsecase Person.ForUsecase) *Pers... |
package rpcd
import (
"bufio"
"encoding/json"
"errors"
"flag"
"os"
"os/exec"
"time"
jsonlib "github.com/Cloud-Foundations/Dominator/lib/json"
"github.com/Cloud-Foundations/Dominator/lib/log"
"github.com/Cloud-Foundations/Dominator/lib/srpc"
"github.com/Cloud-Foundations/Dominator/lib/triggers"
"github.com... |
package leetcode
import (
"reflect"
"testing"
)
func TestDuplicateZeros(t *testing.T) {
arr := []int{1, 0, 2, 3, 0, 4, 5, 0}
duplicateZeros(arr)
if !reflect.DeepEqual(arr, []int{1, 0, 0, 2, 3, 0, 0, 4}) {
t.Fatal()
}
arr2 := []int{1, 2, 3}
duplicateZeros(arr2)
if !reflect.DeepEqual(arr2, []int{1, 2, 3}) {
... |
package camt
import (
"encoding/xml"
"github.com/thought-machine/finance-messaging/iso20022"
)
type Document02800101 struct {
XMLName xml.Name `xml:"urn:iso:std:iso:20022:tech:xsd:camt.028.001.01 Document"`
Message *AdditionalPaymentInformation `xml:"camt.028.001.01"`
}
func (d *Document028... |
/*
* AppManager API
*
* HTTP REST API to connect to the AppManager
*
* API version: 1.0
* Generated by: Swagger Codegen (https://github.com/swagger-api/swagger-codegen.git)
*/
package appManagerApiClient
type Artifact struct {
Kind string `json:"kind"`
JarUri string `json:"jarUr... |
package blockchain
import (
"bytes"
"encoding/json"
"fmt"
"time"
"github.com/golang/glog"
"github.com/jinzhu/gorm"
"sub_account_service/finance/config"
"sub_account_service/finance/db"
"sub_account_service/finance/lib"
"sub_account_service/finance/models"
"sub_account_service/finance/protocol"
"sub_accou... |
package Repositories
import (
"github.com/jinzhu/gorm"
)
type Repository struct {
DbConn *gorm.DB
} |
// Copyright 2020 IOTA Stiftung
// SPDX-License-Identifier: Apache-2.0
package dkg
// TODO: [KP] Check, if error responses are considered gracefully at the initiator.
import (
"errors"
"fmt"
"strconv"
"sync"
"time"
"github.com/iotaledger/hive.go/logger"
"github.com/iotaledger/wasp/packages/coretypes"
"githu... |
package main
import (
"context"
pb "github.com/little-go/practices/grpc/helloworld/proto"
"github.com/openzipkin/zipkin-go"
zipkingrpc "github.com/openzipkin/zipkin-go/middleware/grpc"
httpReporter "github.com/openzipkin/zipkin-go/reporter/http"
"google.golang.org/grpc"
"log"
"time"
)
const (
address = "... |
package common
import (
"fmt"
"os"
appsv1 "k8s.io/api/apps/v1"
corev1 "k8s.io/api/core/v1"
kerr "k8s.io/apimachinery/pkg/api/errors"
)
type FileIntegrityComponent uint
const (
AIDE = iota
OPERATOR
)
var componentDefaults = []struct {
defaultImage string
envVar string
}{
{"quay.io/file-integrity-ope... |
// Package q is the "gedcom query" parser and engine.
//
// Language Basics
//
// The query is split into expressions. The pipe (|) indicates that the result
// of one expression is the input into the next expression.
//
// The starting expression is the gedcom.Document itself that is passed into the
// first expressio... |
package webservice
import (
"InkaTry/warehouse-storage-be/internal/http/admin"
"InkaTry/warehouse-storage-be/internal/http/admin/handlers"
"InkaTry/warehouse-storage-be/internal/pkg/config"
"InkaTry/warehouse-storage-be/internal/pkg/stores/mysql"
"fmt"
_ "github.com/go-sql-driver/mysql"
"github.com/gorilla/mux"... |
package p2p
import (
"context"
"testing"
"time"
"github.com/airbloc/airbloc-go/account"
"github.com/airbloc/airbloc-go/network/p2p/message"
"github.com/airbloc/airbloc-go/network/p2p/message/users"
"github.com/airbloc/logger"
"github.com/klaytn/klaytn/crypto"
"github.com/perlin-network/noise"
perlinLog "gi... |
package problem0345
import "testing"
func TestReverseVowels(t *testing.T) {
t.Log(reverseVowels("aA"))
}
|
package binance
import (
"context"
"net/http"
)
// TradeFeeService shows current trade fee for all symbols available
type TradeFeeService struct {
c *Client
symbol *string
}
// Symbol set the symbol parameter for the request
func (s *TradeFeeService) Symbol(symbol string) *TradeFeeService {
s.symbol = &sym... |
package dsp
import (
"math"
"math/rand"
)
// Clamp limits a value to a specific range
func Clamp(s, min, max Float64) Float64 {
if s > max {
s = max
} else if s < min {
s = min
}
return s
}
// Rand is rand.Float64()
func Rand() Float64 {
return Float64(rand.Float64())
}
// RandRange returns random values... |
/*
Your challenge today is to write a program or function which takes a list l and gives the positions in l at which each successive element of l sorted appears.
In other words, output the index of the smallest value, followed by the index of the second smallest value, etc.
You can assume that the input array will c... |
package user
import (
"camp/week2/api"
"github.com/globalsign/mgo/bson"
)
func (userModel *UserModel) Update(userApi *api.User) error {
c := userModel.GetC()
defer c.Database.Session.Close()
q := bson.M{}
if userApi.Password != "" {
q["password"] = userApi.Password
}
if userApi.Sex == 1 || userApi.Sex == 2... |
package test
import (
"bytes"
"fmt"
"math/rand"
"os"
"reflect"
"strconv"
"sync/atomic"
"testing"
"time"
confluent "github.com/confluentinc/confluent-kafka-go/kafka"
)
type dummyTransformer struct{}
func (d dummyTransformer) Transform(src *confluent.Message) (*confluent.Message, error) {
return src, nil
}... |
package main
import (
"fmt"
"net"
)
func main() {
// get available network interfaces for
// this machine
interfaces, err := net.Interfaces()
if err != nil {
fmt.Print(err)
return
}
for _, i := range interfaces {
fmt.Printf("Name : %v \n", i.Name)
byNameInterface, err := net.InterfaceByName(i.Nam... |
package console
import (
"fmt"
"io"
)
// InteractiveLogEntry is the interface that wraps the methods required for an
// interactive log entry (e.g. as used in an interactive shell)
//
// InteractiveString returns the interactive string e.g. with spinner on front
// Subscribe takes the channel where change signals a... |
package cli
// Консольный клиент
type CLI struct {
IP string
Port string
}
//Client ...
type Client struct {
NickName string
Login string
Password string
}
func New(ip string, port string) *CLI {
return &CLI{
IP: ip,
Port: port,
}
}
|
package simplestake
import (
"github.com/cosmos/cosmos-sdk/codec"
)
// Register concrete types on codec codec
func RegisterCodec(cdc *codec.Codec) {
cdc.RegisterConcrete(MsgBond{}, "simplestake/BondMsg", nil)
cdc.RegisterConcrete(MsgUnbond{}, "simplestake/UnbondMsg", nil)
}
|
package apis
// import (
// "fmt"
// "net/http"
// "strings"
// "github.com/komand/gosea/handlers"
// "github.com/wjase/crowdscore/services"
// "github.com/dgrijalva/jwt-go"
// "github.com/gorilla/context"
// )
// // API holds the api handlers
// type API struct {
// encryptionKey []byte
// Tokens *apis.T... |
package djset
import (
"errors"
)
type djset struct {
parents map[int]int
setHeight map[int]int
sets map[int][]int
}
var AlreadyInOneSet = errors.New("already in one set")
var SetNotExists = errors.New("set not exists")
func NewDisJointSet() *djset {
return &djset{
parents: make(map[int]int, 0),
s... |
package dag
import (
"github.com/babyboy/leveldb"
"github.com/babyboy/common"
"github.com/babyboy/common/ds"
"github.com/babyboy/common/queue"
"github.com/babyboy/config"
"github.com/babyboy/core/types"
"log"
"sort"
"sync"
"time"
"babyboy-dag/boydb"
)
type MainChainUpdater struct {
db *leveldb.Da... |
package hunter
import (
"sync"
"github.com/lucky-loki/bounty"
)
// A WaitGroup must not be copied after first use.
type WaitGroup struct {
pool WorkerPool
wg sync.WaitGroup
}
func jobWithWg(wg *sync.WaitGroup, job bounty.Job) bounty.FuncJob {
wg.Add(1)
return func() {
defer wg.Done()
job.Run()
}
}
// ... |
package main
import (
"github.com/stretchr/testify/assert"
corev1 "k8s.io/api/core/v1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"testing"
)
func TestShouldThrowErrorWhenAnnotationValueIsNotParseable(t *testing.T) {
pod := &corev1.Pod{
ObjectMeta: metav1.ObjectMeta{
Annotations: map[string]string{
"... |
// Copyright 2021 Google Inc. 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... |
package server
import (
"encoding/json"
"net/http"
"os"
"path/filepath"
"strconv"
"strings"
"sync"
"github.com/devspace-cloud/devspace/pkg/devspace/config/generated"
"github.com/devspace-cloud/devspace/pkg/devspace/config/loader"
"github.com/devspace-cloud/devspace/pkg/devspace/config/versions/latest"
"git... |
package main
import (
"bufio"
"fmt"
"io"
"os"
"github.com/adzeitor/stopka"
)
func scan(scanner *bufio.Scanner) bool {
fmt.Print("> ")
return scanner.Scan()
}
func repl(input io.Reader, output io.Writer) {
machine := stopka.New()
buf := bufio.NewScanner(input)
for scan(buf) {
line := buf.Text()
machine... |
package wechat
import (
"testing"
"encoding/xml"
"fmt"
)
var transferRespXML = `
<xml>
<return_code><![CDATA[SUCCESS]]></return_code>
<return_msg><![CDATA[]]></return_msg>
<mch_appid><![CDATA[wxec38b8ff840bd989]]></mch_appid>
<mchid><![CDATA[10013274]]></mchid>
<device_info><![CDATA[]]></device_info>
<nonce_s... |
package main
func specialPythagoreanTriple(sum int) int {
for a := 1; a < sum; a++ {
for b := 1; b < sum; b++ {
c := sum - a - b
if c*c == a*a+b*b {
return a * b * c
}
}
}
return 0
}
|
package main
import (
"flag"
"fmt"
"io/ioutil"
"net/http"
"testing"
"time"
"gotest.tools/assert"
"k8s.io/apimachinery/pkg/api/errors"
v1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/fields"
"k8s.io/client-go/tools/cache"
networkingv1alpha1 "knative.dev/serving/pkg/apis/networking/v1alph... |
// Copyright 2018, Shulhan <ms@kilabit.info>. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
package websocket
import (
"encoding/binary"
"math"
"math/rand"
"time"
)
const (
OpCodeCont = 0x0
OpCodeText = 0x1
OpCodeBin = 0x2
OpC... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.