text stringlengths 11 4.05M |
|---|
//go:build !go1.21
// +build !go1.21
package log
import (
"bufio"
"io"
stdlog "log"
"os"
"strings"
)
var (
stdLogWriter *io.PipeWriter
redirectComplete chan struct{}
)
// RedirectGoStdLog is used to redirect Go's internal std log output to this logger AND registers a handler for slog
// that redirects sl... |
package ssvgc
import (
"encoding/xml"
"image"
"image/draw"
"io/ioutil"
"log"
"strconv"
"github.com/golang/freetype"
"github.com/golang/freetype/truetype"
"golang.org/x/image/math/fixed"
)
type Text struct {
textContext
chunks []*textChunk
buf []byte
}
func NewText() *Text {
t := &Text{}
t.fillColor... |
// Copyright (c) 2015-2017 Marcus Rohrmoser, http://purl.mro.name/recorder
//
// Permission is hereby granted, free of charge, to any person obtaining a copy of this software and
// associated documentation files (the "Software"), to deal in the Software without restriction,
// including without limitation the rights t... |
package silverfish
import (
"errors"
"strconv"
"time"
entity "silverfish/silverfish/entity"
"gopkg.in/mgo.v2/bson"
)
// User export
type User struct {
userInf *entity.MongoInf
}
// NewUser export
func NewUser(userInf *entity.MongoInf) *User {
u := new(User)
u.userInf = userInf
return u
}
// GetUser expor... |
package io
import (
"consumer-importer/io/util"
"consumer-importer/model"
"errors"
"strconv"
"strings"
"time"
)
//IsHeader checks if the line is a header type
func IsHeader(line string) bool {
return len(line) == util.HeaderSize
}
//Format format a string line of the imported file to a Consumer object
func Fo... |
package dict
import (
"context"
"fmt"
"testing"
)
func TestBing_Search(t *testing.T) {
bing := Bing{}
word, err := bing.Search(context.Background(), "hello")
if err != nil {
t.Fatal(err)
}
fmt.Println(word)
}
|
package models
import (
"github.com/astaxie/beego/orm"
"time"
)
//查询的类
type RoleBlackListQueryParam struct {
BaseQueryParam
Phone string `json:"phone"` //手机号 模糊查询
//发布时间
StartTime int64 `json:"startTime"` //开始时间
EndTime int64 `json:"endTime"` //截止时间
}
func (a *RoleBlackList) TableName() string {
return R... |
package main // import "github.com/kidoda/quikalarm"
import (
_ "errors"
"time"
_ "github.com/faiface/beep"
_ "github.com/faiface/beep/speaker"
_ "github.com/faiface/beep/wav"
)
var (
now = time.Now() // A global now just for reference
alarmSound = loadBuzzer() // TODO: Git rid of this global and cal... |
package client
import (
"io/ioutil"
"path/filepath"
"strings"
"github.com/herb-go/herbgo/util/config/tomlconfig"
"github.com/herb-go/herbgo/util"
)
//ModuleName module name
const ModuleName = "900services.client"
var WorldsPath string
func MustLoadWorlds() {
files, err := ioutil.ReadDir(WorldsPath)
if err ... |
package cors
import (
"github.com/Highway-Project/highway/pkg/middlewares"
"net/http"
"strconv"
"strings"
)
type CORSMiddleware struct {
// AllowOrigin defines a list of origins that may access the resource.
// Optional. Default value []string{"*"}.
AllowOrigins []string
// AllowMethods defines a list metho... |
package test_helpers
import (
"fmt"
"github.com/go-martini/martini"
. "github.com/onsi/gomega"
"net/http"
"net/url"
)
var (
GLOBAL_SERVER_URL *url.URL
Router *martini.ClassicMartini
)
func CloneHeaders(headers http.Header) http.Header {
header_cloned := make(http.Header)
for k, v := range headers... |
package backends
import (
"log"
"github.com/liut/staffio/pkg/backends/ldap"
"github.com/liut/staffio/pkg/common"
"github.com/liut/staffio/pkg/models"
"github.com/liut/staffio/pkg/models/cas"
"github.com/liut/staffio/pkg/models/weekly"
"github.com/liut/staffio/pkg/settings"
)
type Servicer interface {
models.... |
/*
* 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... |
/*
Copyright 2022 The KubeVela 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 agreed to in writing, softw... |
package main
import (
"github.com/funkygao/gobench/util"
"testing"
)
func main() {
b := testing.Benchmark(benchmarkStackAllocation)
util.ShowBenchResult("stack alloc:", b)
b = testing.Benchmark(benchmarkHeapAllocation)
util.ShowBenchResult("heap alloc:", b)
}
func stackalloc() [128]int64 {
return [128]int64{... |
package redis
import (
"context"
"errors"
"fmt"
goredis "github.com/go-redis/redis/v8"
"time"
)
const (
PIPELINES_KEY = "pipelines"
LEASE_DURATION = time.Minute
)
var (
LeaseExpired = errors.New("lease expired")
LeaseNotFound = errors.New("lease not found")
LeaseExists = errors.New("lease already exist... |
package main
import (
"fmt"
"net/http"
"log"
"html/template"
"github.com/meditate/miniature-garbanzo-blog/models"
"database/sql"
_ "github.com/lib/pq"
)
var posts map[string]*models.Post
func writeHandler(w http.ResponseWriter, r *http.Request) {
t, err := template.ParseFiles(
"templates/write.... |
package Service
import (
"Work_5/DAO"
"Work_5/object"
)
//获取点赞前十的文章
func SelectTopArticle(articles *[]object.Article) object.ErrMessage {
//获得数据库连接
db, err := DAO.DataBaseInit()
if err.IsErr {
return err
}
//调用DAO层函数
if err = DAO.SelectTopArticle(articles, db); err.IsErr {
return err
}
return object.... |
package net
import (
"context"
"errors"
"strings"
"sync"
"time"
"github.com/drand/drand/protobuf/drand"
"github.com/nikkolasg/slog"
"google.golang.org/grpc"
"google.golang.org/grpc/credentials"
)
var _ Client = (*grpcClient)(nil)
//var defaultJSONMarshaller = &runtime.JSONBuiltin{}
var defaultJSONMarshalle... |
package c46_rsa_parity
import (
"errors"
"math/big"
"github.com/vodafon/cryptopals/set5/c39_rsa"
)
type System struct {
*c39_rsa.RSA
}
func NewSystem(bs int) System {
rsa, err := c39_rsa.Generate(bs)
if err != nil {
panic(err)
}
return System{rsa}
}
func (obj System) IsEven(ciphertext []byte) bool {
pla... |
package main
import (
"log"
"time"
)
func main() {
for range time.Tick(0) {
log.Printf("hello, time now: %v", time.Now().Unix())
}
}
|
package svc11
import (
"fmt"
"github.com/feng/future/go-kit/agfun/trace/middleware"
"github.com/gin-gonic/gin"
opentracing "github.com/opentracing/opentracing-go"
"net/http"
)
type httpService struct {
service Service
}
func (s *httpService) concatHandler(c *gin.Context) {
v := c.Request.URL.Query()
result, ... |
package document
import (
"github.com/spf13/cobra"
"opendev.org/airship/airshipctl/cmd/document/secret"
"opendev.org/airship/airshipctl/pkg/environment"
)
// NewDocumentCommand creates a new command for managing airshipctl documents
func NewDocumentCommand(rootSettings *environment.AirshipCTLSettings) *cobra.Comm... |
package api_test
import (
"bytes"
"context"
"errors"
"fmt"
"io"
"mime/multipart"
"net/http"
"net/http/httptest"
"os"
"strconv"
"testing"
"github.com/grpc-ecosystem/grpc-gateway/v2/runtime"
"github.com/odpf/stencil/models"
stencilv1 "github.com/odpf/stencil/server/odpf/stencil/v1"
"github.com/stretchr/t... |
// Copyright 2020 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 2016 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 adapter
import (
"github.com/giantswarm/aws-operator/service/controller/clusterapi/v30/key"
)
type GuestIAMPoliciesAdapter struct {
ClusterID string
EC2ServiceDomain string
KMSKeyARN string
MasterRoleName string
MasterPolicyName string
MasterProfileName string
RegionARN st... |
package model
// Номенклатура
type Nomenclature struct {
Id int
MeasureId int
Name string
}
|
package mongo
import (
"config"
"errors"
"fmt"
"lebangproto"
"logger"
"strconv"
"strings"
"sync"
"time"
"gopkg.in/mgo.v2"
"gopkg.in/mgo.v2/bson"
)
type MongoManager struct {
session []*mgo.Session
index int
lockGuard sync.Mutex
}
func (this *MongoManager) updateErrandsMainClassification() {
log... |
package cmd
import (
"fmt"
"log"
"os"
"path/filepath"
"github.com/lhopki01/dirin/internal/color"
"github.com/lhopki01/dirin/internal/config"
"github.com/spf13/cobra"
"github.com/spf13/viper"
)
func registerAddCmd(rootCmd *cobra.Command) {
addCmd := &cobra.Command{
Use: "add <space separated list of dire... |
package strategyPattern
import (
"design-patterns-go/strategyPattern/duck"
"fmt"
)
type StrategyPattern interface {
Run()
}
type strategy struct {
strategyPattern StrategyPattern
}
func NewStrategy() strategy {
return strategy{}
}
func (st strategy) Run() {
fmt.Println("~~~~~~~~~~ STRATEGY PATTERN ~~~~~~~~~~... |
package "make-collection"
|
package router
import (
"github.com/kataras/iris"
"github.com/kataras/iris/middleware/recover"
"github.com/iris-contrib/middleware/cors"
"../config"
"../controller"
controller_admin "../controller/admin"
"time"
"github.com/kataras/iris/middleware/basicauth"
)
func Routes(app *iris.Application) {
// use reco... |
package backend
import (
"encoding/json"
"fmt"
"html/template"
"math"
"net/http"
"os"
"path/filepath"
"github.com/TheAndruu/git-leaderboard/models"
"golang.org/x/net/context"
"google.golang.org/appengine"
"google.golang.org/appengine/log"
)
var templates = make(map[string]*template.Template)
var numCommi... |
/*
Given 2 strings, return their concatenation, except omit the first char of each.
*/
package main
import (
"fmt"
)
func non_start(a string, b string) string {
if len(a) > 0 {
a = a[1:]
}
if len(b) > 0 {
b = b[1:]
}
return a + b
}
func main(){
var status int = 0
if non_start("Hello", "There") == "ellohe... |
package ekshealthtest
import (
"context"
"database/sql"
"fmt"
"os"
"strings"
"time"
_ "github.com/lib/pq" // As suggested by lib/pq driver
"github.com/olivere/elastic"
)
func ESHealth() (string, int) {
errs := 0
esProto := os.Getenv("ES_PROTO")
esHost := os.Getenv("ES_HOST")
esPort := os.Getenv("ES_PORT"... |
package reading
import (
"encoding/json"
"fmt"
"log"
"github.com/brittonhayes/godb/pkg/types"
scribble "github.com/nanobox-io/golang-scribble"
)
// One reads an entry from the database
func One(db *scribble.Driver, folder string, file string, entry *types.Fish) error {
result := entry
response := db.Read(fol... |
package handlers
import (
"encoding/json"
"fmt"
"net/http"
"test_server/domain"
"test_server/storage"
)
type TaskHandlers struct{
storage storage.Storage
}
func NewTaskHandlers(store storage.Storage) TaskHandlers{
return TaskHandlers{
storage: store,
}
}
func (th TaskHandlers) GetAllTasks(w http.ResponseW... |
package main
import (
"math"
"fmt"
)
func main () {
fmt.Println(Fib_3(100)) // 没有限定 n 的最大值, 会溢出
}
/**
* fibonacci 数列满足 f(0) = 0, f(1) = 1, f(n) = f(n-1) + f(n-2) (n>=2, *)
* 最小允许计算 f(0), 所以递归出口的判断条件应该是 n < 2 或 n == 0
* 尾递归一般是把这一次的计算结果保存在参数里,递推到下一次调用然后直接使用这个保存值. 但是初始调用时这个参数值就要是明确的。在 fib_1 里需要的初始参数值就是 (n, f... |
package main
import (
"context"
"fmt"
"log"
"sync"
"github.com/prometheus/client_golang/prometheus"
"github.com/prometheus/client_golang/prometheus/push"
)
// PrometheusConfig describes the YAML-provided configuration for a Prometheus
// pushgateway storage backend
type PrometheusConfig struct {
Host str... |
package sqlc
import (
"bytes"
"database/sql"
"errors"
"fmt"
"github.com/alokmenghrajani/sqlc/meta"
"io/ioutil"
"log"
"os"
"regexp"
"strings"
"text/template"
"time"
)
var integer = regexp.MustCompile("(?i)INT")
var int_64 = regexp.MustCompile("(?i)INTEGER|BIGINT")
var varchar = regexp.MustCompile("(?i)VARC... |
/////////////////////////////////////////////////////////////////////
// arataca89@gmail.com
// 20210417
//
// func Fields(s string) []string
//
// Separa a string s em tokens e retorna um slice com estes tokens.
// Considera que o separador dos tokens é o caracter de espaço
// definido por unicode.IsSpace
//
... |
// 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 main
import (
"encoding/json"
"fmt"
"net/http"
"os"
"strconv"
"strings"
"time"
"github.com/Microsoft/ApplicationInsights-Go/appinsights"
)
type Response struct {
Now time.Time `json:"now"`
IsTestStream bool `json:"isTestStream"`
StartedAt time.Time `json:"startedAt"`
AccessKey ... |
package codex
import (
"context"
"github.com/pathbird/pbauthor/internal/auth"
"github.com/pathbird/pbauthor/internal/course"
"github.com/pathbird/pbauthor/internal/graphql"
"github.com/pkg/errors"
"io/ioutil"
"os"
"path/filepath"
)
// Initialize a new codex config file
func InitConfig(dirname string) (*Config... |
// Copyright 2020 The Reed Developers
// Distributed under the MIT software license, see the accompanying
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
package p2p
import (
"bufio"
"bytes"
"encoding/json"
"fmt"
"net"
"testing"
)
func newMockTCP(recvCh chan<- []byte) error {
l, err := ... |
package main
import (
"fmt"
"net/http"
)
var (
n1 = 1
n2 = 2
n3 = 3
)
func main() {
var n4 int
n4 = 100
// n1, n2, n3 := 1, 2, 3
// n1 := 1
fmt.Print(n1, n2, n3, n4)
http.HandleFunc("/", handler)
http.ListenAndServe(":8081", nil)
}
func handler(w http.ResponseWriter, r *http.Request) {
fmt.Fprintf(w, "... |
package utils
import (
"errors"
"io"
"os"
"strings"
"testing"
"github.com/stretchr/testify/require"
)
type testConfig struct {
BackendAddr string `json:"backend_addr"`
}
func (c *testConfig) Read() error {
return nil
}
func (c *testConfig) Write() error {
return nil
}
func (c *testConfig) Init(rd io.Read... |
package main
import (
"net/http"
"fmt"
)
type dog int
type cat int
func(d dog) ServeHTTP(w http.ResponseWriter,r *http.Request){ //this is the signature of handler interface
//switch r.URL.Path {
fmt.Fprintln(w,"barks")
//case "/cat":fmt.Fprintln(w,"meows")
//}
}
func(c cat) ServeHTTP(w http.ResponseWri... |
// macAndIpInfo
package DaeseongLib
import (
_ "fmt"
"net"
)
func macAddress() string {
ifaces, err := net.Interfaces()
if err != nil {
return ""
}
for _, iface := range ifaces {
if iface.Flags&net.FlagUp == 0 || iface.Flags&net.FlagLoopback != 0 {
continue
}
addrs, err := iface.Addrs()
if err !=... |
package converter
import (
"errors"
"log"
"time"
)
// 超时错误
var (
ErrConversionTimeout = errors.New("pdf 转换超时")
)
// Worker 工作者信息
type Worker struct {
id int
}
// InitWorkers 初始化转换队列
// maxWorkers: 最大并行转换数
// maxQueue: 队列里做多等待数量
// timeout: 转换超时时间
func InitWorkers(maxWorkers, maxQueue, timeout int) chan<- Work ... |
package readconfig
import "testing"
func TestReadConfJSON(t *testing.T) {
var path string ="../conf.json"
res := ReadConfJSON(path)
t.Log(res.Enabled,res.Path)
}
|
package constants
type TAG_KEY_TYPE string
type TAG_VALUE_TYPE string
const (
TAG_KEY_JSON TAG_KEY_TYPE = "json" // json标签
TAG_KEY_GORM TAG_KEY_TYPE = "gorm" // gorm标签
TAG_VALUE_keep_ignore TAG_VALUE_TYPE = `"-"` // 忽略
TAG_VALUE_keep_prefix TAG_VALUE_TYPE = `"#` // 标签值前缀
TAG_VA... |
package bundle
import (
"context"
"crypto/sha256"
"fmt"
"strings"
"time"
"github.com/operator-framework/operator-registry/pkg/api"
"github.com/operator-framework/operator-registry/pkg/configmap"
"github.com/sirupsen/logrus"
batchv1 "k8s.io/api/batch/v1"
corev1 "k8s.io/api/core/v1"
rbacv1 "k8s.io/api/rbac/v... |
package test
import (
"fmt"
"gengine/builder"
"gengine/context"
"gengine/engine"
"testing"
"time"
)
const inverse_rules = `
rule "1000" "most priority" salience 1000
begin
cal.Data = 5
end
rule "998" "lower priority" salience 998
begin
cal.Name = "hello world"
end
rule "996" "lowest priority" salience 996
be... |
package user
import (
"backend/user/models"
"backend/utils/response"
)
// User 用户序列化器
type Serializer struct {
ID int `json:"id"`
UserName string `json:"name"`
Nickname string `json:"nick_name"`
Status string `json:"status"`
Avatar string `json:"avatar"`
Admin bool `json:"admin"`
Role... |
package main
import (
"encoding/json"
"flag"
"log"
"net"
"net/http"
"os"
"os/exec"
"runtime"
)
type Message struct {
Message string `json:"message"`
}
const (
helloWorldString = "Hello, World!"
)
var (
helloWorldBytes = []byte(helloWorldString)
)
var prefork = flag.Bool("prefork", false, "use prefork")
... |
//
// Copyright 2020 IBM Corporation
//
// 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 ... |
package server
import (
"context"
"fmt"
"time"
"github.com/CyCoreSystems/ari"
"github.com/CyCoreSystems/ari-proxy/proxy"
"github.com/CyCoreSystems/ari-proxy/server/dialog"
"github.com/CyCoreSystems/ari/client/native"
"github.com/inconshreveable/log15"
"github.com/nats-io/nats"
"github.com/pkg/errors"
)
//... |
package model
// defining player data type
type Players struct {
Name string
Counter int
Score int
}
|
package main
import (
"bytes"
"encoding/json"
"fmt"
"io/ioutil"
"net/http"
"os"
"strconv"
)
const usage = `
usage: todo COMMAND
Commands:
samples Get sample todo tasks
all Get all todo tasks
add Add new todo task
delete Remove a todo task
`
func main() {
if len(os.Args) < 2 ... |
package main
import (
"fmt"
"log"
"net/http"
"os"
"cloud.google.com/go/datastore"
"golang.org/x/net/context"
)
func main() {
ctx := context.Background()
log.SetOutput(os.Stderr)
// Set this in app.yaml when running in production.
projectID := os.Getenv("GCLOUD_DATASET_ID")
datastoreClient, err := datast... |
package model
// AppSetting a struct to rep app settings account
type AppSetting struct {
BaseIntModel
Name string `json:"name" gorm:"not null;type:varchar(50);"`
SKey string `json:"s_key" gorm:"not null;type:varchar(100);unique_index"`
Value string `json:"value" gorm:"not null;type:varchar(200)"`
Comment... |
package main
import (
"flag"
"fmt"
"net/http"
"muto/controllers"
"muto/middleware"
"muto/models"
"muto/rand"
"github.com/gorilla/csrf"
"github.com/gorilla/mux"
)
func main() {
// Production flag for ensuring .config file is provided.
boolPtr := flag.Bool("prod", false, "Provide this flag "+
"in product... |
package wordbreak
import (
"fmt"
"testing"
)
func TestWordBreak(t *testing.T) {
var tests = []struct {
s string
wordDict []string
expect bool
}{
{"catsanddog", []string{"cat", "cats", "and", "sand", "dog"}, true},
}
for _, test := range tests {
if got := wordBreak(test.s, test.wordDict); got... |
package main
import "testing"
func TestLargestPrimeFactor(t *testing.T) {
tests := []struct {
input int64
output int64
}{
{600851475143, 6857},
{13195, 29},
}
for _, test := range tests {
result := LargestPrimeFactor(test.input)
if result != test.output {
t.Errorf("%v should return %v, got %v", t... |
package cipher
import (
"strings"
"unicode"
)
const firstLetterIndex = 'z' - 'a' + 1
type Vigenere struct {
key string
}
func NewCaesar() Cipher {
return NewShift(3)
}
func NewShift(distance int) Cipher {
if distance == 0 || distance > 25 || distance < -25 {
return nil
}
return NewVigenere(string(rune('a'... |
// populate scrapes reads command line arguments and searches rosettacode.org
// for blocks of code listed under headings (programming language names) that
// match those strings. The code blocks are saved under individual files with
// extensions matched to the language or ".txt" as a default if the extension
// is un... |
package main
import (
"bytes" // need to convert data into byte in order to be sent on the network, computer understands better the byte(8bits)language
"crypto/sha256" //crypto library to hash the data
"strconv" // for conversion
"time" // use timestamp
)
// Generating a hash of the block
/... |
// +build !hosted
package router
func extractPath(host, path string) string {
return path
}
func systemPathFromSpace(space string) string {
return basePath
}
func systemPathFromURL(host, path string) string {
return basePath
}
|
package kit
import (
"fmt"
"path/filepath"
"runtime"
"strings"
)
//common resource
var MessageMap = map[string]map[int]string{
"en": {
10001: "System error",
10002: "A required parameter is missing or doesn't have the right format:%v",
10003: "%v is required",
10004: "The parameter format should be %v",
... |
/*
* jQuery File Upload Plugin GAE Go Example 3.1.1
* https://github.com/blueimp/jQuery-File-Upload
*
* Copyright 2011, Sebastian Tschan
* https://blueimp.net
*
* Licensed under the MIT license:
* http://www.opensource.org/licenses/MIT
*/
package app
import (
"appengine"
"appengine/blobstore"
"appengine/i... |
package websocket
type handler interface {
handle() (Message, bool)
} |
package main
import (
"bufio"
"context"
"encoding/csv"
"io"
"io/ioutil"
"log"
"os"
"os/exec"
"strings"
speech "cloud.google.com/go/speech/apiv1"
speechpb "google.golang.org/genproto/googleapis/cloud/speech/v1"
)
func main() {
memories, err := importVocab("vocab.csv")
chk(err)
words, err := recognizeF... |
package commands
import (
"time"
"github.com/pkg/errors"
"gopkg.in/mgo.v2"
"gopkg.in/mgo.v2/bson"
"github.com/michigan-com/brvty-api/brvtyclient"
"github.com/michigan-com/brvty-api/mongoqueue"
m "github.com/michigan-com/gannett-newsfetch/model"
)
type extractor struct {
session *mgo.Session
client ... |
package models
import (
"context"
"errors"
"fmt"
"os"
"github.com/jackc/pgx/v4"
)
var conn *pgx.Conn
func init() {
var err error
pgstr := os.Getenv("PGCONN")
if pgstr == "" {
panic(errors.New("no pgconn provided, put PGCONN='connect string' in your environment"))
}
// "postgresql://user:password@loca... |
package main
import (
"basic-rabbitmq/RabbitMQ"
"fmt"
"strconv"
"time"
)
func main() {
// work mode publisher
rabbitmq := RabbitMQ.NewRabbitMQSimple("goSimple")
for i := 0; i <= 100; i++ {
rabbitmq.PublishSimple("Learning RabbitMQ with go!" + strconv.Itoa(i))
time.Sleep(1 * time.Second)
fmt.Println(i)
... |
package bmc
import (
"context"
"fmt"
"log"
gf "github.com/stmcginnis/gofish"
"github.com/stmcginnis/gofish/redfish"
_ "github.com/stmcginnis/gofish/redfish"
pb "github.com/stopa323/kimbap/api/bmc"
"google.golang.org/grpc/codes"
"google.golang.org/grpc/status"
)
type BMCServer struct {
pb.UnimplementedBMCSe... |
package database
import (
"errors"
"strconv"
db "taskweb/database"
)
type TbCategory struct {
Id int
Name string
Createtime int64
Remark string
}
func ExistTbCategory(id int) (bool, error) {
rows, err := db.Dtsc.Query("select count(0) Count from tb_category where id=?", id)
if err != nil {
return false, ... |
package caaa
import (
"encoding/xml"
"github.com/thought-machine/finance-messaging/iso20022"
)
type Document00900102 struct {
XMLName xml.Name `xml:"urn:iso:std:iso:20022:tech:xsd:caaa.009.001.02 Document"`
Message *AcceptorReconciliationRequestV02 `xml:"AccptrRcncltnReq"`
}
func (d *Do... |
// Copyright 2019-present Open Networking Foundation.
//
// 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 routers
import (
"github.com/astaxie/beego"
"github.com/kingiw/casbin-js-demo/controllers"
)
func init() {
beego.Router("/", &controllers.MainController{})
beego.Router("/api/get-profiles", &controllers.APIController{})
}
|
package utils
import (
"fmt"
"github.com/kelseyhightower/envconfig"
"net/url"
)
type Env struct {
ConsumerKey string
ConsumerSecret string
Token string
TokenSecret string
}
type DatabaseConfig struct {
Username string `envconfig:"DB_USERNAME" required:"true"`
Password string `envconfig:"DB_PA... |
package count_triplets
import (
"fmt"
"testing"
)
type Result struct {
TotalCount int64
FullfilCount int64
PrevCount int64
}
func countTriplets(arr []int64, r int64) int64 {
length := len(arr)
var totalCount int64
if length < 3 {
return 0
}
singleMap := map[int64]*Result{}
for i := 0; i < length; i... |
package resolver
import (
"fmt"
"strings"
"github.com/appootb/substratum/discovery"
"github.com/appootb/substratum/util/iphelper"
"google.golang.org/grpc/resolver"
)
type DiscoveryResolver struct {
target resolver.Target
cc resolver.ClientConn
opts resolver.BuildOptions
}
// ResolveNow will be called ... |
package proto
import (
"os"
)
type File struct {
Filename string
Content []byte
Mode os.FileMode
}
type FileRequest struct {
Filename string
}
type FileResponse struct {
Filename string
Checksum [64]byte
Overwritten bool
}
|
package prettier
import (
"bytes"
"fmt"
"io/fs"
"log"
"path/filepath"
"strings"
"github.com/spf13/afero"
"golang.org/x/sys/unix"
)
type Chart struct {
manifests []Manifest
files map[string][]byte
}
func NewChart() *Chart {
c := &Chart{}
c.files = make(map[string][]byte)
return c
}
func (c *Chart) ... |
package generate
import (
"encoding/json"
"reflect"
"strings"
"testing"
)
func TestThatCapitalisationOccursCorrectly(t *testing.T) {
tests := []struct {
input string
expected string
}{
{
input: "ssd",
expected: "Ssd",
},
{
input: "f",
expected: "F",
},
{
input: "fishPast... |
package main
import (
"fmt"
"gober/gbinterface"
"gober/gbnet"
)
type pingRouter struct {
}
func (this *pingRouter) PreHandle(request gbinterface.IRequest) {
return
}
func (this *pingRouter) PostHandle(request gbinterface.IRequest) {
return
}
func (this *pingRouter) Handler(request gbinterface.IRequest){
fmt... |
package main
import (
"fmt"
"euler"
)
func main() {
f := make([]int,1000002)
for x := 1 ; x < 10; x++ {
f[x] = x
// fmt.Print(x)
}
p := 10
for x := 10; p < 1000001; x++ {
di := euler.GetDigits(x)
for y := 0; y < len(di); y++ {
if p < 1000001 {
f[p] = di... |
// Package soapboxd provides server-side implementation of the
// services defined in the proto package for Soapbox application,
// deployment, environment, etc. related services.
package soapboxd
|
// +build darwin dragonfly freebsd linux,!appengine netbsd openbsd
package jqrepl
import "os"
// ReopenTTY will open a new filehandle to the controlling terminal.
//
// Used when stdin has been redirected so that we can still get an interactive
// prompt to the user.
func ReopenTTY() (*os.File, error) {
return os.O... |
// Each of these tests just come out of either intuition or from my notes
// in cryptography class... don't judge me
package modmath_test
import (
"testing"
"github.com/deanveloper/nikola"
. "github.com/deanveloper/modmath"
)
func TestLpr(t *testing.T) {
nikola.SuggestEqual(t, 0, Lpr(0, 5))
nikola.SuggestEqual(... |
package main
import (
"fmt"
"testing"
)
func TestCombine(t *testing.T) {
ans := Combine(4, 2) // 预期 [[1 2] [1 3] [1 4] [2 3] [2 4] [3 4]] >>> [[1 2] [1 3] [1 4] [1 3] [1 4] [1 4] [2 3] [2 4] [2 4] [3 4]]
fmt.Println("?????????????")
fmt.Println(ans)
fmt.Println("?????????????")
ans1 := Combine(1, 1) // 预期 [[... |
package main
import (
"fmt"
)
func main() {
var num = []int{5,6,89,76,54,3,2,12,34,56,7,8,9,90}
var soma int = 0
for x, n := range num {
if(n % 2 != 0){
num[x] *= 2
}
if(n % 2 == 0){
num[x] /= 2
}
soma += num[x]
}
fmt.Printf("%v\n%d", num, soma)
}
|
package cmd
import (
"flag"
"fmt"
"sort"
"strconv"
"string"
"os"
"github.com/openebs/mayaserver/lib/config"
//using maya configuration can print the bind addr and nodes name
"github.com/mitchellh/cli"
//cli imports all required cli-ui commands
)
type Ports struct {
HTTP int `mapstructure:"http"`
... |
package main
import (
"fmt"
"github.com/lijian777/BitCoin/block"
)
//启动
func main() {
//var bc=bc.NewBlock(1, []byte("aaa"), []byte("vvvv"))
//fmt.Printf("frist bolck: %v\n",bc)
//初始化区块链bc
bc := block.CreateBlockChainWithGenesisBlock()
//上链
bc.AddBlock(bc.Blocks[len(bc.Blocks)-1].Height+1,
bc.Blocks[len(bc... |
// Package search provides a way to index entities and run relatively
// complicated search queries, best served outside of data stores, and
// by specialized search engines like ElasticSearch or Solr etc.
//
// This tackles the limitations caused by gocrud in terms of filtering
// and sort operations which would other... |
package resources
import (
"gopkg.in/mgo.v2"
)
func NewMongoResource(config *MongoConfig) (ResourceInterface, error) {
return &MongoResource{config: config}, nil
}
type MongoResource struct {
config *MongoConfig
session *mgo.Session
}
type MongoConfig struct {
URI string
}
func (this *MongoResource) Get() (i... |
package controllers
import (
"app-auth/types"
"app-auth/utils"
"fmt"
"net/http"
"github.com/dgrijalva/jwt-go"
"github.com/labstack/echo/v4"
)
func GetTeamMembers(ctx echo.Context) error {
user := ctx.Get("user").(*jwt.Token)
claims := user.Claims.(jwt.MapClaims)
admin := claims["id"].(string)
app := clai... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.