text stringlengths 11 4.05M |
|---|
package controllers
import (
core "IRCService/app/core"
"net"
"strings"
coap "github.com/dustin/go-coap"
)
//DetectGameEventHandler .
func DetectGameEventHandler(ci core.CoapInterface) core.CoapHandler {
return func(l *net.UDPConn, a *net.UDPAddr, m *coap.Message) *coap.Message {
if m.IsConfirmable() {
re... |
package environment
import (
"errors"
"flag"
"os"
)
const (
defaultDBDirectory = "./db"
defaultCategoryName = "Member Channels"
defaultListenName = "[ + New ]"
)
type Environment struct {
// Required
DiscordAPIToken string
// Optional
Verbose bool
DBFile string
DefaultCategor... |
// Copyright (c) 2018 Palantir Technologies. 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 require... |
package server
import (
"context"
"fmt"
"net"
"net/http"
"os"
"os/signal"
"strconv"
"syscall"
"time"
"github.com/NYTimes/gziphandler"
"github.com/golang/glog"
"github.com/prebid/prebid-server/config"
"github.com/prebid/prebid-server/metrics"
metricsconfig "github.com/prebid/prebid-server/metrics/config"... |
package main
import (
"fmt"
"time"
)
//func (st *Stack) Pop() int {
// v := 0
// for ix := len(st) - 1; ix >= 0; ix-- {
// if v = st[ix]; v != 0 {
// st[ix] = 0
// return v
// }
// }
//}
//var num int = 10
//var numX2, numX3 int
//
//func main() {
// numX2, numX3 = getX2AndX3(num)
// PrintValues()
// numX2, n... |
package solutions
func lengthOfLastWord(s string) int {
space, result := 0, 0
for i, char := range s {
if char == ' ' {
space = i + 1
} else {
result = i + 1 - space
}
}
return result
}
|
package serviceaccess_test
import (
cfclient "github.com/cloudfoundry-community/go-cfclient"
. "github.com/onsi/ginkgo"
. "github.com/onsi/gomega"
"github.com/vmwarepivotallabs/cf-mgmt/serviceaccess"
"github.com/vmwarepivotallabs/cf-mgmt/serviceaccess/fakes"
)
var _ = Describe("ServiceInfo", func() {
Context("S... |
package userController
type updateParamsStruct struct {
Name string `json:"name" valid:"required~缺少用户名"`
Password string `json:"password" valid:"required~缺少用户密码"`
Avatar string `json:"avatar"`
Email string `json:"email"`
Role string `json:"role" valid:"required~缺少角色"`
}
|
// 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 agreed ... |
package main
import "fmt"
/*
Write a function that takes a string as input and reverse only the vowels of a string.
Example 1:
Input: "hello"
Output: "holle"
Example 2:
Input: "leetcode"
Output: "leotcede"
Note:
The vowels does not include the letter "y".
*/
func main() {
fmt.Println(reverseVowels("hello")... |
package schemes
import (
regv1 "github.com/tmax-cloud/registry-operator/api/v1"
corev1 "k8s.io/api/core/v1"
v1 "k8s.io/apimachinery/pkg/apis/meta/v1"
)
// ImageReplicateSyncJob is a scheme of image replicate sync job
func ImageReplicateSyncJob(repl *regv1.ImageReplicate) *regv1.RegistryJob {
labels := make(map[st... |
package main
import (
"fmt"
"strconv"
)
var (
x int
y int = 0
z = 0
)
var x1, x2 int
var y1, y2 int = 1, 2
var z1, z2 = 1, "a"
var i1, err1 = strconv.Atoi("10")
var _, err2 = strconv.Atoi("10")
var n = 1
var (
n1 = 6789
n2 = 04567
n3 = 0xCDEF
f1 = 1.2
f2 = 1.2e+3
i2 = 1.2i
i3 = 3 + 1.2i
r1 = '... |
package transform
type LookupTable map[string]string
func (jp *LookupTable) LookupValue(k string) (string, bool) {
s, ok := (*jp)[k]
return s, ok
}
func (jp *LookupTable) LookupRecord(k string) (map[string]any, bool) {
if x, ok := (*jp)[k]; ok {
return map[string]any{"value": x}, true
}
return nil, false
}
|
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
package cmd
import (
"bytes"
"regexp"
"github.com/spf13/cobra"
)
func runReplace(start string, pattern *regexp.Regexp, replacement []byte) error {
return walkReplace(func(data [... |
package session
import (
"errors"
"sync"
"time"
"github.com/gomodule/redigo/redis"
"github.com/google/uuid"
)
type RedisSessionMgr struct {
//redis地址
addr string
//密码
passwd string
//连接池
pool *redis.Pool
//锁
rwlock sync.RWMutex
//大map
sessionMap map[string]Session
}
//构造函数
func NewRedisSessionMgr... |
package main
import (
"fmt"
"time"
)
func main() {
user := make(map[string]interface{})
for i := 0;i < 10;i++ {
go doMap(user,i)
}
time.Sleep(time.Second)
fmt.Println(user)
}
func doMap(u map[string]interface{},i int) {
u["name"] = i
}
|
package repository
import "github.com/flaviowilker/rentcar/app/domain"
// UserRepository ...
type UserRepository interface {
FindByLogin(string) (*domain.User, error)
FindAll() ([]*domain.User, error)
Create(*domain.User) (*domain.User, error)
Update(*domain.User) (*domain.User, error)
Delete(uint) (*domain.User... |
/*
Package inmem implements the store DAO interface. This implementation is meant
to help get an instance of Argus up and running quickly without a need to setup
a dedicated DB. Since the current implementation is not scalable, it is recommended
for test environments only.
*/
package inmem
|
package engine
import (
"context"
"errors"
"fmt"
"log"
"os"
"path"
"path/filepath"
"regexp"
"runtime"
"sort"
"strings"
"sync"
"testing"
"time"
"github.com/davecgh/go-spew/spew"
"github.com/docker/distribution/reference"
dockertypes "github.com/docker/docker/api/types"
"github.com/google/uuid"
"gith... |
package parser
import (
"strings"
"testing"
)
func TestParse(t *testing.T) {
md := `
---
title: "Front Matters"
description: "It really does"
---
This is some summary. This is some summary. This is some summary. This is some summary.
<!--more-->
### Title
End value
`
info, err := Parse(strings.NewReader(... |
package main
import (
"net/http"
"os"
"strings"
"github.com/gin-contrib/multitemplate"
"github.com/gin-gonic/gin"
_ "github.com/heroku/x/hmetrics/onload"
"github.com/mattn/go-zglob"
. "go_heroku_test/controllers"
"go_heroku_test/db"
)
func main() {
db.Init()
defer db.Close()
port := os.Getenv("PORT")
... |
package rod_test
import (
"errors"
"fmt"
"net/http"
"os"
"os/exec"
"runtime"
"testing"
"time"
"github.com/go-rod/rod"
"github.com/go-rod/rod/lib/cdp"
"github.com/go-rod/rod/lib/devices"
"github.com/go-rod/rod/lib/launcher"
"github.com/go-rod/rod/lib/proto"
"github.com/go-rod/rod/lib/utils"
"github.com/... |
package freelearning
import (
"bytes"
"testing"
)
func TestParseBooks(t *testing.T) {
// Some book titles
title1, title2 := "title1", "title2"
// The source for a buffer/reader
source := title1 + "\n" + title2 + "\n"
// Create a buffer
buff := bytes.NewBufferString(source)
// Parse books from the source
... |
package main
import (
"log"
"time"
mcp "github.com/ardnew/mcp2221a"
)
func main() {
m, err := mcp.New(0, mcp.VID, mcp.PID)
if nil != err {
log.Fatalf("Open(): %v", err)
}
defer m.Close()
log.Print(mcp.PackageVersion())
// reset device to default settings stored in flash memory
if err := m.Reset(5 * ti... |
package main
import "fmt"
func main() {
i := 0
fmt.Println("numeros impares entre el 1 y el 50: ")
for {
i++
if i%2 == 0 {
continue /* continue manda la ejecucion al principio del loop for,
en este caso cada vez que el numero fuese par mandaria al principio
sin imprimir el numero, sumaria uno y ... |
package commands
type leftovers interface {
Delete(filter string, regex bool) error
DeleteByType(filter, rType string, regex bool) error
List(filter string, regex bool)
ListByType(filter, rType string, regex bool)
Types()
}
|
package main
import (
"bufio"
"fmt"
"net"
"strings"
)
// handleConnection ascolta la connessione per delle keyword che permettono
// di interagire con il database in memory
func handleConnection(conn net.Conn) {
scanner := bufio.NewScanner(conn)
for scanner.Scan() {
cmd := strings.Split(scanner.Text(), " ")
... |
package merge_test
import (
"fmt"
"testing"
"github.com/pavelnikolov/algorithms/algorithms/sorting/merge"
"github.com/pavelnikolov/algorithms/algorithms/sorting/sorttest"
)
func TestMergeSort(t *testing.T) {
sorttest.Test(t, merge.Sort)
}
func BenchmarkMergeSort100(b *testing.B) { sorttest.Benchmark(b, 100,... |
package datasource_test
import (
"context"
"encoding/json"
"strings"
"testing"
"time"
"github.com/aws/aws-sdk-go/aws"
"github.com/aws/aws-sdk-go/aws/request"
"github.com/aws/aws-sdk-go/service/xray"
"github.com/grafana/grafana-plugin-sdk-go/backend"
"github.com/grafana/x-ray-datasource/pkg/datasource"
"git... |
package views
import (
v1 "github.com/jenkins-x/jx-api/v4/pkg/apis/jenkins.io/v1"
"github.com/jenkins-x/octant-jx/pkg/common/viewhelpers"
"github.com/vmware-tanzu/octant/pkg/view/component"
)
func ToEnvironmentNameLink(r *v1.Environment) component.Component {
name := ToEnvironmentName(r)
ref := r.Name
return co... |
// 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 calc contains common functions used in the Calculator app.
package calc
import (
"context"
"fmt"
"time"
"chromiumos/tast/common/action"
"chromiumos/tast/err... |
package main
import (
"encoding/json"
"fmt"
"log"
"net/http"
"time"
"github.com/gin-contrib/cors"
"github.com/gin-gonic/gin"
_ "github.com/go-sql-driver/mysql"
"github.com/gorilla/websocket"
"github.com/jinzhu/gorm"
_ "github.com/jinzhu/gorm/dialects/sqlite"
)
var db *gorm.DB
var err error
type Message s... |
package v1alpha1
import (
"Hybrid_Cluster/apis"
"k8s.io/apimachinery/pkg/runtime/schema"
"k8s.io/apimachinery/pkg/runtime/serializer"
"k8s.io/client-go/kubernetes/scheme"
"k8s.io/client-go/rest"
fedv1b1 "sigs.k8s.io/kubefed/pkg/apis/core/v1beta1"
)
type ExampleV1Alpha1Interface interface {
KubeFedCluster(name... |
package sqlmock
import (
"bytes"
"database/sql/driver"
"encoding/csv"
"errors"
"fmt"
"io"
"strings"
)
const invalidate = "☠☠☠ MEMORY OVERWRITTEN ☠☠☠ "
// CSVColumnParser is a function which converts trimmed csv
// column string to a []byte representation. Currently
// transforms NULL to nil
var CSVColumnParse... |
package employee
type IEmployee interface {
GetName() string
SetName(name string)
Accept(visitor IVisitor)
}
////////////////////////////////////////
type employee struct {
name string
}
func NewEmployee() *employee {
return new(employee)
}
func (e *employee)GetName() string {
return e.name
}
func (e *employ... |
package remove
import (
"errors"
"store"
"sync"
)
var (
mu sync.Mutex
err error
)
var wg sync.WaitGroup
var removeErrorRemoved error = errors.New("Could not remove: This employee has already been removed.")
var removeErrorNotFound error = errors.New("Could not remove: An employee with this id does not exist.")
... |
package services
import "tax-calculator/models"
type ITaxServices interface {
FindAll() []models.ITax
Load(id string) models.ITax
Create(payload models.ITax) bool
} |
package main
import "fmt"
func HeapPermutation(a []int, size int) {
if size == 1 {
fmt.Println(a)
}
for i := 0; i < size; i++ {
HeapPermutation(a, size-1)
if size%2 == 1 {
a[0], a[size-1] = a[size-1], a[0]
} else {
a[i], a[size-1] = a[size-1], a[i]
}
}
}
func main() {
a :=... |
package imgscale
import (
"testing"
"github.com/thatguystone/cog/check"
)
func TestArgsStrings(t *testing.T) {
c := check.New(t)
newInt := func(i int) *int { return &i }
tests := []struct {
args args
query string
nameSuffix string
}{
{},
{
args: args{
W: newInt(100),
Ext: ".... |
// Copyright 2014 qiufeng-sun. 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 applicab... |
package main
import (
"fmt"
"net"
"container/list"
"bytes"
)
type Client struct {
Name string
Incoming chan string
Outgoing chan string
Conn net.Conn
Quit chan bool
ClientList *list.List
}
func (c *Client) Read(buffer []byte) (int, bool) {
bytesRead, error := c.Conn.Read(buffer)
if ... |
package core
import (
"fmt"
"math/rand"
"time"
)
type Brick struct {
length int
raw [100]byte
dirBack bool
isMove bool
}
func (b *Brick) startPoint() int {
for i, v := range b.raw {
if v == '#' {
return i
}
}
return 0
}
func (b *Brick) endPoint() int {
return b.startPoint() + b.length - 1
}
f... |
package main
import (
"bytes"
"encoding/json"
"flag"
"fmt"
"log"
"os/exec"
"reflect"
"regexp"
"strings"
)
var genGoPkg = flag.String("gen_go_pkg", "main", "Go package")
var genGoFmt = flag.Bool("gen_go_fmt", true, "Run gofmt on output")
var genGoDbg = flag.Bool("gen_go_dbg", false, "Add debug to output code"... |
package controllers
import (
"encoding/json"
"github.com/astaxie/beego"
"smtcar/models"
)
type RoleController struct {
beego.Controller
}
const (
DefRolePageRow = 10
DefRolePageOrder = "Name"
)
func (this *RoleController) Get() {
coord := models.RoleListCoord{}
if err := json.Unmarshal(this.Ctx.Input.Requ... |
// 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 main
import (
"fmt"
"reflect"
"sort"
"strconv"
"strings"
"time"
"unicode"
"github.com/bitmark-inc/logger"
)
const (
defaultNum ... |
package lc
// Time: O(n)
// Benchmark: 0ms 2.0mb | 100%
func checkRecord(s string) bool {
var aCount int
for i, ch := range s {
if ch == 'A' {
aCount++
if aCount > 1 {
return false
}
} else if ch == 'L' {
if i+2 < len(s) && s[i+1] == 'L' && s[i+2] == 'L' {
return false
}
}
}
return t... |
package main
import (
"fmt"
"time"
)
func hasPathCore(matrix [][]int, col, row int, str string, pathLength *int, visited []bool) bool {
if len(matrix) == 0 {
return false
}
rows, cols := len(matrix), len(matrix[0])
}
func main() {
}
|
package cmd
import (
"fmt"
"os"
"github.com/KKKKjl/gosfs/master"
"github.com/KKKKjl/gosfs/storage"
"github.com/spf13/cobra"
)
func init() {
rootCmd.AddCommand(masterCmd)
rootCmd.AddCommand(storageCmd)
}
var rootCmd = &cobra.Command{
Use: "gosfs",
Long: `
______ ______ ______ ______ ______
/\ _... |
package main
func main() {
// chapter1.Run()
return
}
|
package cli
import (
"context"
"fmt"
"os"
"path/filepath"
"strings"
"time"
"github.com/fatih/color"
"github.com/pkg/errors"
"github.com/spf13/cobra"
"github.com/tilt-dev/go-get"
"github.com/tilt-dev/tilt/internal/analytics"
"github.com/tilt-dev/tilt/internal/cli/demo"
"github.com/tilt-dev/tilt/pkg/logg... |
package resolver_test
import (
"strings"
"testing"
"github.com/miekg/dns"
"github.com/ooni/probe-cli/v3/internal/engine/netx/resolver"
)
func TestDecoderUnpackError(t *testing.T) {
d := resolver.MiekgDecoder{}
data, err := d.Decode(dns.TypeA, nil)
if err == nil {
t.Fatal("expected an error here")
}
if dat... |
package redpack
import (
"gylib/weixinsdk/wxpay"
"fmt"
"gylib/common"
)
type WxHongBao struct {
AppId string // 微信公众平台应用ID
MchId string // 微信支付商户平台商户号
ApiKey string // 微信支付商户平台API密钥
// 微信支付商户平台证书路径
CertFile string
KeyFile string
RootcaFile string
Wxuser map[string]string
}
func NewWxHongBao(wxu... |
package salia
const (
HeartBeat = "salia/heartbeat"
ChargeMode = "salia/chargemode"
PauseCharging = "salia/pausecharging"
GridCurrentLimit = "grid_current_limit"
)
type Api struct {
Device struct {
ModelName string
SoftwareVersion string `json:"software_version"`
}
Secc Secc
}
type S... |
// 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 utils
import (
"strings"
"github.com/jerolan/slack-poll/domain/entity"
)
func ConvertCommandToPoll(command string) (poll entity.Poll) {
sanitizedCommand := removeDoubleCuotes(command)
poll.Mode = entity.PollModeSingle
if strings.Contains(sanitizedCommand, "-m") {
poll.Mode = entity.PollModeMultiple
... |
package main
import (
"fmt"
"io/ioutil"
"log"
"net/http"
)
func homePage(w http.ResponseWriter, r *http.Request) {
fmt.Println("Received home page request")
fmt.Fprintf(w, "Test Go web app.")
}
func askRust(w http.ResponseWriter, r *http.Request) {
fmt.Println("Received ask request")
resp, err := http.Get("... |
package model
import "strings"
type BuildReason int
const BuildReasonNone = BuildReason(0)
const (
BuildReasonFlagChangedFiles BuildReason = 1 << iota
BuildReasonFlagConfig
// NOTE(nick): In live-update-v1, if a container had live-updated changed,
// then crashed, we would automatically replace it with a fresh... |
package main
import (
"context"
"fmt"
healthz "google.golang.org/grpc/health/grpc_health_v1"
"io"
"log"
"net"
"strings"
"testing"
"google.golang.org/grpc"
"google.golang.org/grpc/test/bufconn"
repos "rpcs.bts.org/service/repository-service"
users "rpcs.bts.org/service/user-service"
healthsvc "google.gol... |
package main
import (
"flag"
"log"
"os"
"runtime"
"runtime/pprof"
)
var concurrency = flag.Int("concurrency", 100, "Number of concurrent files/goroutines")
func main() {
flag.Parse()
f, err := os.Create("cprof")
if err != nil {
log.Fatal(err)
}
pprof.StartCPUProfile(f)
defer pprof.StopCPUProfile()
runt... |
package main
import (
"fmt"
"net/http"
"os"
"strings"
log "github.com/Sirupsen/logrus"
"github.com/gorilla/context"
"github.com/gorilla/sessions"
"github.com/labstack/echo"
"github.com/labstack/echo/engine/standard"
"github.com/satori/go.uuid"
"github.com/SUSE/stratos-ui/components/app-core/backend/config... |
// Copyright 2020 The ChromiumOS Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
package hwsec
import (
"context"
"syscall"
"chromiumos/tast/common/testexec"
"chromiumos/tast/errors"
)
// FakePCAAgent performs the execution and terminiation of the ... |
package main
import (
"fmt"
"net/http"
"github.com/gorilla/mux"
)
// make function to pass as value to HandleFunc handler parameter
// use if statement in place of router. Setting up a router will require refactoring handlerFunc() into separate page functions.
// Doing so is the first level of abstraction require... |
/**
* @file data.go
* @author malin
* @mail malinbupt@163.com
* @time Sun 09 Aug 2015 04:05:22 PM CST
*/
package resource
import (
"bytes"
"compress/gzip"
"io/ioutil"
aint "distributedcache/util/atomicint"
)
// Resource is the resouce should be cached
type Resource struct {
value []byte
miniteQps *ai... |
package main
import (
"fmt"
"log"
"net/http"
)
var TAGS_URL = "http://localhost:1313/tlist.html"
var CATEGORIES_URL = "http://localhost:1313/clist.html"
func main() {
hugoCompleter := HugoCompleter{
tagsUrl: TAGS_URL,
categoriesUrl: CATEGORIES_URL,
}
http.HandleFunc("/tags", func(w http.ResponseWrit... |
package main
import (
"chi-rest/bootstrap"
"chi-rest/lib/mysql"
"chi-rest/lib/utils"
"chi-rest/services/journeyplan"
"fmt"
"log"
"os"
"path/filepath"
"runtime"
"github.com/urfave/cli/v2"
)
var (
_, b, _, _ = runtime.Caller(0)
basepath = filepath.Dir(b)
config utils.Config
debug = false
host... |
package controllers
type NormalResp struct {
Errno string `json:"errno"`
Errmsg string `json:"errmsg"`
Data interface{} `json:"data"`
}
|
/*
Copyright 2019 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 law or agreed to in writing, ... |
// Goroutine memory usage example, page 43
package goroutine
import (
"runtime"
"sync"
"time"
)
var c <-chan interface{}
// Spawns the leaking goroutine.
func Noop(wg *sync.WaitGroup) {
go func() {
wg.Done()
time.Sleep(1 * time.Second)
// blocks here.
<-c
}()
}
// MemConsumed returns the current system... |
package goip
import "testing"
//you need to set the username and license to run the tests
var userName = "101479"
var license = "LLrtcBQcPkkT"
func TestConnect(t *testing.T) {
New(userName, license)
}
func TestCountryName(t *testing.T) {
check := New(userName, license)
country, err := check.CountryName("80.249.8... |
package http
import (
"echo-crud/entity"
"echo-crud/internal/service"
"net/http"
nethttp "net/http"
"github.com/google/uuid"
"github.com/labstack/echo/v4"
)
// CreateSupplierBodyRequest defines all body attributes needed to add supplier.
type CreateSupplierBodyRequest struct {
NamaSupplier string `json:"nama_... |
/*
* OFAC API
*
* OFAC (Office of Foreign Assets Control) API is designed to facilitate the enforcement of US government economic sanctions programs required by federal law. This project implements a modern REST HTTP API for companies and organizations to obey federal law and use OFAC data in their applications.
*
... |
package generic
import (
"strconv"
"github.com/iotaledger/hive.go/kvstore"
"github.com/iotaledger/hive.go/objectstorage"
"github.com/iotaledger/hive.go/stringify"
)
// region CachedObject //////////////////////////////////////////////////////////////////////////////////////////
// CachedObject is a wrapper arou... |
package app
import (
"context"
"crypto/tls"
"fmt"
"knife-panel/internal/app/routers/api/ctl"
"knife-panel/internal/app/ws"
"net/http"
"time"
"github.com/gin-gonic/gin"
"go.uber.org/dig"
"knife-panel/internal/app/config"
"knife-panel/internal/app/middleware"
"knife-panel/internal/app/routers/api"
"knife-p... |
package models
import (
"encoding/json"
"errors"
"fmt"
"log"
"github.com/astaxie/beego"
"github.com/gomodule/redigo/redis"
)
// EventList.
var (
EventList map[string]*Event
)
const (
// DYMFEVENTSREPORT represents fatal errors
DYMFEVENTSREPORT = "dymf_events_report"
)
// addEventToRedis func.
func addEven... |
package client
import (
"fmt"
)
// BaseError is an error type that all other error types embed.
type BaseError struct {
DefaultErrString string
Info string
}
func (e BaseError) Error() string {
e.DefaultErrString = "An error occurred while executing a Gophercloud request."
return e.choseErrString()
... |
package main
import "os"
import "fmt"
import "math"
import "bufio"
import "strconv"
import "strings"
func timeTaken(word_dict map[int][2]int, input string) int {
var timeTakenToType float64
var current_row, current_col float64
var first rune
for _, c := range input {
first = c
break
... |
package mgdb
import (
"bytes"
"context"
"editorApi/config"
"editorApi/init/qmlog"
"log"
"time"
"github.com/mongodb/mongo-go-driver/mongo"
"go.mongodb.org/mongo-driver/bson"
"go.mongodb.org/mongo-driver/mongo/options"
"go.mongodb.org/mongo-driver/mongo/readconcern"
"go.mongodb.org/mongo-driver/mongo/readpre... |
package main
import (
"time"
"github.com/aws/aws-sdk-go/aws"
"github.com/aws/aws-sdk-go/service/s3"
)
type PresignedURL struct {
URL string `json:"url"`
Timeout int `json:"timeout"`
}
func GetS3Presigned(bucket, key string, timeout int) PresignedURL {
svc := s3.New(nil)
req, _ := svc.PutObjectRequest(... |
package netctl
import (
"encoding/json"
"fmt"
"io/ioutil"
"net/http"
"os"
"github.com/codegangsta/cli"
)
var client = &http.Client{}
func handleBasicError(ctx *cli.Context, err error) {
if err != nil {
errExit(ctx, exitRequest, err.Error(), false)
}
}
func baseURL(ctx *cli.Context) string {
return ctx.G... |
package main
func scan_rawstring() {
var r string
r = ``
r = `compilers!`
r = `\a \b \f \n \r \t \v \\ \"`
}
|
package main
import (
"flag"
"fmt"
"os"
"strings"
"Gaia/plugin"
_ "Gaia/plugin/ftp"
_ "Gaia/plugin/smb"
_ "Gaia/plugin/ssh"
"Gaia/util"
)
var version = "0.1"
var banner = `
_________ _____
__ ____/_____ ___(_)_____ _
_ / __ _ __ ` + "`" + `/_ /_ __ ` + "`" + `/
/ /_/ / / /_/ /_ / / /_/ /... |
package database
import "time"
func Migrate() {
db := ConnectToDatabase()
db.AutoMigrate(&Product{}, &Option{}, &Image{}, &Description{}, &Variant{}, &User{}, &Order{}, &OrderDetail{}, &Bill{})
}
type Description struct {
ID int `json:"id"`
IDProduct int `json:"id_product" gorm:"default:null"`
Cont... |
package requests
import (
"encoding/json"
"fmt"
"io/ioutil"
"net/url"
"strings"
"github.com/atomicjolt/canvasapi"
"github.com/atomicjolt/canvasapi/models"
)
// ReLockModuleProgressions Resets module progressions to their default locked state and
// recalculates them based on the current requirements.
//
// Ad... |
package k8s
import (
"errors"
"fmt"
"strings"
dolittleK8s "github.com/dolittle/platform-api/pkg/dolittle/k8s"
platformK8s "github.com/dolittle/platform-api/pkg/platform/k8s"
batchv1 "k8s.io/api/batch/v1"
corev1 "k8s.io/api/core/v1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
)
func CreateApplicationResourc... |
package importer
import (
"context"
"encoding/json"
"net/http"
"time"
"github.com/pkg/errors"
"github.com/ddouglas/ledger"
"github.com/ddouglas/ledger/internal/account"
"github.com/ddouglas/ledger/internal/gateway"
"github.com/ddouglas/ledger/internal/item"
"github.com/ddouglas/ledger/internal/transaction"... |
package ascii
import (
"fmt"
"testing"
"github.com/Snaxai/IS105/ICA02/Oppg1/ascii"
)
const PasserTestC = `"Hello :-)"`
func TestASCIIoppgC(t *testing.T) {
for i := 0; i < len(PasserTestC); i++ {
if PasserTestC[i] >= 126 { //fra og med 126 fordi det er utenfor normale ascii
t.Fail()
fmt.Println("Value no... |
// Copyright 2020 The ChromiumOS Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
package util
import (
"context"
"fmt"
"math"
"os/exec"
"strconv"
"strings"
"sync"
"chromiumos/tast/common/perf"
"chromiumos/tast/testing"
)
// fioResult is a seri... |
package diag
import (
"fmt"
"strings"
"github.com/gosuri/uitable"
"github.com/spf13/cobra"
"github.com/kapitanov/natandb/pkg/model"
"github.com/kapitanov/natandb/pkg/storage"
)
func init() {
cmd := &cobra.Command{
Use: "snapshot",
Short: "Inspect snapshot file",
}
Command.AddCommand(cmd)
dataDir :=... |
package lfsapi
import (
"net/http"
"net/http/httptest"
"strings"
"sync/atomic"
"testing"
"github.com/git-lfs/git-lfs/errors"
"github.com/stretchr/testify/assert"
)
func TestAuthErrWithBody(t *testing.T) {
var called uint32
srv := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Reques... |
package logfiles
import (
"fmt"
"log"
"net"
"regexp"
"sync/atomic"
"time"
"github.com/ActiveState/tail"
)
var counter uint64
// TailFile tails a specific file
func TailFile(search Search, interval time.Duration, server string, hostname string) {
seek := &tail.SeekInfo{0, 2}
regex := regexp.MustCompile(se... |
// Showcase the usage of the 3rd party package `validator`
// https://github.com/go-playground/validator for validation of struct objects.
//
// Code taken from: https://github.com/go-playground/validator/blob/master/_examples/simple/main.go
package main
import (
"fmt"
"github.com/go-playground/validator/v10"
)
//... |
package main;
import "fmt";
func main() {
// var nombre_variable tipo_dato
/* Examples
var x, y, z int;
var cadena string;
var bandera bool;
var cadenas []string;*/
// Inicializacion de variables con :=
nombre := "Coco";
nombre = "cocooooo";
fmt.Println(nombre);
}
|
package main
import (
"net/http"
"github.com/johnamadeo/server"
log "github.com/sirupsen/logrus"
)
func LogAndWriteErr(w http.ResponseWriter, err error, status int, function string) {
log.WithFields(log.Fields{
"logger": "logrus",
"status": status,
"function": function,
}).Error(err)
w.WriteHeader(st... |
package sources
import (
"fmt"
"math"
"time"
MQTT "github.com/eclipse/paho.mqtt.golang"
)
// BeatWave generates a sine wave with beats and sends it over MQTT
func BeatWave(cxn MQTT.Client) {
for i := 0.0; ; i = i + 0.01 {
cxn.Publish("rocket_view/data/beat", 0, false, fmt.Sprintf("%.3f", math.Sin... |
package main
import "fmt"
type Rnum struct {
bottom, top1, top2, z, gcd int64
}
func gcd(a, b int64) int64 {
if a < 0 {
a = -a
}
if b < 0 {
b = -b
}
var t int64
for ; b != 0; {
t = b
b = a % b
a = t
}
return a
}
func norm(r *Rnum) {
r.gcd = gcd(r.top1, r.bottom)
r.top1 /= r.gcd
r.bottom /= r.g... |
package keeper
import (
"encoding/binary"
"encoding/json"
"io/ioutil"
"os"
"testing"
"time"
"github.com/cosmwasm/wasmd/x/wasm/internal/types"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/cosmos/cosmos-sdk/x/auth"
"github.c... |
package usecase
import (
"marketplace/accounts/domain"
"marketplace/accounts/internal/infrastructure/ads"
"github.com/go-pg/pg/v10"
"github.com/gin-gonic/gin"
)
type GetMeCmd func (db *pg.DB, c *gin.Context, user *domain.Account) (*domain.Account, error)
func GetMe(adsFetcher ads.Fetcher) GetMeCmd {
return fun... |
package tempodb
import (
"errors"
"fmt"
"time"
cortex_cache "github.com/cortexproject/cortex/pkg/chunk/cache"
"github.com/grafana/tempo/tempodb/backend/azure"
"github.com/grafana/tempo/tempodb/backend/cache/memcached"
"github.com/grafana/tempo/tempodb/backend/cache/redis"
"github.com/grafana/tempo/tempodb/bac... |
package main
import "fmt"
func sendping(pingchannel chan<- string, msg string) {
pingchannel <- msg // Add the message to the ping channel
}
func recievepong(pingchannel <-chan string, pongchannel chan<- string) {
msg := <-pingchannel // take the message from ping channel and store it in msg
pongchannel <- msg ... |
package tracing
//go:generate mockgen -package mock -destination mock/tracing_mock.go github.com/caos/zitadel/internal/tracing Tracer
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.