text stringlengths 11 4.05M |
|---|
package pulsar
import (
"fmt"
"time"
"github.com/batchcorp/plumber-schemas/build/go/protos/opts"
"github.com/pkg/errors"
"github.com/batchcorp/plumber-schemas/build/go/protos/records"
"github.com/batchcorp/plumber/printer"
)
// DisplayMessage will parse a Read record and print (pretty) output to STDOUT
func (... |
package server
import (
"net/http"
"github.com/r3labs/sse"
"github.com/gorilla/mux"
)
// Server represents a HTTP(S) proxy
type Server struct {
router *mux.Router
http *http.Server
cache *Cache
events *sse.Server
}
// NewServer returns a new HTTP(S) proxy instance
func NewServer(addr string, cachePath st... |
//go:generate reform
package front
//reform:cc_special
type Special struct {
ID uint `reform:"special_id,pk"`
Name string `reform:"special_name"`
Pos int64 `reform:"pos"`
}
//reform:cc_product_special
//type ProductSpecial struct {
// ID uint `reform:"id,pk"`
// SpecialID uint `reform:"special_id"`
//... |
/*
* Copyright 2018- The Pixie 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 ag... |
package back_track
import (
"fmt"
"testing"
)
func TestGenerateBrackets(t *testing.T) {
// 3对括号合法组合
// (,(,(,),),)
// (,(,),(,),)
// (,(,),),(,)
// (,),(,(,),)
// (,),(,),(,)
for _, v := range GenerateBrackets(3) {
fmt.Println(v)
}
}
|
package main
import (
"io"
"net/http"
)
// DogHandler is a Handler
type DogHandler int
func (d DogHandler) ServeHTTP(res http.ResponseWriter, req *http.Request) {
io.WriteString(res, "Snopp Doggy Dogg")
}
// --------
// CatHandler is a Handler
type CatHandler int
func (c CatHandler) ServeHTTP(res http.Response... |
package mysqldb
import (
"context"
"fmt"
"time"
)
// Client 是客户端信息
type Client struct {
ClientID string `gorm:"primary_key"` // client 表主键
SecretKey string `gorm:"column:secret_key"` // 客户端密钥
Name string `gorm:"column:name"` // 客户端名称
Zone string `gorm:"... |
package main
import (
"os"
"runtime"
"strings"
"syscall"
"strconv"
"time"
"golang.org/x/net/context"
"bazil.org/fuse"
"bazil.org/fuse/fs"
)
const (
dirCacheTime = 10 * time.Second
statCacheTime = 1 * time.Second
attrValidTime = 1 * time.Minute
entryValidTime = 1 * time.Minute
)
type WebdavFS struc... |
package api
import (
"context"
"strings"
"github.com/inconshreveable/log15"
"github.com/opentracing/opentracing-go/log"
"github.com/pkg/errors"
"github.com/sourcegraph/sourcegraph/enterprise/internal/codeintel/gitserver"
store "github.com/sourcegraph/sourcegraph/enterprise/internal/codeintel/stores/dbstore"
... |
package texthash
import (
"net/http"
"github.com/gin-gonic/gin"
"github.com/ibraimgm/jolly-crane/rest"
)
var service = NewService(NewInMemRepository())
type controller struct{}
func (c *controller) SetupRoutes(router gin.IRouter) {
router.POST("/hash", func(c *gin.Context) {
input := &TextHash{}
var err er... |
package config
type StapelImageInterface interface {
ImageInterface
ImageBaseConfig() *StapelImageBase
IsArtifact() bool
imports() []*Import
}
|
package migrator
import (
"fmt"
"time"
"github.com/aws/aws-sdk-go/aws/awserr"
"github.com/aws/aws-sdk-go/service/kinesis"
"github.com/aws/aws-sdk-go/service/swf"
. "github.com/sclasen/swfsm/log"
. "github.com/sclasen/swfsm/sugar"
)
// TypesMigrator is composed of a DomainMigrator, a WorkflowTypeMigrator and a... |
/*
* @lc app=leetcode.cn id=445 lang=golang
*
* [445] 两数相加 II
*/
// @lc code=start
/**
* Definition for singly-linked list.
* type ListNode struct {
* Val int
* Next *ListNode
* }
*/
// package leetcode
//
//
// type ListNode struct{
// Val int
// Next *ListNode
// }
func addTwoNumbers_(l1 *ListN... |
package main
type ConcurrencySafeMap struct {
m map[string][]byte
chV chan map[string][]byte
// chGet chan struct{}
// chAdd chan struct{}
}
func NewConcurrencySafeMap() *ConcurrencySafeMap {
cm := &ConcurrencySafeMap{
m: make(map[string][]byte),
chV: make(chan map[string][]byte),
// chGet: make(chan s... |
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT license.
package i18n
import (
"fmt"
"os"
"strings"
"path"
"github.com/leonelquinteros/gotext"
"github.com/pkg/errors"
)
func loadSystemLanguage() string {
language := os.Getenv("LANG")
if language == "" {
return defau... |
/*
* Copyright © 2018-2022 Software AG, Darmstadt, Germany and/or its licensors
*
* SPDX-License-Identifier: Apache-2.0
*
* 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://... |
package sandbox
import (
"unsafe"
"golang.org/x/sys/unix"
)
// set time limit in seconds for the process,generate SIGXCPU.
func setTimelimit(pid int, timeLimit int64) error {
var rlimit unix.Rlimit
rlimit.Cur = uint64(timeLimit)
rlimit.Max = uint64(timeLimit)
return prLimit(pid, unix.RLIMIT_CPU, &rlimit)
}
//... |
package csvreader
import (
"bytes"
)
var BOM_UTF8 = []byte{239, 187, 191}
func bomCheck(data []byte) []byte {
if bytes.Equal(data[:3], BOM_UTF8) {
return data[3:]
}
return data
}
|
package naive
import "testing"
type doc struct {
words []string
class int
}
type check struct {
words []string
classes []int
tied bool
}
type test struct {
docs []doc
checks []check
}
var tests = []test{
{
docs: []doc{
{
words: []string{"alpha", "beta"},
class: 0,
}, {
words: []s... |
package main
/**
拥有最多糖果的孩子
给你一个数组 `candies` 和一个整数 `extraCandies` ,其中 `candies[i]` 代表第 `i` 个孩子拥有的糖果数目。
对每一个孩子,检查是否存在一种方案,将额外的 `extraCandies` 个糖果分配给孩子们之后,此孩子有 最多 的糖果。注意,允许有多个孩子同时拥有 最多 的糖果数目。
示例1:
```
输入:candies = [2,3,5,1,3], extraCandies = 3
输出:[true,true,true,false,true]
解释:
孩子 1 有 2 个糖果,如果他得到所有额外的糖果(3个),那么他总共有 5 个... |
package main
import (
"fmt"
"os"
"os/signal"
"syscall"
"github.com/Bumbodosan/Gummi-Flying-Machine/bot"
"github.com/joho/godotenv"
)
func main() {
b := &bot.Bot{}
godotenv.Load()
if os.Getenv("TOKEN") == "" {
fmt.Println("Missing token.")
os.Exit(-1)
}
b.Token = os.Getenv("TOKEN")
b.Prefix = os.Ge... |
package gsysint
import "testing"
func TestMutex(t *testing.T) {
l := &Mutex{}
Lock(l)
Unlock(l)
}
func BenchmarkMutexUncontended(b *testing.B) {
l := &Mutex{}
for i := 0; i < b.N; i ++ {
Lock(l)
Unlock(l)
}
} |
/*
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, so... |
package util
import (
"fmt"
packetconfigv1 "github.com/packethost/cluster-api-provider-packet/pkg/apis/packetprovider/v1alpha1"
"k8s.io/apimachinery/pkg/runtime"
"k8s.io/apimachinery/pkg/util/json"
clusterv1 "sigs.k8s.io/cluster-api/pkg/apis/cluster/v1alpha1"
"sigs.k8s.io/yaml"
)
const (
machineUIDTag = "clus... |
package editor
import (
"github.com/gdamore/tcell"
"github.com/rivo/tview"
"strconv"
)
type GotoLine struct {
*tview.Box
*Editor
input string
res int
}
// NewView returns a new view view primitive.
func (e *Editor) NewGotoLine() *GotoLine {
return &GotoLine{
Box: tview.NewBox().SetBorder(false),
Edi... |
package disk
import (
"encoding/binary"
"math"
"os"
"strings"
)
const (
SbSig = "NEWFATFS"
BlockSize = 4096
SbSigSize = 8
SbBlockCtOffset = 0x08
SbBlockCtSize = 2
SbRootDirIndOffset = 0x0A
SbRootDirIndSize = 2
SbDataStartIndOffset... |
package inmemory_test
import (
"github.com/Tinee/go-graphql-chat/inmemory"
)
type Client struct {
*inmemory.Client
}
func NewClient() *Client {
inner := inmemory.NewClient()
return &Client{inner}
}
func (c *Client) Reset() {
c.Client = inmemory.NewClient()
}
func (c *Client) FillWithMockData() {
c.Client.Fil... |
package cooker
import (
"context"
"fmt"
"sync"
"time"
"github.com/ProfessorMc/Recipe/spoilers/appliance"
"github.com/ProfessorMc/Recipe/spoilers/dish"
)
type SuperHeatOMatic struct {
hasPower bool
isOn bool
currentTemp float32
currentDish chan *dish.Dish
completedDish chan *dish.Dish
ct... |
package externalservices
import (
"encoding/xml"
"errors"
"fmt"
"hash/fnv"
"io/ioutil"
"net/http"
"poliskarta/api/structs"
)
func CallPoliceRSSGetAll(area structs.Area, numEvents int) (structs.PoliceEvents, error) {
httpResponse, httpErr := http.Get(area.RssURL)
//If we get http-error when calling the polic... |
package swan
import (
"errors"
"github.com/dimuls/swan/classifier"
"github.com/dimuls/swan/postgres"
"github.com/dimuls/swan/web"
)
type Service struct {
webServer *web.Server
}
func NewService(
postgresStorageURI string,
classifierAPIURI string,
webServerBindAddr string,
webServerDebug bool,
) (*Service, ... |
package testutil
import (
"github.com/nsqio/go-nsq"
"time"
)
// NSQTestDelegate is a struct used in unit tests to capture
// NSQ messages and actions. The interface we're mocking is
// the MessageDelegate interface defined here:
// https://github.com/nsqio/go-nsq/blob/master/delegates.go#L35
type NSQTestDelegate st... |
package cloud
import (
"context"
"net/http"
"strings"
"github.com/devspace-cloud/devspace/pkg/devspace/cloud/client"
"github.com/devspace-cloud/devspace/pkg/util/log"
"github.com/devspace-cloud/devspace/pkg/util/survey"
"github.com/pkg/errors"
)
// LoginEndpoint is the cloud endpoint that will log you in
cons... |
// Package sms provides an XMPP component (XEP-0114) which acts as a
// gateway or proxy between XMPP and SMS. It allows you to send and
// receive SMS messages as if they were XMPP messages. This lets you
// interact with the SMS network using your favorite XMPP client.
//
// Many users will be satisfied to run the ... |
package decoder
import (
"encoding/json"
"errors"
"time"
"github.com/Tanibox/tania-core/src/assets/domain"
"github.com/mitchellh/mapstructure"
)
type MaterialEventWrapper EventWrapper
func (w *MaterialEventWrapper) UnmarshalJSON(b []byte) error {
wrapper := EventWrapper{}
err := json.Unmarshal(b, &wrapper)
... |
package main
import "github.com/TomWeek/hellogo/service"
func main() {
service.PrintHello()
}
|
package util
import (
"io/ioutil"
"os"
)
type Dir struct {
FilePath string
}
//获取目录下文件列表
func (d *Dir) GetFileList() []os.FileInfo {
fileList, _ := ioutil.ReadDir(d.FilePath)
return fileList
}
//判断是否是目录
func (d *Dir) IsDir() bool {
dir, err := os.Stat(d.FilePath)
if err != nil {
return false
}
return dir... |
package main
import (
"encoding/json"
"fmt"
"io/ioutil"
"net/http"
"bytes"
"encoding/binary"
"encoding/gob"
"errors"
"flag"
"github.com/boltdb/bolt"
"log"
"time"
)
var (
bucketDoesNotExistError = errors.New("bucket does not exist")
keyDoesNotExist = errors.New("key does not exist")
bucketName... |
// Copyright 2014 William H. St. Clair
// 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 main
import "fmt"
func main() {
var x [10]int
fmt.Println("length: ", len(x))
fmt.Println(x)
for i := 0; i < 10; i++ {
x[i] = i
}
for _, v := range x {
fmt.Printf("%v - %T - %b \n", v, v, v)
}
}
// length: 10
// [0 0 0 0 0 0 0 0 0 0]
// 0 - int - 0
// 1 - int - 1
// 2 - int - 10
// 3 - int - 11
... |
/*
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, so... |
package main
import (
"fmt"
"strings"
)
func main() {
// const min = 5
classList := []string{"Chruschtschov",
"Hristo",
"Nguyen",
"Dmitry",
"Madchen",
"Fujiyama",
"Connor"}
total := 5
count := 0
final := 0
isConstant := false
for _, x := range classList {
x = strings.ToLower(x)
// fmt.Prin... |
/*
Copyright © 2022 SUSE LLC
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distri... |
package config
import (
"io/ioutil"
"os"
"github.com/galenguyer/retina/core"
"gopkg.in/yaml.v2"
)
type Config struct {
Services []core.Service `yaml:"services"`
}
func Load(path string) (*Config, error) {
return loadConfigFile(path)
}
func loadConfigFile(path string) (config *Config, err error) {
var bytes ... |
package core
import (
"log"
"sync"
"time"
)
type HookManager interface {
stopper
AddHook(time.Duration, func() error)
}
func NewHookManager() HookManager {
return &hookManager{}
}
type hook struct {
cb func() error
interval time.Duration
stopCh chan struct{}
doneCh chan struct{}
}
type hookMana... |
package main
import (
"fmt"
"io"
"net/http"
"os"
"strings"
"./plugins/whats_for_lunch"
"github.com/daneharrigan/hipchat"
)
type plugin interface {
ProcessMessage(msg *hipchat.Message, replyChan chan string)
}
func main() {
user := os.Getenv("HIPCHAT_USERNAME")
pass := os.Getenv("HIPCHAT_PASSWORD")
resour... |
package main
import (
"io"
"os"
"github.com/prometheus/common/expfmt"
"github.com/prometheus/common/model"
"github.com/prometheus/common/promlog"
kingpin "gopkg.in/alecthomas/kingpin.v2"
)
func setupLogger() {
if logger == nil {
logger = promlog.New(&promlog.Config{Level: &defaultLogLevel, Format: &promlog.... |
package 字符串
import "fmt"
func freqAlphabets(s string) string {
charMap := getCharMap()
result := make([]byte, 0)
for i := len(s) - 1; i >= 0; {
if s[i] == '#' {
result = append(result, charMap[s[i-2:i+1]])
i -= 3
} else {
result = append(result, charMap[s[i:i+1]])
i -= 1
}
}
return string(rever... |
package utils
import (
"io/ioutil"
"reflect"
"strings"
"testing"
)
func Test_listDirectory(t *testing.T) {
var files = []string{"test.conf"}
dir, err := ioutil.TempDir(".", "tmp")
if err != nil {
t.Fatal(err)
}
if err := ioutil.WriteFile(strings.Join([]string{dir, "test.conf"}, "/"), []byte(""), 0777); er... |
package leetcode
func moveZeroes(nums []int) {
l, r, lens := 0, 0, len(nums)
for r < lens {
if nums[r] != 0 {
nums[l], nums[r] = nums[r], nums[l]
l++
}
r++
}
}
|
package caaa
import (
"encoding/xml"
"github.com/thought-machine/finance-messaging/iso20022"
)
type Document01000101 struct {
XMLName xml.Name `xml:"urn:iso:std:iso:20022:tech:xsd:caaa.010.001.01 Document"`
Message *AcceptorReconciliationResponseV01 `xml:"AccptrRcncltnRspn"`
}
func (d ... |
package cmd
import (
"context"
"database/sql"
"fmt"
"io/ioutil"
"net/http"
"os"
"strings"
"github.com/garyburd/redigo/redis"
_ "github.com/lib/pq"
homedir "github.com/mitchellh/go-homedir"
"github.com/neelance/graphql-go"
"github.com/neelance/graphql-go/relay"
"github.com/s1gu/s1gu-lib/cache"
"github.co... |
package queue
import (
"github.com/google/go-cmp/cmp"
"testing"
)
func TestPush(t *testing.T) {
tests := []struct {
in func() *Queue
add []interface{}
want func() *Queue
}{
{
in: func() *Queue {
n := &Node{1, nil}
return &Queue{head: n, tail: n}
},
add: []interface{}{... |
package server
import (
"encoding/json"
"fmt"
"net/http"
"github.com/Sirupsen/logrus"
"github.com/bryanl/dolb/dao"
"github.com/bryanl/dolb/pkg/app"
"github.com/bryanl/dolb/service"
)
// BootstrapClusterResponse is a bootstrap cluster response.
type BootstrapClusterResponse struct {
LoadBalancer LoadBalancerR... |
package main
import (
"testing"
)
func TestLongestConsecutive(t *testing.T) {
LongestConsecutive([]int{100, 1, 300})
}
|
package pg
import (
"github.com/kyleconroy/sqlc/internal/sql/ast"
)
type CreateDomainStmt struct {
Domainname *ast.List
TypeName *TypeName
CollClause *CollateClause
Constraints *ast.List
}
func (n *CreateDomainStmt) Pos() int {
return 0
}
|
package domain
type UserFriendDomain struct {
Id int `db:"ID, primarykey, autoincrement"`
FromUserId int `db:"FromUserID"`
ToUserId int `db:"ToUserID"`
}
|
package database
import (
"context"
"errors"
"log"
"reflect"
"time"
"github.com/jmoiron/sqlx"
_ "github.com/mattn/go-sqlite3"
)
type Config struct {
DSN string
}
// Open knows how to open a database connection based on the configuration.
func Open(cfg Config) (*sqlx.DB, error) {
db, err := sqlx.Open("sqli... |
package tool
func HashCode(s string) (hash int32) {
if len(s) == 0 {
return 0
}
hash = 0
chr := 0
for i := 0; i < len(s); i++ {
chr = int(rune(s[i]))
hash = ((hash << 5) - hash) + int32(chr)
hash |= 0
}
return hash
}
|
package options
import "github.com/spf13/pflag"
type AppHealthOptions struct {
JoinIp string
Namespace string
SvcName string
}
func NewAppHealthOptions() *AppHealthOptions {
return &AppHealthOptions{
JoinIp: "",
Namespace: "",
SvcName: "",
}
}
func (o *AppHealthOptions) Validate() []error {
re... |
/*
Package qu is a simple executor service. You add jobs to a queue, then run them concurrently with a configurable
amount of concurrency.
*/
package qu
import (
"sync"
"time"
"github.com/ecnepsnai/qu/atomic"
)
// Queue describes a queue of jobs
type Queue struct {
Done bool
jobs []func(payload interfac... |
package main
import (
"github.com/tanema/amore"
"github.com/tanema/gocraftmini/game"
)
func main() {
world := game.NewWorld(149, 20, 300, false)
amore.Start(world.Update, world.Draw)
}
|
package scache
import (
"errors"
"strconv"
"sync/atomic"
"testing"
"github.com/stretchr/testify/require"
)
func TestCache(t *testing.T) {
for _, testInfo := range []struct {
Name string
Func func(Kind) func(*testing.T)
}{
{
Name: "GetSet",
Func: func(kind Kind) func(*testing.T) {
return func(... |
func findK(nums []int, start int, end int, k int) int {
pivot := nums[end]
l := start
for idx := start; idx < end; idx += 1 {
if nums[idx] < pivot {
nums[l], nums[idx] = nums[idx], nums[l]
l += 1
}
}
nums[l], nums[end] = nums[end], nums[l]
if l == k {
return pivot
} else if l < k {
return findK(num... |
package recursion
import (
"fmt"
"testing"
"github.com/sko00o/leetcode-adventure/nary-tree/treenode"
)
func Test_maxDepth(t *testing.T) {
type args struct {
root *Node
}
tests := []struct {
name string
args args
want int
}{
{
name: "Example 1",
args: args{root: treenode.ExampleTree1},
want:... |
// This file was generated for SObject PlatformCachePartitionType, API Version v43.0 at 2018-07-30 03:47:25.203153075 -0400 EDT m=+11.546192758
package sobjects
import (
"fmt"
"strings"
)
type PlatformCachePartitionType struct {
BaseSObject
AllocatedCapacity int `force:",omitempty"`
AllocatedPurchas... |
package main
import (
"github.com/gin-gonic/gin"
"strings"
)
func paxinxicunshujuku(){
for xuehao:=2019210001;xuehao<=2019215203;xuehao++ {
var students Student
body:=paqu(xuehao)
name,week :=nameandweek(body)
var date string
var classes []Class
if name[10:] != ""{
date,classes= classxinxi(body)
... |
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT license.
package kubernetesupgrade
import (
"context"
"fmt"
"math/rand"
"strings"
"time"
"github.com/Azure/aks-engine/pkg/api"
"github.com/Azure/aks-engine/pkg/api/common"
"github.com/Azure/aks-engine/pkg/armhelpers"
"git... |
package main
import (
"time"
)
type BinaryWheel struct {
Effect
startLed int
size int
stepDuration time.Duration
stepStart time.Time
}
func NewBinaryWheel(disp Display, cg ColorGenerator, size int, duration time.Duration) *BinaryWheel {
ef := NewEffect(disp, 0.5, 0.0)
e := &BinaryWheel{
Eff... |
/*
Copyright 2020 Humio https://humio.com
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, ... |
//-------------
package main
import (
"fmt"
"os"
"strings"
"time"
"github.com/k0kubun/pp"
"github.com/pharrisee/poloniex-api"
)
type (
Strategy struct {
p *poloniex.Poloniex
isDebug bool
idxOrders int //Индекс заявок в стакане
isRealTrade bool
}
ThreePair struct {
oneSell string
... |
package main
import (
"go-openapi/restapi/operations/health"
"os"
"go-openapi/models"
logadaptor "go-openapi/pkg/log"
"go-openapi/pkg/storage"
"go-openapi/restapi"
"go-openapi/restapi/operations"
"go-openapi/restapi/operations/user"
"github.com/go-openapi/loads"
"github.com/go-openapi/runtime/middleware"
"g... |
package bca
import (
"encoding/base64"
"fmt"
"github.com/imroc/req"
)
const (
DefaultTimezone string = "Asia/Jakarta"
DefaultCurrencyCode string = "IDR"
TimestampISO8601 string = "2006-01-02T15:04:05.000-07:00"
TimestampTransactionDate string = "2006-01-02"
accessTokenCacheKey stri... |
package main
import "fmt"
// 200. 岛屿数量
// 给你一个由 '1'(陆地)和 '0'(水)组成的的二维网格,请你计算网格中岛屿的数量。
// 岛屿总是被水包围,并且每座岛屿只能由水平方向或竖直方向上相邻的陆地连接形成。
// 此外,你可以假设该网格的四条边均被水包围。
// https://leetcode-cn.com/problems/number-of-islands/
func main() {
fmt.Println(numIslands3([][]byte{
{'1', '1', '1', '1', '0'},
{'1', '1', '0', '1', '0'},
{... |
// access_test.go (access-check)
package main
import (
"testing"
)
// We can check the file exist
// then run this test will prove it checks correctly exists
func TestExistFile(t *testing.T) {
var this_file string = `../config.yml-sample`
if Exists(this_file) != true {
t.Error("Failure TestExistFile")
}
}
// ... |
/*
* @lc app=leetcode.cn id=884 lang=golang
*
* [884] 两句话中的不常见单词
*/
package main
// @lc code=start
func uncommonFromSentences(s1 string, s2 string) []string {
wordCount := make(map[string]int)
start := 0
for i := 1; i < len(s1); {
for i < len(s1) && s1[i] != ' ' {
i++
}
wordCount[s1[start:i]]++
start... |
package goble
import (
"github.com/ge-lighting/goble/xpc"
"log"
)
const (
ALL = "__allEvents__"
)
// Event generated by blued, with associated data
type Event struct {
Name string
State string
DeviceUUID xpc.UUID
ServiceUuid string
CharacteristicUuid string
Peripher... |
package cloudflare
import (
"context"
"encoding/json"
"fmt"
"net/http"
"time"
)
type DLPPayloadLogSettings struct {
PublicKey string `json:"public_key,omitempty"`
// Only present in responses
UpdatedAt *time.Time `json:"updated_at,omitempty"`
}
type GetDLPPayloadLogSettingsParams struct{}
type DLPPayloadLo... |
package main
import (
"bufio"
"bytes"
"fmt"
//"io"
"os"
"regexp"
"strings"
)
const dbg_parse_line = false
func fmt_line(data []string) string {
s := bytes.NewBufferString("[")
for i, v := range data {
if i == 0 {
fmt.Fprintf(s, "%q", v)
} else {
fmt.Fprintf(s, ", %q", v)
}
}
fmt.Fprintf(s, "]"... |
package main
import (
"encoding/json"
"log"
api "github.com/micro/go-api/proto"
"github.com/micro/go-micro/errors"
"context"
)
type Foo struct{}
// Foo.Bar is a method which will be served by http request /example/foo/bar
// Because Foo is not the same as the service name it is mapped beyond /example/
func (f ... |
package cmd
import (
"fmt"
"regexp"
"strings"
"github.com/pkg/errors"
"github.com/spf13/cobra"
analytics "gopkg.in/segmentio/analytics-go.v3"
)
var (
// envCmd represents the env command
envCmd = &cobra.Command{
Use: "env <service>",
Short: "Print the secrets from the parameter store in a format to exp... |
/*
-------------------------------------------------
Author : Zhang Fan
date: 2020/5/17
Description :
-------------------------------------------------
*/
package robot
import (
"encoding/json"
)
type TextMsg struct {
Content string `json:"content"`
}
type LinkMsg struct {
Title ... |
package deezer
import (
"context"
"errors"
"fmt"
"net/http"
"os"
"github.com/go-resty/resty/v2"
"golang.org/x/oauth2"
)
const (
// AuthURL is the URL to Deezer Accounts Service's OAuth2 endpoint.
AuthURL = "https://connect.deezer.com/oauth/auth.php"
// TokenURL is the URL to the Deezer Accounts Service's O... |
package test
import (
"github.com/agiledragon/trans-dsl"
"github.com/agiledragon/trans-dsl/test/context"
"github.com/agiledragon/trans-dsl/test/context/action"
. "github.com/smartystreets/goconvey/convey"
"testing"
"time"
)
var eventId = "assign cmd"
func newWaitTrans() *transdsl.Transaction {
trans := &trans... |
package commonTestUtils
import (
"context"
"github.com/go-logr/logr"
hcoutil "github.com/kubevirt/hyperconverged-cluster-operator/pkg/util"
"k8s.io/apimachinery/pkg/runtime"
"sigs.k8s.io/controller-runtime/pkg/client"
"sigs.k8s.io/controller-runtime/pkg/manager"
"sync"
)
type MockEvent struct {
EventType stri... |
package main
import (
"fmt"
"time"
)
func main() {
now := time.Now() //获取当前时间
fmt.Printf("current time:%v\n", now)
year := now.Year()
month := now.Month()
day := now.Day()
minute := now.Minute()
hour := now.Hour()
second := now.Second()
fmt.Printf("%v-%v-%0v %v:%v:%v\n", year, month, day, hour, minute, sec... |
package report
import (
"encoding/json"
"testing"
"github.com/stretchr/testify/assert"
)
func TestNewToken(t *testing.T) {
type testCase struct {
id uint64
key uint16
token uint64
}
cases := []testCase{
{0, 0, 0},
{1, 1, 0x201},
{0x7FFFFFFFFFFFFF, 0x1FF, 0xFFFFFFFFFFFFFFFF},
}
for _, c := ... |
package acme
import (
"encoding/json"
)
type Gopher struct {
ID json.Number `json:"gopher_id"`
Name string `json:"name"`
Description string `json:"description"`
}
type Thing struct {
ID json.Number `json:"thing_id"`
GopherID json.Number `json:"gopher_id"`
Name stri... |
package controllers
func (s *Server) initializeRoutes() {
v1 := s.Router.Group("/api/v1")
{
// Books routes
v1.POST("/books", s.PostBook)
v1.GET("/books", s.GetBooks)
v1.GET("/books/:id", s.GetBookById)
v1.PUT("/books/:id", s.UpdateBook)
v1.DELETE("/books/:id", s.DeleteBook)
// Genres routes
v1.GET... |
package controller
import (
"encoding/json"
"errors"
"github.com/bearname/videohost/internal/common/infrarstructure/transport"
"github.com/gorilla/mux"
log "github.com/sirupsen/logrus"
"io"
"net/http"
)
var (
ErrBadRequest = errors.New("bad request")
ErrRouteNotFound = errors.New("route not found")
)
typ... |
package memcached
import (
"github.com/Qihoo360/poseidon/service/meta/store"
"github.com/bradfitz/gomemcache/memcache"
"github.com/golang/glog"
)
type Memcached struct {
conn *memcache.Client
config store.Config
}
func NewMemcachedStore(c store.Config) (store.Store, error) {
rc := &Memcached{
config: c,
}... |
// Copyright (c) 2018 Benjamin Borbe All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
package version_test
import (
"context"
"github.com/bborbe/kafka-dockerhub-version-collector/avro"
"github.com/bborbe/kafka-dockerhub-version-collector/... |
package main
import (
"fmt"
"github.com/radovskyb/watcher"
"os"
"os/exec"
"path/filepath"
"syscall"
"time"
)
var (
cmd *exec.Cmd
)
func run(args []string) error {
if cmd != nil {
pgid, err := syscall.Getpgid(cmd.Process.Pid)
if err == nil {
syscall.Kill(-pgid, syscall.SIGTERM)
}
_ = cmd.Wait()
}... |
package env
import (
"fmt"
"os"
)
func Lookup(key string) string {
value, isSuccessful := os.LookupEnv(key)
if !isSuccessful {
panic(fmt.Sprintf("Environment variable \"%s\" not set", key))
}
return value
}
|
// Copyright 2022 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 error
import "net/http"
type Err struct {
Code int
Msg string
}
func (e *Err) Error() string {
return e.Msg
}
var statusCode = map[int]int{
1001: http.StatusBadGateway,
}
func HttpStatusCode(code int) int {
v, ok := statusCode[code]
if ok {
return v
}
return http.StatusOK
}
|
/* Copyright (c) 2016 Jason Ish
* 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, this list of conditions... |
// Copyright © 2020 Banzai Cloud
//
// 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 idg
import (
"encoding/json"
"time"
"github.com/itsmontoya/mum"
)
// newID32 will return a new ID with the provided index and timestamp
// Note: If timestamp is set to -1, the current Unix timestamp will
// be utilized
func newID32(idx uint32, ts int64) (id ID32) {
// Helper for binary encoding
var bw m... |
package main
import (
"encoding/hex"
"fmt"
uc "github.com/unicorn-engine/unicorn/bindings/go/unicorn"
"strings"
)
var asm = strings.Join([]string{
"48c7c003000000", // mov rax, 3
"0f05", // syscall
"48c7c700400000", // mov rdi, 0x4000
"488907", // mov [rdi], rdx
"488b07", // mov rdx... |
package main
import (
"fmt"
"os"
"bufio"
"regexp"
"runtime"
"strconv"
"strings"
"./unlib"
"./thread"
)
type Board struct {
Name string
Ita string
}
type MiniThread struct {
Name string
Ita string
Sure string
Point int
}
func NewMiniThread(t *thread.Thread) (this MiniThread) {
this.Name = t.Na... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.