text stringlengths 11 4.05M |
|---|
/*
* Copyright (c) 2020. Ant Group. All rights reserved.
*
* SPDX-License-Identifier: Apache-2.0
*/
package registry
import (
"reflect"
"testing"
)
func TestConvertToVPCHost1(t *testing.T) {
type args struct {
registryHost string
}
tests := []struct {
name string
args args
want string
}{
{
nam... |
package day05
import (
"fmt"
"testing"
"github.com/stretchr/testify/require"
)
func TestBoardingPasses(t *testing.T) {
tests := map[string]int{
"FBFBBFFRLR": 357,
"BFFFBBFRRR": 567,
"FFFBBBFRRR": 119,
"BBFFBBFRLL": 820,
}
for sequence, expected := range tests {
t.Run(fmt.Sprint("test", sequence), fu... |
//go:generate go-enum -f=$GOFILE
package main
import (
"net"
"strconv"
"strings"
"time"
"unicode"
"github.com/go-redis/redis"
"github.com/pkg/errors"
log "github.com/sirupsen/logrus"
)
// RedisStatus is an enumeration of all possible states the health of a redis instance can have.
/*
ENUM(
Unknown
Ready
Load... |
package influx
import (
"encoding/json"
"fmt"
"log"
"github.com/aws/aws-sdk-go/aws"
"github.com/aws/aws-sdk-go/aws/session"
"github.com/aws/aws-sdk-go/service/iotdataplane"
)
type State struct {
State *Reported `json:"state"`
}
type Reported struct {
Reported *SensorData `json:"reported"`
}
type SensorData s... |
package main
import (
"fmt"
)
func main() {
x := 0
fmt.Printf("BEFORE :: 'x' :: value :: %v :: address :: %v\n", x, &x)
foo(&x)
fmt.Printf("AFTER :: 'x' :: value :: %v :: address :: %v\n", x, &x)
}
func foo(y *int) {
fmt.Printf("BEFORE :: 'y' :: value :: %v :: value at address :: %v\n", y, *... |
package wire
type LastBlockHeightReply struct {
Height uint64
}
|
package proarrays
import (
"fmt"
"learn_go/algorithm/sortfunc"
)
// 题目
// 给你 n 个非负整数 a1,a2,...,an,每个数代表坐标中的一个点 (i, ai) 。在坐标内画 n 条垂直线,垂直线 i 的两个端点分别为 (i, ai) 和 (i, 0)。找出其中的两条线,使得它们与 x 轴共同构成的容器可以容纳最多的水。
// 说明:你不能倾斜容器,且 n 的值至少为 2。
// 仔细读完题,可知,通过双指针,双边紧逼来, 求解最大区域,暴力破解法不再考虑
// DobulePointerArea 求出最大区域
func DobulePointer... |
package stats
import (
"reflect"
"runtime"
"strconv"
"strings"
"sync/atomic"
"unsafe"
)
const Stats = false
const Timing = false
var Nirqs [100]int
var Irqs int
func Rdtsc() uint64 {
if Stats {
return runtime.Rdtsc()
} else {
return 0
}
}
type Counter_t int64
type Cycles_t int64
func (c *Counter_t) I... |
package main
import (
"fmt"
"math/rand"
"net/url"
"time"
)
// Strategy is an interface to be implemented by loadbalancing
// strategies like round robin or random.
type Strategy interface {
NextEndpoint() url.URL
SetEndpoints([]url.URL)
}
// RandomStrategy implements Strategy for random endopoint selection
typ... |
/**
* Given a linked list, swap every two adjacent nodes and return its head.
* For example, Given 1->2->3->4, you should return the list as 2->1->4->3.
* Your algorithm should use only constant space. You may not modify the values in the list, only nodes itself can be changed.
*
* Definition for singly-linked li... |
package c49_cbc_mac_forgery
import (
"crypto/rand"
"errors"
"fmt"
"net/url"
"strconv"
"sync"
"github.com/vodafon/cryptopals/set1/c2_fixed_xor"
)
type BankIV struct {
sync.Mutex
accounts map[string]uint64
cbcmac CBCMAC
attacker string
}
func NewBankIV(attacker string) *BankIV {
accounts := make(map[str... |
package main
import (
"fmt"
"sync"
)
var pool *sync.Pool
type Person struct {
Name string
}
func init() {
pool = &sync.Pool{
New: func() interface{} {
fmt.Println("creating new person")
return new(Person)
},
}
}
/**
creating new person
Get Pool Object: &{}
Get Pool Object: &{first}
creating new per... |
package hash_table_test
import (
"testing"
ht "hash_table"
"reflect"
"errors"
//"fmt"
)
// testing correctness of passed HashTable's length
func TestNew(t *testing.T) {
tables := []struct {
lenInput int
objectType string
tableSize int
err error
}{
{5, "*hash_table.HashTable", 5, nil},
{0,... |
/*
* @lc app=leetcode.cn id=190 lang=golang
*
* [190] 颠倒二进制位
*/
package solution
// @lc code=start
func reverseBits(num uint32) uint32 {
var res uint32 = 0
acc := 31
for num != 0 {
res += (num & 1) << acc
num >>= 1
acc--
}
return res
}
// @lc code=end
|
package tsmt
import (
"encoding/xml"
"github.com/thought-machine/finance-messaging/iso20022"
)
type Document04600101 struct {
XMLName xml.Name `xml:"urn:iso:std:iso:20022:tech:xsd:tsmt.046.001.01 Document"`
Message *IntentToPayReportV01 `xml:"InttToPayRpt"`
}
func (d *Document04600101) AddMessage()... |
/*
# -*- coding: utf-8 -*-
# @Author : joker
# @Time : 2020-09-09 08:14
# @File : lt_114_Flatten_Binary_Tree_to_Linked_List.go
# @Description :
# @Attention :
*/
package v0
/*
就是将二叉树转换成排序链表
1. 左子树,插到右子树的位置,将原先的右子树插到左子树的最右子树
递归法解决: 主要要断开左孩子
核心: 题目规律: 先序+递归
*/
func flatten(root *TreeNode) {
if nil == root {
... |
package main
//给定一个由 整数 组成的 非空 数组所表示的非负整数,在该数的基础上加一。
//
//最高位数字存放在数组的首位, 数组中每个元素只存储单个数字。
//
//你可以假设除了整数 0 之外,这个整数不会以零开头。
//
//
//
//示例 1:
//
//输入:digits = [1,2,3]
//输出:[1,2,4]
//解释:输入数组表示数字 123。
//示例 2:
//
//输入:digits = [4,3,2,1]
//输出:[4,3,2,2]
//解释:输入数组表示数字 4321。
//示例 3:
//
//输入:digits = [0]
//输出:[1]
//
//
//提示:
//
/... |
package gate
import (
"hub000.xindong.com/rookie/rookie-framework/communication"
"hub000.xindong.com/rookie/rookie-framework/protobuf"
"hub000.xindong.com/rookie/rookie-framework/log"
)
type Router struct {
p *Processor
route map[int] communication.Communicator
Communicator communication.Communicator
}
... |
package entity
type Report struct {
ID uint `json:"id"`
TitleEvent string `json:"title_event"`
Description string `json:"description"`
Creator string `json:"creator"`
TicketPrice float32 `json:"ticket_price"`
ParticipantId uint `json:"participant_id"`
Name string `json... |
package qiwi
import (
"bytes"
"context"
"encoding/base64"
"encoding/json"
"errors"
"fmt"
"io"
"net/http"
"net/http/httptest"
"testing"
)
func TestBase64Decode(t *testing.T) {
enc := "YWJjMTIzIT8kKiYoKSctPUB+"
expected := "abc123!?$*&()'-=@~"
res, err := decodeBase64(enc)
if string(res) != expected {
... |
package tempclean_test
import (
"log"
"os"
"path/filepath"
"testing"
"github.com/brentp/go-athenaeum/tempclean"
)
func TestCleanup(t *testing.T) {
tmp, err := tempclean.TempFile("", "asdf")
if err != nil {
t.Fatal(err)
}
if tmp == nil {
t.Fatal("error creating temp file")
}
tmp2, err := tempclean.T... |
package API
import (
"Work_5/Service"
"Work_5/object"
"github.com/gin-gonic/gin"
"net/http"
)
//用户登录API方法
func UserLogin(ctx *gin.Context) {
//绑定user结构体
var user object.User
ctx.ShouldBind(&user)
//调用Service层用户登录方法,并接受err
err := Service.UserLogin(&user)
//若成功则返回用户信息,否则返回err信息
if err.IsErr {
ctx.JSON(h... |
// Copyright 2023 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 ... |
package dao
import (
"fmt"
tgbotapi "github.com/go-telegram-bot-api/telegram-bot-api"
db "github.com/rvramesh/tg-microwin-bot/src/db"
models "github.com/rvramesh/tg-microwin-bot/src/models"
)
var err error
func CheckAndGetUser(chat *tgbotapi.Chat) models.User {
var user models.User
var dbCon = db.GetDB()
res... |
package balancer
type Balancer interface {
Pick(ids []string) (string, error)
}
|
package sns
import (
"encoding/json"
"github.com/BlueDragonX/beacon/beacon"
"github.com/aws/aws-sdk-go/aws"
"github.com/aws/aws-sdk-go/aws/session"
awssns "github.com/aws/aws-sdk-go/service/sns"
"github.com/pkg/errors"
)
// New creates an SNS backend that queues events in the SNS `topic` which lives
// in `regi... |
package cosmos
import "context"
// Database performs operations on a single database
type Database struct {
client Client
dbID string
}
// Databases performs operations on databases
type Databases struct {
client *Client
}
// User operations
func (d Database) User(id string) *User {
return newUser(d, id)
}
/... |
package k8sml
type VirtualFirewall interface {
GetID() string
GetVariableValue(variable string) interface{}
GetIngress() []*Ingress
GetEgress() []*Egress
GetTargetGroups() []*TargetGroup
GetRoles() []*Role
GetSubnet() *Subnet
AddRuntimeVariable(key, value string)
GetRuntimeVariables() map[string]string
Expor... |
package main
import (
adventutilities "AdventOfCode/utils"
passport "AdventOfCode/utils/structs/Passport"
"log"
"strings"
"github.com/go-playground/validator"
)
func splitInputs(lines []string) (records []string) {
record := ""
for n, line := range lines {
if line == "" {
//new record
strings.Trim... |
package main
import (
"container/list"
"fmt"
"path/filepath"
"time"
"github.com/jraams/aoc-2020/helpers"
)
func main() {
inputPath, _ := filepath.Abs("input")
lines := helpers.GetInputValues(inputPath)
d1, d2 := loadDecks(lines)
// Part a
a := solveA(copyDeck(d1), copyDeck(d2))
fmt.Printf("Solution day 2... |
package usecases
type Cleaner interface {
Clean() error
}
|
package ircserver
import (
"strings"
"gopkg.in/sorcix/irc.v2"
)
func init() {
Commands["ISON"] = &ircCommand{
Func: (*IRCServer).cmdIson,
MinParams: 1,
}
}
func (i *IRCServer) cmdIson(s *Session, reply *Replyctx, msg *irc.Message) {
var onlineUsers []string
for _, nickname := range msg.Params {
if ... |
/*
Chef has a sequence A1,A2,…,AN. He needs to find the number of pairs (i,j) (1≤i<j≤N) such that Ai+Aj=Ai⋅Aj.
However, he is busy, so he asks for your help.
Input
The first line of the input contains a single integer T denoting the number of test cases. The description of T test cases follows.
The first line of eac... |
package clouddatastore
import (
"context"
"fmt"
"math/rand"
"net"
"os"
"testing"
"time"
"go.mercari.io/datastore/testsuite"
_ "go.mercari.io/datastore/testsuite/dsmiddleware/dslog"
_ "go.mercari.io/datastore/testsuite/dsmiddleware/fishbone"
_ "go.mercari.io/datastore/testsuite/dsmiddleware/localcache"
_ "... |
package main
import (
"log"
"time"
"github.com/boltdb/bolt"
)
type Storage struct {
db *bolt.DB
petStore *PetStorage
historyStore *PetStorage
}
func NewStorage(file string) *Storage {
db, err := bolt.Open(file, 0600, &bolt.Options{Timeout: 5 * time.Second})
if err != nil {
log.Fatalf("Can't ... |
package main
func wordCount(s string) int {
c := 0
for i := 0; i < len(s); i++ {
for i < len(s) && s[i] == ' ' { // сул зайн тэмдэгт
i++
}
if i < len(s) && s[i] != ' ' {
c++
}
for i < len(s) && s[i] != ' ' { // бусад тэмдэгт
i++
}
}
return c
}
func main() {
str := "Hello World! "
pri... |
/*
Copyright The Helm 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, software
distrib... |
package main
import "fmt"
func main() {
fmt.Printf("%d\n", lengthOfLongestSubstring("a"))
}
// 动态规划方法解题 利用空间换时间
func lengthOfLongestSubstring(s string) int {
maxLength := 0
posOfChar := make(map[rune]int) // 动态规划 map
startPos := 0 // 起始下标
for i, c := range s {
// 当字符再次出现时 触发计算子串长度 更新起始下标值(不... |
package game
import (
"encoding/json"
"errors"
"fmt"
"log"
"net"
"net/http"
"path/filepath"
"strconv"
"time"
"sync"
"github.com/gamejolt/joltron/game/data"
"github.com/gamejolt/joltron/network/messages/incoming"
"github.com/gamejolt/joltron/network/messages/outgoing"
OS "github.com/gamejolt/joltron/os"... |
// Copyright 2018 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 (
"fmt"
"net/http"
"github.com/pkg/errors"
"github.com/thoas/letitgo"
)
func main() {
h1 := letitgo.HandlerFunc(func(w http.ResponseWriter, r *http.Request) error {
return fmt.Errorf("looks like we have a panic situation")
})
h2 := letitgo.HandlerFunc(func(w http.ResponseWriter, r *http... |
package draw
type IBrush interface {
Dispose()
}
|
package main
import (
"fmt"
"time"
"github.com/couchbase/gomemcached/client"
"github.com/couchbaselabs/go-couchbase"
)
func handleError(err error) {
if err != nil {
panic(err)
}
}
func main() {
bucket, err := couchbase.GetBucket("http://localhost:8091/", "default", "demo") // HL
handleError(err)
// STA... |
package main
import (
"fmt"
"math/big"
"github.com/jackytck/projecteuler/tools"
)
func convergent(n int) *big.Int {
a := big.NewInt(2)
b := big.NewInt(3)
if n == 1 {
return a
}
if n == 2 {
return b
}
for i := 3; i <= n; i++ {
k := 1
if i%3 == 0 {
k = 2 * i / 3
}
k2 := big.NewInt(int64(k))
... |
package demo
import (
"bufio"
"compress/gzip"
"fmt"
"io"
"io/ioutil"
"os"
)
func openFileForOnlyRead() {
file, err := os.Open("E:/gospace/src/learn9/fileAndIo/demo.go")
if err != nil {
fmt.Println("open file failed. err: ", err)
return
}
defer file.Close()
}
func readFileByFile() {
file, err := os.Ope... |
package user
import (
"errors"
"github.com/firefirestyle/engine-v01/prop"
"golang.org/x/net/context"
"google.golang.org/appengine/datastore"
"google.golang.org/appengine/log"
)
type UserManagerConfig struct {
UserKind string
UserPointerKind string
LengthHash int
LimitOfFinding int
}
type UserM... |
package main
import (
"context"
"crypto/aes"
"crypto/cipher"
"crypto/rand"
"encoding/base64"
"encoding/json"
"flag"
"fmt"
"io"
"time"
"github.com/gin-contrib/cors"
"github.com/gin-gonic/gin"
"github.com/go-redis/redis/v8"
"github.com/golang/glog"
)
func init() {
flag.Set("alsologtostderr", "true")
fl... |
package api
import (
"encoding/json"
"fmt"
"net/http"
"DeanFoleyDev/go-url-shortener/internal/app"
"DeanFoleyDev/go-url-shortener/internal/data"
"DeanFoleyDev/go-url-shortener/internal/db"
)
// POST /shorten/ { "url": string }
// Returns a shortened URL for a given long URL
func ShortenURLHandler(w http.Respon... |
/*
* @lc app=leetcode.cn id=1207 lang=golang
*
* [1207] 独一无二的出现次数
*/
// @lc code=start
package main
import "fmt"
func main() {
var a []int
a = []int{1,2,2,1,1,3}
fmt.Printf("%v, %t\n", a, uniqueOccurrences(a))
a = []int{1,2}
fmt.Printf("%v, %t\n", a, uniqueOccurrences(a))
a = []int{-3,0,1,-3,1,1,1,-3,1... |
package dao
import (
"github.com/social-network/subscan-plugin/example/system/model"
"github.com/social-network/subscan-plugin/tools"
"github.com/social-network/substrate-api-rpc"
"github.com/social-network/substrate-api-rpc/metadata"
"github.com/jinzhu/gorm"
"strings"
)
func CreateExtrinsicError(db *gorm.DB, h... |
package loket
import (
app "github.com/mataharimall/micro-api"
. "github.com/mataharimall/micro-api/commons/idata/assertion"
. "github.com/smartystreets/goconvey/convey"
"testing"
)
func init() {
app.InitConfig()
}
func TestGetAuth(t *testing.T) {
Convey("Testing Loket API", t, func() {
Convey("should return... |
package sshserver
import (
"github.com/kless/osutil/user/crypt/sha512_crypt"
"github.com/telmomarques/x360h1080p-web-config-server/config"
"github.com/telmomarques/x360h1080p-web-config-server/customerror"
"github.com/telmomarques/x360h1080p-web-config-server/service"
)
const ID = "ssh-server"
const FriendlyName ... |
package utils
import (
"encoding/json"
"io/ioutil"
"../ziface"
)
type GolbalObj struct {
TcpServer ziface.IServer
Host string
TcpPort int
Name string
Version string
MaxPacketSize uint32
MaxConn int
// worker pool
WorkerPoolSize uint32
MaxWorkerTaskLen uint
Ma... |
package lib
import (
"bufio"
"fmt"
"io"
"strings"
"time"
)
// CheckQuestionAnswer displays questions to the user to answer
func CheckQuestionAnswer(input io.Reader, qans []*QuestionAnswer, timeLimit int) (int, error) {
points := 0
reader := bufio.NewReader(input)
timer := time.NewTimer(time.Duration(timeLimit... |
package models
import (
"encoding/json"
"fmt"
"io/ioutil"
"net/http"
"testing"
)
func TestCategory(t *testing.T) {
url := "http://service.picasso.adesk.com/v1/vertical/category?adult=false&first=1"
req, _ := http.NewRequest(http.MethodGet, url, nil)
req.Header.Set("Host", "service.picasso.adesk.com")
req.Hea... |
// Copyright Amazon.com Inc. or its affiliates. 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. A copy of the
// License is located at
//
// http://aws.amazon.com/apache2.0/
//
// or in the "license" file ... |
package crypto
import (
"crypto/hmac"
"crypto/sha512"
)
const algoHmacSha512 = "hmac-sha512"
// HmacSha512 signing algorithm using hmac and sha512
type HmacSha512 struct{}
// Sign return signing of input msg with secret string
func (h *HmacSha512) Sign(msg string, secret string) ([]byte, error) {
mac := hmac.New... |
// Copyright 2016 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 sms
import (
"bufio"
"bytes"
"github.com/sujit-baniya/smpp/coding/gsm7bit"
"github.com/sujit-baniya/smpp/coding/semioctet"
"io"
)
type Address struct {
NPI, TON byte
No string
}
func (p Address) MarshalBinary() (data []byte, err error) {
var kind byte
kind |= p.NPI & 0b1111
kind |= p.TON & 0b... |
package main
import "fmt"
//構造体
//構造体とポインタ
type Point struct {
A int
B string
C float64
}
func Update(p Point) {
p.A = 100
p.B = "Update"
p.C = 2.14
}
func Update2(p *Point) {
p.A = 100
p.B = "Update"
p.C = 2.14
}
func main() {
p := Point{}
Update(p)
fmt.Println(p)
//参照渡し
//アドレスを生成する
//こちらが推奨され... |
package user
import (
"testing"
"encoding/json"
"github.com/danielsomerfield/authful/server/handlers"
"github.com/danielsomerfield/authful/common/util"
"fmt"
"github.com/danielsomerfield/authful/server/service/admin/user"
"errors"
"github.com/danielsomerfield/authful/server/service/oauth"
)
var registeredUser... |
package storage
import (
"bytes"
"errors"
"github.com/golang/mock/gomock"
mock_afero "github.com/nomkhonwaan/myblog/internal/afero/mock"
"github.com/stretchr/testify/assert"
"path/filepath"
"testing"
)
func TestDiskCache_Close(t *testing.T) {
// Given
ctrl := gomock.NewController(t)
defer ctrl.Finish()
va... |
package routers
import (
"net/http"
"../common"
"github.com/gin-gonic/gin"
)
type Question struct {
ID int
Description string
}
func TutorQuestionHistory(c *gin.Context) {
// invoke db conn
db, err := common.InitDB()
if err != nil {
return
}
defer db.Close()
var (
questions Question
resu... |
// Copyright 2014 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.
// Package typeutil defines various utilities for types, such as Map,
// a mapping from types.Type to interface{} values.
package typeutil
import (
"bytes"
"... |
package model
type Database struct {
mysql Mysql
redis Redis
}
type Container struct {
DB Database
}
|
package main
import (
"flag"
"github.com/nats-io/stan.go"
"github.com/teploff/otus/sender/internal/app"
"github.com/teploff/otus/sender/internal/config"
"github.com/teploff/otus/sender/internal/infrastructure/logger"
"go.uber.org/zap"
"go.uber.org/zap/zapcore"
"os"
"os/signal"
"syscall"
)
var (
configFile ... |
package force
import (
"bytes"
"encoding/json"
"fmt"
"io"
"io/ioutil"
"net/http"
"net/url"
"strings"
)
const (
grantType = "password"
loginUri = "https://login.salesforce.com/services/oauth2/token"
testLoginUri = "https://test.salesforce.com/services/oauth2/token"
invalidSessionErrorCode = "INVALI... |
package raft
//
// Raft tests.
//
// we will use the original test_test.go to test your code for grading.
// so, while you can modify this code to help you debug, please
// test with the original before submitting.
//
import "testing"
import "fmt"
import "time"
// The tester generously allows solutions to complete e... |
// +build windows
/**
* Fileserver
* Programmieren II
*
* 8376497, Florian Braun
* 2581381, Lena Hoinkis
* 9043064, Marco Fuso
*/
package Utils
// Colors for Unix, set to empty for Windows because windows cant :O
const (
ANSI_COLOR_RED = ""
ANSI_COLOR_GREEN = ""
ANSI_COLOR_YELLOW = ""
ANSI_COLOR_BLU... |
package main
/**
只出现一次的数字
给定一个非空整数数组,除了某个元素只出现一次以外,其余每个元素均出现两次。找出那个只出现了一次的元素。
说明:
你的算法应该具有线性时间复杂度。 你可以不使用额外空间来实现吗?
示例 1:
```
输入: [2,2,1]
输出: 1
```
示例 2:
```
输入: [4,1,2,1,2]
输出: 4
```
*/
/**
这题之前做过哎...,没理解线性时间复杂度是什么意思,不使用额外空间是不能定义变量吗? 那样的话,直接每次循环的时候,都更新数组的值来保存上一次 ^= 后的值也可以 (试了下,内存占用和执行速度都变慢了,不知道为什么)
*/
func Sin... |
package e2e
import (
"k8s.io/api/core/v1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
)
func NewCertManagerControllerPod(name string) *v1.Pod {
return &v1.Pod{
ObjectMeta: metav1.ObjectMeta{
Name: name,
Labels: map[string]string{
"app": name,
},
},
Spec: v1.PodSpec{
Containers: []v1.Contain... |
package iigointernal
import (
"fmt"
"github.com/SOMAS2020/SOMAS2020/internal/common/config"
"github.com/SOMAS2020/SOMAS2020/internal/common/gamestate"
"github.com/SOMAS2020/SOMAS2020/internal/common/roles"
"github.com/SOMAS2020/SOMAS2020/internal/common/rules"
"github.com/SOMAS2020/SOMAS2020/internal/common/sha... |
package merkle
import (
"fmt"
"hash"
"math"
)
const (
DepthMin = 1
DepthMax = 16
HashSizeMin = 1 // bytes
HashSizeMax = 64 // bytes
)
var (
ErrTooSmallDepth = fmt.Errorf("depth must be %d or more", DepthMin)
ErrTooLargeDepth = fmt.Errorf("depth must be %d or less", DepthMax)
ErrTooSmallHashSiz... |
package transport
import (
"encoding/binary"
//"fmt"
"logging"
)
type TcpPacket struct {
Tcpheader TCPHeader
Payload []byte
}
func MakeTcpPacket(message []byte, h TCPHeader) TcpPacket {
return TcpPacket{h, message}
}
func (Tcp *TcpPacket) PrintTcpPacketString() {
logging.Logger.Printf("[IpHandler][TcpPacke... |
package dalmodel
import "github.com/jinzhu/gorm"
type Resource struct {
gorm.Model
AuditModel
Name string `gorm:"not null;unique_index"`
Hashtags []Hashtag `gorm:"many2many:resource_hashtags;"`
Thumbnail string
Image string
Video string
}
|
// Copyright 2021 Liuxiangchao iwind.liu@gmail.com. All rights reserved.
package nodeconfigs
type NodeIPAddr struct {
Id int64 `json:"id"`
Name string `json:"name"`
Thresholds []*NodeValueThresholdConfig `json:"thresholds"`
IP string ... |
package main
// Config is the root config for Logcli.
type Config struct {
Addr string `yaml:"addr,omitempty"`
Username string `yaml:"username,omitempty"`
Password string `yaml:"password,omitempty"`
}
func getConfig(configFile string) (*Config, error) {
var config Config
// if not specify config file, keep ... |
package main
import (
//"net/http"
"github.com/labstack/echo"
)
type CustomContext struct {
echo.Context
}
func (c *CustomContext) Bar() {
//bar := "brr"
}
func main() {
e := echo.New()
e.Use(func(h echo.HandlerFunc) echo.HandlerFunc {
return func(c echo.Context) error {
cc := &CustomContext{c}
ret... |
package scan
import "strings"
// FileFilter is an interface for filters used in the catalog scanning pipeline
type FileFilter interface {
Include(path string) bool
}
// ExtensionFilter filters the files based on their extension. The listed extensions
// will be excluded
func ExtensionFilter(extensions ...string) Fi... |
package main;
import (
"testing"
)
func TestEmptyArray(t *testing.T) {
input := []int{};
want := -1;
got := max(input);
if got != want {
t.Errorf("wanted %d but got %d", want, got);
}
}
func TestReverseSorted(t *testing.T) {
input := []int{
3,
2,
1,
};
want := 3;
got := max(input);
if got !... |
package secure
import (
"encoding/json"
"fmt"
"github.com/yandex-cloud/go-genproto/yandex/cloud/kms/v1"
)
type Config struct {
SessionKeys []*SessionKeyPair `json:"session_keys"`
OAuthSecret string `json:"oauth_secret"`
}
type SessionKeyPair struct {
HashKey []byte `json:"hash"`
BlockKey []byte `... |
package model
/****************配置项****************/
type GlobalCfg struct {
AppID string `yaml:"appid"`
Name string `yaml:"name"`
Version string `yaml:"version"`
Http Protocol `yaml:"http"`
ConfigCenterUrl string `yaml:"configCenterUrl"`
Cse CseStr... |
package collectors
import (
"github.com/prometheus/client_golang/prometheus"
"github.com/bosh-prometheus/bosh_exporter/deployments"
)
type Collector interface {
Collect(deployments []deployments.DeploymentInfo, ch chan<- prometheus.Metric) error
Describe(ch chan<- *prometheus.Desc)
}
|
package pb
//go:generate trpc create -f --protofile=helloworld.proto --rpconly -o ../../stub/git.woa.com/trpcprotocol/helloworld
|
// Copyright 2017 Jeff Foley. All rights reserved.
// Use of this source code is governed by Apache 2 LICENSE that can be found in the LICENSE file.
package sources
import (
"encoding/json"
"io"
"strings"
"github.com/OWASP/Amass/amass/core"
"github.com/OWASP/Amass/amass/utils"
)
// Crtsh is data source object ... |
package pdl
import (
"fmt"
"github.com/go-xe2/x/encoding/xparser"
"github.com/go-xe2/x/os/xfile"
"github.com/go-xe2/x/type/t"
"sort"
)
func (p *FileData) loadImports(arr []interface{}) error {
for _, v := range arr {
s := t.String(v)
if s != "" {
p.AddImport(s)
}
}
return nil
}
func (p *FileData) lo... |
package structSiradig
import (
"time"
"github.com/xubiosueldos/conexionBD/structGormModel"
)
type Importegananciasotroempleosiradig struct {
structGormModel.GormModel
Siradigid *int `json:"siradigid"`
Mes *time.Time `json:"mes"`
Import... |
// Copyright 2021 Google LLC. 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 applica... |
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT license.
package helpers
import (
// "fmt"
"bytes"
"crypto/rand"
"crypto/rsa"
"encoding/json"
"fmt"
"io"
"os"
"runtime"
"strings"
"github.com/Azure/aks-engine/pkg/i18n"
"golang.org/x/crypto/ssh"
)
// NormalizeAzureReg... |
package loaders
import (
"context"
"time"
"github.com/syncromatics/kafmesh/internal/graph/loaders/generated"
"github.com/syncromatics/kafmesh/internal/graph/model"
"github.com/syncromatics/kafmesh/internal/graph/resolvers"
"github.com/pkg/errors"
)
//go:generate mockgen -source=./services.go -destination=./se... |
package fabonacci
func Recursion(n int) (ret int) { //递归
if n == 0 || n == 1 {
ret = 1
} else {
ret = Recursion(n-1) + Recursion(n-2)
}
return
}
func NoRecusion(n int) int {
x, y := 1, 1
for i := 0; i < n; i++ {
x, y = y, x+y
}
return x
}
|
/*
Copyright 2019 Dmitry Kolesnikov, 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 law... |
package main
import (
"github.com/kiryalovik/gameoflife/cellular/toroid"
)
type Presenter interface {
Render(field toroid.Field) error
Close()
}
|
package main
import "github.com/jinzhu/gorm"
type UserDetailsRepository struct {
db *gorm.DB
}
func NewUserDetailsRepository(db *gorm.DB) *UserDetailsRepository {
return &UserDetailsRepository{db: db}
}
func (repo *UserDetailsRepository) Get(stravaUserId int) (*UserDetails, error) {
user := new(UserDetails)
res... |
/*
Given four integer arrays nums1, nums2, nums3, and nums4 all of length n, return the number of tuples (i, j, k, l) such that:
0 <= i, j, k, l < n
nums1[i] + nums2[j] + nums3[k] + nums4[l] == 0
Example 1:
Input: nums1 = [1,2], nums2 = [-2,-1], nums3 = [-1,2], nums4 = [0,2]
Output: 2
Explanation:
The two tuples ar... |
package client
import (
. "github.com/goodsign/gosmsc/contract"
service "github.com/goodsign/gosmsc/rpcservice"
"github.com/goodsign/goutils/jsonrpc"
"time"
)
const SmscRpcServiceName = "SMSService."
// EmptyStruct is used in funcs where logicaly no input parameters or return values (or both) are needed, but
// ... |
package joypad
import (
"fmt"
"github.com/vfreex/gones/pkg/emulator/memory"
)
const (
Button_A byte = 1 << iota
Button_B
Button_Select
Button_Start
Button_Up
Button_Down
Button_Left
Button_Right
)
const (
Joypad_1 = 0x4016
Joypad_2 = 0x4017
)
type Joypad struct {
Buttons byte
Shift byte
}
//func Ne... |
package api
import "net/http"
func editHandler(writer http.ResponseWriter, request *http.Request) {
title := request.URL.Path[len("/edit/"):]
page, err := loadPage(title)
if err != nil {
page = &Page{Title: title}
}
renderTemplate(writer, "edit", page)
}
|
package peer
import (
"fmt"
"net/http"
"github.com/gin-gonic/gin"
"github.com/naggie/dsnet"
)
var conf *dsnet.DsnetConfig
// Routes sets up endpoints for peers.
func Routes(router *gin.RouterGroup, dsConf *dsnet.DsnetConfig) {
conf = dsConf
router.POST("", handleNewPeer)
router.DELETE("/:hostname", handleRem... |
/*
Copyright 2020 The Kubernetes 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, ... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.