text stringlengths 11 4.05M |
|---|
package main
import (
"errors"
log "github.com/sirupsen/logrus"
"github.com/streadway/amqp"
_ "net/http/pprof"
"time"
)
type MqConn struct {
Conn *amqp.Connection
Channel *amqp.Channel
Qqueue *amqp.Queue
exchangeName string // 交换机名称
exchangeType string // 交换机类型
queueName string // 队列名... |
package tree
func (node Node) getValue() int {
return node.Value
}
// 别名实现
type MyTreeNode struct {
node *Node
}
func (myNode *MyTreeNode) postOrder() {
if myNode == nil || myNode.node == nil {
return
}
left := MyTreeNode{myNode.node.Left}
left.postOrder()
right := MyTreeNode{myNode.node.Right}
right.postO... |
package main
import (
"bytes"
"encoding/json"
"flag"
"fmt"
"io"
"io/ioutil"
"mime/multipart"
"net/http"
"os"
"path/filepath"
"strings"
"time"
)
const (
usageMsg = `usage: jiraattach [-config=path] key path
ARGS
key - The key of the Jira Issue to attach files to.
path - Path to file to attach to Ji... |
// Web UI package
package webui
import "fmt"
// 所有控件都有的属性
type Common struct {
Id, Value string
Left, Top int
Width, Height int
Do func(*Context)
}
func (a Common) Format(l, t int) string {
return fmt.Sprintf(`id="%s" value="%s" style="position:absolute; left:%d; top:%d; width:%d; height:%d" ... |
package shardkv
const (
OK = "OK"
ErrNoKey = "ErrNoKey"
ErrWrongGroup = "ErrWrongGroup"
)
type Err string
type PutAppendArgs struct {
Key string
Value string
Op string // "Put" or "Append"
Impl PutAppendArgsImpl
}
type PutAppendReply struct {
Err Err
}
type GetArgs struct {
Key stri... |
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT license.
package rotatecerts
import (
"fmt"
"math/rand"
"time"
"github.com/Azure/aks-engine/cmd/rotatecerts/internal"
"github.com/Azure/aks-engine/pkg/api/common"
"github.com/pkg/errors"
log "github.com/sirupsen/logrus"
v1... |
// Copyright © 2018 Inanc Gumus
// Learn Go Programming Course
// License: https://creativecommons.org/licenses/by-nc-sa/4.0/
//
// For more tutorials : https://learngoprogramming.com
// In-person training : https://www.linkedin.com/in/inancgumus/
// Follow me on twitter: https://twitter.com/inancgumus
package main
... |
package fsm
import (
"bytes"
"encoding/json"
"strings"
"encoding/gob"
"fmt"
"reflect"
"github.com/aws/aws-sdk-go/aws"
"github.com/aws/aws-sdk-go/service/swf"
)
// constants used as marker names or signal names
const (
StateMarker = "FSM.State"
CorrelatorMarker = "FSM.Correlator"
ErrorMarker ... |
package goSolution
import "testing"
func TestNumSubarrayBoundedMax(t *testing.T) {
nums := []int {2, 1, 4, 3}
AssertEqual(t, 3, numSubarrayBoundedMax(nums, 2, 3))
}
|
package ui
import (
"fyne.io/fyne/v2"
"fyne.io/fyne/v2/container"
"fyne.io/fyne/v2/theme"
"fyne.io/fyne/v2/widget"
)
type toolbarView struct {
view
}
func NewToolBarView(win fyne.Window) *toolbarView {
return &toolbarView{
view: view{
Win: win,
},
}
}
func (t *toolbarView) MakeUI() fyne.CanvasObject ... |
package main
func getScore(w http.ResponseWriter, r *http.Request) {
// Set proper content-type header for jsonp
w.Header().Set("Content-Type", "text/javascript")
callback := r.FormValue("callback")
s1 := Score{"Mika", 64}
s2 := Score{"Mikko", 62}
s3 := Score{"Pekko", 34}
s4 := Score{"Arimas", 95}
... |
// DRUNKWATER TEMPLATE(add description and prototypes)
// Question Title and Description on leetcode.com
// Function Declaration and Function Prototypes on leetcode.com
//313. Super Ugly Number
//Write a program to find the nth super ugly number.
//Super ugly numbers are positive numbers whose all prime factors are in ... |
// 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... |
func findPeakElement(nums []int) int {
res := 0
max := nums[0]
if len(nums)==1{
return 0
}
for i:=1;i<len(nums);i++{
if nums[i]>max{
max = nums[i]
res = i
}else{
res = i-1
break
}
}
return res
}
|
/*
* EVE Swagger Interface
*
* An OpenAPI for EVE Online
*
* OpenAPI spec version: 0.4.1.dev1
*
* Generated by: https://github.com/swagger-api/swagger-codegen.git
*/
package swagger
// 200 ok object
type GetIndustryFacilities200Ok struct {
// ID of the facility
FacilityId int64 `json:"facility_id,omitemp... |
// Copyright (c) 2017-2018 The qitmeer developers
// Copyright (c) 2013-2016 The btcsuite developers
// Use of this source code is governed by an ISC
// license that can be found in the LICENSE file.
package btctypes
import (
"encoding/binary"
"io"
"fmt"
)
const (
// MaxVarIntPayload is the maximum payload size ... |
package bitmap
type Bitmap struct {
data []byte // 保存实际的 bit 数据
bitsize uint // 指示该 Bitmap 的 bit 容量
}
func NewBitmap(size uint) *Bitmap {
if size == 0 {
size = 0x01 << 32
} else if remainder := size % 8; remainder != 0 {
size += 8 - remainder
}
return &Bitmap{
data: make([]byte, size>>3),
bitsiz... |
package mr
//
// RPC definitions.
//
// remember to capitalize all names.
//
import (
"os"
"strconv"
)
//
// example to show how to declare the arguments
// and reply for an RPC.
//
type ExampleArgs struct {
X int
}
type ExampleReply struct {
Y int
}
// RequestTaskArgs is the Request Message for RequestTask
t... |
package main
import "fmt"
/*
sliceの長さは要素数。
sliceの容量は、sliceの元となる配列の要素数。
要素数を超えた参照や、容量を超えた拡張などはruntime errorが起きる
*/
func main() {
s := []int{2, 3, 5, 7, 11, 13}
printSlice(s)
// 要素数0のsliceを作成
s = s[:0]
printSlice(s)
// 要素を拡張。最初に定義した6以上は参照できない。
s = s[:4]
printSlice(s)
// 最初から2つの要素を削除
s = s[2:]
printSlice(... |
/*
Inputs:
Two single digits (let's call them m and n) and two chars (let's call them a and b) in your input format of choice.
Output:
For the walkthrough, pretend m=2, n=5, a='a', b='b'.
Your output will be a string built from your four inputs. Let's call the string result, with value "". First, concatenate a ont... |
package instapi
import (
"bytes"
"context"
"encoding/json"
"errors"
"fmt"
"io"
"net/http"
"net/url"
"os"
"path/filepath"
"strings"
"time"
"github.com/instapi/client-go/internal/csvutil"
"github.com/instapi/client-go/types"
"github.com/tomnomnom/linkheader"
)
// Instapi client constants.
const (
Defa... |
// Copyright (C) Microsoft Corporation.
package mssqlcommon
import (
"fmt"
"testing"
)
func TestDiagnose(t *testing.T) {
t.Parallel()
for _, system := range []bool{true, false} {
for _, resource := range []bool{true, false} {
for _, queryProcessing := range []bool{true, false} {
// Local copies of loop... |
package none
// Platform stores any global configuration used for generic
// platforms.
type Platform struct{}
|
package main
import (
"encoding/json"
)
func getJson(properties []string, data []string) (strResponse string) {
fields := map[string]string{}
for i, field := range properties {
fields[field] = data[i]
}
jsonBytes, err := json.MarshalIndent(fields, "", " ")
if err == nil {
strResponse = string(jsonBytes)
}
... |
package hcledit
import (
"io"
"io/ioutil"
"os"
"path/filepath"
"github.com/hashicorp/hcl/v2"
"github.com/hashicorp/hcl/v2/hclwrite"
)
// New constructs a new HCL file with no content which is ready to be mutated.
func New() (*HCLEditor, error) {
return &HCLEditor{
writeFile: hclwrite.NewEmptyFile(),
}, nil... |
package xtp_wrapper
/*
#cgo CFLAGS: -Wno-error=implicit-function-declaration -I../../C_porting_XTP/include/XTP -I../../C_porting_XTP/include/CXTPApi
#cgo LDFLAGS: -L../../C_porting_XTP/lib/CXTPApi -lCXTPApi -lxtpquoteapi -lxtptraderapi
#include <string.h>
#include "xtp_cmessage.h"
#include "LCxtp_trader_api.h"
*/
impo... |
package dispatcher
import (
"fmt"
)
type JsonRequest struct {
Login string `json:"login"`
Token string `json:"token"`
Method string `json:"method"`
Database string `json:"database"`
Collection string `json:"collection"`
Data interface{} `json:"data"`
}
func (r Js... |
package main
import "fmt"
type float float32
func main() {
var f float = 52.2
// var g float32 = 52.2
fmt.Printf("f has value %v and type %T\n", f, f)
// This trow an error (mismatched types float and float32)
// fmt.Println("f == g", f == g)
}
|
package main
import (
"fmt"
"gopkg.in/yaml.v2"
"io/ioutil"
"log"
"github.com/robbiemcmichael/auth-mux/internal/config"
)
func main() {
data, err := ioutil.ReadFile("config.yaml")
if err != nil {
log.Fatal(err)
}
var config config.Config
if err := yaml.Unmarshal(data, &config); err != nil {
log.Fatal(... |
/*
Boating season is over for this year, and Theseus has parked his boat on land. Of course, the boat looks nothing like it did as of the beginning of the season; it never does.
You see, Theseus is constantly looking for ways to improve his boat.
At every day of the boating season, Theseus bought exactly one type of ... |
package sort
import (
"fmt"
"testing"
"github.com/stretchr/testify/require"
)
func TestSort(t *testing.T) {
tests := []struct {
nums []int
want []int
}{
{
nums: []int{5, 9, 1, 6, 8, 14, 6, 49, 25, 4, 6, 3},
want: []int{1, 3, 4, 5, 6, 6, 6, 8, 9, 14, 25, 49},
},
{
nums: []int{5},
want: []in... |
package utils
import (
"time"
)
//获取唯一ID(serverId,seqId 小于2046 占11位)
func GetMessageId(serverId, seqId uint16) uint64 {
return uint64(time.Now().UnixNano()/1000000)<<22 | uint64(serverId)<<11 | uint64(seqId)
}
|
# https://leetcode.com/problems/kth-smallest-element-in-a-sorted-matrix/
- heap に一列つっこんで、そこから pop するごとに次の候補も heap に追加していく
- 実際には heap ぽいことを全探索で実現
- キューに入っているものを全て調べて最小を取り出している
- priority がついていないキューと同じ
- go にも標準でヒープパッケージがあったらしい
- https://golang.org/pkg/container/heap/
- インタフェースの実装から必要なので面倒だけど
- 正直ヒー... |
package ca
import (
"io/ioutil"
"reflect"
"testing"
"time"
)
func TestConfig(t *testing.T) {
conf, err := ioutil.ReadFile("testdata/root_ca.json")
if err != nil {
t.Fatal(err)
}
cfg, err := LoadConfig(conf)
if err != nil {
t.Fatal(err)
}
req := cfg.CertificateRequest()
if req.Name().CommonName != cf... |
package schema
import mapset "github.com/deckarep/golang-set"
import "encoding/json"
// SchemaGraph represent the graph of a source
type SchemaGraph struct {
Vertices mapset.Set
Edges mapset.Set
}
// SchemaGraphJSON is the json representation of a schema graph
type SchemaGraphJSON struct {
Vertices []AssetTyp... |
// Copyright 2017 The Fuchsia 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 ipcserver
import (
"fmt"
"log"
"strings"
"fidl/bindings"
"syscall/zx"
"syscall/zx/mxerror"
"garnet/amber/api/amber"
"amber/daemon"
"a... |
package string
import "strings"
// MakeUppercase transforms a string to all caps with an exclamation point
func MakeUppercase(s string) string {
return strings.ToUpper(s) + "!"
}
|
package main
import (
//"database/sql"
"encoding/json"
"fmt"
_ "github.com/go-sql-driver/mysql"
"io/ioutil"
"log"
"net/http"
"strconv"
"time"
)
type userData struct {
UserId int
NickName string
HeadUrl string
Gender byte
Age string
}
type shareJson str... |
// DRUNKWATER TEMPLATE(add description and prototypes)
// Question Title and Description on leetcode.com
// Function Declaration and Function Prototypes on leetcode.com
//357. Count Numbers with Unique Digits
//Given a non-negative integer n, count all numbers with unique digits, x, where 0 ≤ x < 10n.
//Example:
//Give... |
// Package rules contains useful pre-defined rego AST rules.
package rules
import "github.com/open-policy-agent/opa/ast"
// GetSession gets the session for the given id.
func GetSession() *ast.Rule {
return ast.MustParseRule(`
get_session(id) = v {
v = get_databroker_record("type.googleapis.com/user.ServiceAccount"... |
/*
EIGER is a brand-new, made-up computer language.
It’s very exciting, and very simple! EIGER only allows the programmer to do two things: define a name for an integer, and compare two names.
Write a metaprogram – a program which can simulate the EIGER language.
Input
Input consists of one command per line, up to 1... |
package enum
//前面统一加abana 防止与其他系统出现相同的key
const (
REDIS_KEY_USER_INFO = "abana_user_info_" //用户信息
)
|
package main
import (
"context"
"crypto/tls"
"crypto/x509"
"fmt"
"io/ioutil"
"net/http"
"net/url"
"os"
"os/signal"
"runtime"
"strings"
"syscall"
"time"
"github.com/alecthomas/kong"
"github.com/docker/libkv/store"
"github.com/docker/libkv/store/boltdb"
"github.com/docker/libkv/store/consul"
"github.c... |
package simulator
import (
"backend/api"
"math/rand"
"time"
)
type Simulator struct {
time int
game *api.Game
}
func SimulateGame(game *api.Game, timeScale float64) *Simulator {
sim := Simulator{
time: 0,
game: game,
}
t := time.Now()
game.StartsAt = &t
go fu... |
package main
import "fmt"
// https://leetcode-cn.com/problems/permutation-sequence/
// solution
// 基于 nextPermutation 的 solution1
// * 计算k对应的各位置的逆序对数
// * 根据逆序对数得出排列
func getPermutation(n int, k int) string {
if n == 0 {
return ""
}
if n == 1 {
return "1"
}
fac := []int{1, 1, 2, 6, 24, 120, 720, 5040, 4032... |
package lib
import (
"math/rand"
"strconv"
"time"
)
type Generator struct {
Operator string
Range int
}
func (gen *Generator) Init(operator string, limit int) {
gen.Operator = operator
gen.Range = limit
}
func swap(a, b *int) {
c := *a
*a = *b
*b = c
}
func (gen *Generator) Generate(Operand int) strin... |
package main
import "fmt"
func main() {
i := 7
inc(i) //We are passing a value so no change will be done to our original variable
fmt.Println(i)
//Through Pointers we can access the original variable through its memory address
increase(&i)
fmt.Println("After accessing through memory")
fmt.Println(i)
}
func i... |
package main
import "fmt"
func main() {
s1 := []string{"北京", "上海", "深圳"}
// s1[3] = "广州" //错误的写法 会导致编译错误:索引越界
// fmt.Pringln(s1)
s1 = append(s1, "武汉")
fmt.Printf("s1=%v,len(s1)=%d,cap(s1)=%d\n", s1, len(s1), cap(s1))
ss := [...]string{"重庆", "成都"}
s1 = append(s1, ss[:]...)
fmt.Printf("s1=%v,len(s1)=%d,cap(s1)=... |
package cve
import (
"glsamaker/pkg/models/bugzilla"
"glsamaker/pkg/models/gpackage"
"glsamaker/pkg/models/users"
"time"
)
// NVDFeed
type NVDFeed struct {
CVEDataFormat string `json:"CVE_data_format"`
// NVD adds number of CVE in this feed
CVEDataNumberOfCVEs string `json:"CVE_data_numberOfCVEs,omitempty"`
... |
package main
var rawHeaderLen int16 = 16
const (
ProtoTCP = 0
ProtoWebsocket = 1
ProtoWebsocketTLS = 2
)
|
// Copyright 2011 Google Inc. All rights reserved.
// Use of this source code is governed by the Apache 2.0
// license that can be found in the LICENSE file.
package counter
// [START push_queues_and_backends]
import (
"net/http"
"net/url"
"google.golang.org/appengine"
"google.golang.org/appengine/taskqueue"
)
... |
package model
import "fmt"
type Response interface {
IsError() bool
Error() string
}
type BaseResponse struct {
Code int `json:"code,omitempty"`
Msg string `json:"msg,omitempty"`
}
func (r BaseResponse) IsError() bool {
return r.Code != 0
}
func (r BaseResponse) Error() string {
return fmt.Sprintf("%d:%s... |
package worker
import (
"fmt"
"io/ioutil"
"net/http"
"net/http/httptest"
"os"
"testing"
"time"
"github.com/brainly/olowek/config"
"github.com/brainly/olowek/marathon"
"github.com/brainly/olowek/stats"
)
func TestNginxReloaderWorker(t *testing.T) {
c, server := newFakeMarathonClient(t, "./fixtures/marathon... |
package main
func Solve(string) bool {
}
func input() (str string) {
return
}
func main() {
Solve(input())
}
|
package kuber
import (
"bytes"
"context"
"fmt"
"time"
"github.com/MagalixTechnologies/core/logger"
"k8s.io/apimachinery/pkg/apis/meta/v1/unstructured"
"k8s.io/client-go/dynamic"
"k8s.io/client-go/dynamic/dynamicinformer"
"k8s.io/client-go/informers"
"k8s.io/client-go/tools/cache"
)
type Observer struct {
... |
package commands
import "github.com/spf13/cobra"
func Execute() {
var rootCmd = &cobra.Command{Use: "bro"}
rootCmd.AddCommand(getEchoCommand())
rootCmd.Execute()
}
|
package subscription
import (
"github.com/dennor/go-paddle/events/types"
"github.com/dennor/phpserialize"
)
const PaymentRefundedAlertName = "subscription_payment_refunded"
// PaymentRefunded refer to https://paddle.com/docs/subscriptions-event-reference/#subscription_payment_refunded
type PaymentRefunded struct {... |
package map_slice_array
import (
"fmt"
"gengine/builder"
"gengine/context"
"gengine/engine"
"testing"
"time"
)
type MapArray struct {
Mx map[string]bool
Ax [3]int
Sx []string
}
const ma_rule = `
rule "测试规则" "rule desc"
begin
x = Ma.Mx["hello"]
PrintName(x)
Ma.Mx["hello"] = false
b = "your"
... |
package main
import "testing"
func Test(t *testing.T) {
var tests = []struct {
arr []int
want int
}{
{[]int{}, 0},
{[]int{8, 4}, 1},
{[]int{8, 12, 4}, 2},
{[]int{8, 6, 1, 16, 4}, 6},
{[]int{2148, 9058, 7742, 3153, 6324, 609, 7628, 5469, 7017, 50}, 21},
}
for _, a := range tests {
got := QuickSort... |
package random
import (
"math/rand"
"time"
)
func GenerateRandomIntInRange(min, max int) int {
rand.Seed(time.Now().Unix())
randNum := rand.Intn(max - min) + min
return randNum
}
func GenerateRandomFloat() float64 {
rand.Seed(time.Now().Unix())
return rand.Float64()
}
func SleepWithDefaultRange() {
time.Slee... |
package wxgamevp
import (
"fmt"
"github.com/birjemin/wxgamevp/utils"
"github.com/spf13/cast"
"log"
)
// Balance model
type Balance struct {
OpenID string
AppID string
OfferID string
Ts int
ZoneID string
Pf string
UserIP string
AccessToken string
Secret ... |
package cli
import (
"github.com/ronaudinho/dot/api"
)
type App struct {
// printer
be api.Service
}
func NewApp(svc api.Service) *App {
return &App{
be: svc,
}
}
|
package utils
type NestedEntityError struct {
InnerError error
Code int
}
func (e NestedEntityError) Error() string {
return e.InnerError.Error()
}
|
// Copyright The OpenTelemetry Authors
// SPDX-License-Identifier: Apache-2.0
package pmetric // import "go.opentelemetry.io/collector/pdata/pmetric"
import (
"bytes"
"go.opentelemetry.io/collector/pdata/internal"
otlpmetrics "go.opentelemetry.io/collector/pdata/internal/data/protogen/metrics/v1"
"go.opentelemet... |
package config
import (
"errors"
"fmt"
"time"
)
//一些系统变量
const (
dZipkinAddr = ""
dConsulAddr = ""
dFileServerStaticPath = ""
dLocalIP = ""
dFileserverIP = ""
dFileserverPort = 0
dCIDir = ""
dLocalSSHPor... |
package main
import (
"log"
"net/smtp"
)
// var (
// subject = flag.String("s", "", "subject of the mail")
// body = flag.String("b", "", "body of themail")
// reciMail = flag.String("m", "", "recipient mail address")
// )
// func main() {
// // Set up authentication information.
// flag.Parse()
// sub ... |
package listener
import (
"app/base/utils"
"context"
"github.com/gin-gonic/gin"
"github.com/segmentio/kafka-go"
ginprometheus "github.com/zsais/go-gin-prometheus"
)
var (
uploadReader *kafka.Reader
eventsReader *kafka.Reader
)
func configure() {
uploadTopic := utils.GetenvOrFail("UPLOAD_TOPIC")
eventsTopic ... |
/*
* @lc app=leetcode.cn id=4 lang=golang
*
* [4] 寻找两个正序数组的中位数
*/
package solution
import "math"
// @lc code=start
func findMedianSortedArrays(nums1, nums2 []int) float64 {
totalLen := len(nums1) + len(nums2)
var pos1, pos2 int
if totalLen%2 == 0 {
pos1, pos2 = totalLen/2-1, totalLen/2
} else {
pos1, pos... |
package action
import (
"context"
"log"
"github.com/artemrys/go-all-repos/internal/config"
"github.com/artemrys/go-all-repos/internal/helpers"
"github.com/artemrys/go-all-repos/internal/repo"
"github.com/google/go-github/github"
)
// GoFmtAction declares "go fmt" action.
type GoFmtAction struct {
Repo ... |
package configuration
import (
"flag"
"reflect"
)
func NewFlagProvider(ptrToCfg interface{}) flagProvider {
fp := flagProvider{flags: map[string]func() *string{}}
fp.initFlagProvider(ptrToCfg)
flag.Parse()
return fp
}
type flagProvider struct {
flags map[string]func() *string
}
func (fp flagProvider) initFla... |
package main
import (
"log"
"math/rand"
"reflect"
)
type color int
const (
red color = iota
green
blue
black
white
)
type person struct {
name string
age int
favoriteColor color
}
func (p person) Generate(rand *rand.Rand, size int) reflect.Value {
randomP := person{
name: ... |
package endpoints
import (
"context"
"encoding/json"
"fmt"
"net/http"
"time"
"github.com/go-kit/kit/endpoint"
kithttp "github.com/go-kit/kit/transport/http"
"github.com/google/uuid"
"github.com/gorilla/mux"
"github.com/sumelms/microservice-course/internal/matrix/domain"
"github.com/sumelms/microservice-co... |
// Copyright 2018 Andrew Bates
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in wri... |
package offer_merge
import "testing"
func TestSolve(t *testing.T) {
a := []int{1, 2, 5, -1, -1}
merge(a, []int{3, 8}, 3)
t.Log(a)
}
|
package main
import (
"archive/zip"
"encoding/xml"
"fmt"
"io"
// "strings"
)
func main() {
r, err := zip.OpenReader("Document.docx")
if err != nil {
panic(err)
}
defer r.Close()
// Iterate through the files in the archive
for _, f := range r.File {
//fmt.Printf("File %s\n", f.Name)
switch {
case ... |
package main
import (
"fmt"
"io"
"io/ioutil"
"log"
"net/http"
"os"
"strings"
"github.com/gorilla/mux"
)
var (
outputDir = "files"
)
func main() {
http.Handle("/", handlers())
log.Printf("Listening on port 8080 ...")
log.Fatal(http.ListenAndServe(":8080", nil))
}
func handlers() *mux.Router {
r := mux... |
package main
import (
"fmt"
"os"
"os/signal"
"strings"
suggest "github.com/picatz/suggest/core"
)
func init() {
c := make(chan os.Signal, 1)
signal.Notify(c, os.Interrupt)
go func() {
for range c {
os.Exit(0)
}
}()
}
var (
StatusNoArgs = 1
StatusGetErr = 2
StatusNoSuggestions = 3
)
... |
package mclock
import (
"time"
"github.com/aristanetworks/goarista/monotime"
)
// AbsTime represents absolute monotonic time.
type AbsTime time.Duration
// Now returns the current absolute monotonic time.
func Now() AbsTime {
return AbsTime(monotime.Now())
}
|
package routes
import (
"github.com/labstack/echo"
"github.com/prometheus/client_golang/prometheus/promhttp"
// HOFSTADTER_START import
// HOFSTADTER_END import
)
// HOFSTADTER_START start
// HOFSTADTER_END start
func addPrometheusHandlers(G *echo.Group) (err error) {
group := G.Group("")
group.GET("/met... |
package main
import (
"bytes"
"flag"
"fmt"
"io/ioutil"
"log"
"math"
"os"
"regexp"
"strconv"
"strings"
"github.com/christopherL91/Parser/toki"
)
type instruction struct {
name string
val int
color string
instructions []instruction
}
const (
NUMBER toki.Token = iota + 1
STRING... |
package main
func main() {
var v interface{}
v = v
}
|
package util
import (
"unicode"
"github.com/Nv7-Github/Nv7Haven/eod/types"
)
func IsASCII(s string) bool {
for i := 0; i < len(s); i++ {
if s[i] > unicode.MaxASCII {
return false
}
}
return true
}
var Wildcards = map[rune]types.Empty{
'%': {},
'*': {},
'?': {},
'[': {},
']': {},
'!': {},
'-': {},... |
package dump
import (
"strings"
"testing"
)
type (
Integer int
String string
StringPtr *string
StringAlias = string
car struct {
Speed int
Owner interface{}
}
Person struct {
Name String
age int
Interests []string
friends [4]*Person
Cars []*car
action []func() string
... |
package models
// Employees export functions
type Employees struct {
ID int64 `form:"id" json:"id"`
Name string `form:"name" json:"name"`
City string `form:"city" json:"city"`
Phone string `form:"phone" json:"phone"`
}
// EmployeeResponse export functions
type EmployeeResponse struct {
Status int `json... |
package extract
import (
"log"
"os"
"os/exec"
"path/filepath"
"sync"
"testing"
"time"
"github.com/gamejolt/joltron/test"
)
const (
xzFile = ".gj-bigTempFile.tar.xz"
xzURL = test.AWS + xzFile
xzChecksum = "ca292a1cfa2d93f6e07feffa6d53e836"
gzipFile = ".gj-bigTempFile.tar.gz"
gzipURL = ... |
package mytest
import (
"fmt"
"regexp"
"testing"
"time"
)
func TestSplit(t *testing.T) {
ucmValue := "TH,CN"
vals := regexp.MustCompile("\\s*,\\s*").Split(ucmValue, -1)
fmt.Println(vals)
}
func TestArrayDefault(t *testing.T) {
input := []interface{}{}
if nil == input {
fmt.Println("is nil")
}
}
func Test... |
package util
import (
"encoding/json"
"fmt"
"io"
"io/ioutil"
"log"
"net/http"
"os"
"path/filepath"
"reflect"
"strings"
)
const CDNJS_API_URL = "https://api.cdnjs.com/libraries"
const CDNJS_AJAX_URL = "http://cdnjs.cloudflare.com/ajax/libs"
// GenerateLink - Generate download link of the lib
func GenerateLi... |
package html
import (
"fmt"
"io"
)
const (
defaultBackground = "white"
defaultForeground = "black"
headingBackground = "#f0f0f0"
highlightBackground = "#fafafa"
)
func newTableWriter(writer io.Writer, doHighlighting bool,
columns []string) (*TableWriter, error) {
if len(columns) > 0 {
if doHighlighti... |
package doc
import (
"fmt"
)
type swaggerInfo struct {
Version string
Host string
BasePath string
Schemes []string
Title string
Description string
}
// SwaggerInfo holds exported Swagger Info so clients can modify it
var SwaggerInfo = swaggerInfo{
Version: "1.0",
Host: "",... |
package main
import (
"InkaTry/warehouse-storage-be/cmd/webservice"
"InkaTry/warehouse-storage-be/internal/pkg/config"
"InkaTry/warehouse-storage-be/internal/pkg/logger"
"gopkg.in/ini.v1"
"log"
"math/rand"
"os"
"os/signal"
"syscall"
"time"
)
func main() {
// if in the future some random number is needed, ... |
package config
import (
"github.com/iikmaulana/gateway/libs/helper/serror"
"github.com/iikmaulana/uzzeet-api/controller"
"github.com/iikmaulana/uzzeet-api/service/handler"
"github.com/iikmaulana/uzzeet-api/service/repository/core"
)
func (cfg Config) InitService() serror.SError {
vehiclesRepo, serr := core.NewV... |
package ircserver
func init() {
// These just use exactly the same code as clients. We can directly assign
// the contents of Commands[x] because cmd_ping.go is sorted lexically
// before scmd_ping.go. For details, see
// http://golang.org/ref/spec#Package_initialization.
Commands["server_PING"] = Commands["PING"... |
package main
import "fmt"
type Customer struct {
Name, Address string
Age int
}
func main() {
var customer Customer
customer.Age = 25
customer.Address = "Jakarta"
customer.Name = "Nabil"
fmt.Println(customer)
// Struct Literal 1
joko := Customer{
Name: "Joko",
Address: "Bandung",
Age: 22,
}
fmt.P... |
package ibmcloud
import (
"context"
"errors"
"fmt"
"github.com/IBM/vpc-go-sdk/vpcv1"
"k8s.io/apimachinery/pkg/util/sets"
"k8s.io/apimachinery/pkg/util/validation/field"
"github.com/openshift/installer/pkg/types"
"github.com/openshift/installer/pkg/types/ibmcloud"
)
// Validate executes platform-specific val... |
package xbase
import (
"bytes"
"crypto/md5"
"encoding/hex"
"fmt"
"io/ioutil"
"os"
"strings"
"testing"
)
const (
dbPath = "/tmp/xbase"
tmpPath = "/tmp/xbase_tmp.txt"
tmpPath2 = "/tmp/xbase_tmp2.txt"
)
func TestPut(t *testing.T) {
xb := NewXBase(dbPath, nil)
defer xb.Close()
k := []byte("a")
v := []b... |
package model
import (
"strings"
"regexp"
)
type Manifest struct {
Team string `yaml:"team"`
Repo Repo `yaml:"repo"`
Tasks []Task `yaml:"tasks"`
}
type Repo struct {
Uri string `yaml:"uri"`
PrivateKey string `yaml:"private_key"`
}
func (r Repo) RepoName() string {
if strings.HasPrefix(r.Uri, "git... |
package personinfor
import "fmt"
type Personinfor struct {
Name string // name字段可以随便访问~~就大写
age int // age 不可以随意访问,所以小写~~~
salary float64 // salary 保密也小写~~
}
func NewPerson(name string) *Personinfor {
// 新建一个人名字~~~只有名字~~其他内容都系统默认~0
return &Personinfor{
Name: name,
}
}
//为了访问age和salary所以需要对这两个函数进行... |
package main
import (
"encoding/json"
"fmt"
"os"
)
type Config struct {
WebServerPort int `json:"web_server_port"`
BaseUri string `json:"base_uri"` // without a trailing slash
RedisEndpoint string `json:"redis_endpoint"`
RedisPassword string `json:"redis_password"`
KeyCategories string `jso... |
package middleware_test
import (
"testing"
. "github.com/onsi/ginkgo"
. "github.com/onsi/gomega"
)
func TestEnvoyMiddlewareSuite(t *testing.T) {
RegisterFailHandler(Fail)
RunSpecs(t, "Envoy Middleware Suite")
}
|
package main
import (
"bytes"
"encoding/json"
"fmt"
"os"
"os/exec"
"sort"
"time"
)
func main() {
target := os.Args[1]
deployment := os.Args[2]
cmd := exec.Command("bosh", "-e", target, "-d", deployment, "vms", "--vitals", "--json")
j, err := cmd.Output()
if err != nil {
panic("Could not run command: " ... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.