text stringlengths 11 4.05M |
|---|
package version
import (
"encoding/json"
"github.com/gin-gonic/gin"
_ "github.com/wangfmD/rvs/log"
"github.com/wangfmD/rvs/models"
"log"
"net/http"
"strings"
)
func QueryTagsHandle(c *gin.Context) {
var tag = models.VersionTag{}
tags := tag.GetAll()
c.JSON(http.StatusOK, gin.H{
"status": "success",
"re... |
package AddressRecover
import (
"encoding/json"
"io/ioutil"
"net/http"
)
// GetIP method will return the user IP address.
func GetAddress() string {
resp, err := http.Get("https://ipinfo.io/json")
if err != nil {
panic("Something went wrong!")
}
body, _ := ioutil.ReadAll(resp.Body)
var dat map[string]inte... |
package mempool
import (
"strconv"
"sync/atomic"
"time"
"github.com/meshplus/bitxhub-model/pb"
raftproto "github.com/meshplus/bitxhub/pkg/order/etcdraft/proto"
cmap "github.com/orcaman/concurrent-map"
)
func (mpi *mempoolImpl) getBatchSeqNo() uint64 {
return atomic.LoadUint64(&mpi.batchSeqNo)
}
func (mpi *m... |
package main
import (
"bufio"
"encoding/json"
"fmt"
"io"
"net"
"os"
"os/exec"
"strings"
"github.com/coreos/go-systemd/unit"
"github.com/urfave/cli"
)
const (
networkBase = "/etc/systemd/network"
apConfigBase = "/etc/"
ethernetService = "fconf-wired-%s.network"
fourgService = "fconf-4g-%s.netw... |
package main
import (
"fmt"
)
type Result struct {
GoodsId int
GoodsName string
}
const solutionQuery = `
WITH all_tags AS (
SELECT
COUNT(1) AS count
FROM
tags
)
SELECT
goods.id,
goods.name
FROM (
SELECT
goods_id,
COUNT(tags_goods.tag_id) AS tags_count
FROM
tags_goods,
... |
package main
import (
"context"
"fmt"
"time"
"cloud.google.com/go/firestore"
"google.golang.org/genproto/googleapis/type/latlng"
)
type Person struct {
Id string `firestore:"id"`
Firstname string `firestore:"firstname"`
Lastname string `firestore:"lastname"`
Dob time.Ti... |
package service
import (
"testing"
)
func TestInitializationTables(t *testing.T) {
service := DatabaseInitializerService{&dbProperties}
service.InitializeDBTables()
}
|
package informer
import (
"time"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/runtime/schema"
"k8s.io/client-go/dynamic"
"k8s.io/client-go/dynamic/dynamicinformer"
"k8s.io/client-go/informers"
"k8s.io/client-go/tools/cache"
"github.com/argoproj/argo/pkg/apis/workflow"
extwfv1 "gith... |
package flow
import (
"sync"
"testing"
"time"
)
// A component that doubles its int input
type doubler struct {
Component
In <-chan int
Out chan<- int
}
// Doubles the input and sends it to output
func (d *doubler) OnIn(i int) {
d.Out <- i * 2
}
// A constructor that can be used by component registry/factor... |
// Copyright 2019 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 (
"bufio"
"fmt"
"io"
"os"
"strings"
cidutil "gx/ipfs/QmdPQx9fvN5ExVwMhRmh7YpCQJzJrFhd1AjVBwJmRMFJeX/go-cidutil"
c "gx/ipfs/QmR8BauakNcBa3RbE4nbQu76PDiJgoQgz8AJdhJuiU4TAw/go-cid"
mb "gx/ipfs/QmekxXDhCxCJRNuzmHreuaT3BsuJcsjcXWNrtV9C8DRHtd/go-multibase"
)
func usage() {
fmt.Fprintf(os.Stde... |
package common
var l *Logger
var c *Config
var d *Db
func init() {
l = NewLogger()
c = NewConfig()
d = NewDb()
}
|
package main
import (
"testing"
"time"
)
type Person struct {
Name string
PhoneNumber string
Date time.Time
}
func TestConnectMongo(t *testing.T) {
connectMongo("mongodb://localhost:27017")
insertMongoDocument("foo", "person", Person{
Name: "Tom",
PhoneNumber: "1662777",
Date: ... |
package yaml
import (
"fmt"
"io"
"strings"
)
type Error struct {
Err error
}
func (le Error) HasErr() bool {
return true
}
type node interface {
Previous() error
Info() string
GetName() (fileName, packageName, functionName string)
GetLine() (line int)
}
func (le Error) Output(co... |
// provides fast matching algorithms
// TODO: aho-corasic on substring matching
package sieve
import (
"github.com/ActiveState/log"
"regexp"
"strings"
)
// MultiRegexpMatch allows matching a string against multiple regular
// expressions along with substrings for a fast fail-early matching.
type MultiRegexpMatcher... |
package easypost_test
import (
"io/ioutil"
"net/http"
"strings"
"github.com/EasyPost/easypost-go/v3"
)
// TestApiError tests that a bad API request returns an InvalidRequestError (a subclass of APIError), and that the
// error is parsed and pretty-printed correctly.
func (c *ClientTests) TestApiError() {
client... |
package worker
import (
"Edwardz43/tgbot/message/from"
"time"
)
type Worker interface {
Do(func(args ...interface{}) error)
}
type Job struct {
ID int64 `json:"id"`
DeliverDate *time.Time `json:"deliver_date"`
FinishDate *time.Time `json:"finish_date"`
Done bool `json:"done... |
package main
type cake []*layer
func (c *cake) String() string {
s := ""
for i := len(*c) - 1; i >= 0; i-- {
s = s + (*c)[i].String() + "\n"
}
return s
}
func (c *cake) bottom() *layer {
if len(*c) == 0 {
return nil
}
return (*c)[0]
}
func (c *cake) top() *layer {
if len(*c) == 0 {
return nil
}
retur... |
package fakes
import "github.com/cloudfoundry-incubator/notifications/models"
type UnsubscribesRepo struct {
Unsubscribes map[string]models.Unsubscribe
}
func NewUnsubscribesRepo() *UnsubscribesRepo {
return &UnsubscribesRepo{
Unsubscribes: map[string]models.Unsubscribe{},
}
}
func (fake *Unsubs... |
// Copyright The OpenTelemetry 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 agre... |
package main
import . "./topic"
import . "./message"
func main(){
msg := Message{}
msg.CreateMessage("mensagem sobre o assunto",7)
topic := Topic{}
topic.CreateTopic("assunto")
topic.AddMessage(msg)
println(topic.Messages.Pop())
topic.AddSubscriber("fulana")
println(topic.Subscribed[0])
}
|
package bslib
import (
"strings"
"testing"
)
const nonExistingCypher = "blah-blah"
func TestInitNonExistingCypher(t *testing.T) {
newCypher := new(bsEncryptor)
err := newCypher.Init(nonExistingCypher)
if err == nil {
t.Error("Should return error, cypher does not exist")
} else if !strings.Contains(err.Error(... |
package search
import "log"
type Result struct {
Field string
Content string
}
type Matcher interface {
Search(feed *Feed, searchTerm string) ([]*Result, error)
}
// 参数中的results chan <- *Result 表示results 是一个 只写*Result 的channel(不能读数据,即使用 <-results 会报错。),
// 同理,还可以定义一个 只读*Result 的 channel : results <-chan *Resu... |
package sudoku
import (
"math/rand"
)
//GenerationOptions provides configuration options for generating a sudoku puzzle.
type GenerationOptions struct {
//symmetrty and symmetryType control the aesthetics of the generated grid. symmetryPercentage
//controls roughly what percentage of cells with have a filled partn... |
package initialize
import "go.uber.org/zap"
func Logger() {
// 定义全局
logger, _ := zap.NewDevelopment()
zap.ReplaceGlobals(logger)
}
|
package upload
import (
"io/ioutil"
"net/http"
"testing"
)
func TestGetURL(t *testing.T) {
filename := UploadTestFile(t)
url := GetURL(filename)
res, err := http.Get(url)
if err != nil {
t.Error(err)
}
defer res.Body.Close()
body, err := ioutil.ReadAll(res.Body)
if err != nil {
t.Error(err)
}
if ... |
package main
type BlockService interface {
Upload([]byte)
}
|
package models
import "time"
const (
UserBodyTemplateName = "user_body"
SpaceBodyTemplateName = "space_body"
EmailBodyTemplateName = "email_body"
OrganizationBodyTemplateName = "organization_body"
SubjectMissingTemplateName = "subject.missing"
SubjectProvidedTemplateNam... |
package server
import "github.com/sirupsen/logrus"
var (
log = logrus.WithField("pkg", "server")
gameSubscriberBuffer = 10
gameChatBuffer = 10
gameMoveBuffer = 2
)
|
package database
import (
"database/sql"
"fmt"
"log"
_ "github.com/go-sql-driver/mysql"
)
func MysqlVersion(host string, port int, database, username, password string) (string, error) {
connString := fmt.Sprintf("%s:%s@tcp(%s:%d)/%s", username, password, host, port, database)
conn, err := sql... |
package web
import (
"net/http"
"github.com/steam-authority/steam-authority/db"
"github.com/steam-authority/steam-authority/logging"
)
func StatsTagsHandler(w http.ResponseWriter, r *http.Request) {
// Get config
config, err := db.GetConfig(db.ConfTagsUpdated)
logging.Error(err)
// Get tags
tags, err := db... |
// Package manifests deals with creating manifests for all manifests to be installed for the cluster
package manifests
import (
"bytes"
"encoding/base64"
"path/filepath"
"strings"
"text/template"
"github.com/pkg/errors"
"sigs.k8s.io/yaml"
"github.com/openshift/installer/pkg/asset"
"github.com/openshift/inst... |
package database
import (
"database/sql"
"log"
)
func Query(q string) *sql.Rows {
/*
Return rows from query to DB
Error handling is handled here in the factory
*/
// prepare query
stmt, err := DB.Prepare(q)
if err != nil {
log.Fatal(err)
return nil
}
defer stmt.Close()
rows, err := stmt.Query()
if... |
package game_map
import (
"github.com/faiface/pixel/pixelgl"
)
type SBEvent interface {
Update(dt float64)
IsBlocking() bool
IsFinished() bool
Render(win *pixelgl.Window)
}
type WaitEvent struct {
Seconds float64
}
func WaitEventCreate(seconds float64) *WaitEvent {
return &WaitEvent{
Seconds: seconds,
}
}... |
// Insert and search for numbers in a binary tree.
// left child <= parent, right chile > parent
// For example, if we had a node containing the data 4, and we added the
// data 2, our tree would look like this:
// 4
// /
// 2
// If we then added 6, it would look like this:
// 4
// / \
// ... |
package main
import (
"bytes"
"encoding/json"
"errors"
"fmt"
"io/ioutil"
"main/hosts/anonfiles"
"main/hosts/catbox"
"main/hosts/fileio"
"main/hosts/filemail"
"main/hosts/ftp"
"main/hosts/gofile"
"main/hosts/krakenfiles"
"main/hosts/letsupload"
"main/hosts/megaup"
"main/hosts/mixdrop"
... |
//
// Copyright 2020 The AVFS 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 log
import "os"
const (
productionMode = "production"
developmentMode = "development"
)
const (
envLogLevel = "BE_LOG_LEVEL"
envLogMode = "BE_LOG_MODE"
defLogLevel = "debug"
defLogMode = developmentMode
)
var (
cfgLogLevel = EnvStr(envLogLevel, defLogLevel)
cfgLogMode = EnvStr(defLogMode, defLo... |
package domain
import (
"encoding/gob"
)
type Product struct {
ProductId string
CategoryId string
Name string
Description string
}
func (p *Product) String() string {
return p.ProductId
}
// 序列化注册 product,用于 session 存储
func init() {
gob.Register(&Product{})
}
|
// Package report Amazon Seller Utilities API Responses
package report
import (
"encoding/json"
"log"
"net/http"
)
// DownloadReportError An error response from the API
func DownloadReportError(w http.ResponseWriter, version int, code int, err error) error {
apiResponse := DownloadReportAPIResponse{
Version: ve... |
package main
import "fmt"
func main() {
size := 49
var numArray []int
for i := 0; i < size; i++ {
numArray = append(numArray, 1)
}
fmt.Println(numArray)
}
|
package main
import (
"net"
"fmt"
"bufio"
"strings"
)
func main() {
l,err:=net.Listen("tcp",":8080")
if err!=nil{
fmt.Println(err)
}
for{
c,err:=l.Accept() //here we accept the tcp connection in c and now we can read and write on this connection
if err!=nil{
fmt.Println(err)
continu... |
// 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 main
import (
"encoding/json"
"io/ioutil"
"lucastetreault/did-tangaroa/pkg/linkeddata"
)
var clusterDdoc *linkeddata.DidDocument
func loadClusterDdoc() {
if clusterDdoc == nil {
b, err := ioutil.ReadFile("./cluster.json")
if err != nil {
panic(err.Error())
}
var ddoc linkeddata.DidDocument
... |
/*****************************************************************
* Copyright©,2020-2022, email: 279197148@qq.com
* Version: 1.0.0
* @Author: yangtxiang
* @Date: 2020-08-20 16:02
* Description:
*****************************************************************/
package pdl
import (
"github.com/go-xe2/x/os/xfile"
"i... |
package setup
import (
"fmt"
"io/ioutil"
"os"
"os/exec"
"path"
"runtime"
"strings"
"github.com/jrperritt/rack/internal/github.com/codegangsta/cli"
"github.com/jrperritt/rack/util"
)
var rackBashAutocomplete = `
#! /bin/bash
_cli_bash_autocomplete() {
local cur prev opts
COMPREPLY=()
cur="${COMP_WORDS... |
package main
import (
"fmt"
"log"
"github.com/jonmorehouse/gatekeeper/gatekeeper"
metric_plugin "github.com/jonmorehouse/gatekeeper/plugin/metric"
)
func maxIdx(vals []uint64) int {
return 0
}
// Plugin is a type that implements the event_plugin.Plugin interface
type plugin struct{}
func (*plugin) Start() err... |
package cachetable
import (
"strconv"
"testing"
)
func TestNewCacheTableInit(t *testing.T) {
cases := []struct {
ina, inb int
}{
{10, 10},
{10, 2},
{0, 0},
{1, 0},
{1, 1},
}
mytest := func(prealloc bool) {
for _, c := range cases {
h, err := NewCacheTable(c.ina, c.inb, prealloc)
if c.ina ==... |
package rpc
// CommandConfig configures a cli command
type CommandConfig struct {
// Order is the listing order on cli help
Order int
// NumArgs is the # of arguments the command expects
NumArgs int
// Description is the cli help string
Description string
// RpcMethod is the method to call
RpcMethod string
... |
package container
import (
"bytes"
"encoding/gob"
"fmt"
"github.com/criyle/go-sandbox/pkg/unixsocket"
)
// 16k buffsize
const bufferSize = 16 << 10
type socket struct {
*unixsocket.Socket
buff []byte
decoder *gob.Decoder
recvBuff bufferRotater
encoder *gob.Encoder
sendBuff bytes.Buffer
}
// bufferRo... |
package models
import (
"database/sql"
_ "github.com/go-sql-driver/mysql"
)
// DB Variables
var UserDB string
var PassDB string
var DatabaseDB string
var HostDB string
var PortDB string
type JsonListClustersMap []jsonListClusters
type JsonApps []jsonApps
type JsonAppsByClustersMap map[string][]jsonAppsByClusters
... |
package gcalc
import (
. "github.com/Focinfi/gtester"
"testing"
)
func TestCalculator(t *testing.T) {
result := Compute(" 1*(-1)* (5.00 + (-2)) * 3-(1.0+ 2)* 3 *(-1)")
AssertEqual(t, result, float64(0))
}
|
package service
import (
"context"
"fmt"
"io"
pbAS "github.com/go-ocf/cloud/authorization/pb"
pbCQRS "github.com/go-ocf/cloud/resource-aggregate/pb"
pbDD "github.com/go-ocf/cloud/resource-directory/pb/device-directory"
pbRD "github.com/go-ocf/cloud/resource-directory/pb/resource-directory"
pbRS "github.com/go... |
package main
import (
"encoding/json"
"fmt"
)
type Animal struct {
Name string `json:"name"`
}
func (a *Animal) GetName() string {
return a.Name
}
type Dog struct {
*Animal
Owner string `json:"owner"`
}
func main() {
a := &Animal{Name: "this is an animal"}
b, _ := json.Marshal(a)
fmt.Println(string(b))
... |
package main
import (
"fmt"
)
func main() {
type NamedParamsInit struct {
_ struct{}
name string
age int
}
x := NamedParamsInit{name: "fan", age: 10}
// failed
// y := NamedParamsInit{"", "dong", 1}
y := NamedParamsInit{struct{}{}, "dong", 1}
fmt.Println(x, y)
}
|
package cp
import (
"io"
"net/http"
"os"
"github.com/vbauerster/mpb"
"github.com/vbauerster/mpb/decor"
"golang.org/x/xerrors"
)
type Source struct {
r io.ReadCloser
pb func() *mpb.Bar
size int64
path string
}
func (s *Source) Read(p []byte) (n int, err error) {
return s.r.Read(p)
}
func (s *Source)... |
package main
import (
"flag"
"fmt"
"io"
"io/ioutil"
"log"
"os"
"os/exec"
"path/filepath"
"strings"
"text/template"
"github.com/pkg/errors"
)
func main() {
store := flag.String("store", "", "directory of the store")
password := flag.String("password", "", "password used to decrypt")
flag.Parse()
err :... |
package glman
var (
//progTest *Program
progTexFont *Program
progTexFontEdge *Program
progSimpleDraw *Program
//progSimpleTex *Program
//progColorDraw *Program
)
// UseProgTexFont load and use the tex font program
func UseProgTexFont(edge bool) (p *Program) {
if edge {
if progTexFontEdge == ni... |
package vkupload_tests
import (
"strings"
"testing"
)
func TestSimpleSimple(t *testing.T) {
uploadTest.Post("/upload").
SetHeader("Content-Disposition", `form-data; name="fieldname"; filename="filename.jpg"`).
BodyString(simpleFileContent).
Expect(t).
Status(200).
T... |
/*
progress.go WJ118
* written by Walter de Jong <walter@heiho.net>
* This is free and unencumbered software released into the public domain.
Please refer to http://unlicense.org/
*/
package progress
import (
"fmt"
"strings"
"time"
)
const (
refresh = 250 * time.Millisecond
spinnerText = "|/-\\"
bar... |
package main
import (
"fmt"
"strconv"
"strings"
"github.com/jnewmano/advent2020/input"
"github.com/jnewmano/advent2020/output"
)
type Rule struct {
start int
stop int
}
var ticketRules = make(map[string][]Rule)
func main() {
//input.SetRaw(raw)
// var things = input.Load()
// var things = input.LoadSli... |
package services
import (
"context"
"sync"
"github.com/golang/protobuf/ptypes/empty"
"github.com/tppgit/we_service/core"
)
var (
Server *WeService
loadOnceServer sync.Once
)
func NewServer() *WeService {
loadOnceServer.Do(func() {
Server = new(WeService)
})
return Server
}
type WeService struct ... |
package pkg
type GemMetadata struct {
Name string `mapstructure:"name" json:"name"`
Version string `mapstructure:"version" json:"version"`
Files []string `mapstructure:"files" json:"files"`
Authors []string `mapstructure:"authors" json:"authors"`
Licenses []string `mapstructure:"licenses" json:"licen... |
package client
import (
"github.com/naruta/terraform-provider-kintone/kintone/raw_client"
"reflect"
"testing"
)
func TestFieldPropertyMapper(t *testing.T) {
testCases := []struct {
title string
property raw_client.FieldProperty
shouldBeError bool
}{
{
title: "SINGLE_LINE_TEXT",
propert... |
package main
import (
"flag"
"bufio"
"fmt"
"gopkg.in/yaml.v2"
"io/ioutil"
"os"
"strings"
"regexp"
)
var shortenKind *bool
var findLowerCase = regexp.MustCompile("[a-z]*")
func init() {
shortenKind = flag.Bool("shorten", false, "Shorten the Kind used in the filename")
flag.Parse()
}
func main() {
reader... |
package dynamic
func max(a, b int) int {
if a > b {
return a
}
return b
}
func min(a, b int) int {
if a < b {
return a
}
return b
}
func maxByte(a, b byte) byte {
if a > b {
return a
}
return b
}
func minByte(a, b byte) byte {
if a < b {
return... |
package main
/*
给定一个正整数,输出它的补数。补数是对该数的二进制表示取反。
比如: 5 的二进制是: 101,则其补数为 2,对应于二进制就是010
*/
// 解法1 (模拟获取补数的过程)
func findComplement(num int) int {
ans := 0
count := uint8(0)
for num != 0 {
ans = ans | (((num & 1) ^ 1) << count)
num >>= 1
count++
}
return ans
}
// 解法2 (获取掩码,将该掩码与原num异或)
func findComplement(num... |
//go:build e2e_test
// +build e2e_test
// Copyright 2017 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.... |
package movie
import (
"context"
"fmt"
"strconv"
"strings"
gomdb "github.com/eefret/go-imdb"
"github.com/google/uuid"
"github.com/ido50/sqlz"
"github.com/jmoiron/sqlx"
"github.com/labstack/gommon/log"
"github.com/movieManagement/gen/models"
"github.com/movieManagement/gen/restapi/operations/movie"
ini "gi... |
package main
import (
"context"
"flag"
"net/http"
"github.com/golang/glog"
"github.com/grpc-ecosystem/grpc-gateway/runtime"
"software/simple_test/pb_gen"
)
func run() error {
ctx := context.Background()
ctx, cancel := context.WithCancel(ctx)
defer cancel()
// Register gRPC server endpoint
// Note: Make ... |
package refImpl
import (
"io/ioutil"
"os"
"path/filepath"
"testing"
"time"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
)
func TestInit(t *testing.T) {
dir, err := ioutil.TempDir("", "gotesttmp")
require.NoError(t, err)
defer os.RemoveAll(dir)
var cfg Config
cfg = testSigner... |
package controller
import (
"encoding/json"
"errors"
"fmt"
"github.com/allentom/youcomic-api/auth"
appconfig "github.com/allentom/youcomic-api/config"
ApiError "github.com/allentom/youcomic-api/error"
ApplicationError "github.com/allentom/youcomic-api/error"
"github.com/allentom/youcomic-api/model"
"github.co... |
package main
import (
"fmt"
"time"
)
func checkChannel(c chan bool) {
select {
case value := <-c:
fmt.Println("received", value)
return
default:
fmt.Println("waiting...")
}
}
func main() {
c := make(chan bool, 10)
for i := 1; i <= 5; i++ {
fmt.Println(i)
time.Sleep(time.Secon... |
package cli
import (
"crypto/sha256"
"encoding/base64"
"encoding/hex"
"fmt"
rpcclient "github.com/tendermint/tendermint/rpc/client"
"strings"
"testing"
)
func TestTxSearch(t *testing.T) {
txStr := "nALZHnawCn4qlySsCjsKFDvFEHUEs4I/M1dfXMv4UZ0X4TtOEiMKCWlyaXMtYXR0bxIWMjA0MDkyODExMDAwMDAwMDAwMDAwMBI7ChR2IdpSv6fM... |
package main
import (
"flag"
"github.com/zero-boilerplate/go-api-helpers/service"
"log"
)
var (
serviceName = flag.String("name", "", "Name of this script-wrapper service")
)
func main() {
defer func() {
if r := recover(); r != nil {
log.Fatalf("Service ERROR: %s", getStringFromRecovery(r))
}
}()
a :=... |
package main
import "fmt"
func sendCh(ch chan<- int) {
ch <- 4
}
func recvCh(ch <-chan int) {
n := <-ch
fmt.Println("读取到:", n)
}
func main() {
ch := make(chan int) //双向
//var sendCh chan <- int=ch
//sendCh<-9 //单向channel不能读取 err
/*var recvCh <- chan int=ch
fmt.Println(<-recvCh) //单向channel 不能写入*/
go fun... |
// Copyright 2016 IBM Corporation
//
// 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... |
package bosh
import (
"fmt"
"github.com/cloudfoundry/bosh-bootloader/storage"
yaml "gopkg.in/yaml.v2"
)
type SSHKeyDeleter struct {
}
func NewSSHKeyDeleter() SSHKeyDeleter {
return SSHKeyDeleter{}
}
func (SSHKeyDeleter) Delete(state storage.State) (storage.State, error) {
var err error
state.Jumpbox.Variable... |
package collectors
import (
"encoding/json"
"fmt"
"os"
"path/filepath"
"strconv"
"strings"
"time"
cclog "github.com/ClusterCockpit/cc-metric-collector/pkg/ccLogger"
lp "github.com/ClusterCockpit/cc-metric-collector/pkg/ccMetric"
)
// running average power limit (RAPL) monitoring attributes for a zone
type R... |
// Leap stub file
// The package name is expected by the test program.
package leap
// testVersion should match the targetTestVersion in the test file.
const testVersion = 3
// given a year and return whether that year is leap year
// 1> if not century years, leap year is divisible by 4
// 2> if century years, leap ... |
package helper_test
import (
"testing"
"ms/sun/shared/helper"
"fmt"
)
func BenchmarkSqlManyDollars(b *testing.B) {
s:=helper.SqlManyDollars(4, 10000, false)
fmt.Println(s)
for i := 0; i < b.N; i++ {
helper.SqlManyDollars(4, 10000, true)
}
}
|
// Copyright 2017 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... |
// 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... |
/*
Copyright 2019 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, ... |
package controller
import (
"fmt"
"os"
"sync"
"sync/atomic"
"time"
"k8s.io/api/core/v1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/util/wait"
"k8s.io/client-go/kubernetes"
"k8s.io/klog"
"k8s.io/kubernetes/pkg/volume"
)
type VolumeStats struct {
FsStats
Name string
PVCNa... |
package main
import (
"fmt"
"io/ioutil"
"log"
)
func printTasks() {
lc := lastestLeetCode()
makeTasksFile(lc.Problems)
}
func makeTasksFile(problems problems) {
content := ""
for _, p := range problems {
if !p.IsAccepted && p.IsAvailable {
content = fmt.Sprintf("%d - #%d分 - %s - %s \n", p.ID, p.Difficult... |
package main
import (
"fmt"
)
func getMessage() string {
return "Go World"
}
// go run main.go
func main() {
var intro = "Message:"
msg := getMessage()
fmt.Println(intro, msg)
}
|
package middleware
import (
"github.com/alexliesenfeld/health"
"net/http"
)
// BasicAuth is a middleware that removes check details (such as service names, error messages, etc.) from the
// HTTP response on authentication failure. Authentication is performed based on basic access authentication
// (https://en.wikip... |
package files
import (
"errors"
"github.com/dgrijalva/jwt-go"
"github.com/julienschmidt/httprouter"
"github.com/sanato/sanato-lib/auth"
"github.com/sanato/sanato-lib/config"
"github.com/sanato/sanato-lib/storage"
"net/http"
"strings"
)
func NewAPI(router *httprouter.Router, cp *config.ConfigProvider, ap *auth... |
package driver
// RunningInSwarm expect to support running on swarm
func RunningInSwarm() {
}
|
package token
type TokenType string
type Token struct{
Type TokenType
Value string
}
const (
EOF = "EOF"
ILLEGAL ="ILLEGAL"//illegal token
SEMICOLON = ";"
LBRACKET ="["//left bracket
RBRACKET ="]"
LBRACE = "{"
RBRACE = "}"
LPAREN = "("
RPAREN = ")"
//OPERATORS
EQ = "==" //equal sign
PL_EQ ... |
package handler
import (
"context"
"encoding/json"
"fmt"
pb "github.com/jlb0906/micro-movie/aria2-srv/proto/aria2"
aria2srv "github.com/jlb0906/micro-movie/aria2-srv/service/aria2"
"github.com/jlb0906/micro-movie/basic/common"
"github.com/jlb0906/micro-movie/movie-srv/proto/movie"
"github.com/micro/go-micro/v2... |
package shortenertest
import (
"testing"
"github.com/toms1441/urlsh/internal/repo/plain"
"github.com/toms1441/urlsh/internal/shortener"
)
var ss shortener.Service
var sr shortener.Repository
var modelid, modelurl string
func TestNewService(t *testing.T) {
var err error
ss, err = shortener.NewService(nil, short... |
package dcp
// ServiceID is a single byte.
type ServiceID byte
// Known ids.
const (
Get ServiceID = 1
Set ServiceID = 4
Identify ServiceID = 5
)
// ServiceType is a single byte.
type ServiceType byte
// Known types.
const (
Request ServiceType = 0
Response ServiceType = 1
)
|
package cobra
func main() {
} |
package cors
import (
"github.com/serverless/event-gateway/internal/zap"
"github.com/serverless/event-gateway/metadata"
"go.uber.org/zap/zapcore"
)
// ID uniquely identifies a CORS configuration.
type ID string
// CORS is used to configure CORS on HTTP subscriptions.
type CORS struct {
Space string ... |
// DRUNKWATER TEMPLATE(add description and prototypes)
// Question Title and Description on leetcode.com
// Function Declaration and Function Prototypes on leetcode.com
//150. Evaluate Reverse Polish Notation
//Evaluate the value of an arithmetic expression in Reverse Polish Notation.
//Valid operators are +, -, *, /. ... |
package bf
import (
"bytes"
"io"
"reflect"
"runtime"
"testing"
"github.com/rasky/gojit/amd64"
)
var helloWorld = "++++++++[>++++[>++>+++>+++>+<<<<-]>+>+>->>+[<]<-]>>.>---.+++++++..+++.>>.<-.<.+++.------.--------.>>+.>++."
// http://esolangs.org/wiki/Dbfi
var dbfi = `
>>>+[[-]>>[-]++>+>+++++++[<++++>>++<-]++>>... |
package v1alpha5
// HasInstanceType returns whether some node in the group fulfils the type check
func HasInstanceType(nodeGroup *NodeGroup, hasType func(string) bool) bool {
if hasType(nodeGroup.InstanceType) {
return true
}
if nodeGroup.InstancesDistribution != nil {
for _, instanceType := range nodeGroup.Ins... |
package main
import (
"fmt"
"os"
"github.com/jnewmano/advent2020/input"
)
func main() {
// input.SetRaw(raw)
var rawImages = input.LoadSliceString("\n\n")
var images = make([]*Image, len(rawImages))
for i, v := range rawImages {
images[i] = parseImage(v)
}
// assume the first image is in the desired tr... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.