text stringlengths 11 4.05M |
|---|
package main
import (
"encoding/json"
"fmt"
"github.com/aws/aws-lambda-go/events"
"github.com/aws/aws-lambda-go/lambda"
"github.com/aws/aws-sdk-go/aws"
"github.com/aws/aws-sdk-go/aws/session"
"github.com/aws/aws-sdk-go/service/sqs"
"io/ioutil"
"log"
"net/http"
"strings"
"time"
)
var (
content string
dat... |
package main
import "tesou.io/platform/brush-parent/brush-core/launch"
func main() {
//生成数据库表
launch.GenTable()
////清空数据表
//launch.TruncateTable()
}
|
package sese
import (
"encoding/xml"
"github.com/thought-machine/finance-messaging/iso20022"
)
type Document02600101 struct {
XMLName xml.Name `xml:"urn:iso:std:iso:20022:tech:xsd:sese.026.001.01 Document"`
Message *SecuritiesSettlementTransactionReversalAdviceV01 `xml:"S... |
package postal_test
import (
"bytes"
"log"
"github.com/cloudfoundry-incubator/notifications/cf"
"github.com/cloudfoundry-incubator/notifications/fakes"
"github.com/cloudfoundry-incubator/notifications/postal"
"github.com/pivotal-cf/uaa-sso-golang/uaa"
. "github.com/onsi/ginkgo"
. "git... |
package main
import (
"casbin-gorm/middleware"
"casbin-gorm/model"
"fmt"
"gorm.io/driver/mysql"
"gorm.io/gorm"
"net/http"
"time"
"github.com/gin-gonic/gin"
gormAdapter "github.com/casbin/gorm-adapter/v3"
)
var authorities = []model.Authority{
{ID: "1", CreatedAt: time.Now(), UpdatedAt: time.Now(), Name: "... |
package controller
import (
"context"
"log"
"github.com/mongodb/mongo-go-driver/bson/primitive"
pb "github.com/SaiNageswarS/builder-factory/model/services"
"github.com/SaiNageswarS/builder-factory/services/dao"
"github.com/SaiNageswarS/builder-factory/services/db"
odm "github.com/SaiNageswarS/mongo-odm"
)
//... |
package golang_map_vs_slice_search_benchmark
type MapIndex map[string]int64
func (m MapIndex) Add(name string, value int64) {
m[name] = value
}
func (m MapIndex) Find(name string) (value int64, found bool) {
value, found = m[name]
return
}
|
package vac
import (
"bytes"
"context"
"errors"
"fmt"
venti "sigint.ca/venti2"
)
func ReadRoot(ctx context.Context, br venti.BlockReader, root *venti.Root) (*File, error) {
entryBuf := make([]byte, 3*venti.EntrySize)
n, err := br.ReadBlock(ctx, root.Score, venti.DirType, entryBuf)
if err != nil {
return ni... |
package api
import (
"compress/gzip"
"database/sql"
"encoding/json"
"fmt"
"io"
"io/ioutil"
"log"
"os"
"strconv"
"strings"
"sync"
_ "github.com/go-sql-driver/mysql"
)
var (
nvdURI = "https://nvd.nist.gov/feeds/json/cve/1.0/nvdcve-1.0-%d.json.gz"
MySQLUserName string
MySQLPassword string
MySQLIP... |
/*
Copyright IBM Corporation 2020
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
di... |
package main
import "fmt"
type Vertex struct {
X int
Y int
}
// 分配方式
var (
v1 = Vertex{1, 2} // 类型为 Vertex
v2 = Vertex{X: 1} // Y:0 被省略
v3 = Vertex{} // X:0 和 Y:0
p1 = &Vertex{1, 2} // 类型为 *Vertex
)
func main() {
fmt.Println(Vertex{1, 2})
v := Vertex{1, 2}
fmt.Printf("%#v\n", v)
v.X = 4
fmt.Prin... |
package main
import (
"bytes"
"io/ioutil"
"log"
"net/http"
"strconv"
"sync"
"sync/atomic"
"time"
lua "github.com/yuin/gopher-lua"
luajson "layeh.com/gopher-json"
)
func request(method, url string, body []byte, l *lua.LState, v *Job) (bts []byte, err error) {
t := time.Now().UnixNano() / 1e6
if int64(atom... |
package main
import (
"fmt"
"github.com/Shopify/sarama"
)
// 基于sarama第三方库开发的Kafka client
func main() {
config := sarama.NewConfig()
// tailf包使用,发送完数据需要 leader 和 follow都确定
config.Producer.RequiredAcks = sarama.WaitForAll
// 新选出一个partition
config.Producer.Partitioner = sarama.NewRandomPartitioner
// 成功交付的消息将在 ... |
package oiio
/*
#include "stdlib.h"
#include "imagebufalgo.h"
*/
import "C"
import (
"errors"
"fmt"
"runtime"
"unsafe"
)
const (
// Let OIIO choose the best filter
FilterDefault = ""
// Let OIIO choose the best filter and filter width
FilterDefaultWidth = 0.0
// Use a default system font
FontNameDefault ... |
package main
import (
"fmt"
//"sort"
// "strings"
)
func main() {
text := "ABCd"
//count := 0
temp := ""
largestWord := ""
var wordArray []string
//textArray := strings.Split(text, " ")
for _, x := range text {
if string(x) >= "a" && string(x) <= "z" || string(x) >= "A" && string(x) <= "Z" {
temp +=... |
package user
import (
// "github.com/MerinEREN/iiPackages/datastore/phone"
"time"
)
/*
Go's declaration syntax allows grouping of declarations. A single doc comment can introduce
a group of related constants or variables. Since the whole declaration is presented, such
a comment can often be perfunctory.
*/
// User... |
package ovirt
import (
"fmt"
"github.com/AlecAivazis/survey/v2"
ovirtsdk "github.com/ovirt/go-ovirt"
"github.com/pkg/errors"
"github.com/sirupsen/logrus"
"k8s.io/apimachinery/pkg/util/validation/field"
"github.com/openshift/installer/pkg/types"
"github.com/openshift/installer/pkg/types/ovirt"
"github.com/op... |
package chaos
import (
"bytes"
"sync"
)
var bbFree = sync.Pool{}
func ByteBufferPoolGet() *bytes.Buffer {
if buf := bbFree.Get(); buf != nil {
return buf.(*bytes.Buffer)
} else {
return &bytes.Buffer{}
}
}
func put(b *bytes.Buffer) { bbFree.Put(b) }
func BytesBufferPoolFree(b *bytes.Buffer) {
b.Reset()
... |
//二分法查找 Binary Search
package main
import (
"fmt"
"sort"
)
func rank(key int, num []int) int {
lo := 0
hi := len(num)
mid := (hi + lo)/2
for lo <= hi {
if key < num[mid] {
hi = mid -1
}else if key > num[mid] {
lo = mid + 1
}else {
return mid
}
}
return -1
}
func main() {
num := []int{11,... |
package web
import (
"net/http"
"github.com/steam-authority/steam-authority/db"
"github.com/steam-authority/steam-authority/logging"
)
func NewsHandler(w http.ResponseWriter, r *http.Request) {
articles, err := db.GetArticles(0, 100)
if err != nil {
logging.Error(err)
returnErrorTemplate(w, r, 500, "Error ... |
/*
*************************************************
Synopsis: Simple Fortune cookie api
Date: 16 December 2018
Usage:
- $URL/fortune
- $URL/cow
- $URL/tux
- $URL/tuxtips
To Do:
* create common interface for exec function
* add figlet support
*************************************************
*/
package main
... |
//My first Go program.
package main
//Equivalent of C's import<stdio.h>
import "fmt"
//Where magic happens. :P
func main() {
//Customary Hello World Message:
fmt.Println("Hello World")
//Declaring some variables:
var age int = 40
var frac float64 = 3.14
var myName = "Harsh"
//assignment requires the :=... |
// Copyright 2020 IOTA Stiftung
// SPDX-License-Identifier: Apache-2.0
package coretypes
import (
"fmt"
"github.com/iotaledger/wasp/packages/kv/dict"
)
// package present processor interface. It must be implemented by VM
// Processor is a abstract interface to the VM processor instance.
type Processor interface ... |
package bertymessenger
import (
"errors"
"testing"
"github.com/stretchr/testify/require"
"go.uber.org/multierr"
)
func TestDispatcher(t *testing.T) {
d := NewDispatcher()
called := false
var n NotifieeBundle
const errStr = "Test error"
n.StreamEventImpl = func(*StreamEvent) error {
called = true
return... |
package csv_test
import (
"reflect"
"strings"
"testing"
"github.com/nylo-andry/playupdate/csv"
)
type testCase struct {
in string
out []string
}
func TestReadFile(t *testing.T) {
testCases := []testCase{
{"", []string{}},
{"mac_addresses, id1, id2, id3", []string{}},
{`mac_addresses, id1, id2, id3
a1:... |
package main
import (
"fmt"
)
func average(slice []float64) float64{
size := float64(len(slice))
if size == 0 {
return float64(0.0)
}
var sum float64 = 0.0
for _, val := range slice {
sum += val
}
return sum / size
}
func main() {
slice := []float64{1.9, 2.8, 3.7, 4.6, 5.5, 6.4, 7.3, 8.2, 9... |
// Existem dois times de futebol, o time amarelo e o time vermelho. O time amarelo tem 5 jogadores (Fernando, João, Lúcia, Mariana e Ana) e o time vermelho tem 4 jogadores (Helena, Jonas, José e Juliana).
// 1) Crie um array de string para cada time e nomeie com o nome do time.
// 2) Printe na tela os nomes dos jogador... |
package cli
import (
"encoding/hex"
"fmt"
"strings"
"github.com/spf13/cobra"
"github.com/cosmos/cosmos-sdk/client"
"github.com/cosmos/cosmos-sdk/client/context"
"github.com/cosmos/cosmos-sdk/client/flags"
"github.com/cosmos/cosmos-sdk/codec"
"github.com/cosmos/cosmos-sdk/version"
"github.com/irismod/htlc/... |
package content
import (
"emailSender/db"
"github.com/go-playground/validator"
"github.com/gofiber/fiber/v2"
)
type postInfo struct {
Heading string `json:"heading" validate:"required,min=2"`
Content string `json:"content" validate:"required,min=2"`
Author string `json:"author" validate:"required,min=2"`
Nonc... |
package cmds
import (
"os"
"github.com/urfave/cli"
"github.com/ayufan/docker-composer/helpers"
)
var dockerImage = os.Getenv("DOCKER_IMAGE")
func runUpgradeCommand(c *cli.Context) error {
cmd := helpers.Docker("pull", dockerImage)
cmd.Stdout = os.Stdout
return cmd.Run()
}
func init() {
if dockerImage != ""... |
package actions
import (
"net/http"
"github.com/nerdynz/datastore"
flow "github.com/nerdynz/flow"
"github.com/nerdynz/schwifty/backend/server/models"
)
// NewTask Route
func NewTask(w http.ResponseWriter, req *http.Request, ctx *flow.Context, store *datastore.Datastore) {
siteULID, err := ctx.SiteULID()
if err... |
// Licensed to SolID under one or more contributor
// license agreements. See the NOTICE file distributed with
// this work for additional information regarding copyright
// ownership. SolID licenses this file to you under
// the Apache License, Version 2.0 (the "License"); you may
// not use this file except in compli... |
// 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 server_test
import (
"context"
"testing"
"time"
"github.com/gogo/googleapis/google/rpc"
"github.com/gogo/protobuf/proto"
"github.com/gogo/protobuf/types"
"github.com/golang/mock/gomock"
"google.golang.org/grpc/codes"
"google.golang.org/grpc/status"
pbExample "github.com/gogo/grpc-example/proto"
"g... |
package utils
import (
"encoding/json"
"fmt"
"net/http"
"os"
"strconv"
"github.com/aws/aws-lambda-go/events"
"github.com/gemcook/pagination-go"
)
// NewResponse はレスポンス情報を返す
func NewResponse(body string, statusCode int, optionalHeaders ...map[string]string) (events.APIGatewayProxyResponse, error) {
// ヘッダーを設... |
package heatsapi
import (
"encoding/json"
"fmt"
"net/http"
"github.com/gorilla/mux"
"github.com/wjase/crowdscore/apis"
"github.com/wjase/crowdscore/db"
)
// ConfigureRouting - configure paths for this api
func ConfigureRouting(router *mux.Router) {
router.PathPrefix("/heats/{slug}").
Methods("GET").
Han... |
// chan project doc.go
/*
chan document
*/
package main
|
package main
import (
"os"
)
var hint = map[int]string{
1: "semicolons http://golang.org/doc/go_spec.html#Semicolons",
2: "multi line string use backquote" +
"\n `line 1" +
"\n line 2`" +
"\n for string include backquote use strings.Replace(`.X..`,\"X\",\"'\",-1)" +
"\n or use \"line 1\"+" +
"\n ... |
// Package nullconn holds a null connection that satisfies interfaces.Bot
package nullconn
import (
"awesome-dragon.science/go/goGoGameBot/internal/interfaces"
"awesome-dragon.science/go/goGoGameBot/pkg/log"
)
// New creates a new NullConn for use with a bot
func New(l *log.Logger) *NullConn {
return &NullConn{l, ... |
package main
import (
"fmt"
)
func main() {
var numberUint8 uint8 = 10 // uint8 0 ↔ 255
fmt.Println(numberUint8)
}
|
package server
import (
"archive/tar"
"compress/gzip"
"io"
"io/ioutil"
"os"
"os/exec"
"path"
"path/filepath"
"strings"
"time"
"github.com/pkg/errors"
)
type fileInformation struct {
Name string
Size int64
Mtime time.Time
}
func untarAll(reader io.Reader, options *UpstreamOptions) error {
gzr, err :... |
package services
import "github.com/cloudfoundry-incubator/notifications/models"
type PreferencesBuilder map[string]map[string]map[string]interface{}
func NewPreferencesBuilder() PreferencesBuilder {
return map[string]map[string]map[string]interface{}{}
}
func (pref PreferencesBuilder) Add(preference models.Pre... |
package main
import (
"context"
"fmt"
"os"
"github.com/serverless/better/lib/model"
"github.com/aws/aws-sdk-go/aws/awserr"
"github.com/aws/aws-sdk-go/service/cognitoidentityprovider/cognitoidentityprovideriface"
"github.com/aws/aws-lambda-go/lambda"
"github.com/aws/aws-sdk-go/aws"
"github.com/aws/aws-sdk-g... |
package main
import (
"context"
"errors"
cli "github.com/jawher/mow.cli"
"github.com/ozbe/wom"
)
type CmdSvc struct {
getSvc func(context.Context, string) string
}
func (c CmdSvc) Cmd(i wom.Input, o wom.Output) cli.CmdInitializer {
return func(cmd *cli.Cmd) {
cmd.Command("get", "", func(cmd *cli.Cmd) {
n... |
// Package rand provides several utility functions using the math.rand package.
package rand
import (
"github.com/cyfdecyf/goutil"
"math/rand"
"time"
)
func init() {
rand.Seed(time.Now().UnixNano())
}
// Rand returns a pseudo-random number in [l, h).
// It panics if l >= h.
func Rand(l, h int) int {
if l >= h {... |
// Copyright 2015-2018 trivago N.V.
//
// 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 ... |
// Copyright 2020 MongoDB 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 in... |
package main
import
// buffered output
"net/http"
func main() {
//http.Handle("/", new(MyHandler))
// MUX: Creates a new thread
http.ListenAndServe(":8000", http.FileServer(http.Dir("public")))
}
//
// //MyHandler struct wrapper for http.Handler
// type MyHandler struct {
// http.Handler
// }
//
// //ServeHTTP ... |
package models
import "time"
type BankBalanceHistory struct {
ID int `gorm:"primary_key" json:"id"`
BankBalanceID int `gorm:"column:bank_balance_id"` //`gorm:"foreignkey:ID"`
BalanceBefore int `gorm:"column:balance_before;not null;default:0;type:int"`
BalanceAfter int `gorm:"column:balance_after;n... |
package main
import (
"flag"
"fmt"
"github.com/justfallingup/gocore/hw04-gosearch01binary/pkg/crawler"
"github.com/justfallingup/gocore/hw04-gosearch01binary/pkg/crawler/spider"
"github.com/justfallingup/gocore/hw04-gosearch01binary/pkg/index"
"log"
"sort"
"strings"
)
func main() {
token := flag.String("s",... |
/* SPDX-License-Identifier: Apache-2.0
* Copyright (c) 2019-2020 Intel Corporation
*/
package ngcnef
import (
"context"
"errors"
)
const correlationIDOffset = 20
const subNotFound string = "Subscription Not Found"
const pfdNotFound string = "PFD transaction Not Found"
const appNotFound string = "Application in PF... |
package cmd
import (
"fmt"
"github.com/bitmaelum/bitmaelum-suite/cmd/bm-config/internal/fileio"
"github.com/bitmaelum/bitmaelum-suite/cmd/bm-config/internal/letsencrypt"
"github.com/bitmaelum/bitmaelum-suite/internal/config"
"github.com/spf13/cobra"
"os"
"path/filepath"
"strconv"
"time"
)
// letsEncryptCmd r... |
package sortsets
import (
"github.com/emirpasic/gods/lists/arraylist"
"github.com/emirpasic/gods/maps/hashmap"
"github.com/emirpasic/gods/utils"
)
import (
"errors"
"time"
// "fmt"
)
type SSet struct {
list *(arraylist.List) `简单切片列表`
m *(hashmap.Map) `has... |
package schedule
import (
"testing"
"time"
)
func TestCron(t *testing.T) {
now, _ := time.Parse("2006-01-02", "2015-01-01")
testCases := []struct {
cronLine string
expected time.Time
}{
{
cronLine: "30 * * * *",
expected: now.Add(30 * time.Minute),
},
{
cronLine: "* 2 * * *",
expected: now.... |
package main
import (
"Open_IM/internal/msg_transfer/logic"
"sync"
)
func main() {
var wg sync.WaitGroup
wg.Add(1)
logic.Init()
logic.Run()
wg.Wait()
}
|
package floc
import "sync"
/*
State is the container of data shared amongst jobs. Depending on
implementation the data can be thread-safe or not.
The state is aware of possible implementation of Releaser interface by contained
data. So if the contained data implements Releaser call to state.Release() will
be propaga... |
package activity
import (
"testing"
"github.com/aws/aws-sdk-go/service/swf"
)
func TestHandler(t *testing.T) {
handler := NewActivityHandler("activity", Handler)
ret, err := handler.HandlerFunc(&swf.PollForActivityTaskOutput{}, &TestInput{Name: "testIn"})
if ret.(*TestOutput).Name != "testInOut" {
t.Fatal("No... |
/*
Package extractor has the interface to extract data from a gin.Context and validate the result.
*/
package extractor
import (
"errors"
"fmt"
"github.com/gin-gonic/gin"
)
// Extractor interface can be implemented by struct that have the Extract and Validate methods.
type Extractor interface {
Extract(c *gin.Con... |
package sheet_logic
import (
"hub/sheet_logic/sheet_logic_types"
)
type And BoolComparator
func NewAnd(name string) *And {
tmp := NewBoolComparator(
name,
sheet_logic_types.And,
func(a bool, b bool) bool { return a && b })
return (*And)(tmp)
}
|
package main
import "C"
// go build -buildmode=c-shared -o path/test.so path/main.go
import (
"fmt"
"C"
)
/* 定义结构体 */
type Circle struct {
Radius float64
}
//该 method 属于 Circle 类型对象中的方法
func (c Circle) getArea() float64 {
//c.Radius 即为 Circle 类型对象中的属性
return 3 * c.Radius * c.Radius
}
func (c Circle) ... |
package hpx
import (
"fmt"
"strings"
"github.com/gin-gonic/gin"
"github.com/gin-gonic/gin/binding"
ut "github.com/go-playground/universal-translator"
"github.com/go-playground/validator/v10"
"github.com/pkg/errors"
"github.com/thoohv5/template/pkg/hpx/middleware"
pkgvalidator "github.com/thoohv5/template/pk... |
package affine_test
import (
"testing"
"github.com/mkamadeus/cipher/cipher/affine"
)
func TestDecrypt(t *testing.T) {
cipher := "CZOLNE"
expected := "KRIPTO"
encrypted := affine.Decrypt(cipher, 7, 10)
if encrypted != expected {
t.Fatalf("affine encryption failed, expected %v, found %v", expected, encrypted... |
package responses
import (
"encoding/json"
"net/http"
"github.com/ybbus/jsonrpc"
)
// this is the message to show when authentication info is required but was not provided in the request
// this is NOT the message for when auth info is provided but is not correct
const AuthRequiredErrorMessage = "authentication r... |
/*
Given an array and a set, return a sorted array with its items in ascending order but prioritize the elements in the set over the other items in the array.
Examples
prioritySort([5, 4, 3, 2, 1], new Set([2, 3])) ➞ [2, 3, 1, 4, 5]
prioritySort([5, 4, 3, 2, 1], new Set([3, 6])) ➞ [3, 1, 2, 4, 5]
prioritySort([-5, ... |
package actions
import (
"strings"
"github.com/barrydev/api-3h-shop/src/common/connect"
"github.com/barrydev/api-3h-shop/src/common/response"
"github.com/barrydev/api-3h-shop/src/factories"
"github.com/barrydev/api-3h-shop/src/model"
)
func GetListWarranty(queryWarranty *model.QueryWarranty) (*response.DataList... |
package main
import (
"encoding/binary"
"fmt"
"github.com/rs/zerolog"
"github.com/rs/zerolog/log"
"github.com/xtaci/smux"
"net"
"net/http"
"runtime"
"sync"
)
var pool sync.Pool
func init() {
if runtime.GOOS == "windows" {
//windows机器设置为debug级别
zerolog.SetGlobalLevel(zerolog.DebugLevel)
} else {
zero... |
package main
import (
"flag"
"fmt"
"github.com/kyokomi/lottery"
)
func lot() string {
if lottery.NewDefault().LotOf(1, 40) {
return "あたり"
}
return "はずれ"
}
func main() {
count := flag.Int("count", 1, "")
flag.Parse()
for i := 0; i < *count; i++ {
fmt.Println(lot())
}
}
|
package backtracking
import (
"fmt"
"testing"
)
func Test_letterCombinations(t *testing.T) {
// res := letterCombinations("23")
res := letterCombinations2("23")
if len(res) != 9 {
t.Error("error")
}
fmt.Println(res)
}
|
package main
import "fmt"
type Node struct {
Left *Node
Value int
Right *Node
}
func createNode(value int) *Node {
node := new(Node)
node.Left = nil
node.Value = value
node.Right = nil
return node
}
func lca(root *Node, v1 int, v2 int) *Node {
if v1 < root.Value && v2 < root.Value { return lca(root.Left, v... |
package main
import "fmt"
func main() {
// Go 中所有函数参数传递都是值拷贝。
// 但参数是map, slice, chan等类型时,在函数中修改参数的值也是会影响源参数的内容,
// 因为它们是引用类型,存储的是值的地址,所以当函数修改参数时,自然也就修改了底层的值
s := []string{"1", "2", "3"}
fmt.Printf("调用前指针: %p, s[1]指针: %p\n", &s, &s[1])
test2(s)
fmt.Println("s: ", s) // [1 6 3]
m := map[string]... |
// Copyright The OpenTelemetry Authors
// SPDX-License-Identifier: Apache-2.0
package plogotlp // import "go.opentelemetry.io/collector/pdata/plog/plogotlp"
import (
"bytes"
otlpcollectorlog "go.opentelemetry.io/collector/pdata/internal/data/protogen/collector/logs/v1"
"go.opentelemetry.io/collector/pdata/plog/in... |
package catalog
import (
"testing"
"github.com/stretchr/testify/assert"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
)
func TestMergedOwnerReferences(t *testing.T) {
var (
True = true
False = false
)
for _, tc := range []struct {
Name string
In [][]metav1.OwnerReference
Out []metav1.OwnerRefer... |
package view
import (
"log"
"net/http"
"strings"
"go.sancus.dev/web"
"go.sancus.dev/web/errors"
)
func (v *View) pageInfo(r *http.Request) (web.Handler, bool) {
path := v.config.GetRoutePath(r)
log.Printf("%+n: %s", errors.Here(), path)
if p, ok := v.pageSitemap(path); ok {
return p, true
} else if p, ok... |
package frappe_api
import (
"context"
"log"
)
// Server represents the gRPC server
type Server struct {
}
// SayHello generates response to a Ping request
func (s *Server) Brew(ctx context.Context, in *CoffeeOrder) (*Coffee, error) {
log.Printf("Received order for coffee of type %s", in.Coffee)
return in.Coffee,... |
package httpserver
import (
"errors"
"fmt"
"io/ioutil"
"net/http"
)
func LoadPage(w http.ResponseWriter, r *http.Request) error {
page, err := ioutil.ReadFile("resources/send.html")
if err != nil {
return errors.New("Error loading page send.html")
}
fmt.Fprintf(w, "%s", page)
return nil
}
|
// +build ent
package imports
import _ "github.com/bitxhub/parallel-executor"
|
package format
import (
"github.com/plandem/xlsx/internal/ml/primitives"
)
//List of all possible values for HAlignType
const (
_ primitives.HAlignType = iota
HAlignGeneral
HAlignLeft
HAlignCenter
HAlignRight
HAlignFill
HAlignJustify
HAlignCenterContinuous
HAlignDistributed
)
func init() {
primitives.From... |
package cmds
import (
"bytes"
"encoding/json"
"fmt"
"net/http"
"github.com/BaritoLog/barito-flow/flow"
"github.com/BaritoLog/instru"
)
type MetricPayload struct {
ApplicationGroups []ApplicationGroup `json:"application_groups"`
}
type ApplicationGroup struct {
AppSecret string `json:"token"`
LogCount int6... |
package dstate
import (
"testing"
"time"
)
func TestCacheSetGet(t *testing.T) {
c := NewCache()
key := "123"
c.Set(key, "hey")
v := c.Get(key)
if v == nil {
t.Error("value did not set")
}
if v != "hey" {
t.Error("value is not 'hey': ", v)
}
}
func TestCacheEviction(t *testing.T) {
c := NewCache()
... |
package server
import "testing"
func TestBSON(t *testing.T) {
id := bsonID()
if len(id) != 24 {
t.Fail()
}
}
|
//A http reverse proxy for developer to debug.
package main
import (
"flag"
"fmt"
"log"
"net/url"
"os"
)
//logpath is the file path for log.
var logpath = flag.String("l", "/dev/stdout", "path of log file")
//port is the port which server listened.
var port = flag.Int("p", 80, "port which server listened")
//... |
package model
import (
"time"
)
/*************************/
/********角色结构体*********/
/*************************/
// Role Object
type Role struct {
Id int `json:"id" binding:"min=1"` //角色ID
Name string `json:"name" binding:"required,min=1"` //角色名
Remark string `json:"remark"` //描述
... |
package mqops
import (
"encoding/json"
"github.com/matscus/Hamster/Guns/busM5/errors"
)
func init() {
GetDMAList()
}
type getDMAListJSON struct {
Data struct {
Hid string `json:"hid"`
} `json:"data"`
}
//GetDMAList - init script struct
func GetDMAList() {
getDMAList := New()
getDMAList.Name = "GetDMAList... |
// Package gitlab - discussion
package gitlab
import (
"context"
"encoding/json"
"fmt"
)
type (
// Discussion entity
Discussion struct {
ID string `json:"id"`
IndividualNote bool `json:"individual_note"`
Notes []Note `json:"notes"`
}
// Note (comment) entity
Note struct {
ID ... |
package helper
import (
"log"
"runtime"
)
func PrintPanicStack() {
if x := recover(); x != nil {
// log.Printf(x)
for i := 0; i < 10; i++ {
funcName, file, line, ok := runtime.Caller(i)
if ok {
log.Printf("frame ", i, ":[func:", runtime.FuncForPC(funcName).Name(), ",file:", file, ",line:%v]\n", line)... |
package models
import (
"errors"
"time"
)
//"wid" INTEGER PRIMARY KEY AUTOINCREMENT,
//"wx_id" VARCHAR(64) NOT NULL,
//"type" TEXT NOT NULL,
//"msg" TEXT NOT NULL,
//"created" TIMESTAMP default (datetime('now', 'localtime'))
type Work struct {
Wid int `xorm:"int(20) pk not null autoincr 'wid'" json:"wid... |
package moviedetail
import (
"log"
"time"
)
type loggingMiddleware struct {
Service
}
func NewLoggingMiddleware(s Service) Service {
return &loggingMiddleware{s}
}
func (l *loggingMiddleware) MovieDetail(imdbID string) (m *Movie, err error) {
defer func(begin time.Time) {
log.Printf("took %v, id %s, err %v\... |
package cool
import (
"testing"
"github.com/stretchr/testify/require"
abci "github.com/tendermint/tendermint/abci/types"
"github.com/tendermint/tendermint/crypto/ed25519"
sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/cosmos/cosmos-sdk/x/auth"
bank "github.com/cosmos/cosmos-sdk/x/bank"
"github.com/cosm... |
package allmulti
import "github.com/micromdm/nanomdm/mdm"
func (ms *MultiAllStorage) HasCertHash(r *mdm.Request, hash string) (bool, error) {
hasFinal, finalErr := ms.stores[0].HasCertHash(r, hash)
for n, storage := range ms.stores[1:] {
if _, err := storage.HasCertHash(r, hash); err != nil {
ms.logger.Info("m... |
package main
import (
"errors"
"fmt"
"github.com/aws/aws-sdk-go/aws/ec2metadata"
"github.com/aws/aws-sdk-go/aws/session"
)
type EC2Metadata struct {
Region,
SubnetID,
SubnetCIDR,
VpcID,
VpcCIDR string
}
func NewEc2Metadata() (*EC2Metadata, error) {
service := ec2metadata.New(session.New())
if !service.A... |
// Copyright 2020 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 processer
import (
"encoding/xml"
"github.com/superboy724/wechatmessage/message"
"github.com/superboy724/wechatmessage/response"
)
type MessageProcesser struct {
}
func (t *MessageProcesser) GetRequest(values map[string]string) string {
return ""
}
func (t *MessageProcesser) PostRequest(values map[strin... |
// Copyright 2020. Akamai Technologies, 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 t... |
package main
import (
"fmt"
"math/rand"
"time"
)
func main0401() {
//1.导入头文件 math/rand
//2.随机数种子
//3.创建随机数
//创建随机数种子
rand.Seed(time.Now().UnixNano())
fmt.Println(rand.Int()) //生成比较大随机数
fmt.Println(rand.Intn(10)) //常用 取模10 0-9
}
//练习 双色球
func main() {
//随机数
//红球 1-33 选择6个 不重复 蓝球 1-16 ... |
package leetcode
func isValid(s string) bool {
stack := make([]int32, 0)
top := 0
for _, c := range s {
if top <= 0 {
if c == '(' || c == '[' || c == '{' {
stack = append(stack, c)
top++
} else {
return false
}
} else if c == '(' || c == '[' || c == '{' {
stack = append(stack, c)
t... |
package main
import (
"github.com/spf13/pflag"
cliflag "k8s.io/component-base/cli/flag"
"math/rand"
"time"
"k8s.io/component-base/logs"
_ "k8s.io/component-base/metrics/prometheus/clientgo" // load all the prometheus client-go plugin
_ "k8s.io/component-base/metrics/prometheus/version" // for version metric r... |
// Copyright 2019-2023 The sakuracloud_exporter 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 appl... |
// Copyright (c) 2013 The Go Authors. All rights reserved.
//
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file or at
// https://developers.google.com/open-source/licenses/bsd.
// Package lintutil provides helpers for writing linter command lines.
package lintutil /... |
package main
import (
"authentication/models"
"authentication/router"
)
func main() {
db := models.SetupModels()
defer db.Close()
router := router.SetupRouter(db)
router.Run() // listen and serve on 0.0.0.0:8080
}
|
package rabbitmq
import (
"context"
"fmt"
"log"
"sync"
"github.com/google/uuid"
"github.com/streadway/amqp"
)
var conn *amqp.Connection
var ch *amqp.Channel
var rpcMap map[string]chan amqp.Delivery
var rpcMapMutex sync.RWMutex
// RabbitMQ is a concrete instance of the package
type RabbitMQ struct {
Conn ... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.