text stringlengths 11 4.05M |
|---|
package algorithms
import (
"AlgorizmiGo/algorithms"
"testing"
)
func TestPlay(t *testing.T) {
algorithms.Play()
}
|
package types
import (
sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/stretchr/testify/require"
"testing"
)
func Test_validateIsIbcDenomParam(t *testing.T) {
type args struct {
i interface{}
}
tests := []struct {
name string
args args
wantErr bool
}{
{"invalid type", args{sdk.OneInt()}, t... |
package carchivum
import (
"archive/tar"
"compress/gzip"
"io/ioutil"
"os"
"path/filepath"
"testing"
)
type testFile struct {
name string
content []byte
}
var TestFiles []testFile
func initTestFiles() {
TestFiles = make([]testFile, 0)
TestFiles = append(TestFiles, testFile{name: "test/test1.txt", conten... |
package mtasts_test
import (
"context"
"fmt"
"github.com/foxcpp/go-mtasts"
)
func ExampleCache_Get() {
c := mtasts.NewRAMCache()
policy, err := c.Get(context.Background(), "gmail.com")
if err != nil {
fmt.Println("Oh noes!", err)
return
}
fmt.Println("Allowed MXs:", policy.MX)
}
|
package port
import (
"fmt"
"net"
"time"
"sync"
)
type PortResult struct {
Port int
State bool
Service string
}
type PortRange struct {
Start int
End int
}
func ScanPorts(hostname string) []PortResult{
wg := sync.WaitGroup{}
var portResult []PortResult
results := make(cha... |
package main
import (
"encoding/json"
"fmt"
"log"
"net/http"
"time"
"github.com/gorilla/mux"
)
type CallbackPostRequestBody struct {
JobID string `json:"job_id" bson:"job_id"`
JobName string `json:"job_name" bson:"job_name"`
JobContainerID string `json:"job_container_id" bson:"job_c... |
// Copyright 2020 The Cockroach Authors.
//
// Use of this software is governed by the Business Source License
// included in the file licenses/BSL.txt.
//
// As of the Change Date specified in that file, in accordance with
// the Business Source License, use of this software will be governed
// by the Apache License, ... |
package proc
import (
"github.com/akhenakh/statgo"
"code.cloudfoundry.org/bytefmt"
"strconv"
)
type Proc struct {
Host *statgo.HostInfos
CPU *statgo.CPUStats
Mem *statgo.MemStats
}
func (p *Proc) Get() Proc {
s := statgo.NewStat()
return Proc{
Host: s.HostInfos(),
CPU: s.CPUStats(),
Mem... |
// Copyright 2022 The ChromiumOS Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
package network
import (
"context"
"time"
"chromiumos/tast/ctxutil"
"chromiumos/tast/local/cellular"
"chromiumos/tast/local/chrome"
"chromiumos/tast/local/chrome/uiau... |
package git
import "github.com/goreleaser/goreleaser/context"
// Pipe for brew deployment
type Pipe struct{}
// Description of the pipe
func (Pipe) Description() string {
return "Getting Git info"
}
// Run the pipe
func (Pipe) Run(ctx *context.Context) (err error) {
tag, err := currentTag()
if err != nil {
ret... |
package main
import (
"flag"
"log"
"github.com/gin-gonic/gin"
"github.com/lmdtfy/lmdtfy/pkg/handler"
"github.com/lmdtfy/lmdtfy/pkg/store"
)
var (
listenAddr string
address string
dbName string
staticDir string
insertTestData bool
)
func main() {
// docker.New()
// docker.Build()... |
package cache
import (
"context"
"github.com/I-Reven/Hexagonal/src/infrastructure/repository/redis"
redisV8 "github.com/go-redis/redis/v8"
"os"
"sync"
)
var (
once sync.Once
client *redisV8.Client
ctx context.Context
config = &redisV8.Options{
Addr: os.Getenv("REDIS_URL"),
Password: "",
DB: ... |
// Copyright 2020 The Mellium Contributors.
// Use of this source code is governed by the BSD 2-clause
// license that can be found in the LICENSE file.
package stanza
import (
"encoding/xml"
"mellium.im/xmlstream"
"mellium.im/xmpp/internal/attr"
"mellium.im/xmpp/internal/ns"
"mellium.im/xmpp/jid"
)
// Namespa... |
package main
func intsSliceExist(slice []int, value int) bool {
for _, v := range slice {
if v == value {
return true
}
}
return false
}
|
package wineutil
import (
"fmt"
"testing"
"github.com/lukeic/vinogo/config"
"github.com/stretchr/testify/assert"
)
func TestNewApiQuery(t *testing.T) {
expected := fmt.Sprintf("akey=%s", config.GetString("SNOOTH_API_KEY"))
actual := NewAPIQuery().Encode()
assert.Equal(t, expected, actual, "should be equal")
}... |
package util
import (
"crypto/hmac"
"crypto/md5"
"crypto/rand"
"crypto/sha256"
"encoding/base64"
"encoding/hex"
"errors"
"hash"
"strings"
//shanna.chang start at 2018.10.05
"bytes"
"crypto/cipher"
"crypto/aes"
//shanna.chang end at 2018.10.05
)
// source: https://github.com/gogits/gogs/blob/9ee80e... |
package handle
import (
"quadtree"
. "twof"
)
const (
QuadtreeInitSize = 6400
)
type GameMap struct {
Name string
Tree *quadtree.Quadtree
}
var (
// All players and monsters are stored in an Quadtree, to make it quick to find distances.
lowerLeftNearCorner = TwoF{-QuadtreeInitSize, -QuadtreeInitSize}
upperL... |
/*
Copyright 2020 The Skaffold 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, sof... |
// Copyright (c) 2018-present, MultiVAC Foundation.
// This source code is licensed under the MIT license found in the
// LICENSE file in the root directory of this source tree.
package vrf
import "io"
// PublicKey defines to be public key data structure of MultiVAC account.
type PublicKey []byte
// PrivateKey defi... |
package terminal
import (
"fmt"
"io"
"time"
"github.com/loft-sh/devspace/pkg/devspace/kubectl/selector"
"github.com/loft-sh/devspace/pkg/devspace/config/versions/latest"
devspacecontext "github.com/loft-sh/devspace/pkg/devspace/context"
"github.com/loft-sh/devspace/pkg/devspace/kubectl"
"github.com/loft-sh/d... |
// Copyright 2018 The gVisor Authors.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agree... |
package main
import (
"./lib"
"./run"
"fmt"
"os"
"path"
"strings"
)
func main() {
config,err:= lib.GetConfig()
if err != nil {
fmt.Printf(err.Error())
}
dir, _ := os.Getwd()
sourceFolderPath:=path.Join(dir,fmt.Sprintf("%s/%s/source",config.OutPath,getVideoName(config)))
mp3Path:=fmt.Sprintf("%s/%s_%s.m... |
package main
import (
"fmt"
"github.com/jinzhu/gorm"
_ "github.com/lib/pq"
)
func CheckError(err error, message string) {
if err != nil {
panic(fmt.Sprintf("Error : %v", message))
}
}
func SetupDatabase() *gorm.DB {
db, err := gorm.Open(config.Get("database"), config.Get("databaseURL"))
CheckError(err, "Una... |
package mutator
import (
"fmt"
"net/http"
"github.com/golang/glog"
"github.com/gorilla/mux"
"k8s.io/api/extensions/v1beta1"
apierrors "k8s.io/apimachinery/pkg/api/errors"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/runtime"
"k8s.io/apimachinery/pkg/types"
platform "kolihub.io/koli... |
/**
深度优先遍历
通过邻接表构建逆邻接表
即s->t的关系是,s依赖于t,
t优先于s执行
*/
package topology
import (
"fmt"
"github.com/kakiezhang/Algo/geekTime/graph"
)
func topoByDfs(g *graph.Graph) {
invert_g := graph.NewGraph(g.Max) // 逆邻接表
for i := 1; i < g.Max; i++ {
if g.Vtx[i] == nil {
continue
}
for j := 0; j < g.Vtx[i].Size(); j++ ... |
package backend
import (
"bytes"
"fmt"
"io"
"os"
"os/exec"
"path/filepath"
"time"
gocontext "context"
"github.com/travis-ci/worker/config"
)
var (
errNoScriptUploaded = fmt.Errorf("no script uploaded")
localHelp = map[string]string{
"SCRIPTS_DIR": "directory where generated scripts will be wr... |
// Copyright 2017 Inca Roads LLC. All rights reserved.
// Use of this source code is governed by licenses granted by the
// copyright holder including that found in the LICENSE file.
package main
import (
"bytes"
"crypto/tls"
"crypto/x509"
"encoding/json"
"fmt"
"github.com/blues/note-go/notehub"
"github.com/b... |
package source
import (
"encoding/json"
"errors"
"fmt"
"io/ioutil"
"net/http"
"net/url"
)
// GoDaddyConfig holds the configuration for the namecheap.com source
type GoDaddyConfig struct {
Key string
Secret string
Enabled bool
}
type goDaddyResponse struct {
Available bool
Domain string
Definiti... |
// Package gate provides manager all the physical nodes and the virtual nodes.
// CRUD operations
// Contact configuration server && Do dynamic configs
package gate
import (
"errors"
"fmt"
"io/ioutil"
"path/filepath"
"sync"
"time"
// third pkgs
log "github.com/cihub/seelog"
// company pkgs
alg "shadow/agent/... |
package main
import (
"context"
"fmt"
"log"
"time"
tracker_pb "github.com/mhannig/traack/service/lib/v1/tracker"
"google.golang.org/grpc"
)
func main() {
fmt.Println("traak v1")
// Set up a connection to the server.
conn, err := grpc.Dial("localhost:2344", grpc.WithInsecure())
if err != nil {
log.Fatalf... |
package main
import (
"context"
"fmt"
"log"
"net"
"strings"
"time"
"github.com/moby/moby/pkg/pubsub"
"example.com/hello/rpc/pubsub/sub"
"google.golang.org/grpc"
)
type PublishServiceImp struct {
sub *pubsub.Publisher
}
func (p *PublishServiceImp) Publish(ctx context.Context, arg *sub.String) (*sub.String... |
package models
import "github.com/bykof/go-plantuml/test/address/models"
type (
User struct {
FirstName string
LastName string
Age uint8
Address *models.Address
}
)
func (user *User) SetFirstName(firstName string) {
user.FirstName = firstName
}
func PackageFunction() string {
return "Hello Worl... |
package app
import (
"log"
"net/http"
"gorm.io/driver/sqlite"
"gorm.io/gorm"
"github.com/gin-gonic/gin"
"github.com/sahlinet/go-tumbo/pkg/app/handler"
"github.com/sahlinet/go-tumbo/pkg/config"
)
type App struct {
Router *gin.Engine
DB *gorm.DB
}
func (a *App) Initialize(config *config.Config) {
// Da... |
package controller
import (
"context"
"fmt"
"github.com/rancher/k3p/pkg/apis/helm.k3s.io/v1alpha1"
helmcontroller "github.com/rancher/k3p/pkg/generated/controllers/helm.k3s.io/v1alpha1"
"github.com/rancher/k3p/types"
batch "k8s.io/api/batch/v1"
v1 "k8s.io/api/core/v1"
rbacv1 "k8s.io/api/rbac/v1"
metav1 "k8s.... |
// Copyright 2020 The gVisor Authors.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agree... |
package main
import "github.com/tobymiller/s3-fast-transfer/cmd"
func main() {
cmd.Execute()
}
|
package helper
import (
"log"
"gopkg.in/mgo.v2"
)
const (
MongoTestingAddr = "127.0.0.1:27017"
)
func MustCreateMongoSession(mongoURL string) *mgo.Session {
session, err := mgo.Dial(mongoURL)
if err != nil {
log.Fatal("mongo server connection failed:", err)
}
// Optional. Switch the session to a monotonic ... |
package main
import (
"encoding/json"
"flag"
"fmt"
"io"
"os"
"github.com/yeboahnanaosei/go/cval"
)
type e struct {
Msg string `json:"msg"`
Fix string `json:"fix"`
}
type jsonPayload struct {
Ok bool `json:"ok"`
Msg string `json:"msg"`
Data interface{} `json:"data,omitempty"`
Error e ... |
// Copyright 2020 apirator.io
//
// 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 message
// ConfigNotFound should be used if devspace.yaml cannot be found
const ConfigNotFound = "Cannot find a devspace.yaml for this project. Please run `devspace init`"
// ServiceNotFound should be used if there are no Kubernetes services resources
const ServiceNotFound = "Cannot find any services in names... |
/*
Copyright (C) 2018 Gravitational, 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 writing, soft... |
package wasmvm
import "testing"
func TestNewWasmStateMachine(t *testing.T) {
sm := NewWasmStateMachine()
if sm == nil {
t.Fatal("NewWasmStateMachine should return a non nil state machine")
}
if sm.WasmStateReader == nil {
t.Fatal("NewWasmStateMachine should return a non nil state reader")
}
if !sm.Exists(... |
package viewhelpers
import (
"time"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
)
// ToTimeMarkdown returns a formatted time as markdown
func ToTimeMarkdown(mt *metav1.Time) string {
if mt == nil {
return ""
}
return mt.Time.Format(time.RFC822)
}
|
package explore
import (
"encoding/json"
"fmt"
"os"
"github.com/sirupsen/logrus"
"github.com/spf13/cobra"
"github.com/dolittle/platform-api/pkg/k8s"
platformK8s "github.com/dolittle/platform-api/pkg/platform/k8s"
)
var ingressCMD = &cobra.Command{
Use: "ingress",
Short: "Get ingress data for customer ten... |
package backup
import (
"fmt"
"time"
)
var daysOfWeek = map[string]time.Weekday{
"sunday": time.Sunday,
"monday": time.Monday,
"tuesday": time.Tuesday,
"wednesday": time.Wednesday,
"thursday": time.Thursday,
"friday": time.Friday,
"saturday": time.Saturday,
}
func parseWeekday(v string) (time.W... |
package graph
import (
"encoding/json"
)
// ParseJSON parses a given definition in NoFlo's .JSON and returns
// unified Description structure
func ParseJSON(definition []byte) (*Description, error) {
var graph Description
err := json.Unmarshal(definition, &graph)
if err != nil {
return nil, err
}
return &gra... |
package main
import (
"fmt"
"os"
"runtime"
"strconv"
"time"
)
func SetupCPU() {
num := runtime.NumCPU()
runtime.GOMAXPROCS(num)
}
func Date2Time(date string) (time.Time, error) {
const shortForm = "2006-01-02"
t1, err := time.Parse(shortForm, date)
return t1, err
}
func Today() (time.Time, error) {
t3 :=... |
package main
import (
"fmt"
"sort"
"strings"
"testing"
)
type column []int
type columns []column
func (slice columns) Len() int { return len(slice) }
func (slice columns) Less(i, j int) bool {
var k int
for k < len(slice[i])-1 && slice[i][k] == slice[j][k] {
k++
}
return slice[i][k] < slice[j][k]
}
func (s... |
package leetcode
func firstUniqChar(s string) byte {
cnt := [26]int{}
for _, ch := range s {
cnt[ch-'a']++
}
for i, ch := range s {
if cnt[ch-'a'] == 1 {
return s[i]
}
}
return ' '
}
|
package gcp
import (
"encoding/json"
compute "google.golang.org/api/compute/v1"
)
// ComputeSubnetworkResource represents a Google Compute Engine subnetwork
type ComputeSubnetworkResource struct {
s *compute.Subnetwork
}
// NewComputeSubnetworkResource returns a new ComputeSubnetworkResource
func NewComputeSubne... |
package event
import "github.com/ionous/sashimi/util/ident"
// Proc implements IEvent
type Proc struct {
msg *Message
currentTarget ITarget
phase Phase
cancelled bool
stopMore bool
stopNow bool
path PathList
target ITarget
}
//
func (evt *Proc) sendToTarget(lo... |
package selfhosted
import (
"context"
"regexp"
"strconv"
"time"
"gopkg.in/mcuadros/go-syslog.v2"
"github.com/pganalyze/collector/util"
)
var logLinePartsRegexp = regexp.MustCompile(`^\[(\d+)-(\d+)\] (.*)`)
var logLineNumberPartsRegexp = regexp.MustCompile(`^\[(\d+)-(\d+)\]$`)
func setupSyslogHandler(ctx cont... |
package datastore
import "github.com/globalsign/mgo/bson"
func (p *PeopleDAO) FindAll() ([]Person, error) {
var people []Person
err := db.C(COLLECTION).Find(bson.M{}).All(&people)
return people, err
}
func (p *PeopleDAO) FindById(personId string) (Person, error) {
var person Person
err := db.C(COLLECTION).Find... |
package service
import (
user_store "github.com/torinos-io/api/store/user_store"
"github.com/torinos-io/api/type/model"
"github.com/torinos-io/api/type/system"
)
// Context holds interfaces of external services
type Context struct {
UserStore user_store.Store
Config *system.Config
}
// Service is an interfac... |
package wkb
import (
"testing"
"github.com/paulmach/orb"
"github.com/paulmach/orb/encoding/internal/wkbcommon"
)
var (
testPoint = orb.Point{-117.15906619141342, 32.71628524142945}
testPointData = []byte{
//01 02 03 04 05 06 07 08
0x01, 0x01, 0x00, 0x00, 0x00,
0x46, 0x81, 0xF6, 0x... |
// SPDX-License-Identifier: ISC
// Copyright (c) 2014-2020 Bitmark Inc.
// Use of this source code is governed by an ISC
// license that can be found in the LICENSE file.
package rpc_test
import (
"testing"
"time"
"github.com/stretchr/testify/assert"
"github.com/bitmark-inc/bitmarkd/announce/fingerprint"
"gith... |
// Copyright 2021 The ChromiumOS Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
package arc
import (
"context"
"time"
"chromiumos/tast/common/android/ui"
"chromiumos/tast/errors"
"chromiumos/tast/local/bundles/cros/arc/standardizedtestutil"
"chro... |
package model
var Configurationins AppConfigs
type AppConfigs struct {
Server struct {
Mode string `yaml:"mode"`
Port string `yaml:"port"`
}
Database struct {
Username string `yaml:"username"`
Password string `yaml:"password"`
Sslmode string `yaml:"sslmode"`
Dbname string `yaml:"dbname"`
Host ... |
package session
import (
"context"
"gamesvr/manager"
"shared/protobuf/pb"
"shared/utility/errors"
)
func (s *Session) RPCGuildIsDissolved(ctx context.Context) (*pb.GuildIsDissolvedResp, error) {
resp, err := manager.RPCGuildClient.IsDissolved(ctx, &pb.GuildIsDissolvedReq{
GuildID: s.Guild.GuildID,
})
if er... |
// Copyright 2022 The ChromiumOS Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
package inputs
import (
"bufio"
"context"
"io"
"io/ioutil"
"math"
"net/http"
"net/http/httptest"
"regexp"
"time"
"chromiumos/tast/common/testexec"
"chromiumos/ta... |
package cmd
import (
ui "github.com/ernoaapa/eliot/pkg/cmd/ui"
"github.com/ernoaapa/eliot/pkg/progress"
)
// ShowDownloadProgress prints UI "downloading" lines and updates until
// the progress channel closes
func ShowDownloadProgress(progressc <-chan []*progress.ImageFetch) {
lines := map[string]ui.Line{}
for fe... |
/*
Package json-store reads/writes data to json flat files
Given a top level directory, `Get`, `Put`, and `Del` json encoded flat files of
a given name.
*/
package jsonstore
import (
"encoding/json"
"os"
)
// default dir/file permission
const PERM = 0755
// var MISS = errors.New("File Not Found")
// Bucket holds... |
package artifactory
import (
"errors"
"sync"
)
// AlreadyPresentInSetErrorMessage is the message returned for AlreadyPresentInSetError errors
const AlreadyPresentInSetErrorMessage = "resource with given path already present in set"
/*
ResourceSet is a thread-safe hash map of resource values. Resources may be adde... |
package typrls
import "github.com/typical-go/typical-go/pkg/typgo"
type (
// Releaser responsible to release (put file to release folder)
Releaser interface {
Release(*Context) error
}
// Releasers for composite release
Releasers []Releaser
// ReleaseFn release function
NewReleaser func(*Context) error
// ... |
package main
import "fmt"
// docs: https://blog.golang.org/go-maps-in-action
/*
python sample
x = {"A":1, "B":2 }
*/
/*
This variable m is a map of string keys to int values:
var m map[string]int
Map types are reference types, like pointers or slices, and so the value of m above is nil; it doesn't point to an initi... |
// 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... |
package main
import (
"flag"
"fmt"
"net/url"
"os"
"sync"
"github.com/influxdb/influxdb/client"
"github.com/op/go-logging"
)
var log = logging.MustGetLogger("postcache")
func main() {
initLogging()
log.Info("Starting AlertD")
confPath := flag.String("p", "conf.json", "path to config file")
flag.Parse()
... |
package iofiles
import (
"io"
"io/ioutil"
"os"
"path/filepath"
"strconv"
"github.com/pkg/errors"
log "github.com/sirupsen/logrus"
"nidavellir/libs"
)
// Opens a new LogFile instance for general logging purposes.
func NewLogFile(appFolder string, sourceId, jobId int, readonly bool) (*LogFile, error) {
folde... |
package sqlstorage
/*
Docker postgres run:
docker run --name golang-postgres -e POSTGRES_USER=postgres -e POSTGRES_PASSWORD=postgres -d -p 5432:5432 postgres:alpine
docker exec -ti golang-postgres psql -U postgres
*/
import (
"context"
"database/sql"
"errors"
"fmt"
"time"
storage "github.com/ezhk/golang-lea... |
package main
import "fmt"
func main()
{
mapka := map[slice]slice{
"Owner 1": "BWM"
"Owner 2": "Mercedes"
}
}
|
package antlr
import (
"fmt"
"github.com/antlr/antlr4/runtime/Go/antlr"
"github.com/hyperjumptech/grule-rule-engine/antlr/parser"
"github.com/hyperjumptech/grule-rule-engine/model"
"github.com/sirupsen/logrus"
"io/ioutil"
"reflect"
"testing"
"time"
)
func TestLexer(t *testing.T) {
data, err := ioutil.ReadFi... |
package vault
import (
"errors"
"net/http"
"net/url"
vault "github.com/hashicorp/vault/api"
"github.com/mlowicki/rhythm/conf"
tlsutils "github.com/mlowicki/rhythm/tls"
log "github.com/sirupsen/logrus"
)
// Client implements Vault client reading secrets with specified prefix.
type Client struct {
c *vault.... |
// Package s3manager provides utilities to upload and download objects from
// S3 concurrently. Helpful for when working with large objects.
package s3manager
//Added a line for testing
//Adding another line for Git event testing part 2
//Adding another line for Git event testing part 2.1
//Adding another line for Git ... |
package auditlog
// Account actions
const (
Banned Action = "banned"
CodeSent Action = "code_sent"
ConfirmSent Action = "confirm_sent"
Confirmed Action = "confirmed"
Deleted Action = "deleted"
Signup Action = "signup"
)
// System actions
const (
Startup Action = "startup"
Shutdown Action =... |
package producer
import (
"fmt"
"time"
"github.com/couchbase/eventing/logging"
"github.com/couchbase/eventing/util"
"github.com/couchbase/gocb"
"github.com/couchbase/gomemcached"
)
var gocbConnectMetaBucketCallback = func(args ...interface{}) error {
p := args[0].(*Producer)
connStr := fmt.Sprintf("couchbas... |
package main
import (
"fmt"
"net"
"time"
)
func CheckError(err error) {
if err != nil {
fmt.Println("Error: " , err)
}
}
func main() {
ServerAddr,err := net.ResolveUDPAddr("udp","129.241.187.255:20003")
CheckError(err)
Conn, err := net.DialUDP("udp", nil, ServerAddr)
C... |
package main
import (
"testing"
)
func TestCode(t *testing.T) {
var tests = []struct {
array []int
index int
paid int
output int
}{
{[]int{3, 10, 2, 9}, 1, 12, 5},
{[]int{3, 10, 2, 9}, 1, 7, 0},
}
for _, test := range tests {
if got := bonAppetit(test.array, test.index, test.paid); got != test... |
package person
import "time"
const Collection string = "people"
// Person represents a user, whether he's seeking or
// offering.
type Person struct {
ID string `json:"id" bson:"_id,omitempty"`
FirstName string `json:"firstName"`
LastName string `json:"lastName"`
Email ... |
package global
import "github.com/BurntSushi/toml"
func GetSysConfig() (sysConfig SysConfig,err error){
_,err = toml.DecodeFile("config.toml",&sysConfig)
return
}
|
package main
import (
"bufio"
"bytes"
"encoding/binary"
"encoding/csv"
"errors"
"flag"
"fmt"
"io"
"io/ioutil"
"math/rand"
"net/http"
"os"
"os/exec"
"os/signal"
"runtime"
"strconv"
"strings"
"text/tabwriter"
"time"
log "github.com/Sirupsen/logrus"
"github.com/bwmarrin/discordgo"
"github.com/dusti... |
package dao
import (
"database/sql"
"fmt"
_ "github.com/lib/pq"
)
type DAO interface {
ChallengeStore
}
type dao struct {
connectionString string
connection *sql.DB
}
type PostgresBuilder struct {
dao
}
func (pb PostgresBuilder) SetConnectionString(connectionString string) PostgresBuilder {
a := pb
... |
package db
import (
"github.com/chadweimer/gomp/models"
"github.com/jmoiron/sqlx"
)
type sqlNoteDriver struct {
Db *sqlx.DB
}
func (d *sqlNoteDriver) Create(note *models.Note) error {
return tx(d.Db, func(db sqlx.Ext) error {
return d.createImpl(note, db)
})
}
func (*sqlNoteDriver) createImpl(note *models.No... |
package conf
import (
"gopkg.in/yaml.v2"
"testing"
)
var f = `
#
# Gw framework configurations.
#
# -----------------------
# Common configurations
# -----------------------
version: 1.0
server:
listenAddr: ":8090"
TLS:
enabled: false
certificate:
key: "tls/app.key"
cert: "tls/app.crt"
... |
/*
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, software
distributed under the License... |
package main
import (
// "context"
"bytes"
"crypto/hmac"
"crypto/sha256"
"encoding/hex"
"encoding/json"
"fmt"
"io/ioutil"
"log"
"net/http"
"net/url"
"os"
"os/signal"
"strings"
"syscall"
"time"
camundaclientgo "github.com/citilinkru/camunda-client-go/v2"
"github.com/citilinkru/camunda-client-go/v2/pr... |
package storage
import (
"context"
"path/filepath"
"testing"
"time"
"github.com/google/uuid"
"github.com/spf13/afero"
"github.com/stretchr/testify/require"
"github.com/openshift/oc-mirror/pkg/api/v1alpha2"
"github.com/openshift/oc-mirror/pkg/config"
)
func TestLocalBackend(t *testing.T) {
underlyingFS :=... |
package server
import (
"github.com/go-chi/chi"
"github.com/sergeychur/avito_auto/internal/models"
"github.com/sergeychur/avito_auto/internal/repository"
"log"
"net/http"
)
func (server *Server) CreateLink(w http.ResponseWriter, r *http.Request) {
link := models.Link{}
err := ReadFromBody(r, w, &link)
if err ... |
package main
import "fmt"
func main() {
var height int
var length int
fmt.Scan(&height, &length)
fmt.Println(height*length, (height+length)*2)
}
|
package api_test
import (
"encoding/json"
"fmt"
"net/http"
"net/http/httptest"
"reflect"
"strings"
"testing"
"github.com/go-test/deep"
"github.com/porter-dev/porter/internal/auth/token"
"github.com/porter-dev/porter/internal/models"
)
// ------------------------- TEST TYPES AND MAIN LOOP ------------------... |
// Copyright 2016 The Lucas Alves Author. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
package payable
import (
"github.com/luk4z7/pagarme-go/auth"
liberr "github.com/luk4z7/pagarme-go/error"
"github.com/luk4z7/pagarme-go/lib/payable"
... |
package main
import (
"fmt"
"github.com/tietang/props/ini"
"github.com/tietang/props/kvs"
)
func main() {
path := kvs.GetCurrentFilePath("config.ini", 1)
conf := ini.NewIniFileCompositeConfigSource(path)
appName := conf.GetDefault("app.name", "test")
appPort := conf.GetIntDefault("app.server.port", 8080)
appE... |
// Copyright 2021 The Cockroach Authors.
//
// Use of this software is governed by the Business Source License
// included in the file licenses/BSL.txt.
//
// As of the Change Date specified in that file, in accordance with
// the Business Source License, use of this software will be governed
// by the Apache License, ... |
package terminal
import (
"fmt"
"learn/src/go-talker/log"
"sync"
"github.com/cjbassi/termui"
)
type MessageBox struct {
*termui.Block
Messages []Message
Boxes []Box
MessageChan chan *Message
InChan chan *Message
locker sync.Mutex
showIndex int32
lastIndex int32
}
func (self *Messa... |
package go_wasm_exec
func NewGlobal(fs Value) Object {
return NewObject(ObjectClass, map[string]Value{
"fs": fs,
"Object": ValueOf(ObjectClass),
"Array": ValueOf(ArrayClass),
"Function": ValueOf(FunctionClass),
"Uint8Array": ValueOf(Uint8ArrayClass),
})
}
|
package main
import (
"log"
"net/http"
"strings"
"time"
"github.com/Unknwon/com"
)
func main() {
log.Println("201402191")
client := &http.Client{}
p, err := com.HttpGetBytes(client, "http://godoc.org/-/index", nil)
if err != nil {
log.Fatalf("Fail to load page: %v", err)
}
content := string(p)
start :=... |
// Copyright 2021 Comcast Cable Communications Management, 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 ... |
package main
import (
"github.com/gopherjs/gopherjs/js"
"github.com/waybeams/waybeams/examples/todo/ctrl"
"github.com/waybeams/waybeams/examples/todo/model"
"github.com/waybeams/waybeams/pkg/clock"
"github.com/waybeams/waybeams/pkg/env/browser"
"github.com/waybeams/waybeams/pkg/scheduler"
)
func CreateCanvas() ... |
package postgres
import (
"bytes"
"encoding/json"
"log"
"net/http"
)
//go:generate $GOPATH/bin/easytags $GOFILE json
type TenantNotification struct {
TenantId uint32 `db:"tenant_id" json:"tenantId"`
Title string `db:"title" json:"title"`
Description string ... |
// Copyright 2017 Zhang Peihao <zhangpeihao@gmail.com>
package mock
import (
"flag"
"fmt"
"sync"
"testing"
"time"
"github.com/golang/glog"
"github.com/zhangpeihao/zim/pkg/broker"
"github.com/zhangpeihao/zim/pkg/broker/register"
"github.com/zhangpeihao/zim/pkg/protocol"
)
var (
cmdPublish, cmdSubscribe *pr... |
package application
import (
"log"
"os"
)
type (
ApplicationLogger interface {
LogWithTimeDiff(arg ...interface{})
}
AppLogger struct {
Logger *log.Logger
Service *interface{}
}
)
func NewAppLogger(service *interface{}) *AppLogger {
return &AppLogger{
Logger: log.New(os.Stderr, "[SYSTEM]", log.Ldat... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.