text stringlengths 11 4.05M |
|---|
// Copyright 2018 The adeia 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 domain
import (
"encoding/json"
"net/http"
"github.com/pkg/errors"
)
//go:generate counterfeiter -o ../mocks/domain_client.go --fake-name Domai... |
package stormpath
import (
"net/http"
"testing"
"github.com/stretchr/testify/assert"
)
func TestGetAPIKey(t *testing.T) {
t.Parallel()
application := createTestApplication(t)
defer application.Purge()
account := createTestAccount(application, t)
apiKey, _ := account.CreateAPIKey()
k, err := GetAPIKey(ap... |
package main
import (
"fmt"
"log"
"github.com/josetom/go-chain/config"
"github.com/josetom/go-chain/constants"
"github.com/spf13/cobra"
)
func main() {
log.SetFlags(log.Ldate | log.Ltime | log.Lmicroseconds | log.LUTC | log.Lshortfile)
config.Load("config.yaml")
var cmd = &cobra.Command{
Use: constants.... |
package db
import (
"context"
"errors"
"github.com/i-hate-nicknames/redeamtask/pkg/book"
)
// BookRecord represents a single record in the book database
type BookRecord struct {
ID int // todo maybe uint
book.Book
}
// BookDB is a generic book database interface
type BookDB interface {
Create(context.Context,... |
package fakes
import (
"sync"
gcpcompute "google.golang.org/api/compute/v1"
)
type InstanceGroupsClient struct {
DeleteInstanceGroupCall struct {
sync.Mutex
CallCount int
Receives struct {
Zone string
InstanceGroup string
}
Returns struct {
Error error
}
Stub func(string, string) ... |
package main
import (
"fmt"
"strconv"
"time"
)
/*
How many ways can I get from the top left
to the bottom right.
*/
func main() {
//defer timeTrack(time.Now(), "gridTraveler")
//fmt.Printf("gridTraveler(1, 1) = %d\n", gridTraveler(1, 1)) //1
//fmt.Printf("gridTraveler(3, 2) = %d\n", gridTraveler(3, 2)) //3
//... |
package paw
import (
"net/http"
"github.com/gin-gonic/gin"
)
// UserResource -
type UserResource struct {
App *App
}
// CreateUser -
func (r *UserResource) CreateUser(c *gin.Context) {
var user User
if !c.Bind(&user) {
c.JSON(http.StatusBadRequest, gin.H{"error": "Unable to decode request"})
return
}
r... |
package tree_traversal
import "container/list"
func PostOrder(root *Tree) []int {
var result []int
if root == nil {
return nil
}
result = append(result, PostOrder(root.Left)...)
result = append(result, PostOrder(root.Right)...)
result = append(result, root.Val)
return result
}
func PostOrderNonRecursive(... |
package euler
func FilterIntChannel(predicate func(int) bool, in chan int) chan int {
out := make(chan int)
go func() {
for {
if v := <-in; predicate(v) {
out <- v
}
}
}()
return out
}
func CapIntChannel(in chan int, limit int) chan int {
out := make(chan int)
go func() {
for {
v := <-in
i... |
package dbsearch
import (
"reflect"
"testing"
)
func Test_Array(t *testing.T) {
s := init_test_data()
if s != nil {
_01_array_int(t, s)
_02_array_int64(t, s)
_03_array_uint64(t, s)
_04_array_uint(t, s)
_11_array_bool(t, s)
_12_array_bool(t, s)
_21_array_string(t, s)
_31_array_float32(t, s)
_32_a... |
package response
import "github.com/madneal/gshark/model"
type ExaCustomerResponse struct {
Customer model.ExaCustomer `json:"customer"`
}
|
package database
import (
"fmt"
"strings"
"time"
"github.com/covista/commons/proto"
)
// given a request for downloading DiagnosisKeys, build the SQL query that returns
// the keys that match the filter. We know because of 'checkGetKeyRequest' that
// there is at least one filter defined in 'request'
func buildQ... |
package main
import (
"fmt"
"log"
)
func (cli *PHBCLI) phbstartNode(nodeID, minerAddress string) {
fmt.Printf("Starting node %s\n", nodeID)
if len(minerAddress) > 0 {
if PHBValidateAddress(minerAddress) {
fmt.Println("Mining is on. Address to receive rewards: ", minerAddress)
} else {
log.Panic("Wrong m... |
package acceptance
import (
"context"
"fmt"
"os"
"testing"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/acctest"
"github.com/databrickslabs/terraform-provider-databricks/common"
. "github.com/databrickslabs/terraform-provider-databricks/compute"
"github.com/databrickslabs/terraform-provider-databrick... |
package spec
// Surface is an interface that should hide concrete drawing implementations
// from controls. Using this interface should allow us to reasonably easily
// swap rendering backends (e.g., NanoVg, Cairo, Skia, HTML Canvas, etc.)
type Surface interface {
Init()
// Arc draws an arc from the x,y point along... |
package main
import (
"flag"
"fmt"
"github.com/containerd/containerd/namespaces"
units "github.com/docker/go-units"
"github.com/genuinetools/img/client"
"github.com/moby/buildkit/identity"
"github.com/moby/buildkit/session"
"github.com/moby/buildkit/util/appcontext"
)
const pullHelp = `Pull an image or a rep... |
package fml
import (
. "github.com/fipress/fiputil"
"strings"
"unicode"
)
//Skip spaces and comments
func skipLeft(input []byte) (skip int) {
i := 0
for i < len(input) {
if input[i] == '#' {
i += skipComments(input[i:])
} else if IsSpaceOrLineEnd(input[i]) {
i++
} else {
return i
}
}
return i
... |
package main
import (
"fmt"
"math/rand"
"strings"
"time"
"github.com/fatih/color"
)
var ASCI = "QWERTYUIOPLKJHGFDSAZXCVBNMmnbvcxzasdfghjklopiuytrewq7869543210"
var Pass = []string{}
var Sign = "#!@&()_-][><"
func strung() []string {
for i := 0; i < 10; i++ {
Pass = append(Pass, string(ASCI[rand.Intn(len(AS... |
package gen
import (
"fmt"
"go/ast"
"go/printer"
"go/token"
"strings"
)
// Struct is an alias for ast.StructType
type Struct ast.StructType
// NewStruct creates a new struct definition
func NewStruct() *Struct {
return (*Struct)(&ast.StructType{
Fields: &ast.FieldList{List: make([]*ast.Field, 0, 1)},
})
}
... |
package client
import (
"encoding/json"
"fmt"
"github.com/gojektech/heimdall/v6/httpclient"
"github.com/pkg/errors"
"io/ioutil"
"log"
"net/http"
"strings"
"time"
)
type Memo struct {
Content string
Tag string
Api string
}
type Payload struct {
Content string `json:"content"`
}
func (m *Memo) Su... |
package e4
import (
"io"
"testing"
)
func TestInfo(t *testing.T) {
TestWrapFunc(t, NewInfo("foo"))
info := NewInfo("foo %s", "bar")(io.EOF)
if info.Error() != "foo bar\nEOF" {
t.Fatalf("got %s", info.Error())
}
if !is(info, io.EOF) {
t.Fatal()
}
}
|
package cli
import (
"os"
"github.com/codegangsta/cli"
orderconstant "github.com/xozrc/cqrs/eventsourcing/examples/order/constant"
)
var (
bus string = orderconstant.OrderCommandBusAddr
topic string = orderconstant.OrderCommandTopic
)
var (
commands []cli.Command
)
func appendCmd(cmd cli.... |
package nmea
import (
"github.com/stretchr/testify/assert"
"testing"
)
//$GPGSV,3,1,11,03,03,111,00,04,15,270,00,06,01,010,00,13,06,292,00*74
//$GPGSV,3,2,11,14,25,170,00,16,57,208,39,18,67,296,40,19,40,246,00*74
//$GPGSV,3,3,11,22,42,067,42,24,14,311,43,27,05,244,00,,,,*4D
//$GPGSV,1,1,13,02,02,213,,03,-3,000,,11,... |
package pulsepoint
import (
"encoding/json"
"testing"
"github.com/prebid/prebid-server/openrtb_ext"
)
func TestValidParams(t *testing.T) {
validator, err := openrtb_ext.NewBidderParamsValidator("../../static/bidder-params")
if err != nil {
t.Fatalf("Failed to fetch the json-schemas. %v", err)
}
for _, vali... |
// Copyright 2017 The Cockroach Authors.
//
// Use of this software is governed by the Business Source License
// included in the file licenses/BSL.txt.
//
// As of the Change Date specified in that file, in accordance with
// the Business Source License, use of this software will be governed
// by the Apache License, ... |
package sink
import (
"testing"
"github.com/google/go-cmp/cmp"
"github.com/pragkent/slackwork/wework"
)
func TestTranslate(t *testing.T) {
tests := []struct {
payload *Payload
want []wework.SendChatMessageRequest
}{
{
payload: &Payload{
Channel: "#haha",
Parse: "full",
Attachments: []A... |
package main
import (
"flag"
"github.com/go-redis/redis/v7"
"github.com/qubard/claack-go/lib/microservice"
"github.com/qubard/claack-go/websocket/socket"
)
func main() {
var addr string
flag.StringVar(&addr, "redis", "", "The address (ip:port) of a redis instance")
flag.Parse()
redis := redis.NewClient(&redi... |
package db
import (
"log"
"time"
"github.com/jelinden/stock-portfolio/app/service"
)
func GetHistory(portfolioid string) []service.ClosePrice {
timeFrom := time.Now()
var closePrices = []service.ClosePrice{}
rows, err := mdb.Query(`SELECT h.symbol, h.closePrice, h.epoch
FROM history AS h,
(SELECT symbol,... |
package schema
type EndpointsData struct {
Currency string `json:"currency"`
Addresses []string `json:"addresses"`
Stopped []string `json:"stopped"`
}
|
package main
import (
"bufio"
"fmt"
"go-sns-test/snsclient"
"os"
"github.com/aws/aws-sdk-go/aws"
"github.com/aws/aws-sdk-go/aws/session"
"github.com/aws/aws-sdk-go/service/sns"
)
// usage:
// go run main.go
func main() {
scanner := bufio.NewScanner(os.Stdin)
fmt.Println("You need to have configured the AWS ... |
package main
import (
"errors"
"strconv"
"strings"
)
// Degree API student-v1 degree response message.
type Degree struct {
ID string `json:"id"`
StudentDegNbr string `json:"studentDegNbr"`
Code string `json:"degreeCode"`
Desc string `json:"degreeDesc"`
AcadCareer ... |
package main
import (
"fmt"
"log"
"net/http"
)
func main() {
/**
Defer function
*/
fmt.Println("start") // LIFO order
defer fmt.Println("middle")
fmt.Println("end")
a := "hi"
defer fmt.Println(a)
a = "hello"
/**
Panic function
*/
http.HandleFunc("/", func(writer http.ResponseWriter, request *http.R... |
package service
import (
"errors"
"net/http"
"time"
"github.com/chidam1994/happyfox/group"
"github.com/chidam1994/happyfox/models"
"github.com/chidam1994/happyfox/utils"
"github.com/google/uuid"
)
type groupService struct {
repo group.Repository
}
func NewService(r group.Repository) group.Service {
return ... |
/*
Copyright 2014 Huawei Technologies Co., Ltd. All rights reserved.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable la... |
// Copyright 2018, Shulhan <ms@kilabit.info>. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
package net
import (
"net"
"testing"
"github.com/shuLhan/share/lib/test"
)
func TestIsTypeUDP(t *testing.T) {
cases := []struct {
desc stri... |
package cmd
import (
"fmt"
"github.com/khushmeeet/vc/vc"
"github.com/spf13/cobra"
)
// commitCmd represents the commit command
var commitCmd = &cobra.Command{
Use: "commit",
Short: "A brief description of your command",
Long: `A longer description that spans multiple lines and likely contains examples
and usa... |
package _6_RainOfReason
import "fmt"
func main() {
inputString := "crazy"
result := alphabeticShift(inputString)
fmt.Println(result)
}
func alphabeticShift(inputString string) string {
outputSlice := []rune(inputString)
for index, value := range outputSlice {
if value == 122 {
value = 96
}
value++
... |
package compute_test
import (
"errors"
"github.com/genevieve/leftovers/gcp/compute"
"github.com/genevieve/leftovers/gcp/compute/fakes"
. "github.com/onsi/ginkgo"
. "github.com/onsi/gomega"
)
var _ = Describe("InstanceTemplate", func() {
var (
client *fakes.InstanceTemplatesClient
name string
instance... |
package cache
import (
"bytes"
"fmt"
"sync"
"time"
"github.com/Skipor/memcached/internal/tag"
"github.com/Skipor/memcached/log"
)
type lru struct {
lock sync.RWMutex
table map[string]*node
queues []*queue
limits limits
log log.Logger
}
func newLRU(l log.Logger, conf Config) *lru {
c := &lru{
log... |
package main
import "fmt"
func main() {
fmt.Println("I am the child")
}
|
package zrpc
import "encoding/json"
// Input 輸出參數
type Input struct {
Service string `json:"service"`
Method string `json:"method"`
Params interface{} `json:"params"`
ID int `json:"id"`
Address string `json:"address"`
}
// Output 輸出參數
type Output struct {
Result interface{} `json:... |
package function
import (
"bytes"
"context"
"encoding/json"
"errors"
dataBaseClient "github.com/dgraph-io/dgo"
dataBaseAPI "github.com/dgraph-io/dgo/protos/api"
"github.com/hecatoncheir/Storage"
"google.golang.org/grpc"
"log"
"os"
"testing"
"text/template"
)
func TestExecutor_DeleteEntityByID(t *testing.T... |
// Copyright 2020 The gVisor 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 agree... |
// Package loadbalancer provides methods of finding available backends.
package loadbalancer
import (
"fmt"
"net"
"reflect"
"sync"
"time"
v1 "k8s.io/api/core/v1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/fields"
"k8s.io/apimachinery/pkg/util/wait"
watchtypes "k8s.io/apimachinery... |
package fakes
import (
"sync"
gcpdns "google.golang.org/api/dns/v1"
)
type ManagedZonesClient struct {
DeleteManagedZoneCall struct {
sync.Mutex
CallCount int
Receives struct {
Zone string
}
Returns struct {
Error error
}
Stub func(string) error
}
ListManagedZonesCall struct {
sync.Mutex
... |
// Copyright 2014 The Cockroach 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... |
// Copyright 2022 The gVisor 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 agree... |
package main
import (
"encoding/json"
"fmt"
"log"
"net/http"
"os"
"time"
"github.com/gorilla/handlers"
"github.com/gorilla/mux"
)
func serveHttp() error {
p := os.Getenv("HTTP_PORT")
r := mux.NewRouter()
r.PathPrefix("/blocks").HandlerFunc(blockHandler).Methods("GET")
fileServe(r, "/", "./www")
srv :... |
package controllers
import (
"fmt"
"github.com/astaxie/beego"
"github.com/astaxie/beego/logs"
"homework/common/encrypt"
"homework/models/datamodels"
"homework/models/services"
"strconv"
)
type ProductController struct {
beego.Controller
ProductService services.IProductService
}
type ProductDetail struct {
... |
package s3cli
import (
"context"
"encoding/json"
"errors"
"io"
"io/ioutil"
"os"
"path"
"path/filepath"
"sort"
"strings"
"github.com/aws/aws-sdk-go/service/s3/s3manager"
"github.com/astaxie/beego"
"github.com/qiaogw/pkg/filemanager"
"github.com/qiaogw/pkg/logs"
"github.com/qiaogw/pkg/tools"
"time"
... |
package main
import (
"../foo"
"fmt"
"math"
)
func main() {
fmt.Println(math.Pi)
fmt.Println(foo.Baz)
}
|
// Copyright 2020 The Moov Authors
// Use of this source code is governed by an Apache License
// license that can be found in the LICENSE file.
package wire
import (
"encoding/json"
"strings"
"unicode/utf8"
)
// CurrencyInstructedAmount is the currency instructed amount
type CurrencyInstructedAmount struct {
//... |
package event
import (
"sync/atomic"
"testing"
"time"
"github.com/stretchr/testify/require"
"github.com/iotaledger/hive.go/runtime/workerpool"
)
func Benchmark(b *testing.B) {
testEvent := New1[int]()
testEvent.Hook(func(int) {})
b.ResetTimer()
for i := 0; i < b.N; i++ {
testEvent.Trigger(i)
}
}
func... |
package main
import (
"bufio"
"fmt"
"math/rand"
"os"
"strconv"
"time"
)
func main() {
fmt.Println("Start game")
deck := initDeck()
fmt.Println(deck)
var player Player
var dealer Dealer
var drawed Card
drawed = deck.Pop()
fmt.Printf("You: first %s\n", drawed)
player.AddCard(drawed)
drawed = deck.Pop... |
package lexers
import (
. "github.com/alecthomas/chroma/v2" // nolint
)
// Chapel lexer.
var Chapel = Register(MustNewLexer(
&Config{
Name: "Chapel",
Aliases: []string{"chapel", "chpl"},
Filenames: []string{"*.chpl"},
MimeTypes: []string{},
},
func() Rules {
return Rules{
"root": {
{`\n`, ... |
package audit
import (
"github.com/google/uuid"
"github.com/jrapoport/gothic/core/context"
"github.com/jrapoport/gothic/models/account"
"github.com/jrapoport/gothic/models/auditlog"
"github.com/jrapoport/gothic/models/types"
"github.com/jrapoport/gothic/models/types/key"
"github.com/jrapoport/gothic/models/user... |
package commands
import (
"os"
"io"
"github.com/sonm-io/core/cmd/cli/task_config"
pb "github.com/sonm-io/core/proto"
"github.com/sonm-io/core/util"
"github.com/spf13/cobra"
)
func init() {
nodeTaskRootCmd.AddCommand(
nodeTaskListCmd,
nodeTaskStartCmd,
nodeTaskStatusCmd,
nodeTaskLogsCmd,
nodeTaskSto... |
/*
Copyright 2014 Google Inc. All rights reserved.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in ... |
// Copyright (C) 2016-Present Pivotal Software, Inc. All rights reserved.
// This program and the accompanying materials are made available under the terms of the 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 Licen... |
// Copyright 2019 The SwiftShader Authors. 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 b... |
package domain
import (
"time"
"github.com/traPtitech/trap-collection-server/src/domain/values"
)
// LauncherSession
// ランチャーのプロダクトキーでの認証後のセッションを表すドメイン。
// プロダクトキーでの認証から一定時間を過ぎると無効になり、
// 再度認証が必要になる。
// 有効期限の延長は不可能。
type LauncherSession struct {
id values.LauncherSessionID
accessToken values.LauncherSes... |
// SPDX-License-Identifier: MIT
// Package site 用于生成网站内容
//
// 包括网站的基本信息,以及文档的翻译内容等。
package site
import (
"encoding/xml"
"io/ioutil"
"os"
"github.com/issue9/errwrap"
"golang.org/x/text/language/display"
"github.com/caixw/apidoc/v7/core"
"github.com/caixw/apidoc/v7/internal/ast"
"github.com/caixw/apidoc/v7/... |
package backend
import (
"context"
"errors"
"io"
"time"
"github.com/travis-ci/worker/config"
)
func init() {
Register("fake", "Fake", map[string]string{
"LOG_OUTPUT": "faked log output to write",
"RUN_SLEEP": "faked runtime sleep duration",
"ERROR": "error out all jobs (useful for testing requeue s... |
package persistent
import (
"log"
"strconv"
"time"
"github.com/EventStore/EventStore-Client-Go/position"
"github.com/EventStore/EventStore-Client-Go/protos/persistent"
"github.com/EventStore/EventStore-Client-Go/protos/shared"
system_metadata "github.com/EventStore/EventStore-Client-Go/systemmetadata"
"github... |
package metas
import (
"fmt"
"github.com/daiguadaidai/haechi/utils"
"strings"
)
type Partition struct {
Type string `json:"type" form:"type"`
ColumnNames []string `json:"column_names" form:"column_names"`
ListPartition *ListPartition `json:"list_partition" form:"list_partition"`
... |
package configutils
import (
"encoding/json"
"io"
"io/ioutil"
"net/http"
"os"
flags "github.com/jessevdk/go-flags"
yaml "gopkg.in/yaml.v2"
)
func LoadFromYaml(configPath string, out interface{}) error {
f, err := os.Open(configPath)
if err != nil {
return err
}
defer f.Close()
data, err := ioutil.ReadA... |
package model
import (
"app/internal/config"
"app/internal/log"
"errors"
_ "github.com/go-sql-driver/mysql"
"github.com/jmoiron/sqlx"
)
var _db *sqlx.DB
func Initialize() error {
dsn := config.GetMySQLDSN()
if dsn == "" {
return errors.New("Empty MySQL DSN")
}
db, err := sqlx.Connect("mysql", dsn)
if er... |
package main
import (
"fmt"
)
func main() {
/**
Declaring boolean value
*/
var n bool = true // initially false
fmt.Printf("%v, %T\n", n, n)
/**
Integers - Comparing values
*/
i := 1 == 1
j := 2 == 1
fmt.Printf("\n%v, %T\n", i, i)
fmt.Printf("%v, %T\n", j, j)
/**
Declaring int values
*/
k := 33 //... |
package flutter
import (
"encoding/json"
"fmt"
"log"
"runtime"
"time"
"unsafe"
"github.com/go-flutter-desktop/go-flutter/embedder"
"github.com/go-gl/glfw/v3.2/glfw"
"github.com/pkg/errors"
)
// dpPerInch defines the amount of display pixels per inch as defined for Flutter.
const dpPerInch = 160.0
// Run ex... |
package renderer
import (
"errors"
"image"
"github.com/driusan/de/demodel"
"golang.org/x/image/math/fixed"
)
var ErrNoCharacter = errors.New("No character under the mouse cursor.")
type ImageLoc struct {
Loc fixed.Rectangle26_6
Idx uint
}
type ImageMap struct {
IMap []ImageLoc
Buf *demodel.CharBuffer
}
f... |
package main
import (
"fmt"
"math/rand"
"net"
"time"
"golang.org/x/net/icmp"
"golang.org/x/net/ipv4"
)
const maxHops = 64
// Hop stores information about a single traceroute hop.
type Hop struct {
Number int
Addr net.Addr
Rtt time.Duration
Type icmp.Type
Success bool
}
// TraceRoute returns a... |
package handlers
import (
"encoding/json"
"log"
"net/http"
"path"
)
const (
ApiError = "api_error"
InvalidRequestError = "invalid_request_error"
)
// ErrorMessage type holds API error related information.
// It is typically serialized to JSON then returned to the client.
type ErrorMessage struct {
... |
// Copyright 2020 The Moov Authors
// Use of this source code is governed by an Apache License
// license that can be found in the LICENSE file.
package wire
import (
"bytes"
"encoding/json"
"fmt"
)
// File contains the structures of a parsed WIRE File.
type File struct {
ID string `json:"id"... |
package main
import (
"flag"
"fmt"
"os"
)
func main() {
for i, v := range os.Args {
fmt.Printf("%d : %s\n", i, v)
}
s := flag.String("s", "hello s", "input string!!!")
i := flag.Int("i", 0, "int value")
//clone :=flag.NewFlagSet("clone",flag.ExitOnError)
flag.Parse()
fmt.Printf("s : %s\n", *s)
fmt.Prin... |
package experiment
// import (
// "fmt"
// "testing"
// "gopkg.in/ddspog/mspec.v1/bdd"
// )
// // Feature Create Data with functional Getters
// // - As a developer,
// // - I want to be able to create a Data object and get values with its
// // getters,
// // - So that I could use these getters to manipulate and... |
package utils
import (
"github.com/stretchr/testify/assert"
"testing"
)
func TestVector2_Add(t *testing.T) {
v1 := Vector2{X: 1, Y: 2}
v2 := Vector2{X: 3, Y: 4}
v3 := v1.Add(v2)
assert.Equal(t, Vector2{X: 4, Y: 6}, v3)
}
|
package representation
import (
"fmt"
"math/big"
"testing"
)
func TestMulImpl(t *testing.T) {
var a U256
var b U256
uint64max := ^uint64(0)
a[0] = uint64max
a[1] = uint64max
a[2] = uint64max
a[3] = uint64max
b[0] = uint64max
b[1] = uint64max
b[2] = uint64max
b[3] = uint64max
fmt.Println(a.String())
... |
package requirements
/**
isEmpty receives a string s and returns true if it is empty
As there are no nulls in go, only the length of the string was checked
*/
func isEmpty(s string) bool {
return len(s) == 0
}
|
package main
import (
"net/http"
"github.com/gin-gonic/gin"
)
// FormHandler Form处理函数
func FormHandler(c *gin.Context) {
name := c.DefaultPostForm("name", "张三")
city := c.DefaultPostForm("city", "雄安")
c.JSON(http.StatusOK, gin.H{
"name": name,
"city": city,
})
}
// PathHandler Path处理函数
func PathHandler(c... |
package main
import ("fmt"
"golang.org/x/oauth2")
func main(){
conf := &oauth2.Config{
ClientID :"",
ClientSecret: "-hJmkRnmsPLZ",
Scopes: []string{"wl.offline_access", "onedrive.readwrite"},
Endpoint: oauth2.Endpoint{
AuthURL: "https://login.live.com/oauth20_authorize.srf",
TokenURL: "https://login.l... |
package keeper
import (
"fmt"
"github.com/tendermint/tendermint/libs/log"
"github.com/cosmos/cosmos-sdk/codec"
sdk "github.com/cosmos/cosmos-sdk/types"
authtypes "github.com/cosmos/cosmos-sdk/x/auth/types"
paramstypes "github.com/cosmos/cosmos-sdk/x/params/types"
"github.com/irismod/service/types"
)
// Keep... |
package dashrates
import (
"encoding/json"
"io/ioutil"
"net/http"
"strconv"
"time"
)
// LiquidAPI implements the RateAPI interface and contains info necessary for
// calling to the public Liquid price ticker API.
type LiquidAPI struct {
BaseAPIURL string
PriceTickerEndpoint string
}
// NewLiquidAPI i... |
package app
import (
"io/ioutil"
"strings"
"github.com/pkg/errors"
)
type fileReader struct {
file string
}
func newFileReader(f string) *fileReader {
return &fileReader{file: f}
}
func (r *fileReader) ReadExecutables() ([]string, error) {
content, err := ioutil.ReadFile(r.file)
if err != nil {
return nil... |
package model
import "github.com/jinzhu/gorm"
type Announce struct {
gorm.Model
Title string `gorm:"type:varchar(50);not null"`
Content string `gorm:"type:varchar(200);"`
Url string `gorm:"type:varchar(100);"`
}
|
package pkg
import (
"path/filepath"
"github.com/appscode/go/flags"
"github.com/appscode/go/log"
"github.com/spf13/cobra"
"k8s.io/client-go/tools/clientcmd"
"kmodules.xyz/client-go/tools/backup"
"stash.appscode.dev/stash/pkg/restic"
"stash.appscode.dev/stash/pkg/util"
)
const (
JobClusterBackup = "stash-clu... |
package logx
import "io"
// Option is the common type of functions that set options
type Option func(*options)
type options struct {
marshaler Marshaler
writer io.Writer
level Level
withoutTime bool
withoutFileInfo bool
additionalFileSkipLeve... |
package eventsourcing
import (
"context"
"github.com/caos/zitadel/internal/errors"
es_models "github.com/caos/zitadel/internal/eventstore/models"
org_model "github.com/caos/zitadel/internal/org/model"
"github.com/caos/zitadel/internal/org/repository/eventsourcing/model"
)
func OrgByIDQuery(id string, latestSeque... |
package rest
import (
"net/http"
"net/url"
"strconv"
"github.com/HDIOES/su4na-API-main/models"
"github.com/pkg/errors"
)
//StudioHandler struct
type StudioHandler struct {
Dao *models.StudioDAO
}
func (g *StudioHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) {
requestBody, rawQuery, headers, err :... |
package block
import (
"blockchain/pkg/cryptoAPI"
"time"
)
type Block struct {
Index int
Timestamp string
Data int
Hash string
PrevHash string
}
var BlockChain []Block
func CreateBlock(oldBlock Block, data int) Block {
B := Block{
Index: oldBlock.Index + 1,
Timestamp: time.Now().String(),
Data: ... |
package domain
// Alerm :
type Alerm struct {
ID string `json:"_id"`
UserID string `json:"userId"`
Stop bool `json:"stop"`
}
|
package steps
import (
"errors"
"strings"
s "github.com/pganalyze/collector/setup/state"
"github.com/pganalyze/collector/setup/util"
)
var ConfirmAutoExplainAvailable = &s.Step{
Kind: s.AutomatedExplainStep,
ID: "aemod_check_auto_explain_available",
Description: "Confirm the auto_explain contr... |
// Copyright 2016 Zhang Peihao <zhangpeihao@gmail.com>
/*
Package plaintext 纯文本格式
用多行来分隔Command字段
第一行:信令版本(纯文本格式:第一个字符为:'t',后面是协议版本号)
第二行:信令所属App ID
第三行:信令名
第四行:信令数据
第五行:信令负载
*/
package plaintext
import (
"bufio"
"bytes"
"encoding/json"
"fmt"
"strings"
"github.com/golang/glog"
"github.com/zhangpeihao/zim/pkg... |
package hosts
import (
"github.com/jrapoport/gothic/core"
"github.com/jrapoport/gothic/hosts/rpc"
"github.com/jrapoport/gothic/hosts/rpc/system"
)
const rpcName = "rpc"
// NewRPCHost creates a new rpc host.
func NewRPCHost(a *core.API, address string) core.Hosted {
return rpc.NewHost(a, rpcName, address,
[]rpc... |
package v1
import "bytes"
// NopCloser テストでbytes.Readerをmultipart.Fileに対応するための構造体
type NopCloser struct {
*bytes.Reader
}
func (r *NopCloser) Close() error {
return nil
}
|
package main
import (
"fmt"
ellipse "github.com/diversemix/learn-golang/projects/ellipse"
)
func main() {
//Initalise the Init function with value of A,B
e := ellipse.Init{
9, 2,
}
//this will give answer as 0.9749960430435691
fmt.Println(e.GetEccentricity())
}
|
package dbmigrate
import (
"database/sql"
"fmt"
"strings"
"time"
"github.com/pkg/errors"
)
var (
errDBNameNotProvided = errors.New("database name is not provided")
errUserNotProvided = errors.New("user is not provided")
)
// dbWrapper encapsulates all database access operations
type dbWrapper struct {
*Se... |
// Copyright 2019 The Cockroach Authors.
//
// Use of this software is governed by the Business Source License
// included in the file licenses/BSL.txt.
//
// As of the Change Date specified in that file, in accordance with
// the Business Source License, use of this software will be governed
// by the Apache License, ... |
package main
import "fmt"
func maxSlidingWindow(nums []int, k int) []int {
res, s, si, i := make([]int, 0, len(nums)), make([]int, 0, len(nums)), make([]int, 0, len(nums)-k), 0
for ; i < k-1; i++ {
for len(s) > 0 && s[len(s)-1] <= nums[i] {
s, si = s[:len(s)-1], si[:len(si)-1]
}
s, si = append(s, nums[i]),... |
package lib_gc_cache_helpers
// Cache Object metadata fields
const METADATA_VERSION = "VERSION"
const METADATA_STATUS = "STATUS"
const (
CACHEOBJECTSTATUS_ENABLED int16 = 0
CACHEOBJECTSTATUS_DISABLED int16 = 1
CACHEOBJECTSTATUS_DELETED int16 = 2
)
|
package models
import (
"gopkg.in/mgo.v2"
)
var (
session *mgo.Session
url string = "127.0.0.1:27017"
basename string = "test"
)
func GetSession() *mgo.Session {
if session == nil {
var err error
session, err = mgo.Dial(url)
if err != nil {
panic(err)
}
}
return session.Clone()
}
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.