text stringlengths 11 4.05M |
|---|
package main
import (
"os"
"github.com/timakin/md2mid/command"
"github.com/urfave/cli"
)
func main() {
app := cli.NewApp()
app.Commands = []cli.Command{
command.InitCommand(),
command.PublishCommand(),
}
app.HideVersion = true
app.Copyright = "MIT"
app.Usage = "Set your token to call a Medium API, and p... |
package main
import (
"encoding/json"
"flag"
"fmt"
"io/ioutil"
"os"
"path/filepath"
//"reflect"
"sort"
//"syscall"
)
// camliTypes
const (
file = 1
bytes = 2
static_set = 3
directory = 4
permanode = 5
claim = 6
)
type BlobRef string
type BlobType struct {
camliContent BlobRef
caml... |
package model
import (
"github.com/cepljxiongjun/omgo/app"
)
type Tree struct {
Label string `json:"label"`
Value uint `json:"value"`
Children []Tree `json:"children"`
}
func GetTree(pid uint) []Tree {
var tree []Tree
var category []Category
app.Conn.Where("pid = ?", pid).Find(&category)
length := ... |
package admin
import (
"context"
"tpay_backend/adminapi/internal/common"
"tpay_backend/model"
"tpay_backend/upstream"
"tpay_backend/adminapi/internal/svc"
"tpay_backend/adminapi/internal/types"
"github.com/tal-tech/go-zero/core/logx"
)
type GetUpstreamBalanceLogic struct {
logx.Logger
ctx context.Contex... |
package grpc
import (
"context"
"time"
"github.com/pkg/errors"
"github.com/sirupsen/logrus"
"github.com/JokeTrue/otus-golang/hw12_13_14_15_calendar/pkg/models"
"github.com/golang/protobuf/ptypes/duration"
"github.com/google/uuid"
"google.golang.org/grpc/codes"
"github.com/JokeTrue/otus-golang/hw12_13_14... |
package v1
import (
"context"
v1 "github.com/coreos/prometheus-operator/pkg/apis/monitoring/v1"
"github.com/coreos/prometheus-operator/pkg/client/versioned"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/watch"
)
type ServiceMonitorsGetter interface {
ServiceMonitors(namespace string) Se... |
package converter
import (
. "encoding/binary"
"math"
)
func BigEndianUInt642Bytes(i uint64) []byte {
var buf = make([]byte, 8)
BigEndian.PutUint64(buf, i)
return buf
}
func BigEndianInt642Bytes(i int64) []byte {
var buf = make([]byte, 8)
BigEndian.PutUint64(buf, uint64(i))
return buf
}
func LittelEndianInt64... |
/*
From SO.
https://stackoverflow.com/questions/4897280/given-an-array-of-positive-and-negative-integers-re-arrange-it-so-that-you-have
You are given an array with positive and negative integers. Write a function to change the elements order in the array such that negative integers are at the beginning, the positive ... |
/*
Package 'pathfileops' provides software types and methods used in
the management, organization and control of disk files and directories.
This package incorporates three primary types:
1. FileHelper - A series of generalized file maintenance utilities
2. DirMgr - Directory Manager: Designed for the creati... |
// Copyright 2019 The OpenSDS Authors.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agre... |
package git
import (
"io/ioutil"
"os"
"os/exec"
"testing"
"github.com/abhinav/git-pr/gateway"
"github.com/stretchr/testify/require"
)
func TestPushNoRefs(t *testing.T) {
dir, err := ioutil.TempDir("", "git-pr")
require.NoError(t, err, "couldn't create a temporary directory")
defer os.RemoveAll(dir)
restor... |
package goSolution
import "testing"
func TestRemoveDuplicates(t *testing.T) {
AssertEqual(t, "ca", removeDuplicates("abbaca"))
}
|
// +build linux,!dockerless
/*
Copyright 2021 The Kubernetes Authors.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable ... |
package main
import (
"fmt"
"strings"
"unicode"
)
func main() {
a := "gopher"
b := "hello world"
fmt.Println(strings.Compare(a, b))
fmt.Println(strings.Compare(a, a))
fmt.Println(strings.Compare(b, a))
fmt.Println(strings.EqualFold("GO", "go"))
fmt.Println(strings.EqualFold("壹", "一"))
s := "测试包含con"
fmt... |
package main
import (
"testing"
"net/http"
"github.com/julienschmidt/httprouter"
"bytes"
)
func mockServe(string, http.Handler) error {
return nil
}
func mockServeTls(string, string, string, http.Handler) error {
return nil
}
var r = 5
func mockPsName(ps httprouter.Params) string {
if r == 5 {
r = 4
ret... |
package helpers
import (
"encoding/json"
)
func JSONEncodeToString(data interface{}) (string, error) {
if data_bytes, err := json.Marshal(data); err == nil {
data := string(data_bytes)
return data, nil
} else {
return "", err
}
}
func JSONEncodeToMap(data string, fields ...string) (map[string]interface{}, ... |
// Copyright 2020 The Operator-SDK 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 ... |
package main
import (
"fmt"
"os"
"os/signal"
"sync"
"github.com/urfave/cli"
"github.com/op/go-logging"
. "github.com/leochan007/xtp.go/go_src/defs"
. "github.com/leochan007/xtp.go/go_src/xtp_wrapper"
)
type StockMap map[string]string
var (
log = logging.MustGetLogger("go_xtp_trader")
Stocks = make(StockM... |
package main
//Todo: implement SSL/https
import (
"bytes"
"fmt"
"github.com/gorilla/handlers"
"github.com/gorilla/mux"
"log"
"net/http"
"net/http/httputil"
"os"
)
type token_auth struct {
Email string `json:"email"`
Password string `json:"password"`
}
func putValue(key string, value string) {... |
package db
import (
"time"
"github.com/bwmarrin/discordgo"
"github.com/jackc/pgx"
)
type User struct {
ID string `db:"id"`
InsertedAt *time.Time `db:"inserted_at"`
UpdatedAt *time.Time `db:"updated_at"`
Name string `db:"name"`
Discriminator string `db:"discriminator"`
... |
/*
Copyright © 2020 Thomas Mitchell
*/
//Package cmd defines actions to be run from the command line.
package cmd
import (
"fmt"
"os"
"github.com/cloudfoundry-community/merge-bosh-dns/config"
"github.com/jhunt/go-ansi"
"github.com/spf13/cobra"
"github.com/spf13/viper"
)
var cfgFile string
var cfg config.Co... |
package main
import (
"html/template"
"net/http"
)
func main() {
template := template.Must(template.ParseFiles("template.html"))
http.HandleFunc("/", func(res http.ResponseWriter, req *http.Request) {
template.ExecuteTemplate(res, "template.html", "Index")
})
http.HandleFunc("/dog/", func(res http.ResponseW... |
package base
import (
"fmt"
"strings"
)
// Session represents a PostgreSQL backend
type Session struct {
Pid int64
User string
Db string
Client string
State string
Query string
StateDuration float64
ApplicationName string
}
// NewSession in... |
package aes
import (
"crypto/aes"
"crypto/cipher"
"fmt"
"io/ioutil"
"log"
)
func DecryptTxt(args []string) {
if len(args) == 0 {
log.Fatal("No arguments provided. Please see small-aes -h")
}
key := []byte(args[1])
ciphertext, err := ioutil.ReadFile(args[0])
if err != nil {
log.Fatal(err)
}
c, err :... |
package tsrv
import (
"encoding/xml"
"github.com/thought-machine/finance-messaging/iso20022"
)
type Document01300101 struct {
XMLName xml.Name `xml:"urn:iso:std:iso:20022:tech:xsd:tsrv.013.001.01 Document"`
Message *UndertakingDemandV01 `xml:"UdrtkgDmnd"`
}
func (d *Document01300101) AddMessage() *... |
package config
type CityUrl struct{
Name string
Url string
}
type Salary struct {
Low int
Avg int
High int
}
type DBConfig struct {
DBname string
Username string
Password string
Protocol string
Address string
Tablename string
}
/*
招聘信息
Pid 去重唯一id
Postion 职位
Salary 薪资
City 城市
WorkYear 工作年限
Education 学历要求
... |
package arrays
func dominantIndex(nums []int) int {
if nums == nil || len(nums) == 0 {
return -1
}
if len(nums) == 1 {
return 0
}
max := nums[0]
max2 := -1
h := map[int]int{}
for i := 1; i < len(nums); i++ {
h[nums[i]] = i
if nums[i] > max {
max2 = max
max = nums[i]
} else if nums[i] > max2 {
... |
// 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 twosum
import (
"testing"
)
func TestTwoSum(t *testing.T) {
var nums = []int{2, 7, 11, 15}
var target = 13
a := twoSum(nums, target)
if a[0] == 0 && a[1] == 2 {
t.Log(twoSum(nums, target))
} else {
t.Error("算法有误")
}
}
|
package vfs
import (
"bytes"
"fmt"
"io"
"os"
"path/filepath"
"strings"
"testing"
"time"
"github.com/capnspacehook/pandorasbox/fstesting"
"github.com/capnspacehook/pandorasbox/ioutil"
)
const (
dots = "1....2....3....4"
abc = "abcdefghijklmnop"
)
func TestWalk(t *testing.T) {
fs := NewFS()
testpath :=... |
package tags
import (
"testing"
)
func TestTags(t *testing.T) {
F()
}
|
// Copyright (C) 2019 Cisco Systems 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 agr... |
package repository
import (
"github.com/freelifer/gohelper/server/repository/database"
)
const (
// root error no
SUCCESS = 0
SERVER_ERROR = 10001
POST_HAS_NO_PARAM = 10002
// user error no
LOGIN_ERROR = 30001
CREATE_USER_ERROR = 30002
)
type Repository struct {
Mark string
errno int... |
/*
This package contains generic functions used by caryatid. It should not be used for functions that contain caryatid specific logic.
*/
package util
import (
"crypto/sha1"
"encoding/hex"
"io"
"os"
)
// PathExists tests whether path exists
// Note that Stat() may return other errors, which we do not check for
f... |
package influxql_test
import (
"testing"
"github.com/influxdata/influxql"
)
func TestSanitize(t *testing.T) {
var tests = []struct {
s string
stmt string
}{
// Proper statements that should be redacted.
{
s: `create user "admin" with password 'admin'`,
stmt: `create user "admin" with password... |
/*
* Tencent is pleased to support the open source community by making Blueking Container Service available.
* Copyright (C) 2019 THL A29 Limited, a Tencent company. All rights reserved.
* Licensed under the MIT License (the "License"); you may not use this file except
* in compliance with the License. You may obta... |
// Copyright 2021 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... |
type Greeting struct {
Author string
Content string
Date time.Time
}
func x(w http.ResponseWriter, r *http.Request) {
c := appengine.NewContext(r)
g := Greeting{
Content: r.FormValue("content"),
Date: time.Now(),
}
rootKey := datastore.NewKey(c, "Guestbook... |
package models
import "errors"
var (
SameForumeError = errors.New("duplicate key value violates unique constraint \"forum_pkey\" (SQLSTATE 23505)")
NoUser = errors.New("")
)
|
package bot
type Type string
const (
Supreme Type = "Supreme"
Shopify Type = "Shopify"
)
type Base interface {
Run()
GetInfo() *Info
}
type SearchProduct struct {
ProductKeywords []string
StyleKeywords []string
SizeKeywords []string
}
type BillingProfile struct {
Name string
FirstName string
La... |
// Copyright (c) YugaByte, Inc.
package task
import (
"bufio"
"bytes"
"context"
"encoding/json"
"fmt"
"node-agent/model"
"node-agent/util"
"os"
"os/exec"
"os/user"
"path/filepath"
"regexp"
"sort"
"strconv"
"strings"
"sync/atomic"
"syscall"
"github.com/olekukonko/tablewriter"
funk "github.com/thoas... |
package source
import (
"fmt"
"log"
"net/http"
"regexp"
"strconv"
"strings"
"time"
"github.com/PuerkitoBio/goquery"
"github.com/xlaurent/proxycrawler/proxy"
)
func Cyber() ([]*proxy.Proxy, error) {
resp, err := http.Get("http://www.cybersyndrome.net/search.cgi?q=CN&a=ABC&f=s&s=new&n=500")
if err != nil {
... |
package filters_test
import (
. "github.com/onsi/ginkgo"
. "github.com/onsi/gomega"
. "github.com/bosh-prometheus/bosh_exporter/filters"
)
var _ = Describe("CollectorsFilter", func() {
var (
err error
filters []string
collectorsFilter *CollectorsFilter
)
JustBeforeEach(func() {
collectorsFilter, ... |
package main
import (
"context"
"fmt"
"net"
"os"
"os/signal"
"strings"
"sync"
"syscall"
"time"
etcdClient "github.com/coreos/etcd/clientv3"
etcdnaming "github.com/coreos/etcd/clientv3/naming"
grpc "google.golang.org/grpc"
naming "google.golang.org/grpc/naming"
)
const (
publicIP = "127.0.0.1"
publi... |
package controllers
import (
"github.com/astaxie/beego"
"fmt"
"time"
"strconv"
)
type Item struct {
Itemid string
Productid string
Listprice float64
Unitcost float64
Attr1 string
Status string
Date time.Time
Amount float64
}
type Goods struct {
Id int
Name string
Price float64
}
type FooterData struc... |
package utils
const (
//STATUSSUCESS successstatus
STATUSSUCESS = 1
//STATUFAILS fails
STATUFAILS = 0
//STATUUNAUTH unth
STATUUNAUTH = 3
)
|
package items
type Director struct {
ID int64
Name string
Surname string
Nacionality string
}
|
package main
import (
"testing"
)
func NewTestingSlack(t *testing.T) Slack {
if len(SlackApiKey) == 0 {
t.Skip("Slack API key missing")
}
slack := Slack{Token: SlackApiKey}
err := slack.ApiTest()
if err != nil {
t.Skip("Unable to make trivial call to Slack API: " + err.Error())
}
return slack
}
func T... |
package main
// Model for queueing to the highscore api
type queueModel struct {
Playlist string `json:"playlist"`
Username string `json:"username"`
Result string `json:"result"`
}
// Model to put on the queue
type ResultModel struct {
Result string `json:"result"`
}
// Request model
type RandomizeRequest struct... |
package dal
import (
_ "re/db"
"re/db/client"
"re/db/form"
)
func DomainBridgeGet(from_domain_id int, bridgeCode string) (form.DomainBridge, error) {
var d form.DomainBridge
sql := client.DB.Where(&form.DomainBridge{From: from_domain_id, Code: bridgeCode}).First(&d)
if sql.Error != nil {
return form.DomainBri... |
package mongodb
import (
"context"
"errors"
"go.mongodb.org/mongo-driver/mongo"
"go.mongodb.org/mongo-driver/mongo/options"
)
// ErrInvalidObjectID indicates that a provided string is not a valid object id.
var ErrInvalidObjectID = errors.New("the provided string is not a valid ObjectID")
var client *mongo.Clie... |
package controllers
import (
"test/models"
"github.com/astaxie/beego"
)
type BaseController struct {
beego.Controller
}
func (this *MainController) Prepare() {
if this.GetSession("userinfo") == nil {
this.Redirect("/user/login", 302)
} else {
//载入模块配置信息
models.LoadConfig()
}
}
|
package mongo
import (
"context"
"errors"
"time"
"go.mongodb.org/mongo-driver/mongo"
"go.mongodb.org/mongo-driver/mongo/options"
)
const (
defaultConnctTimeOut = 10 * time.Second
defaultPingWaitingTime = 2 * time.Second
)
// Cfg config for mongodb
type Cfg struct {
Size uint64
Addr []st... |
// Copyright (C) 2017 Google 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... |
/*
* Copyright 2017 StreamSets 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... |
package commands
import (
"fmt"
"log"
"os"
"github.com/argoproj/argo/workflow/common"
"github.com/spf13/cobra"
)
func init() {
RootCmd.AddCommand(pauseCmd)
}
var pauseCmd = &cobra.Command{
Use: "pause WORKFLOW1 WORKFLOW2...",
Short: "pause a workflow",
Run: func(cmd *cobra.Command, args []string) {
if ... |
package web3
import (
"github.com/stretchr/testify/assert"
"testing"
"web3.go/consts"
"web3.go/providers"
)
func Test_Web3_GetBalance(t *testing.T) {
web3 := NewWeb3(providers.NewHTTPProvider(consts.HOST_HTTP_PROVIDER_LOCAL, 10))
t.Run("web3_clientVersion", func(t *testing.T) {
v, err := web3.ClientVersion()... |
// Copyright 2016 CoreOS, 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 (
"fmt"
"sort"
)
func main() {
slice := []int{3, 2, 1}
slices := [][]int{}
sort.Ints(slice)
slices = append(slices, slice)
fmt.Println(slices) // [[1 2 3]]
slice[0], slice[1] = slice[1], slice[0]
slices = append(slices, slice)
fmt.Println(slices) // [[2 1 3] [2 1 3]]
slice[1], slice[2... |
package main
import (
"github.com/garyburd/redigo/redis"
)
// 转存到redis
func toredis(server string, r string) {
conn, err := redis.Dial("tcp", server)
if err != nil {
panic(err)
}
defer conn.Close()
_, err = conn.Do("lpush", "weeklyreport", r)
if err != nil {
panic(err)
}
//fmt.Println(v)
}
|
// Copyright 2017 PingCAP, Inc.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to i... |
// Copyright 2010 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.
package json
import (
"strings"
"testing"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
"github.com/wal-g/json/mocks"
)
fu... |
package sessao
import (
"api/factory"
"api/middleware"
"encoding/json"
"net/http"
"strings"
"time"
)
func Refresh(response http.ResponseWriter, request *http.Request) {
bearerToken := request.Header.Get("Authorization")
bearTokenSlice := strings.Split(bearerToken, " ")
if len(bearTokenSlice) < 4 {
respons... |
package main
import (
"context"
"fmt"
"github.com/google/uuid"
"github.com/aws/aws-sdk-go/aws/awserr"
"github.com/aws/aws-sdk-go/service/dynamodb/dynamodbiface"
"github.com/aws/aws-lambda-go/lambda"
"github.com/aws/aws-sdk-go/aws"
"github.com/aws/aws-sdk-go/service/dynamodb"
"github.com/aws/aws-sdk-go/serv... |
rootKey := datastore.NewKey(c, "Guestbook", "default_guestbook", 0, nil)
q := datastore.NewQuery("Greeting").Ancestor(rootKey).Order("-Date").Limit(10)
greetings := make([]Greeting, 0, 10)
if _, err := q.GetAll(c, &greetings); err != nil {
http.Error(w, err.Error(), http.StatusInternalServerError)
return
} |
package main
import (
"crypto/md5"
"encoding/hex"
"fmt"
"io/ioutil"
"log"
"os"
"strconv"
)
type User struct {
name string
monthlySalary int64
workTime int64
TotalPayment int64
}
var userArr [3]User
var token = false
func main() {
var (
name,hash string
money, worktime int64
... |
package division_test
import (
"testing"
division "github.com/crhntr/IAA-Code/Algorithms/1.1_Division"
)
func TestAlg3_6(t *testing.T) {
if q, r := division.Alg(6, 3); q != 2 && r != 0 {
t.Fail()
}
}
func TestAlg7_2(t *testing.T) {
if q, r := division.Alg(7, 2); q != 3 && r != 1 {
t.Fail()
}
}
func Bench... |
package aws
import (
"bytes"
"encoding/json"
"strings"
"text/template"
"github.com/cloudfoundry/bosh-bootloader/storage"
)
var AMIs = `{
"ap-northeast-1": "ami-10dfc877",
"ap-northeast-2": "ami-1a1bc474",
"ap-south-1": "ami-74c1861b",
"ap-southeast-1": "ami-36af2055",
"ap-southeast-2": "ami-1e9181... |
// Copyright (c) 2020 TomoChain
package services
import (
"context"
"github.com/coinbase/rosetta-sdk-go/server"
"github.com/coinbase/rosetta-sdk-go/types"
"github.com/tomochain/tomochain-rosetta-gateway/common"
tc "github.com/tomochain/tomochain-rosetta-gateway/tomochain-client"
tomochaincommon "github.com/tomo... |
package transport_test
import (
"bytes"
"encoding/json"
"github.com/atymkiv/echo_frame_learning/blog/cmd/api/user"
"github.com/atymkiv/echo_frame_learning/blog/cmd/api/user/transport"
"github.com/atymkiv/echo_frame_learning/blog/model"
"github.com/atymkiv/echo_frame_learning/blog/pkg/utl/mock"
"github.com/atymk... |
package main
import (
"fmt"
"sync"
)
var (
wG sync.WaitGroup //信号量
)
var rwlock sync.RWMutex //读写锁
// 验证多个goroutine可以同时获取读锁
func main() {
wG.Add(1)
//1.
rwlock.RLock()
fmt.Println("--main goroutine get rlock---")
//2.
go func() {
rwlock.RLock() //2.1
fmt.Println("--new goroutine get rlock---")
rwloc... |
package decorator
import (
"fmt"
"log"
"net/http"
_ "strings"
)
func WithServerHeader(h http.HandlerFunc) http.HandlerFunc {
return func(w http.ResponseWriter, r *http.Request) {
log.Println("--->WithServerHeader_()")
w.Header().Set("Server", "HelloServer v0.0.1")
h(w, r)
}
}
func hello(w http.ResponseWri... |
package model
type Function struct {
name string
comment string
returns *VarList
params *VarList
body *Block
}
func NewFunction() *Function {
ret := &Function{}
ret.returns = NewVarList()
ret.params = NewVarList()
ret.body = NewBlock()
return ret
}
func (this *Function) GetName() string {
return th... |
package prime_numbers
import (
"fmt"
"geekbrains-go/lvl-1/scan"
"io"
"math"
"os"
)
func run() {
fmt.Println("Ввведите целое число")
maxNumber := scan.Int64(os.Stdout, os.Stdin)
primeNumbers := findPrimeNumbers(maxNumber, os.Stdout)
fmt.Println(primeNumbers)
}
func findPrimeNumbers(maxNumber int64, w io.Writ... |
package transactionservice
import (
"github.com/morscino/wallet-engine/models/transactionmodel"
"github.com/morscino/wallet-engine/utility/log"
"github.com/morscino/wallet-engine/utility/message"
"gorm.io/gorm"
)
type TransactionService struct {
db *gorm.DB
}
type TransactionRepository interface {
CreateTransa... |
package r10kshelldeployer
import (
"context"
"github.com/pkg/errors"
"go.opencensus.io/trace"
)
// DeployR10KEnv call the deploy command for r10k via a local shell call.
func (sh *Shell) DeployR10KEnv(ctx context.Context, env string) error {
ctx, span := trace.StartSpan(ctx, "r10kshelldeployer.deploy-r10k-env")
... |
// Copyright 2019-present 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 agr... |
package menu
import (
"fmt"
tgbotapi "github.com/go-telegram-bot-api/telegram-bot-api"
"math"
"projja_telegram/command/util"
"projja_telegram/model"
"strings"
)
func MakeTaskStatusesMenu(
message *util.MessageData,
project *model.Project,
taskStatuses []*model.TaskStatus,
page int,
count int,
) tgbotapi.Me... |
package netcode
import "inet.af/netaddr"
type NetcodeAddress struct {
Hostname string
Port uint16
IPPort netaddr.IPPort
}
|
package main
import "fmt"
func main() {
// 변수는 기본 초기화 과정 필요
// 정수 타입: 0, 실수(소수점): 0.0, 문자열: "", Boolean: true, false
// var a int32 // 선언만 하고 초기화 안하면 에러 발생
// var b string
// var c, d, e int32
// var f, g, h int32 = 1, 2, 3
// var i float32 = 11.4
// var j string = "Hi, Golang!"
// var m = true
var k ... |
package common
import (
"time"
)
const DEFAULT_SYSLOG_PRIORITY = "13"
// http://en.wikipedia.org/wiki/Syslog#Format_of_a_Syslog_Packet
type syslogMessage struct {
Priority string `json:"priority"`
Time string `json:"time"`
}
func newSyslogMessage(pri string, t time.Time) syslogMessage {
return syslogMessage... |
package streamview
import (
"html/template"
"io/ioutil"
"net/http"
"github.com/gorilla/websocket"
)
func (sv *StreamView) httpRouteConfig() {
http.HandleFunc("/", sv.indexView)
http.HandleFunc("/pkgconfig", sv.pkgConfigView)
http.HandleFunc("/stats", sv.statsView)
http.HandleFunc("/streamview", sv.webSock)
}... |
package main
import (
"math/rand"
"github.com/faiface/pixel"
)
// genPlanetParameters generates random numbers for all parameters of a planet
// the valid values / ranges are passed in as arrays.
func genPlanetParameters(sizes []int) (size, vel, dir float64) {
size = float64(sizes[rand.Intn(len(sizes))])
vel = (... |
/*
* Copyright (C) 2019 Rohith Jayawardene <gambol99@gmail.com>
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.... |
package redisz
import (
"Common/logger"
"github.com/garyburd/redigo/redis"
)
func (r *RedisPool) Zadd(key string, score int, member string) int {
conn := r.pool.Get()
defer conn.Close()
val, err := redis.Int(conn.Do("ZADD", key, score, member))
if err != nil {
logger.Warn("ZADD ", r.server, " ", r.name, " "... |
// Copyright © 2018 VMware, Inc. All Rights Reserved.
// SPDX-License-Identifier: BSD-2-Clause
package processors
import (
"fmt"
"github.com/vmware/kube-fluentd-operator/config-reloader/util"
"strings"
"github.com/vmware/kube-fluentd-operator/config-reloader/fluentd"
)
const (
macroThisns = "$thisns"
)
type e... |
package v1
import (
"net"
log "github.com/sirupsen/logrus"
)
// Disconnected is invoked when invokee client disconnected
func (h Handle) Disconnected(addr *net.TCPAddr) {
log.WithField("addr", addr.String()).Info("Disconnected")
}
|
// Copyright 2015 Daniel Theophanes.
// Use of this source code is governed by a zlib-style
// license that can be found in the LICENSE file.package service
//go:build windows
// +build windows
package minwinsvc
import (
"os"
"sync"
"golang.org/x/sys/windows/svc"
)
var (
onExit func()
guard sync.Mutex
)
fun... |
package main
import (
"fmt"
"math"
"math/big"
)
func main() {
den := big.NewRat(1, 1024)
fmt.Printf("res is %v,Type is %T\n", den, den)
res := big.NewInt(1).SetUint64(1000)
fmt.Printf("res is %v,Type is %T\n", res, res)
im := big.NewInt(math.MaxInt64)
fmt.Printf("Big Int im is: %v\n", im)
... |
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT license.
package engine
func createCosmosDBAccount() map[string]interface{} {
cosmosEtcdMap := map[string]interface{}{
"apiVersion": "[variables('apiVersionCosmos')]",
"name": "[variables('cosmosAccountName')]",
"locat... |
package leetcode
func buildTree(preorder []int, inorder []int) *TreeNode {
if len(preorder) == 0 {
return nil
}
if len(preorder) == 1 {
return &TreeNode{Val: preorder[0]}
}
var c = TreeNode{Val: preorder[0]}
for i := 0; i < len(inorder); i++ {
if inorder[i] == preorder[0] {
c.Left = buildTree(preorder[1... |
package handlers
import (
"coffeebeans-people-backend/constants"
"coffeebeans-people-backend/models"
"coffeebeans-people-backend/utility"
"net/http"
)
func Logout() http.HandlerFunc {
return func(w http.ResponseWriter, r *http.Request) {
userFromContext := r.Context().Value(constants.USER_KEY).(models.User)
... |
package core
import (
"github.com/mauricelam/genny/generic"
)
// ===========================================================================
// Beg of generation for anyType
// Copyright 2018 Andreas Pannewitz. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found i... |
package mcache
import (
"encoding/json"
"fmt"
"time"
lru "github.com/hashicorp/golang-lru"
du "github.com/notduncansmith/duramap"
)
// Index represents a collection of documents managed by the cache
type Index struct {
ID string `json:"id"`
docs *du.Duramap
cache *lru.TwoQueueCache
}
// NewIndex returns... |
package util
import (
"context"
"database/sql"
"fmt"
"github.com/elgris/sqrl"
"github.com/alewgbl/fdwctl/internal/database"
"github.com/alewgbl/fdwctl/internal/logger"
)
func EnsureUser(ctx context.Context, dbConnection *sql.DB, userName string, userPassword string) error {
log := logger.Log(ctx).
WithFiel... |
// 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 util
import (
"crypto/sha1"
"fmt"
"log"
"os"
"path"
"path/filepath"
"strings"
)
// GetProcessBaseName возвращает только имя процесса, указанное в полном пути <path>.
// Пример:
// path: "/home/folder/command"
// return: "command"
func GetProcessBaseName(path string) string {
return filepath.Base(strin... |
package day2
import (
"aoc-2020/internal/utils"
"fmt"
"strconv"
"strings"
)
type dbEntry struct {
min int
max int
char string
password string
}
func Solution() {
lines := utils.ReadInput("internal/day2/input2")
numValidA := 0
numValidB := 0
for _, line := range lines {
entry := parseLine(line)
if ... |
package common
import (
"errors"
)
var (
ErrRoleNotExist = errors.New("Role does not exist")
ErrRoleTypeNotExist = errors.New("Role type does not exist")
ErrRoleExist = errors.New("Role existed")
ErrPermNotExist = errors.New("Permission does not exist")
ErrPermTypeNotExist = errors.New("Permissio... |
package main
import (
"testing"
)
// goos: windows
// goarch: amd64
// BenchmarkStringSliceLoopCompare-4 30000000 36.4 ns/op
// BenchmarkStringSliceReflectEqual-4 1000000 1682 ns/op
// PASS
// ok command-line-arguments 2.926s
var (
s1 = []string{"hi", "this", "is", "a"... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.