text stringlengths 11 4.05M |
|---|
package path_util
import (
"log"
"os"
"path/filepath"
"runtime"
"strings"
)
func ModulePath(path string) string {
rootCode := strings.Split(path, "/")[0]
rootPath := ""
pwd, err := os.Getwd()
if err != nil {
log.Fatal(err)
}
currentPath := filepath.Clean(pwd)
if strings.Contains(currentPath, rootCode)... |
package graph
import "fmt"
// Graph represents directed acyclic graph consisting of nodes of arbitrary types;
// every graph node (or vertex) has string identifier.
type Graph interface {
fmt.Stringer
phasicTopologicalSortBuilder
// public API
GetNode(string) (Node, error)
CreateNode(string, interface{}) (Node... |
package solcast
import "time"
type ApiLimits struct {
ResetTime time.Time
Limit int64
Remaining int64
}
|
package gocaptcha
import (
"bytes"
"crypto/md5"
"encoding/gob"
"encoding/hex"
"fmt"
"strconv"
"strings"
"time"
// "ruoniu.com/cache/redis"
// "ruoniu.com/utils"
"github.com/qiniu/log"
"gopkg.in/redis.v2"
)
func init() {
RegisterStore(storeName, CreateCaptchaRedisStore)
}
const (
captchaKeyFormat = "c... |
package main
import (
"fmt"
"math"
"gonum.org/v1/gonum/stat/distuv"
)
type ExperimentSetup struct {
probControl float64
convControl float64
fpr float64
effectSize float64
power float64
sampleSize int64
twoSided bool
}
type ExperimentResult struct {
yesControl int64
totalCo... |
// try struct
package main
import "fmt"
type T struct {a, b int}
func main() {
t := new(T)
t.a = 10
t.b = 20
printStruct(t)
}
func printStruct(tt *T) {
fmt.Printf("t.a = %d and t.b =%d\n", tt.a, tt.b)
}
|
// SPDX-License-Identifier: Apache-2.0
// Copyright © 2019 Intel Corporation
package af
import (
"context"
"encoding/json"
"net/http"
"net/url"
"strconv"
)
func createSubscription(cliCtx context.Context, ts TrafficInfluSub,
afCtx *Context) (TrafficInfluSub, *http.Response, error) {
cliCfg := NewConfiguration... |
package controller
import (
"bytes"
"html/template"
"github.com/GoAdminGroup/go-admin/modules/remote_server"
"github.com/GoAdminGroup/go-admin/modules/language"
"github.com/GoAdminGroup/go-admin/modules/logger"
)
func GetPluginsPageJS(data PluginsPageJSData) template.JS {
t := template.New("plugins_page_js").... |
// Copyright 2016 The Gem Authors. All rights reserved.
// Use of this source code is governed by a MIT license
// that can be found in the LICENSE file.
package middleware
import (
"bufio"
"testing"
"time"
"github.com/go-gem/gem"
"github.com/go-gem/gem/bytes"
"github.com/valyala/fasthttp"
)
func TestBodyLimi... |
package queries
import (
"database/sql"
"log"
"gitlab.com/semestr-6/projekt-grupowy/backend/obsluga-formularzy/configuration"
"gitlab.com/semestr-6/projekt-grupowy/backend/obsluga-formularzy/units/models"
)
const ADD_QUANTITY_SQL = `
INSERT INTO units."Quantities"
(
"QuantityNamePl"
,"QuantityNameEn"
,"B... |
package promise
type Resolve func(interface{}) (interface{}, error)
type Reject func(error)
type Ticket func(resolve Resolve, reject Reject)
type Future struct {
nextTicket Ticket
reject Reject
response interface{}
}
func NewFuture(init Ticket) *Future {
return &Future{
nextTicket: init,
}
}
func (fu... |
// Copyright 2018 Lars Hoogestraat
// Use of this source code is governed by a MIT-style
// license that can be found in the LICENSE file.
package handler
import (
"net/http"
"git.hoogi.eu/snafu/go-blog/logger"
"git.hoogi.eu/snafu/go-blog/middleware"
"git.hoogi.eu/snafu/go-blog/models"
)
// LoginHandler shows ... |
package types
import (
"fmt"
"strings"
)
type GetResponse struct {
Exists bool
Message string
}
func (dat *ServerData) GetElement(name string, noLock ...bool) (Element, GetResponse) {
if len(noLock) == 0 {
dat.Lock.RLock()
}
el, exists := dat.Elements[strings.ToLower(name)]
if len(noLock) == 0 {
dat.Loc... |
package midware1
import (
"github.com/urfave/negroni"
"net/http"
)
func Negronimain() {
n := negroni.New()
n.Use(negroni.NewLogger())
n.Use(negroni.NewStatic(http.Dir("/tmp")))
n.Run(":8080")
}
|
var mat[][] int
func getMoneyAmount(n int) int {
mat = make([][]int, n+1)
for idx := 0; idx <= n; idx += 1{
mat[idx] = make([]int, n+1)
}
dfs(1, n)
return mat[1][n]
}
func min(a, b int) int {
if a < b{
return a
}
return b
}
func max(a, b int) int {
if a > b{
... |
package leetcode
/*Given a string s consisting only of letters 'a' and 'b'. In a single step you can remove one palindromic subsequence from s.
Return the minimum number of steps to make the given string empty.
A string is a subsequence of a given string, if it is generated by deleting some characters of a given str... |
package server
import (
"context"
"encoding/json"
"net/http"
"os"
"strings"
"sync/atomic"
"time"
throttle "github.com/boz/go-throttle"
"github.com/tsaikd/KDGoLib/errutil"
"github.com/tsaikd/go-grpc-echo/logger"
pb "github.com/tsaikd/go-grpc-echo/pb"
"golang.org/x/net/http2"
"golang.org/x/net/http2/h2c"
... |
/*
Your challenge today is to write a program that can find the amount of anagrams within a .txt file. For example, "snap" would be an anagram of "pans", and "skate" would be an anagram of "stake".
*/
package main
import (
"flag"
"fmt"
"log"
"os"
"regexp"
"sort"
)
func main() {
log.SetFlags(0)
log.SetPrefi... |
package sun_utils
import "regexp"
var IranPhoneReg = regexp.MustCompile(`^989[\d]{9}$`)
func IsValidIranPhoneNumber(phone string) bool {
return IranPhoneReg.MatchString(phone)
}
|
package server
import (
"encoding/gob"
"encoding/json"
"sync"
"github.com/coreos/tectonic-installer/installer/server/aws/cloudforms"
)
func init() {
gob.Register(&TectonicAWSChecker{})
}
// TectonicAWSChecker is a serializable StatusChecker for Tectonic AWS
// clusters.
type TectonicAWSChecker struct {
Access... |
package service
import (
"context"
"github.com/erizaver/grpc-gateway-example/pkg/pb/user"
)
type Service struct {
}
func NewService() *Service {
return &Service{}
}
func (s *Service) GetById(ctx context.Context, req *user.GetByIdRequest) (*user.GetByIdResponse, error) {
return &user.GetByIdResponse{
Data: "Th... |
package constants
const (
ErrorCode_General = -1
ErrorCode_UnLogin = 10
)
|
package ircserver
import (
"fmt"
"gopkg.in/sorcix/irc.v2"
)
func init() {
Commands["INVITE"] = &ircCommand{
Func: (*IRCServer).cmdInvite,
MinParams: 2,
}
}
func (i *IRCServer) cmdInvite(s *Session, reply *Replyctx, msg *irc.Message) {
nickname := msg.Params[0]
channelname := msg.Params[1]
c, ok := i... |
package app
import (
"fmt"
"github.com/go-chi/chi"
"github.com/go-chi/chi/middleware"
"github.com/go-chi/render"
"log"
"net/http"
"os"
"redis_proxy/app/db"
"redis_proxy/app/models"
"redis_proxy/app/routes"
)
var (
ADDR = os.Getenv("REDIS_URL")
APP_ADDR = ":" + os.Getenv("PORT")
DEMO = os.Getenv("... |
package main
import (
"fmt"
"log"
"payment/internal/config"
"github.com/golang-migrate/migrate/v4"
_ "github.com/golang-migrate/migrate/v4/database/postgres"
_ "github.com/golang-migrate/migrate/v4/source/file"
)
func main() {
conf := config.New().Database.Postgre[config.PaymentConnect]
log.Printf("%+v", co... |
package testdata
import (
"github.com/frk/gosql/internal/testdata/common"
)
type FilterEmbeddedRecords struct {
_ *common.Embedded `rel:"test_nested:n"`
common.FilterMaker
}
|
package appenginetesting
import (
"text/template"
)
const helperTemplString = `
package helper
import (
"fmt"
"io/ioutil"
"log"
"net/http"
"os"
"appengine"
)
func init() {
http.HandleFunc("/info", info)
http.HandleFunc("/call", call)
}
func info(w http.ResponseWriter, r *http.Request) {
w.Header().Se... |
package streamview
func PKGFormat(pkg *netMessages) {
}
|
package dcmimage
import (
"bytes"
"encoding/binary"
"errors"
_ "log" // for debug
"os"
)
// BitmapFileHeader is for BMP file header
type BitmapFileHeader struct {
bfType [2]byte // must always be 'BM'
bfSize uint32
bfReserved1 uint16 // reserved, should be '0'
bfReserved2 uint16 // reserved, should... |
// Package actionlist is a Authorizer that looks at specific claims in a JWT token and allow requests based on the approved list of actions.
//
// The JWT claims must have a "agents" claim that is a list of a strings with the following possible values:
//
// Allow all requests to any agent and action
//
// []string{"*"... |
package image_operator_test
import (
"image/color"
"image/jpeg"
"os"
"testing"
image_op "github.com/satbirdd/image_operator"
)
var (
utf8FontFile string = "src/fonts/simsun.ttf"
imagepath string = "src/images/blank.jpg"
fontsize float64 = 15
)
func TestOsd(t *testing.T) {
textLines := []string{
... |
package main
import (
"context"
"crypto/rand"
"flag"
"net"
"os"
"strings"
//"crypto/rand"
//"flag"
"crypto/ecdsa"
"encoding/hex"
"fmt"
"log"
//"os"
"github.com/libp2p/go-libp2p"
"github.com/libp2p/go-libp2p-core/crypto"
"github.com/libp2p/go-libp2p-core/host"
"github.com/libp2p/go-libp2p-core/netwo... |
package aws
import (
"context"
"fmt"
"github.com/aws/aws-sdk-go/aws"
"github.com/aws/aws-sdk-go/service/servicequotas"
"github.com/pkg/errors"
"k8s.io/apimachinery/pkg/util/sets"
)
// SupportedRegions is a list of AWS regions that support the servicequota APIs.
// see https://docs.aws.amazon.com/general/latest... |
package main
import (
"context"
"google.golang.org/grpc/credentials"
pb "github.com/naichadouban/learngrpc/demo7-simple-http/proto"
"google.golang.org/grpc"
"google.golang.org/grpc/codes"
"google.golang.org/grpc/status"
"log"
"time"
)
const (
port = ":8010"
)
type Auth struct {
Appkey string
AppSecre... |
package main
var nextDirectionMap = map[string]string{
">\\": "v",
">/": "^",
"<\\": "^",
"</": "v",
"^\\": "<",
"^/": ">",
"v\\": ">",
"v/": "<",
}
var intersectionMap = map[string][]string{
"^": []string{"<", "^", ">"},
"v": []string{">", "v", "<"},
"<": []string{"v", "<", "^"},
">": []string{"^", "... |
package main
import (
"fmt"
"io/ioutil"
"log"
"math/rand"
"os"
"path"
"regexp"
"streamjury/confighandler"
"streamjury/connections"
"streamjury/protector"
"time"
)
var reStripTrailingSlash = regexp.MustCompile(`/$`)
var loggingFileAbsPath string
func pathExists(path string) (bool, error) {
_, err := os.St... |
package main
import (
"net/http"
"github.com/gorilla/mux"
"github.com/gorilla/handlers"
"rest-commander/controller"
"rest-commander/store"
"rest-commander/process"
"os"
"log"
"io/ioutil"
)
func main() {
workTempDir, err := ioutil.TempDir(os.TempDir(), "rest-commander_")
if err != nil {
panic("Could not c... |
package coverage
import (
"errors"
"fmt"
"io/ioutil"
"os"
"os/exec"
"path/filepath"
"strconv"
"strings"
"github.com/moltin/gocicov/internal/modules"
)
func filterModules(modules modules.List) []string {
r := make([]string, 0, len(modules))
for _, mod := range modules {
file := mod.Path + "/.skip_coverag... |
/*
Adapter 适配器模式:
将一个类的接口转换成客户端希望的另一个接口。
适配器模式使得原本由于接口不兼容而不能一起工作的那些类可以一起工作
个人想法:代理和适配器:代理和代理的对象接口一致,客户端不知道代理对象,
而适配器是客户端想要适配器的接口,适配器对象的接口和客户端想要的不一样,
适配器将适配器对象的接口封装一下,改成客户端想要的接口
作者: HCLAC
日期: 20170306
*/
package adapter
type Pig struct {
name string
}
func NewPig() Pig {
p := Pig{"Pig"}
... |
package main
import (
// default go
"fmt"
"io/ioutil"
"os"
"strconv"
"strings"
)
const (
// StringNewLine is an exported variable to declare string new line
StringNewLine string = "\n"
// StringSpace is an exported variable to declare string space
StringSpace string = " "
// CreateParkingLot is a command ... |
package message
import (
"github.com/TuiBianWuLu/samplewechat/config"
)
const (
SendCustomMsgUrl = "https://api.weixin.qq.com/cgi-bin/message/custom/send"
SendTemplateUrl = "https://api.weixin.qq.com/cgi-bin/message/template/send"
)
type Message struct {
*config.Config
}
var m = new(Message)
func New(c *confi... |
package main
import (
"os"
"log"
"github.com/theckman/go-flock"
"strconv"
"github.com/Pallinder/go-randomdata"
//"flag"
//"time"
)
const tmpLockDir string = "/tmp/lslock-test"
var lockPath string
func main() {
// TODO add SIGINT functionality
// And flag parsing
// lCount := flag.Int("l", 10, "Th... |
package errors
import "net/http"
var (
ErrServer = PaymentError{
Code: http.StatusInternalServerError,
Title: "Server error",
Detail: "",
}
ErrTransaction = PaymentError{
Code: http.StatusInternalServerError,
Title: "Server error",
Detail: "Transaction Error",
}
ErrInvalidBalance = PaymentError... |
package tsmt
import (
"encoding/xml"
"github.com/thought-machine/finance-messaging/iso20022"
)
type Document04100103 struct {
XMLName xml.Name `xml:"urn:iso:std:iso:20022:tech:xsd:tsmt.041.001.03 Document"`
Message *TransactionReportV03 `xml:"TxRpt"`
}
func (d *Document04100103) AddMessage() *Trans... |
// +build !integration
package crs
import (
"testing"
)
func BenchmarkCRS(b *testing.B) {
// lfu
lfuCache := New(0)
benchmarkCacheSet(b, "lfu-unlimited", lfuCache)
benchmarkCacheSet(b, "lfu-limited", New(10000))
benchmarkCacheUpdate(b, "lfu", lfuCache)
benchmarkCacheGet(b, "lfu", lfuCache) // should output 1
... |
package utils
import (
"log"
"os"
)
const (
ColorSuccess = "\033[32m"
ColorError = "\033[31m"
ColorReset = "\033[0m"
)
func NewLogger() *log.Logger {
logger := log.New(os.Stdout, "", log.Ldate|log.Ltime)
return logger
}
|
package metadata_test
import (
"regexp"
. "github.com/onsi/ginkgo"
. "github.com/onsi/gomega"
"github.com/rightscale/rsc/metadata"
)
var _ = Describe("Action", func() {
Context("PathPattern Substitute", func() {
var (
// In
pattern *metadata.PathPattern
variables []*metadata.PathVariable
// Ou... |
package day4
import (
"testing"
"github.com/achakravarty/30daysofgo/assert"
)
type testCase struct {
age int
expectedError string
expectedNow string
expectedThreeYearsLater string
}
var testCases = []testCase{
testCase{age: 4, expectedNow: "You are young.", expectedT... |
package main
import (
"encoding/json"
"fmt"
)
type A struct {
Num int
}
type B struct {
Num int
}
type Monster struct {
Name string `json:"name"`
Age int `json:"age"`
Skill string `json:"skill"`
}
func main() {
var a A
var b B
b.Num = 12
a = A(b) // 可以转换,但是有要求,就是结构体的字段要完全一致
b.Num = 13
fmt.Println(a,... |
/**
Write a program that prints a number in decimal, binary and hex
*/
package main
import "fmt"
func main() {
number := 42
fmt.Println("Number\t:: ", number)
fmt.Printf("Decimal\t\t:: %d\n", number)
fmt.Printf("Binary\t\t:: %b\n", number)
fmt.Printf("Hexadecimal\t:: %#x\n", number)
}
|
// Copyright 2014 Google. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
// The git-cleanup command deletes branches which have already
// been merged to the Gerrit server.
package main
import (
"bufio"
"bytes"
"log"
"os/exec"
"regexp"... |
package cf
import (
"encoding/json"
"fmt"
)
type CloudControllerUser struct {
Guid string `json:"guid"`
}
type CloudControllerUsersResponse struct {
Resources []struct {
Metadata struct {
Guid string `json:"guid"`
} `json:"metadata"`
} `json:"resources"`
}
func (cc Cl... |
package tblfmt
import (
"bufio"
"bytes"
"encoding/csv"
"encoding/json"
"io"
"strings"
runewidth "github.com/mattn/go-runewidth"
)
// TableEncoder is a buffered, lookahead table encoder for result sets.
type TableEncoder struct {
// ResultSet is the result set to encode.
resultSet ResultSet
// count is the... |
package workflow
import (
"reflect"
"testing"
"github.com/dymm/orchestrators/messageQ/pkg/messaging"
)
func Test_getSessionStoredInTheWorkItem(t *testing.T) {
session1 := createNewSession()
session1.assignedWorkflow = 1
session1.CurrentStep.Name = "first"
session2 := createNewSession()
session2.assignedWor... |
package main
import (
"fmt"
"github.com/spf13/cobra"
)
const major = "0"
const minor = "5"
const patch = "0"
const desc = "Blockchain in Go"
var versionCmd = &cobra.Command{
Use: "version",
Short: "Displays xpay version",
Run: func(cmd *cobra.Command, args []string) {
fmt.Printf("Version: %s.%s.%s-beta %s"... |
package acme
import (
"bufio"
"context"
"crypto/x509"
"encoding/base64"
"errors"
"fmt"
"net"
"os"
)
type Continue interface {
DNSSetup(ctx context.Context, domain, text string) bool
}
type Lego interface {
Continue
Present(ctx context.Context, domain, token, keyAuth string) error
}
type Renew struct {
c... |
package database
import (
"crypto/sha1"
"encoding/hex"
"fmt"
"go.mongodb.org/mongo-driver/bson"
"go.mongodb.org/mongo-driver/mongo"
"golang.org/x/net/context"
"log"
"github.com/google/uuid"
)
//User ......
type User struct {
UUID string
Name string
Email string
PasswordHash string
... |
package api
import (
"testing"
)
var (
config = &Config{
Source: &SourceRepo{
Repo: &Repo{
Url: "ht//:fake.source.com",
Kind: Kind_CHARTMUSEUM,
Auth: &Auth{
Username: "user",
Password: "password",
},
},
},
Target: &TargetRepo{
Repo: &Repo{
Url: "http://fake.target.com"... |
package main
import (
"fmt"
"strings"
"os"
"bufio"
"sort"
)
func main(){
file,_ := os.Open("pass.txt")
scanner := bufio.NewScanner(file)
count := 0
for scanner.Scan() {
valid := true
m := make(map[string]int)
s := strings.Split(scanner.Text(), " ")
for i := range s {
tmp := strings.Split(s[i], "... |
package gpacker
import (
"bytes"
"compress/gzip"
"io"
"io/ioutil"
"github.com/bnch/uleb128"
)
type Entry struct {
EntryName string
EntryType entrytype
EntryData []byte
AdditionalData []byte
}
func (e *Entry) WriteToStream(w io.Writer) (err error) {
_, err = w.Write(uleb128.Marshal(len(e.Ent... |
package a
import (
"exGo/a/sort"
"testing"
)
//func BenchmarkBinarySearch(b *testing.B) {
// data, f := Presentation()
// for n := 0; n < b.N; n++ {
// LSearch(data, f)
// }
//}
//
//func BenchmarkCommonSearch(b *testing.B) {
// data, f := Presentation()
//
// for n := 0; n < b.N; n++ {
// LSearch(data, f)
// }
/... |
package paginate
import (
"math"
"net/http"
"strconv"
"github.com/jinzhu/gorm"
)
const (
defaultPerPage = 25
defaultPageParam = "page"
defaultPerPageParam = "per_page"
)
var (
// PageParam is a name of URL query param "page"
PageParam = defaultPageParam
// PerPageParam is a name of URL query param... |
package db
import (
"github.com/boltdb/bolt"
"log"
"time"
"encoding/json"
)
type SMS struct{
Id string
Name string
Status int
Retries int
Created time.Time
}
func (sms *SMS) Save() error{
Ddb.Update(func(tx *bolt.Tx) error {
log.Println("--- Save SMS")
b := tx.Bucket([]byte("SMS")) ... |
package configo
import (
"os"
"bufio"
"strconv"
"strings"
"errors"
"regexp"
)
const (
separator = "="
configFolder = "./config"
configFile = "app.config"
)
var re *regexp.Regexp
type Config struct {
environment string
configData map[string]string
configKeys []string
}
//noinspection GoUnusedExportedF... |
//+build test
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT license.
package hpa
import (
"context"
"encoding/json"
"log"
"os/exec"
"regexp"
"time"
"github.com/Azure/aks-engine/test/e2e/kubernetes/util"
"github.com/pkg/errors"
)
type List struct {
HPAs []HPA `json:"... |
package 一维数组
import "github.com/Lxy417165709/LeetCode-Golang/新刷题/util/sort_util"
// sortArray 快速排序。
func sortArray(nums []int) []int {
sort_util.QuickSort(nums)
return nums
}
// sortArrayByHeap 堆排序。
func sortArrayByHeap(nums []int) []int {
return sort_util.HeapSort(nums)
}
|
package main
import "math"
//给你一个二叉树,请你返回其按 层序遍历 得到的节点值。 (即逐层地,从左到右访问所有节点)。
//
//
//
//示例:
//二叉树:[3,9,20,null,null,15,7],
//
//3
/// \
//9 20
/// \
//15 7
//返回其层序遍历结果:
//
//[
//[3],
//[9,20],
//[15,7]
//]
func main() {
}
type TreeNode struct {
Val int
Left *TreeNode
Right *TreeNode
}
// 直接一个队列先进先出
// 时间... |
package 链表
// --------------------- MyQueue ---------------------
// 双栈。
// Pop 时间复杂度为 O(n)
// Push 时间复杂度为 O(1)
type MyQueue struct {
pushStack *MyStack
popStack *MyStack
}
func Constructor() MyQueue {
return MyQueue{
pushStack:NewMyStack(),
popStack:NewMyStack(),
}
}
func (mq *MyQueue) Push(x int) {... |
package _42_Trapping_Rain_Water
func trap(height []int) int {
if len(height) < 3 {
return 0
}
return trapStack(height)
}
func trapStack(height []int) int {
s := []int{}
sum := 0
for idx, h := range height {
for len(s) != 0 && height[s[len(s)-1]] < h {
tmpIdx := s[len(s)-1]
s = s[:len(s)-1]
if len(s... |
package problem0680
func validPalindrome(s string) bool {
return isPalindrome(s, 0, len(s)-1, false)
}
func isPalindrome(s string, left, right int, isDeleted bool) bool {
for left < right {
if s[left] == s[right] {
left++
right--
} else if isDeleted {
return false
} else {
return isPalindrome(s, l... |
package main
type Door struct {
ID int
status string
}
func NewDoor(_id int) *Door {
doors := new(Door)
doors.ID = _id
doors.status = ""
return doors
}
|
// Package debug for debugging
package debug
|
// Copyright 2020 Red Hat, Inc. and/or its affiliates
//
// 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 applic... |
package main
// 计算斐波纳契数列(Fibonacci)的第N个数
func fib(n int) int {
x, y := 0, 1
for i := 0; i < n; i++ {
x, y = y, x+y
}
return x
}
func main() {
println(fib(10))
}
|
package weblog
import "fmt"
func ExampleOpen() {
// bufSize: 1024
err := Open(".", 1024)
if err != nil {
fmt.Println(err)
// handle error
}
defer func() {
// CloseLater makes sure all pending
// logging operations are executed
// before closing
if errs := <-CloseLater(); errs != nil {
// handle er... |
package cryptotrader
import "strings"
// ExchangeConfig represents the config for the exchange to trade on
type ExchangeConfig struct {
// Name of the exchange
Name string
// Exchange specific map of arguments
ArgMap map[string]string
}
// NewExchangeConfigFromFlags creates a new ExchangeConfig insance from the... |
package calendarscheduler
import (
"encoding/json"
"os"
"os/signal"
"time"
config "github.com/JokeTrue/otus-golang/hw12_13_14_15_calendar/pkg/config/calendar_scheduler"
"github.com/JokeTrue/otus-golang/hw12_13_14_15_calendar/pkg/database"
"github.com/JokeTrue/otus-golang/hw12_13_14_15_calendar/pkg/event/usecas... |
package twig
import (
"fmt"
"net/http"
)
type HttpError struct {
Code int
Msg interface{}
Internal error
}
func NewHttpError(code int, msg ...interface{}) *HttpError {
e := &HttpError{
Code: code,
Msg: http.StatusText(code),
}
if len(msg) > 0 {
e.Msg = msg[0]
}
return e
}
func (e *HttpEr... |
package main
import (
"context"
"fmt"
"time"
"github.com/dymm/orchestrators/grpc-consul/pkg/messaging/process"
)
const valueToAdd = 7
type processServiceServer struct {
}
func (s *processServiceServer) Process(ctx context.Context, request *process.ProcessRequest) (*process.ProcessResponse, error... |
// This file was generated for SObject AdditionalNumber, API Version v43.0 at 2018-07-30 03:47:15.766751157 -0400 EDT m=+2.109436747
package sobjects
import (
"fmt"
"strings"
)
type AdditionalNumber struct {
BaseSObject
CallCenterId string `force:",omitempty"`
CreatedById string `force:",omitempty"`
C... |
package lockservice
import "net"
import "net/rpc"
import "log"
import "sync"
import "fmt"
import "os"
import "io"
import "time"
type LockServer struct {
mu sync.Mutex
checkmu sync.Mutex
l net.Listener
dead bool // for test_test.go
dying bool // for test_test.go
am_primary bool // am I the primar... |
package main
import (
"errors"
"fmt"
"io/ioutil"
"os"
"path/filepath"
"strings"
"github.com/sirupsen/logrus"
_ "github.com/jinzhu/gorm/dialects/mysql"
"github.com/jungju/circle_manager/modules"
"github.com/jungju/gorm_manager"
"github.com/urfave/cli"
)
var (
envs *Envs
)
type Envs struct {
Mode ... |
package main
import (
"fmt"
"os"
)
func main() {
// os.Args provides access to raw CLI arguments
argsWithProg := os.Args // includes program name
argsWithoutProg := os.Args[1:] // does not include program name
arg := os.Args[3] // select the 3rd argument
... |
package mocks
import (
"context"
"reflect"
"sync/atomic"
"github.com/google/uuid"
cmap "github.com/orcaman/concurrent-map"
"go.uber.org/zap"
"gopkg.in/jeevatkm/go-model.v1"
"github.com/jybbang/go-core-architecture/core"
)
type adapter struct {
tableName string
model core.Entitier
db ... |
package configuration
import (
"fmt"
"os"
"github.com/alexedwards/scs/v2"
"github.com/casbin/casbin"
"github.com/joho/godotenv"
"go.uber.org/zap"
)
//Environment settings
type Environment struct {
Port string
Address string
}
//Configuration struct
type Configuration struct {
Environment *Environment
S... |
// Package ordershandler API calls for dishes web
// --------------------------------------------------------------
// .../src/restauranteweb/areas/disherhandler/orderapicalls.go
// --------------------------------------------------------------
package ordershandler
import (
"encoding/json"
helper "festajuninaweb/ar... |
package demo
import (
"net/http"
"gaea/app/service/demo"
"gaea/utils"
"github.com/gin-gonic/gin"
)
//accept http request
func GaeaDemo(ctx *gin.Context) {
goCtx := utils.TransferToContext(ctx)
param := ctx.PostForm("param")
ret, err := demo.DoFun(goCtx, param)
if err != nil {
resp := utils.Error(err)
ct... |
package identity
import (
"net/http"
"os"
"testing"
"time"
"github.com/databrickslabs/databricks-terraform/common"
"github.com/databrickslabs/databricks-terraform/internal/qa"
"github.com/stretchr/testify/assert"
)
func TestResourceTokenRead(t *testing.T) {
d, err := qa.ResourceFixture{
Fixtures: []qa.HTTP... |
package clipboard
import (
"fmt"
"testing"
"time"
)
func TestChange(t *testing.T) {
testStrings := []string{
"content 1",
"content 2",
"content 3",
}
WriteAll("")
ch, cancel := Watch(20 * time.Millisecond)
go func() {
for _, c := range testStrings {
WriteAll(c)
time.Sleep(100 * time.Millisecon... |
package virtual_security
import (
"fmt"
"time"
)
func newValidatorComponent() iValidatorComponent {
return &validatorComponent{}
}
type iValidatorComponent interface {
isValidStockOrder(order *stockOrder, now time.Time, positions []*stockPosition) error
isValidMarginOrder(order *marginOrder, now time.Time, posi... |
package quizzee
import "time"
const (
weightBaidu = 0.969039 // Baidu搜索权重
weightBing = 1.000000 // Bing搜索权重
weightSogou = 0.836369 // Sogou搜索权重
weight360 = 0.841272 // 360搜索权重
)
const Timeout = time.Second * 3 // 搜索超时时间
|
package window
import (
"bitbucket.org/avanz/anotherPomodoro/common"
"bitbucket.org/avanz/anotherPomodoro/repository"
"bitbucket.org/avanz/anotherPomodoro/sync"
"errors"
"fmt"
"fyne.io/fyne"
"fyne.io/fyne/layout"
"fyne.io/fyne/widget"
"github.com/atotto/clipboard"
"net"
"strings"
"time"
)
func NewSettings... |
package lang
import (
. "jvmgo/any"
"jvmgo/jvm/rtda"
rtc "jvmgo/jvm/rtda/class"
)
func init() {
_cl(findLoadedClass0, "findLoadedClass0", "(Ljava/lang/String;)Ljava/lang/Class;")
}
func _cl(method Any, name, desc string) {
rtc.RegisterNativeMethod("java/lang/ClassLoader", name, desc, method)
}
// private nativ... |
package scrape
import (
"bytes"
"fmt"
"github.com/gorilla/mux"
"github.com/sandro-h/prom_rest_exporter/spec"
"github.com/stretchr/testify/assert"
"net/http"
"sort"
"strings"
"testing"
"time"
)
func TestScrape(t *testing.T) {
spec, _ := spec.ReadSpecFromYamlFile("testdata/scrape_test_spec.yml")
metrics := ... |
// 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... |
package sessions
import (
"errors"
)
var (
// ErrNoSessionFound is the error for when no session is found.
ErrNoSessionFound = errors.New("internal/sessions: session is not found")
// ErrMalformed is the error for when a session is found but is malformed.
ErrMalformed = errors.New("internal/sessions: session is... |
// Copyright 2020. Akamai Technologies, Inc
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
// http://www.apache.org/licenses/LICENSE-2.0
// Unless required by applicable law or agreed t... |
package admin
import (
"fmt"
"github.com/astaxie/beego"
"go_blog/models"
"go_blog/utils"
"time"
)
func (c *AdminController) GetBlog() {
director := GetBlogDirector(c, &GetBlog{})
director.getModel()
}
func (c *AdminController) EditBlog() {
director := GetBlogDirector(c, &EditBlog{})
director.getModel()
}
f... |
/*
* Copyright (c) 2018 Jeffrey Walter <jeffreydwalter@gmail.com>
*
* 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 to use, c... |
package sql_test
import (
"fmt"
"reflect"
"strings"
"testing"
"github.com/ndilsou/go-rdbms-playground"
)
// Ensure the scanner can scan tokens correctly.
func TestScanner_Scan(t *testing.T) {
var tests = []struct {
s string
item sql.Lexeme
}{
// Special tokens (EOF, ILLEGAL, WS)
{s: ``, item: sql.L... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.