content stringlengths 44 6.13M | membership stringclasses 2
values |
|---|---|
package main
import (
"bufio"
"bytes"
"io"
"net/http"
"os"
"github.com/gin-gonic/gin"
)
func boiInteractive() {
userin := bufio.NewReader(os.Stdin)
var lastContext *BoiContext = nil
for {
text, err := userin.ReadBytes('\n')
if err != nil {
boiError(err)
break
}
lex := NewBoiInterpreter(text... | non-member |
package stub
// CocoonCode defines the interface of a cocoon code.
type CocoonCode interface {
OnInit() error
OnInvoke(header Metadata, function string, params []string) ([]byte, error)
OnStop()
}
| non-member |
package scripts
import (
"testing"
"time"
)
func TestStartClipboardListening(t *testing.T) {
StartClipboardListening()
time.Sleep(time.Second * 10)
}
| non-member |
package parlia
import (
"bytes"
"sort"
"testing"
"github.com/stretchr/testify/assert"
"github.com/tenderly/bsc/common"
)
func TestValidatorSetSort(t *testing.T) {
size := 100
validators := make([]common.Address, size)
for i := 0; i < size; i++ {
validators[i] = randomAddress()
}
sort.Sort(validatorsAsce... | non-member |
package stringutil
//Reverse returns the reverse of the string passed as `s`
func Reverse(s string) string {
//convert string to a slice so we can manipulate it
//since strings are immutable, this creates a copy of
//the string so we won't be modifying the original
chars := []byte(s)
//starting fr... | non-member |
package main
import (
"github.com/gomarkdown/markdown/ast"
"io"
"strings"
"testing"
)
func Test_RenderChunk_CodeBlockMarkup(t *testing.T) {
code := "import something\n" +
"export something\n"
data := map[string]string{
"program.md": "# Section one\n" +
"``` main.go\n" +
code +
"```\n",
}
s := ne... | member |
package common
// InterruptHandler defines methods for handling interrupt
type InterruptHandler interface {
// Wait blocks and waits for predefined system signal
Wait()
}
| member |
package main
import (
"bufio"
"fmt"
"os"
"path"
"strings"
"wordle/wordle"
log "github.com/sirupsen/logrus"
)
func main() {
if len(os.Args) < 2 {
fmt.Printf("Usage: %s <dictionary-file>\n", path.Base(os.Args[0]))
return
}
d := wordle.NewWordle(os.Args[1])
reader := bufio.NewReader(os.Stdin)
for {
f... | non-member |
package main
import (
"io"
"math/rand"
"net"
smux "github.com/jbenet/go-stream-muxer"
ymux "github.com/jbenet/go-stream-muxer/yamux"
sroute "github.com/whyrusleeping/go-multistream"
)
var transport = ymux.DefaultTransport
type ErrorCodeRWC interface {
io.Reader
io.Writer
Close(ec byte) error
ErrorCodeCh()... | member |
package validators
import (
"context"
"fmt"
"popplio/config"
perms "github.com/infinitybotlist/kittycat/go"
)
// For staging, ensure user is in whitelist
//
// This is because staging uses test keys
func StagingCheckSensitive(ctx context.Context, userId string) error {
// This is because staging uses test keys
... | non-member |
// Package profile provides functions to start/stop profiling of go apps
package profile
import (
"fmt"
"log"
"os"
"runtime"
"runtime/pprof"
)
// MemProfile runs the GC and dump memory profile
func MemProfile(file string) {
fmt.Println("Writing memory profile to", file)
f, err := os.Create(file)
if err != nil... | non-member |
package logging
import (
"net/http"
"os"
"runtime"
"time"
)
type LogClient interface {
LogRequest(*RequestLog, string, string)
LogRelay(*RelayLog, string, string)
}
type LogHandler struct {
client LogClient
}
type RequestLog struct {
Date time.Time `json:"date"`
RequestID string `json:"requ... | non-member |
package main
import (
"bytes"
"fmt"
"os"
"os/signal"
"strings"
log "github.com/Sirupsen/logrus"
"github.com/gigawattio/go-commons/pkg/upstart"
"github.com/jaytaylor/tesseract-web/interfaces"
"gopkg.in/urfave/cli.v2"
)
const (
AppName = "tesseract-web"
)
var (
webService *interfaces.WebService
)
func run... | member |
package main
import (
"log"
"net/http"
"github.com/gorilla/websocket"
)
var (
upgrader = websocket.Upgrader{
ReadBufferSize: 1024,
WriteBufferSize: 1024 * 16,
}
)
func APIWSHub(hub *WSHub, w http.ResponseWriter, r *http.Request) {
username := sessionGetUsername(r)
if username == "" {
respondWithUnauth... | non-member |
package util
import (
"testing"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
)
func TestSplitNext(t *testing.T) {
s := " a,b , c "
assert.Equal(t, "a", SplitNext(&s, ','))
assert.Equal(t, "b", SplitNext(&s, ','))
assert.Equal(t, "c", SplitNext(&s, ','))
require.Empty(t, s)
}
| non-member |
package sql
import (
"context"
"database/sql/driver"
"time"
pgx "github.com/jackc/pgx/v5/stdlib"
)
const adaptedDriverOpenTimeout = 60 * time.Second
// This is the wrapper around sql driver. By default, pgx driver returns connection
// error with the host, username and password. `adaptedDriver` and `postgresCon... | non-member |
package main
import (
"fmt"
)
func main() {
Input := []int{6, 5, 4, 2, 1, 10, 3, 7, 8, 9, 44, -2, -1}
Output := Insertionsort(&Input)
fmt.Println("sorted array is :", Output)
}
//improved insertion sort
//insertion sort has time complexity of O(n^2) and space complexity of O(1)
//but we can bring down time compl... | non-member |
//
package authServer
import (
pb "ULZAccountService/proto"
"bufio"
"log"
"os"
"ULZAccountService/insecure"
"golang.org/x/crypto/bcrypt"
"google.golang.org/grpc/codes"
"google.golang.org/grpc/status"
)
// GetCred(context.Context, *CredReq) (*CreateCredResp, error)
func (CAB *CreditsAuthBackend) GetCred(cq... | non-member |
// Package github contains the Github bridge implementation
package github
import (
"time"
)
const (
target = "github"
metaKeyGithubLogin = "github-login"
githubV3Url = "https://api.github.com"
defaultTimeout = 60 * time.Second
)
type Github struct{}
func (*Github) Target() string {
ret... | non-member |
//go:build !bucket
package bucket
const Enabled bool = false
func GetRain() float64 {
return 0.0
}
func Monitor() error {
println("Bucket was disabled at build time.")
return nil
}
func ResetRain() {
Tips = 0
} | non-member |
package jsonschema
type DefaultRender struct {
Code int `json:"code" doc:"错误码"`
Message string `json:"message" doc:"错误信息"`
Data interface{} `json:"data" doc:"数据"`
}
| non-member |
package main
import (
"log"
"strconv"
"sync"
"time"
)
var _backgroundFunc func()
var _backgroundTask sync.WaitGroup
func restartBackgroundTask(oldValue *string, newValue *string) {
log.Println("Restart background task")
if nil == _backgroundFunc {
return
}
log.Println("Stopping background task")
// wg :=... | non-member |
package main
import(
"fmt"
"strings"
)
func OutputWeatherData(weatherData *OpenWeatherMapWeatherResponse, requestedData string){
switch strings.ToLower(requestedData) {
case "longitude", "lon":
fmt.Println(requestedData, ":", weatherData.Coord.Lon)
case "latitude", "lat... | non-member |
package service
import (
"github.com/curltech/go-colla-biz/ruleengine/entity"
"github.com/curltech/go-colla-core/container"
"github.com/curltech/go-colla-core/service"
"github.com/curltech/go-colla-core/util/message"
)
/**
同步表结构,服务继承基本服务的方法
*/
type RuleDefinitionService struct {
service.OrmBaseService
}
var rul... | non-member |
// netServe project httpServe.go
package netServe
import (
"encoding/json"
"errors"
"github.com/filestorm/go-filestorm/moac/chain3go/utils"
"io/ioutil"
"net/http"
"strings"
"time"
"fmt"
)
//网络请求结构体
type HttpProvider struct {
httpResponse *http.Response
address string //http(https) + ip + 端口
timeout ... | non-member |
package compeng
type CompilationEngine interface {
CompileClass() string
CompileClassVarDec()
CompileSubroutineDec()
CompileParameterList()
CompileSubroutineBody()
CompileVarDec()
CompileStatements()
CompileLet()
CompileIf()
CompileWhile()
CompileDo()
CompileReturn()
CompileExpression()
CompileTerm()
}... | non-member |
package zap
import (
"fmt"
"io"
"sync"
"time"
"github.com/mgutz/ansi"
)
var (
ansiPool = sync.Pool{
New: func() interface{} {
return &ansiEncoder{
textEncoder: textEncoder{
bytes: make([]byte, 0, _initialBufSize),
},
}
},
}
resetColor = ansi.ColorCode("reset")
// Default colors for l... | member |
package log
import (
"github.com/pkg/errors"
"github.com/rs/zerolog"
"github.com/spf13/cobra"
"github.com/spf13/viper"
)
// Config configures the logger.
type Config struct {
Level string `mapstructure:"level"`
ForceTTY bool `mapstructure:"tty"`
JSON bool `mapstructure:"json"`
ShowLine bool `maps... | member |
package mpeer
import (
"strings"
"testing"
)
var pm *PeerManager
var peer *Peer
var pubKeyHash = "0a2be4d884e10e4d0151"
var ip = "10.27.16.1"
func TestPeerManagerInstance(t *testing.T) {
t.Log("TestPeerManagerInstance called")
pm = PeerManagerInstance()
if pm != PeerManagerInstance() {
t.Error("Can onl... | non-member |
package serializers
import (
"encoding/json"
"github.com/manhattanite/models"
)
// CartesianSerializer interface definition.
type CartesianSerializer interface {
Decode([]byte) ([]models.Point, error)
Encode(interface{}) []byte
}
// JSONFormat implementation of cartesian serializer interface.
type JSONFormat st... | non-member |
package parser_test
import (
"testing"
"github.com/stretchr/testify/assert"
"github.com/zsolt-jakab/nand-to-tetris/assembler/parser"
)
func Test_Translate_A_Instruction(t *testing.T) {
expected := []string{"0000000000000000", "0000000000010000", "0000000000010001", "0000000000010000", "0000000000010001"}
line... | non-member |
package models
import (
"crypto/rand"
"encoding/base64"
"errors"
"fmt"
"io"
"time"
"github.com/google/uuid"
"github.com/jinzhu/gorm"
)
type Session struct {
ID string `json:"id" sql:"primary key"`
UserID uuid.UUID `json:"user_id"`
Creation time.Time `json:"creation"`
Expiration time.Time... | non-member |
package main
import "fmt"
func TestIfThenElseStatements(t *T) {
var result string
if true {
result = "true value"
} else {
result = "false value"
}
t.AssertTrue("true value" == result)
}
func TestIfThenStatement(t *T) {
var result string = "default value"
if true {
result = "true value"
}
t.AssertTru... | non-member |
//Struts2-045-checker
//检测是否含有Struts2-045漏洞的小东西
//
//作者:labrusca
//邮箱:labrusca@live.com
//version:0.1.0
//许可证:GPLv3
package main
import (
"fmt"
"net/http"
"regexp"
"github.com/andlabs/ui"
)
func main() {
err := ui.Main(func() {
website := ui.NewEntry()
button := ui.NewButt... | non-member |
package raftcache
import (
"encoding/json"
"errors"
"log"
"net"
"os"
"path/filepath"
"strconv"
"time"
"github.com/xiaomLee/trade-engine/entrust/queue"
raftboltdb "github.com/hashicorp/raft-boltdb"
"github.com/hashicorp/raft"
)
type RaftCache struct {
RaftDir string
RaftBind string
raft *raft.Raft /... | member |
package instance_test
import (
"testing"
"beryju.io/gravity/pkg/instance"
"beryju.io/gravity/pkg/roles"
"beryju.io/gravity/pkg/tests"
"github.com/stretchr/testify/assert"
)
func TestEvents(t *testing.T) {
defer tests.Setup(t)()
rootInst := instance.New()
called := false
rootInst.ForRole("test", tests.Contex... | non-member |
package versioncontrol
import (
"errors"
"fmt"
"os/exec"
"path/filepath"
"strings"
"github.com/nebloc/gitdo/utils"
)
// Git is an implementation of the VersionControl interface for the Git version control system.
type Git struct {
name string
dir string
TopLevel string
}
// CheckClean verifies tha... | non-member |
package MessageBuilder
type poke struct {
Type int64 `json:"type"`
Id int64 `json:"id"`
Strength int64 `json:"strength"`
}
func (self *IMessageBuilder) Poke() *IMessageBuilder {
self.message = append(self.message, iMessage[poke]{
Type: "poke",
Data: poke{
Type: 1,
Id: 10000,
Stren... | non-member |
package hubitat
// Command represents a device command.
type Command struct {
Command string `json:"command"`
}
| non-member |
package buffer_list
import (
"fmt"
"math/rand"
"reflect"
"runtime"
"testing"
)
var g_t *testing.T = nil
var enable_gc_check bool = true
type TestData struct {
a int64
b int32
c int64
}
type TestDataPtr struct {
a int
b *TestData
}
type TestNestData struct {
a int
b TestDataPtr
}
func createList() *Lis... | non-member |
package api
import "firlus.dev/firl.us/internal/store"
// Storage is the store instance to talk with the data layer
var Storage store.Store
| non-member |
package main
import (
"fmt"
"math/rand"
"strconv"
"strings"
"time"
)
var board Board
func main(){
rand.Seed(time.Now().UnixNano())
init_board()
fmt.Println("Start Game: Y/N")
var startGame string
fmt.Scanln(&startGame)
if (strings.ToLower(strings.TrimSpace(startGame)) == "y"){
update_board()
... | non-member |
package status
import (
"github.com/1dustindavis/gorilla/pkg/gorillalog"
)
// GetFileMetadata is just a placeholder on darwin
func GetFileMetadata(path string) WindowsMetadata {
// Log a warning since we are not running on windows
gorillalog.Warn("GetFileMetadata only supported on Windows:", path)
// Set a fake ... | member |
package main
import (
"fmt"
"strings"
)
type Ingredient struct {
name string
capacity, durability, flavor, texture, calories int
}
func day15a(input []string) int {
return day15(input, -1)
}
func day15b(input []string) int {
return day15(input, 500)
}
func day15(inp... | non-member |
// Copyright 2016 The Linux 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 applicable law or agre... | non-member |
package polysdk_test
import (
"testing"
"time"
"polysdk"
"polysdk/internal/config"
"polysdk/internal/polysign"
)
var c *polysdk.PolyClient
func init() {
_c, err := polysdk.NewPolyClient(&config.PolyConfig{})
if err != nil {
panic(err)
}
c = _c
}
func TestClient(t *testing.T) {
accessToken := ""
body ... | non-member |
package db
//--
// Database Setup
//--
import (
"database/sql"
"fmt"
"log"
"os"
_ "github.com/lib/pq"
)
const (
HOST = "postgres-db"
PORT = 5432
)
type Database struct {
Connection *sql.DB
}
var ErrorNoMatch = fmt.Errorf("the requested record does not exist in the table")
func InitializeDB(username strin... | non-member |
/*
* EVE Swagger Interface
*
* An OpenAPI for EVE Online
*
* OpenAPI spec version: 0.3.4
*
* Generated by: https://github.com/swagger-api/swagger-codegen.git
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obta... | non-member |
package bcc
import (
"os"
"testing"
)
func getTestBaiduCloudAccessConfig() *BaiduCloudAccessConfig {
return &BaiduCloudAccessConfig{
BaiduCloudAccessKey: "ak",
BaiduCloudSecretKey: "sk",
}
}
func TestBaiduCloudAccessConfigPrepare_Region(t *testing.T) {
c := getTestBaiduCloudAccessConfig()
if v := os.Geten... | non-member |
package main
import (
"fmt"
"os"
"github.com/madimaa/aoc2020/lib"
)
func main() {
part1()
part2()
os.Exit(0)
}
func part1() {
lib.Start()
fmt.Println("Part 1")
input := lib.OpenFile("24.txt")
g := placeTiles(input)
blackTiles := countBlackTiles(g)
fmt.Println("Result: ", blackTiles)
lib.Elapsed()
}
... | non-member |
package cmd
import (
"bufio"
"fmt"
"os"
)
//Pause ...
type Pause struct {
}
//AddOp ...
func (m *Pause) AddOp(s string, i interface{}) {
return
}
//Validate ...
func (m *Pause) Validate() bool {
return true
}
//Run detiene la ejecución continua de comandos
func (m *Pause) Run() {
fmt.Print("Presiona 'Enter'... | non-member |
//go:build darwin || dragonfly || freebsd || (linux && !appengine) || netbsd || openbsd || solaris
// +build darwin dragonfly freebsd linux,!appengine netbsd openbsd solaris
package readline
import (
"io"
"os"
"os/signal"
"sync"
"syscall"
)
type winsize struct {
Row uint16
Col uint16
Xpixel uint16
Ypi... | non-member |
package domain
type TriangleType string
const (
TriangleTypeEquilateral TriangleType = "equilateral"
TriangleTypeIsosceles TriangleType = "isosceles"
TriangleTypeScalene TriangleType = "scalene"
)
func (t TriangleType) GetTriangleType(typeTriangle string) string {
switch typeTriangle {
case string(Triang... | non-member |
package null
import (
"testing"
"github.com/axsh/openvdc/handlers"
"github.com/stretchr/testify/assert"
)
func TestResourceName(t *testing.T) {
assert := assert.New(t)
assert.Equal("vm/null", handlers.ResourceName(&NullHandler{}))
}
func TestTypes(t *testing.T) {
assert := assert.New(t)
assert.Implements((*h... | non-member |
package run
import (
"errors"
"fmt"
"io"
"os"
"os/exec"
"strings"
"time"
)
func LoadCommands() {
SetCommand("CreateDir", execCreateDir)
SetCommand("AppendFile", execAppendFile)
SetCommand("AddGroup", execAddGroup)
SetCommand("AssignGroups", execAssignGroups)
SetCommand("PrimaryGroup", execPrimaryGroup)
S... | non-member |
package monitor
import "errors"
type Monitor struct {
id string
name string
configPath string
scriptPath string
}
func NewMonitor(
id string,
name string,
configPath string,
scriptPath string,
) (Monitor, error) {
if id == "" {
return Monitor{}, errors.New("empty id")
}
if name == "" {
... | non-member |
package main
import (
"fmt"
"math"
goioc "github.com/dgawlik/go-ioc"
)
type IsPrime func(num int) bool
type Greeter func(name string, age int)
func main() {
goioc.Bind[IsPrime](func(num int) bool {
if num < 2 {
return false
}
sq_root := int(math.Sqrt(float64(num)))
for i := 2; i <= sq_root; i++ {
... | non-member |
package main
import (
"context"
"fmt"
"google.golang.org/grpc"
)
// import "github.com/bbest31/golang-grpc/client/echo"
func main() {
ctx := context.Background()
conn, err := grpc.Dial("localhost:8080", grpc.WithInsecure())
if err != nil {
panic(err)
}
defer conn.Close()
client := echo.NewEchoServerCl... | non-member |
package service
import (
"os"
"time"
"github.com/godbus/dbus/v5"
log "github.com/sirupsen/logrus"
)
// getRootName gets 'org.freedesktop.secrets' name exclusively on session dbus
func getRootName(connection *dbus.Conn) {
const name = "org.freedesktop.secrets"
// try 15 *2 = 30 seconds to acquire 'org.freedes... | member |
package model
const (
MinimumChannels = 1
MaximumChannels = 100
MaximumGuilds = 100
CookieName = "xonia-auth"
)
| non-member |
package entity_test
import (
"testing"
"github.com/anggi-susanto/go-exercise/entity"
"github.com/stretchr/testify/assert"
)
func TestNewSku(t *testing.T) {
s, err := entity.NewUser("a", "a")
assert.Nil(t, err)
assert.Equal(t, s.Type, "a")
assert.Equal(t, s.Name, "a")
}
func TestSkuValidate(t *testing.T) {
t... | non-member |
// Get the tests from the greek paper.
// Includes the example from the Altschul paper which cannot be
// done with the method as described in the original paper.
package gotoh_test
import (
gth "github.com/andrew-torda/goutil/gotoh"
"github.com/andrew-torda/goutil/randseq"
"github.com/andrew-torda/goutil/seq"
"g... | non-member |
package main
import (
"bytes"
. "gopkg.in/check.v1"
)
type VerifierSuite struct{}
var _ = Suite(&VerifierSuite{})
var verifierTests = []struct {
reader string
writer string
result bool
}{
{"foo", "foo", true},
{"foo", "fo1", false},
{"foo", "fooa", false},
{"fooa", "foo", false},
}
func (s *VerifierSuite... | non-member |
/*
Currency Converter. +50 XP
You are making a currency converter app.
Create a function called convert, which takes two parameters: the amount to convert, and the rate, and returns the resulting amount.
The code to take the parameters as input and call the function is already present in the Playground.
Create the fun... | non-member |
package main
import (
"encoding/json"
"fmt"
"github.com/Radiobox/web_responders"
"github.com/stretchr/goweb"
"io/ioutil"
"log"
"math/rand"
"net"
"net/http"
"os"
"path"
"strings"
"time"
)
const (
escape = "\x1b"
)
var (
projectRoot string
bookPath string
quotes []string
goPath = os.Gete... | non-member |
package main
import "fmt"
func fullversion() string {
return fmt.Sprintf("hedynip v%s\n Build: %s\n GIT: %s\n Copyright (c) 2018 eServices Greece - https://esgr.in\n", version, buildstamp, githash)
}
| non-member |
package inputhandlers
import "github.com/volte6/gomud/connections"
// All this does is manage the input history stack
func HistoryInputHandler(clientInput *connections.ClientInput, sharedState map[string]any) (nextHandler bool) {
// Save whatever was in the buffer when enter was hit as the last submitted
if clientI... | non-member |
package password
import (
"strings"
"github.com/haleyrc/pkg/hash"
)
func New(s string) Password {
s = strings.TrimSpace(s)
return Password{s: s}
}
type Password struct {
s string
}
func (p Password) Hash() string {
return hash.Generate(p.s)
}
| non-member |
package domainrouting
import (
"testing"
"github.com/stretchr/testify/assert"
"github.com/getlantern/domains"
)
func TestBuildTree(t *testing.T) {
rules := RulesMap{
"D1": Proxy,
"P1": Direct,
"P3": Proxy,
}
expectedResult := domains.Map{
".d1": Proxy,
".p1": Direct,
".p3": Proxy,
}
result := ... | non-member |
package ref
import (
"context"
"errors"
"github.com/treeverse/lakefs/pkg/db"
"github.com/treeverse/lakefs/pkg/graveler"
)
type RepositoryIterator struct {
db db.Database
ctx context.Context
value *graveler.RepositoryRecord
buf []*graveler.RepositoryRecord
offset string
fetchSize i... | member |
package utils
import (
"../types"
)
// PanicOnError panics if err is not nil
func PanicOnError(err error) {
if err != nil {
panic(err)
}
}
// ExtractContainerResourceUsage parses a ContainerStatsRaw object and extracts a ContainerResourceUsage object
func ExtractContainerResourceUsage(stats types.ContainerStats... | non-member |
package main
import (
"flag"
"fmt"
"io/ioutil"
"os"
"path/filepath"
pb "gopkg.in/cheggaaa/pb.v2"
"github.com/google/gopacket"
"github.com/google/gopacket/layers"
"github.com/google/gopacket/pcap"
"github.com/google/gopacket/pcapgo"
)
var (
filter *string
)
func main() {
path := flag.String("path", "./"... | member |
package exit
import (
"context"
"sync"
)
var BaseContext, Close = context.WithCancel(context.Background())
var QuitWG = sync.WaitGroup{}
var testExitLock = sync.Mutex{}
| non-member |
/*
Package collision adds the Collision updater system with the collider component as well as helpers for collision detection
*/
package collision
import (
"fmt"
"github.com/autovelop/playthos"
)
func init() {
engine.RegisterPackage(&engine.Package{"collision", []string{}, []string{"collision"}, []string{"generic... | non-member |
package home
import (
"context"
"crypto/tls"
"net"
"net/http"
"net/url"
)
// httpClient returns a new HTTP client that uses the AdGuard Home's own DNS
// server for resolving hostnames. The resulting client should not be used
// until [Context.dnsServer] is initialized.
//
// TODO(a.garipov, e.burkov): This is ... | non-member |
package gorm
import (
"fmt"
"ghotos/config"
"time"
"ghotos/util/logger/gorm_logger"
gosql "github.com/go-sql-driver/mysql"
"gorm.io/driver/mysql"
"gorm.io/gorm"
)
// gorm.Model definition
type ModelUID struct {
UID string `gorm:"primaryKey"`
ID uint
CreatedAt time.Time
UpdatedAt time.Time
D... | non-member |
package types
const (
Point2DStructSignature byte = 'X'
Point2DStructSize int = 3
Point3DStructSignature byte = 'Y'
Point3DStructSize int = 4
)
type Point2D struct {
SRID int
X, Y float64
}
func (p *Point2D) Signature() int {
return int(Point2DStructSignature)
}
func (p *Point2D) AllFields() []i... | member |
package main
//#include<stdio.h>
//void SayHello(_GoString_ s);
import "C"
import "fmt"
func main(){
C.SayHello("Hello world")
}
//export SayHello
func SayHello(s string){
fmt.Printf("Test: %s\n",s)
}
| non-member |
package models
import (
"encoding/json"
"errors"
"fmt"
"github.com/jinzhu/gorm"
"github.com/shop-r1/utils/pkg"
log "github.com/sirupsen/logrus"
"strconv"
)
type Member struct {
gorm.Model
TenantId string `sql:"type:char(20);index" description:"租户ID" json:"tenant_id"`
Region string ... | non-member |
package helpers
import (
"net/mail"
)
func GetValidEmail(email string) (string, error) {
e, err := mail.ParseAddress(email)
if err != nil {
return "", err
}
return e.Address, nil
}
| non-member |
package main
import (
"fmt"
"runtime"
"strings"
)
type (
Sect struct {
Decorators []string
Label string
Content []string
SubSects []*Sect
}
Prog struct {
ConstSect, FuncSect *Sect
LibrarySubSect *Sect
CurSect *Sect
Scope *Scope
}
)
func NewProg() *Prog ... | non-member |
package main
import (
"time"
"github.com/google/uuid"
"github.com/paradigm-lab/rssagg/internal/database"
)
type User struct {
ID uuid.UUID `json:"id"`
CreatedAt time.Time `json:"created_at"`
UpdatedAt time.Time `json:"updated_at"`
Name string `json:"name"`
APIKey string `json:"api_key"`
... | non-member |
package processor
import (
"fmt"
"path"
"strings"
"unicode"
"github.com/neurosnap/sentences"
"go.uber.org/zap"
"golang.org/x/text/language"
"golang.org/x/text/language/display"
"fb2converter/static"
)
type tokenizer struct {
t *sentences.DefaultSentenceTokenizer
}
func newTokenizer(lang language.Tag, log... | non-member |
// Copyright 2011 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
package packet
import (
"encoding/binary"
"io"
)
// LiteralData represents an encrypted file. See RFC 4880, section 5.9.
type LiteralData struct {
IsBinary... | non-member |
package plugin
const (
upsertHostCatalogSecretQuery = `
insert into host_plugin_catalog_secret
(catalog_id, secret, key_id)
values
(@catalog_id, @secret, @key_id)
on conflict (catalog_id) do update
set secret = excluded.secret,
key_id = excluded.key_id
returning *;
`
deleteHostCatalogSecretQuery = `
d... | non-member |
package keeper
import (
"github.com/cosmos/cosmos-sdk/store/prefix"
sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/UnUniFi/chain/x/yieldaggregator/submodules/records/types"
)
// SetUserRedemptionRecord set a specific userRedemptionRecord in the store
func (k Keeper) SetUserRedemptionRecord(ctx sdk.Context, ... | non-member |
package main
import (
"fmt"
"os"
)
func main() {
for i, arg := range os.Args[1:] {
fmt.Printf("%d, %s\n", i+1, arg)
}
}
| non-member |
// Copyright 2015 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
package google
import (
"crypto/rsa"
"fmt"
"time"
"golang.org/x/oauth2"
"golang.org/x/oauth2/internal"
"golang.org/x/oauth2/jws"
)
// JWTAccessTokenSou... | non-member |
package router
import (
"context"
"github.com/dmalykh/axeloy/axeloy/profile"
"github.com/dmalykh/axeloy/axeloy/way"
)
//Destination is profile with ways which can sent messages. One destination for one profile.
type Destination interface {
GetWays(ctx context.Context) []way.Sender
GetProfile(ctx context.Context)... | non-member |
package main
import (
"image/color"
"machine"
"time"
"tinygo.org/x/drivers/ws2812"
)
const (
ledPin = machine.P0 // NeoPixels pin
ledNUm = 12 // number of NeoPixels
ledMaxLevel = 0.5 // brightness level of NeoPxels (0~1)
)
// NeoPixels struct build upon the WS2812 driver
type NeoPixe... | non-member |
package proxy
import (
"context"
"fmt"
v1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/client-go/kubernetes"
"k8s.io/client-go/rest"
"log"
"net"
"net/http"
"net/http/httputil"
"net/url"
"os"
"strings"
)
type handler struct {
proxy *httputil.ReverseProxy
conf *Conf
authorizedToken... | non-member |
package main
import (
"context"
"crypto/hmac"
"crypto/sha256"
"encoding/base64"
"encoding/json"
"log"
"net/http"
"net/url"
"os"
"strings"
)
// sessionData represents session data stored in the database
type sessionData struct {
CASUser string `json:"cas_user"`
Authenticated bool `json:"is_authenti... | non-member |
package ctdf
type RealtimeJourneyDetailedRail struct {
Carriages []RailCarriage `groups:"basic"`
}
| non-member |
package main
import (
"bytes"
"flag"
"fmt"
"github.com/fatih/color"
"net"
"os"
"telecon/input"
"telecon/logger"
"telecon/network"
"telecon/utils"
"time"
)
const (
VERSION = "2.0.0"
CODENAME = "Elite"
BUILD = "3"
)
var client Client
var log logger.Logger = logger.Logger{}
var username *string = fl... | member |
package stringutils
import "sort"
func Unique(strSlice []string) []string {
keys := make(map[string]bool)
var list []string
for _, entry := range strSlice {
if _, value := keys[entry]; !value {
keys[entry] = true
list = append(list, entry)
}
}
sort.Strings(list)
return list
}
| non-member |
package model
import (
"fmt"
"io"
"strconv"
"time"
"github.com/schartey/dgraph-lambda-go/examples/models"
"github.com/twpayne/go-geom"
)
type Color interface {
IsColor()
}
type Fruit interface {
IsFruit()
}
type Post interface {
IsPost()
}
type Shape interface {
IsShape()
}
type Apple struct {
Id strin... | non-member |
package iterator
import (
"fmt"
"testing"
)
func TestIterator(t *testing.T) {
arr2 := make([]interface{}, 0)
arr := []interface{}{1, 2, 3}
it := NewIterator()
it.Init(arr)
for it.HasNext() {
fmt.Println(it.Next())
}
arr2 = append(arr2, it)
arr1 := []interface{}{4, 5}
it2 := NewIterator()
it2.Init(arr1)
... | non-member |
package git
import (
"os"
"github.com/go-git/go-git/v5"
)
func CurrentWorkingDirectoryRepository() (*git.Repository, error) {
cwd, err := os.Getwd()
if err != nil {
return nil, err
}
return git.PlainOpenWithOptions(
cwd,
&git.PlainOpenOptions{
DetectDotGit: true,
EnableDotGitCommonDir: tru... | non-member |
package healthcheck
import (
"net/http"
"github.com/sirupsen/logrus"
)
func health(w http.ResponseWriter, _ *http.Request) {
w.Write([]byte("OK"))
}
// StartHealthService starts a health-check service
func StartHealthService() {
http.HandleFunc("/health", health)
logrus.Infof("Staring health check on http://lo... | non-member |
package main
import (
"bufio"
"context"
"encoding/json"
"flag"
"fmt"
"log"
"os"
"strings"
//"net/http"
"google.golang.org/api/option"
youtube "google.golang.org/api/youtube/v3"
)
type Liver struct {
Name string `json:"name,omniempty"`
Slug string `json:"slug,omniempty"`
Affiliation string `json:"aff... | non-member |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.