text stringlengths 11 4.05M |
|---|
package main
import (
"database/sql"
"fmt"
_ "github.com/go-sql-driver/mysql"
)
func main() {
// useMysqlDriver()
}
func useMysqlDriver() {
// user@unix(/path/to/socket)/dbname?charset=utf8
// user:password@tcp(localhost:5555)/dbname?charset=utf8
// user:password@/dbname
// user:password@tcp([de:ad:be:ef::c... |
package primitives
import (
"encoding/xml"
)
//VisibilityType is a type to encode XSD ST_Visibility and ST_SheetState
type VisibilityType byte
var (
ToVisibilityType map[string]VisibilityType
FromVisibilityType map[VisibilityType]string
)
func (e VisibilityType) String() string {
return FromVisibilityType[e]
... |
package config
type ActivityConf struct {
ID int32
StartTS int64
EndTS int64
Skins map[int32]int32
}
|
package main
import (
"fmt"
"log"
"labix.org/v2/mgo"
"net/http"
)
var peopleContainer *mgo.Collection
var records []Record
type Record struct {
FirstName string
MiddleName string
LastName string
Text string
}
func familyTreeHandler(w http.ResponseWriter, r *http.Request) {
iter... |
// Copyright 2019 HAProxy Technologies LLC
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or a... |
package log
import (
"go.uber.org/zap"
"go.uber.org/zap/zapcore"
"gopkg.in/natefinch/lumberjack.v2"
"os"
)
type Logger struct {
logLevel zap.AtomicLevel
logger *zap.SugaredLogger
}
func NewLogger(path string, level string) *Logger {
return newFileLogger(path, level)
}
func (l *Logger) Debug(format string, ... |
package main
import "fmt"
func max(a, b int) int {
if a > b {
return a
}
return b
}
func maxKnapsackValue(w int, ws, vs []int) int {
dp := make([][]int, w+1)
n := len(ws)
for i, _ := range dp {
dp[i] = make([]int, n+1)
}
// dp[i][j] is the maximum value of the knapsack containing
// a subset of the i... |
//
//
//
package unique
import (
"testing"
"gotest.tools/assert"
)
func TestUnique01(t *testing.T) {
u := NewUnique(65536)
u.AddUint64(1)
assert.Assert(t, u.Count() == 1)
}
|
package metaverse
import (
"math"
"github.com/unixpickle/anydiff"
"github.com/unixpickle/anynet/anyconv"
"github.com/unixpickle/anyvec"
"github.com/unixpickle/essentials"
gym "github.com/unixpickle/gym-socket-api/binding-go"
)
// FlashObservationSpaces stores observation meta-data for
// each Flash game enviro... |
package controller
import (
"log"
"k8s.io/api/core/v1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/labels"
"k8s.io/apimachinery/pkg/runtime"
"k8s.io/apimachinery/pkg/watch"
"k8s.io/client-go/tools/cache"
)
func (c *TelegrafController) createIndexerInformer() {
labelSelector := labe... |
package aes
import (
"fmt"
"log"
"github.com/gusandrioli/small-aes/utils"
"github.com/pdfcpu/pdfcpu/pkg/api"
"github.com/pdfcpu/pdfcpu/pkg/pdfcpu"
)
func EncryptPDF(args []string) {
var key string
if len(args) == 0 {
log.Fatal("No arguments provided. Please see small-aes -h")
} else if len(args) == 2 {
... |
/* 实验返回文件, 需在当前路径下,建一个images文件夹,然后放入11.jpeg 图片
*/
package main
import (
"net/http"
"path"
)
func main(){
mux := http.NewServeMux()
mux.HandleFunc("/file",fileHandle)
http.ListenAndServe(":12345",mux)
}
func fileHandle(w http.ResponseWriter, r *http.Request) {
fp := path.Join("images","11.jpeg")
http.ServeF... |
package models
import (
"time"
"github.com/jungju/circle_manager/modules"
)
// User struct represent user model.
// gen:qs
type User struct {
ID uint `description:""`
CreatedAt time.Time `description:"등록일"`
UpdatedAt time.Time `description:"수정일"`
Name string... |
package beacon
// NewRoute creates a route from the provided filter and backend.
func NewRoute(filter Filter, backend Backend) Route {
if filter == nil {
filter = &allFilter{}
}
return struct {
Filter
Backend
}{
filter,
backend,
}
}
// Route processes events which match a particular filter pattern.
typ... |
package array
import (
"bytes"
"container/list"
"fmt"
"reflect"
"github.com/Kretech/xgo/dict"
)
type any = interface{}
// Stream 提供对一组数据集的操作,接口 api 参考自 Laravel 的 Collection 和 Java 的 stream
type Array struct {
*list.List
}
func (a *Array) String() string {
b := bytes.NewBuffer([]byte{})
a.each(func(it *list... |
package main
import "fmt"
func main() {
// s := "My String"
// sptr := &s
// fmt.Println(s)
// fmt.Println(*sptr)
// sptr := new(string)
// fmt.Println(*sptr)
// s := "My String"
// var stpr *string
// stpr = &s
// fmt.Print(*stpr)
i := new(int)
fmt.Println(*i)
}
|
package gomega
import (
"fmt"
"github.com/onsi/gomega/matchers"
"github.com/onsi/gomega/types"
"github.com/operator-framework/api/pkg/operators/v1alpha1"
"github.com/operator-framework/operator-lifecycle-manager/test/e2e/util"
)
func HaveSubscriptionState(state v1alpha1.SubscriptionState) types.GomegaMatcher {
... |
package sese
import (
"encoding/xml"
"github.com/thought-machine/finance-messaging/iso20022"
)
type Document00600107 struct {
XMLName xml.Name `xml:"urn:iso:std:iso:20022:tech:xsd:sese.006.001.07 Document"`
Message *TransferInCancellationRequestV07 `xml:"TrfInCxlReq"`
}
func (d *Documen... |
package amazonmwsapi
import (
"context"
"encoding/xml"
)
// RequestReportRequest requests a single amzMWS report be prepared for download
type RequestReportRequest struct {
amazonRequest
}
// Do sends request to amazonMWS reports API and returns report request info
func (r *RequestReportRequest) Do(ctx context.Co... |
package pgsql
import (
"testing"
)
func TestByteaArray(t *testing.T) {
testlist2{{
valuer: ByteaArrayFromStringSlice,
scanner: ByteaArrayToStringSlice,
data: []testdata{
{input: []string(nil), output: []string(nil)},
{input: []string{}, output: []string{}},
{
input: []string{"", ""},
output... |
package rest_test
import (
"bytes"
"encoding/gob"
"encoding/json"
"encoding/xml"
"log"
"net/http"
"net/http/httptest"
"net/url"
"regexp"
"strings"
"testing"
"github.com/go-playground/validator/v10"
"github.com/phogolabs/rest"
. "github.com/onsi/ginkgo/v2"
. "github.com/onsi/gomega"
)
type (
handlerF... |
// Copyright 2015 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 structured
import (
"testing"
"github.com/apex/log"
"github.com/apex/log/handlers/discard"
)
func TestThrowError(t *testing.T) {
tests := []struct {
name string
wantErr bool
}{
{"base-case", true},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
if err := ThrowError(); (... |
// Package main implements a client for Greeter service.
package main
import (
"context"
"flag"
"fmt"
"log"
"time"
"google.golang.org/grpc"
"google.golang.org/grpc/metadata"
walletpb "google.golang.org/grpc/grpc-wallet/grpc/examples/wallet"
_ "google.golang.org/grpc/xds/experimental"
)
var (
address = fla... |
package sstring
import (
"math/rand"
"testing"
"time"
"github.com/tidwall/assert"
)
func TestShared(t *testing.T) {
for i := -1; i < 10; i++ {
var str string
func() {
defer func() {
assert.Assert(recover().(string) == "string not found")
}()
str = Load(i)
}()
assert.Assert(str == "")
}
as... |
package article
import (
"encoding/json"
"time"
"golang.org/x/net/context"
miniprop "github.com/firefirestyle/engine-v01/prop"
)
//
func (obj *Article) ToMap() map[string]interface{} {
return map[string]interface{}{
TypeUserName: obj.gaeObject.UserName, //
TypeTitle: obj.gaeObject.Title, //
Typ... |
package models
import (
"github.com/nsqio/go-nsq"
"time"
)
// RestoreState stores information about the state of a bag restoration
// operation. This entire structure will be converted to JSON and saved
// as a WorkItemState object in Pharos.
type RestoreState struct {
// NSQMessage is the NSQ message being proces... |
package sleepytcp
import (
"bufio"
"github.com/valyala/bytebufferpool"
"sync"
"time"
)
var (
framePool sync.Pool
frameBodyPool bytebufferpool.Pool
)
func AcquireFrame() *Frame {
v := framePool.Get()
if v == nil {
return &Frame{}
}
return v.(*Frame)
}
func ReleaseFrame(req *Frame) {
req.Reset()
fra... |
package main
import (
"github.com/alecthomas/kong"
"gorm.io/gorm"
"io"
)
type CmdSync struct {
Data []string `arg help:"Sync the specified data" enum:"users,bagels"`
}
func (cmd *CmdSync) Run(ctx *kong.Context, db *gorm.DB, s *Slack) (err error) {
for _, whatToSync := range cmd.Data {
switch whatToSync {
ca... |
package mhfpacket
import (
"errors"
"github.com/Andoryuuta/Erupe/network"
"github.com/Andoryuuta/Erupe/network/clientctx"
"github.com/Andoryuuta/byteframe"
)
// GuacotUpdateEntry represents an entry inside the MsgMhfUpdateGuacot packet.
type GuacotUpdateEntry struct {
Unk0 uint32
Unk1 uint1... |
package models
import (
"go.mongodb.org/mongo-driver/bson/primitive"
)
type User struct {
ID primitive.ObjectID `bson:"_id" json:"id"`
Name string `bson:"name" json:"name"`
Email string `bson:"email" json:"email"`
Password []byte `bson:"password" json:"-"`
Active... |
package neatly
import (
"github.com/viant/toolbox"
"github.com/viant/toolbox/data"
"github.com/viant/toolbox/storage"
"github.com/viant/toolbox/url"
"path"
"strings"
"unicode"
)
//Tag represents a nearly tag
type Tag struct {
OwnerSource *url.Resource
OwnerName string
Name string
Group strin... |
/*
Copyright (C) 2018 Synopsys, Inc.
Licensed to the Apache Software Foundation (ASF) under one
or more contributor license agreements. See the NOTICE file
distributed with this work for additional information
regarding copyright ownershia. The ASF licenses this file
to you under the Apache License, Version 2.0 (the
"... |
/*
Package sgf contains various tools for working with SGF files and the SGF trees
within them. Trees are simply a collection of nodes connected together via
parent and child relationships. Each node can have properties, which are keys
with a slice of values. All keys and values are stored as strings.
In general, func... |
package protoutil
import (
"fmt"
"testing"
"time"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
"google.golang.org/protobuf/encoding/protojson"
"google.golang.org/protobuf/proto"
"google.golang.org/protobuf/types/known/structpb"
"google.golang.org/protobuf/types/known/wrapperspb"... |
package controllers
import (
"SocialWebsite/config"
"SocialWebsite/models"
"context"
"fmt"
"go.mongodb.org/mongo-driver/bson"
"go.mongodb.org/mongo-driver/bson/primitive"
"io/ioutil"
"log"
"net/http"
"strings"
"time"
)
func DeletePost(w http.ResponseWriter, r *http.Request) {
//Go to login if not logged i... |
package cards
const (
//CARD_VOID used for undefined card
CARD_VOID = iota
//CARD_FARM card to enable farm action
CARD_FARM
//CARD_FEED_SHEEP card to enable feed sheep action
CARD_FEED_SHEEP
//CARD_TAKE_OFF card to enable take off and take vacation action
CARD_TAKE_OFF
//CARD_PARTTIME_WORK card to enable ... |
package glog
import (
"errors"
logging "github.com/shenwei356/go-logging"
)
// LogLevel represents the available logging levels.
type LogLevel int
// Available log levels.
const (
Debug LogLevel = iota + 1
Info
Notice
Warning
Error
Critical
)
// Mapping from LogLevel to string name/label
var logLevelMap = ... |
package v2
import (
"fmt"
"strings"
"unicode"
"github.com/davyxu/tabtoy/util"
"github.com/davyxu/tabtoy/v2/i18n"
"github.com/davyxu/tabtoy/v2/model"
"github.com/davyxu/tabtoy/v2/printer"
)
/*
Sheet数据表单类型头
*/
const (
// 信息所在的行
DataSheetHeader_FieldName = 3 // 字段名(对应proto)
DataSheetHeader_FieldType = 2 //... |
// Copyright 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.com/apache2.0/
//
// or in the "license" file ... |
// 43. DSA key recovery from nonce
package main
import (
"crypto/rand"
"crypto/sha1"
"errors"
"fmt"
"math/big"
"strings"
)
const (
dsaPrime = `800000000000000089e1855218a0e7dac38136ffafa72eda7
859f2171e25e65eac698c1702578b07dc2a1076da241c76c6
2d374d8389ea5aeffd3226a0530cc565f3bf6b50929139ebe
ac04f48c3c84afb79... |
//
// 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 leetcode
/*We are given a list nums of integers representing a list compressed with run-length encoding.
Consider each adjacent pair of elements [a, b] = [nums[2*i], nums[2*i+1]] (with i >= 0).
For each such pair, there are a elements with value b in the decompressed list.
Return the decompressed list.
来源:力扣(... |
package cryptosquare
import (
"bytes"
"strings"
"unicode"
)
func Encode(s string) string {
s = parsedString(s)
slice := []string{}
_, m := rectangleSize(s)
for column := 0; column < m; column++ {
slice = append(slice, stringFor(column, s))
}
return strings.Join(slice, " ")
}
func parsedString(s string) st... |
// Copyright 2018 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... |
package scraper
import (
"bytes"
"testing"
"github.com/PuerkitoBio/goquery"
"github.com/osiloke/grapple/mocks"
. "github.com/smartystreets/goconvey/convey"
. "github.com/stretchr/testify/mock"
)
var testHtml = `
<html>
<body>
<div>
</div>
<table id="customers">
<tbody>
<tr>
<th>Comp... |
// Copyright 2016 The G3N 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 gui
import (
"github.com/hecate-tech/engine/math32"
"github.com/hecate-tech/engine/window"
)
/***************************************
... |
package checks
func Is_even(number int) bool {
return number % 2 == 0
}
|
package wallet
import (
"strings"
"testing"
"github.com/appditto/pippin_nano_wallet/libs/database/ent"
"github.com/appditto/pippin_nano_wallet/libs/utils"
"github.com/appditto/pippin_nano_wallet/libs/utils/ed25519"
"github.com/stretchr/testify/assert"
)
func TestGetAccount(t *testing.T) {
// Predictable seed
... |
package platform
import (
"image"
"github.com/trevor403/gostream/pkg/common"
)
type UpdateCallback func(img image.Image, width int, height int, hotx int, hoty int)
type CursorHandle struct {
callback UpdateCallback
factor float32
prev common.CursorImage
}
func NewCursorHandle() *CursorHandle {
h := Cur... |
package main
import (
"fmt"
"math"
)
type Circle struct {
r float64
}
type Rectangle struct {
width, height float64
}
func (r Rectangle) area() float64 {
return r.width * r.height
}
func (c Circle) area() float64 {
return c.r * c.r * math.Pi
}
func main() {
r1 := Rectangle{12, 4}
... |
package webhooks
import (
"encoding/xml"
"fmt"
"io"
"io/ioutil"
"github.com/blacklightcms/recurly"
)
// Webhook notification constants.
const (
// Subscription notifications.
ExpiredSubscription = "expired_subscription_notification"
// Invoice notifications.
NewInvoice = "new_invoice_notification"
Pas... |
package main
import (
"fmt"
"math"
"math/rand"
"strconv"
"github.com/btracey/amosfuzz/amos"
"github.com/btracey/amosfuzz/amos/amostest"
"github.com/gonum/floats"
)
func main() {
nRuns := 1000000
for i := 0; i < nRuns; i++ {
fmt.Println("\nrun = ", i)
x := make([]float64, 8)
for j := range x {
x[j] ... |
package domain
import (
"github.com/st3redstripe/termbank/parser"
"io/ioutil"
"net/http"
"net/url"
"strings"
)
type Account struct {
User *User
Name string
Href string
Balance string
}
func (a *Account) StatementPretty() []byte {
// Obtain our cookie for the account page
_, err := a.User.client.G... |
// Unit testing is an important part of writing
// principled Go programs. The `testing` package
// provides the tools we need to write unit tests
// and the `go test` command runs tests.
// For the sake of demonstration, this code is in package
// `main`, but it could be any package. Testing code
// typically lives i... |
package main
import (
"fmt"
)
func main() {
n := "Bond"
switch n {
case "honeybunny", "Bond", "Novi":
fmt.Println("This is honeybunny or Bond or Novi")
case "B":
fmt.Println("This is bond")
case "N":
fmt.Println("This is Novi")
default:
fmt.Println("This is default value")
}
}
|
package main
import (
"fmt"
"check_proto/proto"
"github.com/Melsoft-Games/protobuf/proto"
)
func main() {
msg := new(rrfp.Message)
msg.Hd = &rrfp.Head{
"wdijiwdcjiu",
"rrfp.ExampleEchoRequest",
}
msg.By = &rrfp.Body{
MsgType: &rrfp.Body_ExampleEchoRequest{
ExampleEchoRequest: &rrfp.ExampleEchoRequest{... |
package log
import "github.com/pkg/errors"
import "log"
// OriginalError returns the error original error
func OriginalError() error {
return errors.New("error occurred")
}
// PassThroughError calls OriginalError and
// forwards the error along after wrapping.
func PassThroughError() error {
err := OriginalError()... |
package main
import (
"fmt"
)
// func PrintType(arr []int){
// fmt.Println(reflect.TypeOf(arr).Kind())
// }
func SumFloat64(s []float64) (aver float64) {
sum := 0.0
for _, v := range s {
sum += v
}
aver = sum/float64(len(s))
return
}
func main() {
var arr = []float64{1.1, 2.3, 4.5, 100.5}
aver := SumFl... |
package typeutil
import (
"go/types"
)
// Identical reports whether x and y are identical types.
// Unlike types.Identical, receivers of Signature types are not ignored.
// Unlike types.Identical, interfaces are compared via pointer equality (except for the empty interface, which gets deduplicated).
// Unlike types.... |
package blocks
import (
"github.com/dbolotin/deadmanswitch/bctx"
"github.com/dbolotin/deadmanswitch/comm"
"github.com/hashicorp/hcl/v2"
)
type Splitter struct {
SingleChannelBlock
Expr hcl.Expression `hcl:"expr"`
SendTo bctx.ChannelPointer `hcl:"send_to"`
TerminateOnError bool ... |
package handlers
import (
"log"
services "github.com/chutommy/metal-price/api-server/app/services"
)
// Handler defines the api handler.
type Handler struct {
log *log.Logger
cs *services.Currency
ms *services.Metal
}
// NewHandler is the constructor of the Handler.
func NewHandler(l *log.Logger, cs *service... |
package netqos
import (
"fmt"
"time"
)
type QosInf interface {
ShowQos()
Stat()
StatAccpetConns()
StatCloseConns()
StatReadMsgs()
StatWriteMsgs()
IsEnable() bool
SetEnable(b bool)
}
type ServerQos struct {
timeSleep int //每隔多少秒开始统计
timeStartSecond time.Time
acceptedConns int //总共接收的连接数
closedCo... |
// Copyright © 2020. All rights reserved.
// Author: Ilya Stroy.
// Contacts: qioalice@gmail.com, https://github.com/qioalice
// License: https://opensource.org/licenses/MIT
package privet
import (
"path/filepath"
"strings"
"unsafe"
"github.com/qioalice/ekago/v2/ekaerr"
"github.com/qioalice/ekago/v2/ekaunsafe"
... |
package server
import (
"00-newapp-template/pkg/acme"
)
type SimpleDB struct {
gophers []acme.Gopher
things []acme.Thing
}
func NewDB() (s SimpleDB) {
s.gophers = []acme.Gopher{
{ID: "1", Name: "Gopher1", Description: "The first Gopher (#1st)"},
{ID: "2", Name: "Gopher2", Description: "The second Gopher (#2... |
// Package ghook provides a minimal toolset for receiving with GitHub web hooks.
package ghook
import (
"crypto/hmac"
"crypto/sha1"
"encoding/hex"
"errors"
"fmt"
"io"
"io/ioutil"
"net/http"
"strings"
)
type (
// Callback is the type of function that is called when a GitHub web hook
// request is received a... |
package metadata
import "github.com/root-gg/plik/server/common"
// GetUploadStatistics return statistics about uploads
// for userID and tokenStr params : nil doesn't activate the filter, empty string enables the filter with an empty value to generate statistics about anonymous upload
func (b *Backend) GetUploadStati... |
package main
import (
"github.com/open_sesame/trigger"
"github.com/open_sesame/decider"
"github.com/open_sesame/utils"
)
func main() {
log.Log.Debug("Open Sesame start!")
// triggers
triggers := trigger.NewTriggers()
triggers.StartTriggers()
// deciders
deciders := []decider.Decider{}
config := decider... |
package main
import (
"errors"
"flag"
"fmt"
"log"
"math/big"
"os"
"os/signal"
"time"
"github.com/ethereum/go-ethereum/accounts"
"github.com/ethereum/go-ethereum/accounts/keystore"
"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/console"
"github.com/ethereum/go-ethereum/ethclient... |
package ladon
// AuditLoggerNoOp is the default AuditLogger, that tracks nothing.
type AuditLoggerNoOp struct{}
func (*AuditLoggerNoOp) LogRejectedAccessRequest(r *Request, p Policies, d Policies) {}
func (*AuditLoggerNoOp) LogGrantedAccessRequest(r *Request, p Policies, d Policies) {}
var DefaultAuditLogger = &Aud... |
package rpc_hello
import "net/rpc"
// HelloServiceClient 实现 HelloServiceInterface 接口
var _ HelloServiceInterface = (*HelloServiceClient)(nil)
// 新增客户端 HelloServiceClient 结构体,该类型必须满足HelloServiceInterface 接口,
// 这样客户端用户就可以直接通过接口对应的方法调用RPC 函数
type HelloServiceClient struct {
*rpc.Client
}
// 实现 Hello 函数
func (p *Hel... |
package database
import (
"log"
"github.com/solrac97gr/cryptoAPI/models"
)
func GetEncryptMessage(id string) (bool, models.ReturnedMsg) {
ref := DatabaseClient.NewRef("/text/" + id)
var response models.ReturnedMsg
if err := ref.Get(FirebaseCtx, &response); err != nil {
log.Fatalln("Error reading value:", err)... |
/*
* @File: models.movie_genre.go
* @Description: Defines Movie Genre information will be returned to the clients
* @Author: Nguyen Truong Duong (seedotech@gmail.com)
*/
package models
import "gopkg.in/mgo.v2/bson"
// MovieGenre information
type MovieGenre struct {
ID bson.ObjectId `bson:"id"... |
package main
import (
"fmt"
"log"
"github.com/go-resty/resty/v2"
)
var client *resty.Client
func init() {
client = resty.New()
}
func main() {
for i := 1; i < 77; i++ {
r := fmt.Sprintf("T3-%d", i)
params := fmt.Sprintf(`{"warehouseID": "232414789256686855","regionID": "314420765674045445","containerCode"... |
package caaa
import (
"encoding/xml"
"github.com/thought-machine/finance-messaging/iso20022"
)
type Document01300105 struct {
XMLName xml.Name `xml:"urn:iso:std:iso:20022:tech:xsd:caaa.013.001.05 Document"`
Message *AcceptorDiagnosticRequestV05 `xml:"AccptrDgnstcReq"`
}
func (d *Document013... |
/*
Background
Entombed is an Atari 2600 game released in 1982, with the goal of navigating through a continuous mirrored maze as it scrolls upwards.
In recent times, the game has been subject to research — despite the strict hardware limitations of the Atari 2600, it somehow manages to create solvable mazes every tim... |
// Copyright 2020 Authors of Cilium
//
// 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 ... |
package dtos
type UploadInventoriesRequest struct {
WarehouseID int64
}
type UploadInventoriesTemplateResponse struct {
Filename string
UploadInventories UploadInventories
}
type UploadInventories []UploadInventory
type UploadInventory struct {
ID int64 `json:"product_id" csv:"product_id"`
War... |
package commands
import (
"bytes"
"github.com/bmizerany/assert"
"io/ioutil"
"os"
"path/filepath"
"testing"
)
func TestClean(t *testing.T) {
repo := NewRepository(t, "empty")
defer repo.Test()
content := "HI\n"
oid := "f712374589a4f37f0fd6b941a104c7ccf43f68b1fdecb4d5cd88b80acbf98fc2"
prePushHookFile := fil... |
// 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... |
package strand
func ToRNA(dna string) (rna string) {
var keyMap = map[rune]rune{
'G': 'C',
'C': 'G',
'T': 'A',
'A': 'U',
}
for _, char := range dna {
rna = rna + string(keyMap[char])
}
return rna
}
|
/*
* @File: databases.mongodb.go
* @Description: Handles MongoDB connections
* @Author: Nguyen Truong Duong (seedotech@gmail.com)
*/
package databases
import (
"time"
"../common"
log "github.com/sirupsen/logrus"
mgo "gopkg.in/mgo.v2"
)
// MongoDB manages MongoDB connection
type MongoDB struct... |
package main
import (
"github.com/zmb3/spotify"
"worker/spotty"
"fmt"
)
func main() {
var tracks []spotify.FullTrack
//response := parser.GetPage(parser.AristocratsMain)
//var tracks = parser.GetTrackList(response)
//
//
//for _, track := range tracks {
// log.Println(track.... |
package c13_ecb_cut_and_paste
import (
"fmt"
"strings"
)
type Profile struct {
Email string
UID int64
Role string
}
func (obj Profile) ToQuery() string {
return fmt.Sprintf("email=%s&uid=%d&role=%s", obj.Email, obj.UID, obj.Role)
}
func ParseQuery(query string) map[string]string {
mp := make(map[string]st... |
package main
import "fmt"
func main() {
var key byte
fmt.Println("请输入一个字符 a, b, c, d, e, f, g")
fmt.Scanf("%c", &key)
switch key {
case 'a':
fmt.Println("周一")
case 'b':
fmt.Println("周二")
case 'c':
fmt.Println("周三")
case 'd':
fmt.Println("周四")
case 'e':
fmt.Println("周五")
case 'f':
fmt... |
package main
import (
"encoding/json"
"fmt"
"io/ioutil"
"net/http"
"strings"
"time"
"github.com/joho/godotenv"
"github.com/labstack/echo/v4"
"github.com/labstack/echo/v4/middleware"
)
func mainHandler(c echo.Context) error {
fmt.Println("mainHandler çağrıldı")
return c.String(http.StatusOK, "Main endpoint... |
package main
import (
"os"
"fmt"
)
func main() {
f, err := os.Create("tmp/some.txt")
if err != nil {
fmt.Println(err.Error() + " ooops")
} else {
defer f.Close()
fmt.Println("file created!")
}
}
|
// Copyright 2019 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... |
package max7219
import (
"fmt"
"github.com/pkg/errors"
"periph.io/x/conn/v3"
"periph.io/x/conn/v3/physic"
"periph.io/x/conn/v3/spi"
)
const (
REG_DECODE = 0x09 // "decode mode" register
REG_INTENSITY = 0x0a // "intensity" register
REG_SCAN_LIMIT = 0x0b // "scan limit" register
REG_SHUTDOWN = ... |
package main
import "fmt"
func main() {
var num1 int = 6
var num2 float64 = 6.2623
var b bool = true
var char byte = 'i'
var str string
str = fmt.Sprintf("%d", num1)
fmt.Printf("str = %v;str = %T\n", str, str)
str = fmt.Sprintf("%f", num2)
fmt.Printf("str = %v;str = %T\n", str, str)
str = fmt.Sprintf("%t"... |
// DRUNKWATER TEMPLATE(add description and prototypes)
// Question Title and Description on leetcode.com
// Function Declaration and Function Prototypes on leetcode.com
//42. Trapping Rain Water
//Given n non-negative integers representing an elevation map where the width of each bar is 1, compute how much water it is ... |
package main
import (
"fmt"
"github.com/rossifedericoe/bootcamp/clase2/services/movieService"
)
func main() {
movie, err := movieService.Crear(123, "foo", "bar")
if err != nil {
fmt.Println(err)
} else {
fmt.Println("Película creada exitosamente: " + fmt.Sprintf("%+v", *movie))
}
}
|
package main
import (
"database/sql"
"fmt"
_ "github.com/go-sql-driver/mysql"
)
//Go连接mysql示例
func main() {
//数据库信息
dsn:="root:root@tcp(127.0.0.1:3306)/goday10"
//连接数据库
db,err :=sql.Open("mysql",dsn) //不会校验用户名和密码是否正确
if err !=nil{
fmt.Println("dsn格式不正确,",err)
return
}
err =db.Ping()
if err !=nil{
fmt... |
package main
import (
"exterminal/prompter"
"fmt"
)
func main() {
username, password := prompter.Credentials()
fmt.Printf("Username: %s, Password: %s\n", username, password)
}
|
package collatzconjecture
import (
"errors"
)
func CollatzConjecture(n int) (int, error) {
if n <= 0 {
return 0, errors.New("n should not be negative number")
}
var steps int
for {
if n == 1 {
break
}
if n%2 == 0 {
n /= 2
} else {
n = 3*n + 1
}
steps++
}
return steps, nil
}
|
package main
import (
"context"
"fmt"
"os"
"os/signal"
"syscall"
"cloud.google.com/go/bigtable/bttest"
"cloud.google.com/go/bigtable"
"google.golang.org/grpc"
"strings"
"google.golang.org/api/option"
"flag"
"errors"
)
func... |
package ascii
import (
"github.com/gin-gonic/gin"
"net/http"
)
func ResponseAsciiJson(c *gin.Context) {
data := map[string]interface{}{
"lang": "GO语言",
"tag": "<br>",
"code": 200,
}
c.PureJSON(http.StatusOK, data)
}
|
package pdl
import (
"fmt"
"github.com/go-xe2/x/os/xstream"
"math"
"sort"
)
type FileServiceMethod struct {
Name string `json:"name"`
Summary string `json:"summary"`
Args []*FileDataField `json:"args"`
Result *FileDataType `json:"resultType"`
Exception *FileDataType `... |
package leetcode
import "strings"
func uniqueMorseRepresentations(words []string) int {
morse := []string{".-", "-...", "-.-.", "-..", ".", "..-.", "--.", "....", "..", ".---", "-.-", ".-..", "--", "-.", "---", ".--.", "--.-", ".-.", "...", "-", "..-", "...-", ".--", "-..-", "-.--", "--.."}
set := make(map[string]s... |
package bootstrap
import (
"encoding/json"
"io/ioutil"
"net"
"net/http"
"github.com/go-logr/logr"
"github.com/kumahq/kuma/pkg/core"
"github.com/kumahq/kuma/pkg/core/resources/store"
"github.com/kumahq/kuma/pkg/core/validators"
"github.com/kumahq/kuma/pkg/util/proto"
"github.com/kumahq/kuma/pkg/xds/bootstra... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.