text stringlengths 11 4.05M |
|---|
package main
import (
"bufio"
"fmt"
"log"
"os"
"strconv"
"strings"
)
func main() {
input := parseLines("day6/input.txt")
demo := parseLines("day6/demo.txt")
fmt.Printf("Day 6 Part Demo: %d is the size of the largest area that isn't infinite\n", partOne(demo))
fmt.Printf("Day 6 Part 1: %d is the size of the... |
package main
import "math"
func main() {
}
func jump(nums []int) int {
min := func(a, b int) int {
if a < b {
return a
}
return b
}
dp := make([]int, len(nums))
for i := range dp {
dp[i] = math.MaxInt / 2
}
dp[0] = 0 // 以 i 为终点需要多少步
for i := 1; i < len(nums); i++ {
for j := 0; j < i; j++ {
... |
package flags_test
import "testing"
import "github.com/CrimeanBitches/go-flags"
func TestByteFlags(t *testing.T) {
v := make([]flags.Byte, 8)
for i := uint(0); i < 8; i++ {
v[i] = flags.Byte(1 << i)
}
flag := flags.Byte(0)
for i := 0; i < len(v); i++ {
flag = flag.Add(v[i])
}
if byte(flag) != 255 {
t.... |
package main
import (
"encoding/json"
"fmt"
"log"
"net/http"
"os"
"strings"
)
type Error struct {
Message string `json:"error"`
}
type IndexedWord struct {
Word string `json:"word"`
Index int `json:"index"`
}
type MessyText []IndexedWord
func route(w http.ResponseWriter, r *http.Request) {
fmt.Printl... |
package msgHandler
import (
"fmt"
tdmComm "github.com/HNB-ECO/HNB-Blockchain/HNB/consensus/algorand/common"
"github.com/HNB-ECO/HNB-Blockchain/HNB/consensus/consensusManager/comm/consensusType"
"github.com/HNB-ECO/HNB-Blockchain/HNB/ledger"
"github.com/HNB-ECO/HNB-Blockchain/HNB/sync"
psync "github.com/HNB-ECO/H... |
package filter
import v1 "k8s.io/api/core/v1"
// StatusMatch is used to filter pods by status
type StatusMatch struct {
State v1.PodPhase
}
|
package controlplane
import (
"context"
"net"
"testing"
"time"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
"golang.org/x/sync/errgroup"
"google.golang.org/grpc"
"google.golang.org/protobuf/proto"
"github.com/pomerium/pomerium/config"
"github.com/pomerium/pomerium/internal/at... |
/*
* @File: controllers.user.go
* @Description: Implements User API logic functions
* @Author: Nguyen Truong Duong (seedotech@gmail.com)
*/
package controllers
import (
"net/http"
"../common"
"../daos"
"../models"
"../utils"
"github.com/gin-gonic/gin"
log "github.com/sirupsen/logrus"
"gopk... |
package drawork
import "sync"
type Cube struct {
SideLength float64
PP [8]POINT3D
PT [8]POINT3D
Pp [8]POINT3D
Taking int
ShopTime int
HadDone int
}
var (
cubeOnce sync.Once
instance *[Cubenum]Cube = nil
)
func GetCube() *[Cubenum]Cube {
cubeOnce.Do(func() {
instance = &[... |
package peerstream_multiplex
import (
"testing"
test "gx/ipfs/QmY9JXR3FupnYAYJWK9aMr9bCpqWKcToQ1tz8DVGTrHpHw/go-stream-muxer/test"
)
func TestMultiplexTransport(t *testing.T) {
test.SubtestAll(t, DefaultTransport)
}
|
// Copyright 2016 The Gem Authors. All rights reserved.
// Use of this source code is governed by a MIT license
// that can be found in the LICENSE file.
package middleware
import (
"github.com/go-gem/gem"
)
var defaultSkipper = func(c *gem.Context) bool {
return false
}
// Skipper defines a function to skip midd... |
package pb
const ApiVersion = 1
|
package parcels
/*
import (
"context"
"fmt"
"io"
"sort"
document2 "spWebFront/FrontKeeper/server/app/domain/service/searcher/document"
"testing"
"github.com/stretchr/testify/assert"
)
func TestSearchRules(t *testing.T) {
type Test struct {
rule Rule
cases map[string][]string // Drug name -> list of iden... |
// Package random provides functions to generate random values for
// metheorological data
package random
import (
"fmt"
"github.com/LuighiV/payload-generator/generator/converter"
"math/rand"
"time"
)
// GenerateRandom returns a random value receiving the a base value and
// variation value which determines the r... |
package p
import (
"sync"
"github.com/petermattis/goid"
)
// GoID 获取当前 Goroutine 的 ID
func GoID() int {
return int(goid.Get())
}
var _globals struct {
ms map[int]rwmap
sync.RWMutex
}
// G 获取当前协程内的全局变量
// 参考自 http://php.net/manual/zh/reserved.variables.globals.php
func G() *rwmap {
_globals.Lock()
if _globa... |
package pulsar
import (
"context"
"errors"
"io/ioutil"
"github.com/apache/pulsar-client-go/pulsar"
. "github.com/onsi/ginkgo"
. "github.com/onsi/gomega"
"github.com/sirupsen/logrus"
"github.com/batchcorp/plumber-schemas/build/go/protos/args"
"github.com/batchcorp/plumber-schemas/build/go/protos/opts"
"gith... |
package nes
import (
"fmt"
pkgLogger "github.com/vfreex/gones/pkg/emulator/common/logger"
"github.com/vfreex/gones/pkg/emulator/cpu"
"github.com/vfreex/gones/pkg/emulator/joypad"
"github.com/vfreex/gones/pkg/emulator/memory"
"github.com/vfreex/gones/pkg/emulator/ppu"
"github.com/vfreex/gones/pkg/emulator/ram"
... |
// Package ds provides ...
package ds
import (
"testing"
)
func TestIsEmpty(t *testing.T) {
queue := new(LoopQueue)
if !queue.IsEmpty() {
t.Errorf("queue.IsEmpty() == %t, want %t", queue.IsEmpty(), true)
}
queue.Insert(1)
if queue.IsEmpty() {
t.Errorf("queue.IsEmpty() == %t, want %t", queue.IsEmpty(), fal... |
/*
Write a function that inverts the keys and values of a dictionary.
Examples
invert({ "z": "q", "w": "f" })
➞ { "q": "z", "f": "w" }
invert({ "a": 1, "b": 2, "c": 3 })
➞ { 1: "a", 2: "b", 3: "c" }
invert({ "zebra": "koala", "horse": "camel" })
➞ { "koala": "zebra", "camel": "horse" }
Notes
N/A
*/
package mai... |
package main
import (
"encoding/json"
"fmt"
"log"
"github.com/boltdb/bolt"
)
type PetStorage struct {
db *bolt.DB
bucket []byte
}
func NewPetStorage(db *bolt.DB, bucket string) *PetStorage {
petStorage := &PetStorage{
db: db,
bucket: []byte(bucket),
}
db.Update(func(tx *bolt.Tx) error {
tx.Cr... |
package main
import (
"fmt"
"os"
"strings"
"log"
_ "github.com/joho/godotenv/autoload"
"github.com/nlopes/slack"
)
type User struct {
Info slack.User
Rating int
}
type Token struct {
Token string `json:"token"`
}
type Message struct {
ChannelId string
Timestamp string
Payload string
Rating int... |
package c37_break_srp
import (
"math/big"
"testing"
"github.com/vodafon/cryptopals/set5/c36_srp"
)
func TestExploit(t *testing.T) {
email := []byte("email@test.com")
password := []byte("paSSw0rD")
keys := []*big.Int{big.NewInt(0), c36_srp.N, new(big.Int).Mul(c36_srp.N, big.NewInt(2))}
for i, pk := range keys ... |
package main
import (
"bytes"
"errors"
"io"
"strconv"
"time"
"github.com/go-logfmt/logfmt"
)
type SchedulerPhase int8
const (
SPUninitialised SchedulerPhase = iota
SPStartUp
SPMaintaining
SPUnknown
)
func (s SchedulerPhase) String() string {
switch s {
case SPUninitialised:
return "uninitialised"
ca... |
package models
type Object struct {
Id int `json:"id"`
Num int `json:"num"`
Text string `json:"text"`
} |
// Содержит стурктуру, представляющую собой инвертированный индекс и методы этой структуры
// для создания индекса и поиска по этому индексу
package index
import (
"fmt"
"math/rand"
"sort"
"strings"
"unicode"
"engine/pkg/index/btree"
)
type Document struct {
ID uint64
Title string
URL string
}
type In... |
package bean
import (
// "log"
"time"
"github.com/astaxie/beego/orm"
)
type WinReward struct {
UID uint32 `orm:"column(uid);pk"`
Win int32 `orm:"column(win)"`
UpdateTime int64 `orm:"column(update_time)"`
}
func (w *WinReward) Update() {
_, err := defaultOrm.Update(w)
checkError("更新玩家胜场奖励数据,错... |
package main
/**
爬楼梯
假设你正在爬楼梯。需要 n 阶你才能到达楼顶。
每次你可以爬 1 或 2 个台阶。你有多少种不同的方法可以爬到楼顶呢?
注意:给定 n 是一个正整数。
示例1:
```
输入: 2
输出: 2
解释: 有两种方法可以爬到楼顶。
1. 1 阶 + 1 阶
2. 2 阶
```
示例2:
```
输入: 3
输出: 3
解释: 有三种方法可以爬到楼顶。
1. 1 阶 + 1 阶 + 1 阶
2. 1 阶 + 2 阶
3. 2 阶 + 1 阶
```
*/
func ClimbStairs(n int) int {
p, q := 1, 1
for i := 2; i <... |
// Copyright 2021 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
// https://leetcode.com/problems/power-of-two/
// Given an integer n, return true if it is a power of two. Otherwise, return false.
//
// An integer n is a power of two, if there exists an integer x such that n == 2x.
func isPowerOfTwo(n int) bool {
if n == 0 {
return false
}
for ; n != 1; n = n /... |
package middlewares
import (
"context"
"net/http"
)
func WithContextValues(keyValues map[interface{}]interface{}) func(next http.Handler) http.Handler {
return func(next http.Handler) http.Handler {
return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
ctx := r.Context()
for key, value := ... |
package config
import (
"sync"
)
//参数配置
type Config struct {
Bind string `bind`
Network string `network`
Boss int `boss`
Work int `work`
MaxProcs int `maxProcs`
}
//全局配置
var (
GlobalConfig Config
W sync.WaitGroup
)
const (
DefaultBind = "127.0.0.1:8080"
DefaultNetwork =... |
package fs
import "fmt"
// File ...
type File struct {
Name string
}
// Print ...
func (f *File) Print(indent string) {
fmt.Printf("%s%s_name\n", indent, f.Name)
}
// Clone ...
func (f *File) Clone() INode {
return &File{Name: fmt.Sprintf("%s_clone", f.Name)}
}
|
/*
Copyright 2021 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 sync
import "sync"
// ShutdownGuard facilitates coordinating the shutdown of multiple components.
type ShutdownGuard struct {
sync.Mutex
sync.WaitGroup
ShuttingDown chan struct{}
}
// NewShutdownGuard creates a new ShutdownGuard.
func NewShutdownGuard() *ShutdownGuard {
return &ShutdownGuard{
ShuttingD... |
package main
import "fmt"
func main() {
fmt.Println(countVowelStrings(1))
fmt.Println(countVowelStrings(2))
fmt.Println(countVowelStrings(3))
fmt.Println(countVowelStrings(4))
//fmt.Println(countVowelStrings(33))
}
func countVowelStrings(n int) int {
dp := make([][]int, n)
for i := 0; i < n; i++ {
dp[i] =... |
package main
import (
"bytes"
"io/ioutil"
"log"
"net/http"
"github.com/prashant-agarwala/apiauth"
)
func postCall() error {
posturl := "http://localhost:8070/api/v1/lists/create.json"
var jsonStr = []byte(`{"currency":"INR","amount":"1"}`)
req, err := http.NewRequest("POST", posturl, bytes.NewBuffer(jsonStr)... |
package core
import (
"fmt"
"gin-vue-admin/global"
"github.com/fsnotify/fsnotify"
"github.com/spf13/viper"
"os"
"strings"
)
const defaultConfigFile = "config.dev.yaml"
func init() {
v := viper.New()
var configFile = defaultConfigFile
mode := os.Args[1]
if len(mode) > 0 {
configFile = strings.Replace(defa... |
package processor
import (
"config"
"httprouter"
"logger"
"net/http"
"processor/classification"
"processor/errandsclassification"
"processor/feedback"
"processor/ordermanager"
"processor/picture"
"processor/rider"
"processor/usermanager"
)
func Init() {
router := httprouter.New()
usermanager.Init(router)... |
// Package pca9955b allows interfacing with the pca9955b 16-channel, 8-bit PWM Controller through I2C protocol.
package pca9955b
import (
"sync"
"github.com/zlowred/embd"
)
type AutoIncrementMode byte
type Register byte
type PinMode byte
const (
AutoIncrement_00_43 AutoIncrementMode = 0
AutoIncrement_08_17 = 1
... |
package invoice
import (
"fmt"
"github.com/imrenagi/go-payment"
)
type InvoiceError struct {
Code int
}
const (
InvoiceErrorPaymentMethodNotSet = iota
InvoiceErrorBillingAddressNotSet
InvoiceErrorNoMoreItemExist
InvoiceErrorInvalidStateTransition
InvoiceErrorNoPaymentSet
InvoiceErrorInvalidDiscountValue
)
... |
package allergies
import "sort"
var AllergyMap = map[string]uint{"eggs": 1,
"peanuts": 2,
"shellfish": 4,
"strawberries": 8,
"tomatoes": 16,
"chocolate": 32,
"pollen": 64,
"cats": 128}
func Allergies(score uint) []string {
var allergies []string
for allergen, _ := range AllergyM... |
package models
import (
"encoding/json"
"io/ioutil"
"testing"
)
func BenchmarkCreatePostListing(b *testing.B) {
data, _ := ioutil.ReadFile("./tests/postlisting.json")
postListingExampleJson := string(data)
for i := 0; i < b.N; i++ {
sub := PostListing{}
json.Unmarshal([]byte(postListingExampleJson), &sub)
... |
package camt
import (
"encoding/xml"
"github.com/thought-machine/finance-messaging/iso20022"
)
type Document03300104 struct {
XMLName xml.Name `xml:"urn:iso:std:iso:20022:tech:xsd:camt.033.001.04 Document"`
Message *RequestForDuplicateV04 `xml:"ReqForDplct"`
}
func (d *Document03300104) AddMessag... |
package main
import (
"database/sql"
"encoding/json"
"fmt"
"io"
"net/http"
"os"
"strconv"
"gopkg.in/natefinch/lumberjack.v2"
"github.com/gorilla/mux"
"github.com/sirupsen/logrus"
common "github.com/dheerajgopi/todo-api/common"
"github.com/dheerajgopi/todo-api/config"
_taskHttpDelivery "github.com/dheer... |
package camt
import (
"encoding/xml"
"github.com/thought-machine/finance-messaging/iso20022"
)
type Document04300103 struct {
XMLName xml.Name `xml:"urn:iso:std:iso:20022:tech:xsd:camt.043.001.03 Document"`
Message *FundDetailedConfirmedCashForecastReportV03 `xml:"FndDtldConfdC... |
package sphinx
import (
"bytes"
"testing"
"github.com/btcsuite/btcd/btcec/v2"
)
var (
s *OnionPacket
p *ProcessedPacket
)
func BenchmarkPathPacketConstruction(b *testing.B) {
b.StopTimer()
var (
err error
sphinxPacket *OnionPacket
route PaymentPath
)
for i := 0; i < 20; i++ {
priv... |
package adapters
import (
"errors"
"os/exec"
"strings"
)
// GitRepository is an abstraction for git repositories
type GitRepository struct{}
// GetCurrentBranchName gets the current branch name of the repository.
func (repo GitRepository) GetCurrentBranchName() string {
output, _ := exec.Command("git", "rev-pars... |
package bfloat
import (
"fmt"
"math/big"
)
const (
// precision specifies the number of bits in the mantissa (including the
// implicit lead bit).
precision = 8
// exponent bias.
bias = 127
)
// Float is a floating-point number in bfloat16 floating-point format.
type Float struct {
// Sign, exponent and frac... |
package utils
import (
"fmt"
"runtime"
)
// ErrSliceSortAlphabetical is a helper type that can be used with sort.Sort to sort a slice of errors in alphabetical
// order. Usage is simple just do sort.Sort(ErrSliceSortAlphabetical([]error{})).
type ErrSliceSortAlphabetical []error
func (s ErrSliceSortAlphabetical) L... |
package main
import (
"database/sql" //这包一定要引用
//"fmt" //这个前面一章讲过
_"mysql"
// "strconv" //这个是为了把int转换为string
"log"
"time"
"fmt"
"common"
)
type DbMysql struct {
db *sql.DB
url string
state bool //状态 true:正常,false:关闭
opFlag chan uint8 //退出标记,0:正常,1:退出, 2:PING
querychann... |
package staticutil
var types = map[string]string{
".aac": "audio/aac",
".abw": "application/x-abiword",
".arc": "application/x-freearc",
".avi": "video/x-msvideo",
".azw": "application/vnd.amazon.ebook",
".bin": "application/octet-stream",
".bmp": "image/bmp",
".bz": "application/x-bzi... |
package variable
import (
"testing"
"github.com/stretchr/testify/assert"
)
func TestReplaceVariables(t *testing.T) {
assert := assert.New(t)
r1 := ReplaceVariables("{{ $env.XXX}} {{$vars.BBB}} {{$xxx.CCC}}")
assert.Equal(r1, "{{ __phistage_env__.XXX}} {{__phistage_vars__.BBB}} {{$xxx.CCC}}")
}
func TestBu... |
package clickhouse_20200328
import (
"database/sql"
"fmt"
"github.com/ClickHouse/clickhouse-go/lib/column"
"github.com/elastic/beats/libbeat/logp"
"github.com/elastic/beats/libbeat/outputs"
"github.com/elastic/beats/libbeat/outputs/codec"
"github.com/elastic/beats/libbeat/outputs/outil"
"github.com/elastic/bea... |
package main
import "fmt"
func main() {
str := "hello world"
slice := str[1:9]
fmt.Printf("slice=%v;slice地址=%p\n", slice, &slice)
//修改字符串
changeSlice := []byte(str)
fmt.Println(changeSlice)
changeSlice[0] = 'z'
str = string(changeSlice)
fmt.Printf("str=%v;str地址=%p\n", str, &str)
//修改成中文字符串
changeSlice1 :=... |
package mainWindow
import (
"github.com/myProj/scaner/new/include/AppGui/mainMenu"
"github.com/myProj/scaner/new/include/appStruct"
"github.com/myProj/scaner/new/include/config"
"github.com/myProj/scaner/new/include/logggerScan"
"github.com/therecipe/qt/gui"
"github.com/therecipe/qt/widgets"
"os"
)
//названи... |
package SecretsManager
import (
"context"
"github.com/aws/aws-sdk-go-v2/service/secretsmanager"
"testing"
)
type TestType struct {
Foo string `secret:"/acceptance/PrivateJWTRSAKey"`
Bar string `secret:"bla,required"`
}
type MockSecretsManager struct {
MockGetSecretValueResponse func() (*secretsmanager.GetSecre... |
package main
import (
"bufio"
"fmt"
"math/big"
"os"
)
func main() {
var reader = bufio.NewReader(os.Stdin)
var n big.Int
var m big.Int
fmt.Fscan(reader, &n, &m)
var a big.Int
var b big.Int
fmt.Fscan(reader, &a, &b)
ret := new(big.Int)
ret = ret.Mul(&a, &b)
fmt.Println(ret)
}
|
package pipe
import (
"fmt"
"os/exec"
"strings"
"testing"
)
func TestPipes_WriteAndRead(t *testing.T) {
pipes := []Pipe{}
for i := 0; i < 8; i++ {
pipes = append(pipes, NewExecPipe(exec.Command("./a.out")))
}
p := NewPipes(pipes)
err := p.Start()
if err != nil {
t.Error(err)
}
defer p.Stop()
for i ... |
package main
import (
"fmt"
"net"
)
func main() {
fmt.Println("UDP Server")
//Open socket
udpAddr, err := net.ResolveUDPAddr("udp", "0.0.0.0:8805")
if err != nil {
fmt.Println("Wrong Address")
return
}
fmt.Println("Resolve Success ", udpAddr)
//Listen for client connection
udpConn, err := net.ListenUD... |
package solutions
import (
"testing"
)
func TestRemoveDuplicates(t *testing.T) {
t.Run("Test [1,1,2]", func(t *testing.T) {
input := []int{1, 1, 2}
want := 2
wantInPlace := []int{1, 2}
r := removeDuplicates(input)
if r != want {
t.Errorf("got %v, want %v", r, want)
}
for i := 0; i < want; i++ {
... |
package main
import "fmt"
func main() {
printPattern(5, 3)
}
func printPattern(n int, m int) {
for i := 0 ; i < n ; i++ {
s := ""
for j := 0 ; j < m ; j++ {
s += "*"
}
fmt.Println(s)
}
} |
package commands
import (
"crypto/ecdsa"
"crypto/ed25519"
"crypto/elliptic"
"crypto/rsa"
"crypto/x509"
"crypto/x509/pkix"
"encoding/pem"
"fmt"
"math/big"
"net"
"os"
"path/filepath"
"strings"
"time"
"github.com/spf13/cobra"
"github.com/authelia/authelia/v4/internal/utils"
)
func cmdFlagsCryptoCertifi... |
package common
import (
"crypto/tls"
"crypto/x509"
"image"
"io/ioutil"
"net"
"net/http"
c_url "net/url"
"regexp"
"strconv"
"strings"
"time"
)
type myRegexp struct {
*regexp.Regexp
}
/**
* 写入cookie
*/
func InsertCookie(w http.ResponseWriter, doname string, key string, val string, exptime int) {
name :=... |
package omise
// ChargeStatus represents an enumeration of possible status of a Charge object, which
// can be one of the following list of constants:
type ChargeStatus string
const (
ChargeFailed ChargeStatus = "failed"
ChargePending ChargeStatus = "pending"
ChargeSuccessful ChargeStatus = "successful"
Ch... |
package main
import "testing"
func TestUnique(t *testing.T) {
var tests = []struct {
input string
unique bool
}{
{"abcde", true},
{"test", false},
{"ぁあぃぎじ", true},
{"せぬがだぬ", false},
{"The quick brown fox jumps over the lazy dog", false},
{"", true},
}
for _, c := range tests {
got := unique(c.... |
// Copyright 2020 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... |
/*
# -*- coding: utf-8 -*-
# @Author : joker
# @Time : 2020-08-10 09:47
# @File : lt_94_Binary_Tree_Inorder_Traversal.go
# @Description :
# @Attention :
*/
package stack
// 中序遍历
func inorderTraversal(root *TreeNode) []int {
if nil == root {
return nil
}
stack := make([]*TreeNode, 0)
result := make([]int, 0)
... |
package global
const (
dburl = "mongodb://localhost:27017/?readPreference=primary&appname=MongoDB%20Compass&directConnection=true&ssl=false"
dbelasticurl = "http://localhost:9200"
)
|
// Copyright 2020 beego-dev
//
// 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 writin... |
package main
import (
coreserver "github.com/water25234/golang-line-chatbot/app/server"
)
func main() {
coreserver.StartServer()
}
|
package fliptest_test
import (
"encoding/json"
"fmt"
"github.com/GESkunkworks/fliptest"
"github.com/aws/aws-sdk-go/aws"
"github.com/aws/aws-sdk-go/aws/session"
)
// resume-stack-with-custom-tests
//
// This example resumes an existing stack and changes
// the test URLs that it's calling on the lambda.
func Exam... |
package cfa
import (
"bytes"
"encoding/json"
"io/ioutil"
"log"
"net"
"net/http"
)
// AccessRule represents a Cloudflare access rule.
type AccessRule struct {
ID string `json:"id"`
Notes string `json:"notes"`
Mode string `json:"mode"`
Configuration Ac... |
// 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 (
"encoding/json"
"fmt"
"io/ioutil"
"net/http"
"os"
"time"
"github.com/apex/log"
)
var wcd WorldcupData
var allmatches [64]*Match
var timeStamp = time.Now().AddDate(0, 0, -1)
var threshold float64 = 5
func fetchData() (WorldcupData, Results) {
response, err := http.Get(dataWCD)
if err !... |
package handlers
import (
"github.com/gorilla/mux"
)
// Router register necessary routes and returns an instance of a router.
func Router() *mux.Router {
r := mux.NewRouter()
r.HandleFunc("/", query).Methods("GET")
r.HandleFunc("/healthz", healthz)
r.HandleFunc("/readyz", readyz)
return r
}
|
package misc
import (
"bytes"
"encoding/json"
"fmt"
"io/ioutil"
"os"
"os/exec"
"path/filepath"
bprel "github.com/bosh-dep-forks/bosh-provisioner/release"
bpreljob "github.com/bosh-dep-forks/bosh-provisioner/release/job"
semver "github.com/cppforlife/go-semi-semantic/version"
)
type ReleaseIndex struct {
D... |
/**
* THIS IS A SAMPLE FILE WHICH WORKS AND IS FOR TESTING PURPOSES.
* - https://github.com/kelseyhightower/grpc-hello-service
* - https://davidsbond.github.io/2019/06/14/creating-grpc-interceptors-in-go.html
*
*/
package internal // github.com/growlog/things-server/internal
import (
"context"
"log"
// "ne... |
// Copyright 2023 The etcd 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 t... |
/*
Program showing off the built in sort library
*/
package main
import (
"fmt"
"sort"
)
func main() {
num := []int{10,2040, 120, 10000, 56}
fmt.Println(num)
if sort.IntsAreSorted(num)==false{
sort.Ints(num)
}
fmt.Println(num)
fmt.Println(sort.SearchInts(num,2040))
strings := []string{"Red","Blue","Yello... |
package sample
import (
"github.com/stretchr/testify/assert"
"testing"
)
func TestSampleFunc( test *testing.T ) {
assert.True( test, true )
}
// func TestSampleFunc( test *testing.T ) {
// var assert = assert.New( test )
//
// assert.True( true )
// }
|
package check
import (
"encoding/json"
"errors"
"fmt"
"io/ioutil"
"net/http"
"os"
"strconv"
"github.com/matscus/Hamster/Package/Clients/client"
"github.com/matscus/Hamster/Package/Services/service"
)
//InitGetResponseAllData - function to obtain information about all services from the database. all services... |
package main
import "html/template"
var templates = map[string]*template.Template{
"error": template.Must(template.ParseFiles("static/error.html")),
"login": template.Must(template.ParseFiles("static/login.html")),
"setup": template.Must(template.ParseFiles("static/setup.html")),
"preview": template.Mus... |
package main
//字典 wordList 中从单词 beginWord 和 endWord 的 转换序列 是一个按下述规格形成的序列:
//
//序列中第一个单词是 beginWord 。
//序列中最后一个单词是 endWord 。
//每次转换只能改变一个字母。
//转换过程中的中间单词必须是字典 wordList 中的单词。
//给你两个单词 beginWord 和 endWord 和一个字典 wordList ,找到从 beginWord 到 endWord 的 最短转换序列 中的 单词数目 。如果不存在这样的转换序列,返回 0。
//
//
//示例 1:
//
//输入:beginWord = "hit",... |
package ucs
import (
"bufio"
"context"
"fmt"
"io"
"io/ioutil"
"log"
"net"
"strconv"
"sync"
"time"
"github.com/msiebuhr/ucs/cache"
"github.com/prometheus/client_golang/prometheus"
)
var (
ops = prometheus.NewCounterVec(prometheus.CounterOpts{
Name: "ucs_server_ops",
Help: "Operations performed on th... |
package main
type fc func(en bool, args ...interface{}) []interface{}
// Functions ...
var Functions = map[string]fc{
"EQ_R": EQR,
"GT_R": GTR,
"LT_R": LTR,
"GE_R": GER,
"LE_R": LER,
// Mathematics
"ADD_R": ADDR,
}
|
package main
import (
handle "blog/common"
"github.com/gin-gonic/gin"
"log"
"net/http"
)
func init() {
log.SetPrefix("TRACE: ")
log.SetFlags(log.Ldate | log.Ltime | log.Llongfile)
}
func pingFunc(context *gin.Context) error {
context.JSONP(http.StatusOK, gin.H{
"message": "ok",
})
log.Println("服务端进程心跳检测")... |
package httpparser
import (
"bytes"
"fmt"
"github.com/bonjourmalware/melody/internal/config"
"io"
"io/ioutil"
"net/http"
"net/http/httputil"
"strconv"
"github.com/c2h5oh/datasize"
)
// GetBodyPayload extract the body of an http.Request without striping it
func GetBodyPayload(r *http.Request) ([]byte, error)... |
//
// cache.go
// Copyright (C) 2019 Grigorii Sokolik <g.sokol99@g-sokol.info>
//
// Distributed under terms of the MIT license.
//
package config
import (
"crypto/tls"
"encoding/json"
"fmt"
)
type cacheType string
const (
CacheTypeRedis cacheType = "redis"
CacheTypeInMemory cacheType = "inMemory"
)
var Un... |
package brain
import (
"log"
"github.com/xr-hui/raspi-center/brain/tts"
)
var brain Brain
// Brain
type Brain struct {
ttsConverter tts.TtsConverter
}
func HandleForever() {
log.Println("Raspi center stared! I'am serving for you.")
go brain.ttsConverter.Say("儿童节快乐,honey")
// Handle forever
for {
}
}
// I... |
package main
import "fmt"
func main() {
// var s string
// s = `Hello World!`
s := `Hello World!`
s1 := ` 🏆`
fmt.Println(s + s1)
b := s[0]
b1 := s[4]
fmt.Println(b, b1, string(b), string(b1))
a := s[0:5]
a1 := s[7:10]
a2 := s[:5]
a3 := s[7:]
fmt.Println(a, a1, a2, a3)
fmt.Println(len(a))
//Rune
v... |
/*
Given an "out" string even length, such as "<<>>", and a word, return a new string where the word is in the middle of the out string, e.g. "<<word>>". */
package main
import (
"fmt"
)
func make_out_word(out string, word string) string {
if len(out) % 2 == 1 {
return out
}
middle := len(out) / 2
return out[:... |
package crypto
import (
"testing"
"fmt"
)
func TestGeneratePwd(t *testing.T) {
salt := "123456"
pwd := GeneratePwd("抖音", salt, 12)
fmt.Println(pwd)
}
|
package models
import "gorm.io/gorm"
type Mentor struct {
gorm.Model
Occupation string
Institution string
Photo string
UserID uint
} |
package controller
import (
"encoding/json"
"github.com/GoAdminGroup/go-admin/context"
"github.com/GoAdminGroup/go-admin/modules/config"
"github.com/GoAdminGroup/go-admin/plugins/admin/models"
"github.com/GoAdminGroup/go-admin/plugins/admin/modules/constant"
"github.com/GoAdminGroup/go-admin/plugins/admin/modul... |
// Copyright 2023 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... |
package eventbus
import (
"errors"
"fmt"
"log"
"sync"
)
type Event interface {
Type() EventType
Topic() Topic
SetTopic(t Topic)
}
type Topic string
type EventType string
func (e EventType) String() string {
return string(e)
}
type EventBus struct {
lock sync.RWMutex
topics map[Topic]*Subscriptions
}
... |
package caaa
import (
"encoding/xml"
"github.com/thought-machine/finance-messaging/iso20022"
)
type Document01200103 struct {
XMLName xml.Name `xml:"urn:iso:std:iso:20022:tech:xsd:caaa.012.001.03 Document"`
Message *AcceptorBatchTransferResponseV03 `xml:"AccptrBtchTrfRspn"`
}
func (d *D... |
// textwork.go
package textwork
import (
"fmt"
"io/ioutil"
"os"
"strconv"
"strings"
)
type TWORK struct {
TEXT string
si, ei, ci int
}
func (tw *TWORK) SetText(text string) {
tw.TEXT = text
tw.ci = 0
tw.si = 0
tw.ei = 0
}
// OpenFile load text from file
func (tw *TWORK) Open... |
package common
import "github.com/pkg/errors"
var (
NilPointerError = errors.New("Nil value")
NoSuchElementError = errors.New("No Such Element")
IndexOutOfRangeError=errors.New("Index out of range" )
EmptyListError=errors.New("Empty List error")
)
|
package test
import (
"testing"
)
func TestVaultEC2AuthWithUbuntuAmi(t *testing.T) {
t.Parallel()
runVaultEC2AuthTest(t, "ubuntu16-ami")
}
func TestVaultEC2AuthWithAmazonLinuxAmi(t *testing.T) {
t.Parallel()
runVaultEC2AuthTest(t, "amazon-linux-ami")
}
func TestVaultIAMAuthWithUbuntuAmi(t *testing.T) {
t.Para... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.