text stringlengths 11 4.05M |
|---|
package kube
const (
MaxEventSize = 100 * 1024 // 100KB per k8s.io/kubernetes/apiserver/pkg/server/options/audit.go
) |
package trial
import (
"bufio"
"io"
"regexp"
"strings"
)
// Conduct attempts to match the file header lines of reader and expected.
// Returns whether there was a valid match and the file header contents of
// reader.
func Conduct(expected regexp.Regexp, reader io.Reader) (bool, string) {
evidence := getEvidence... |
package limit
// import "sync"
// type Mux map[string]*sync.Mutex
|
package main
import (
"database/sql"
"github.com/alejandrox1/setup_sqldb"
_ "github.com/lib/pq"
)
type Text interface {
Retrieve(id int) (err error)
Create() (err error)
Update() (err error)
Delete() (err error)
}
type Post struct {
Db *sql.DB
Id int `json:"id"`
Content string `json:"conte... |
package main
const INF = 10000000000000
func luckyNumbers(matrix [][]int) []int {
minValueInRow, maxValueInCol := getMinValueInRowAndMaxValueInCol(matrix)
return getLuckyNumbers(matrix, minValueInRow, maxValueInCol)
}
func getMinValueInRowAndMaxValueInCol(matrix [][]int) ([]int, []int) {
rows, cols := getRowsAndC... |
package workers
import (
"log"
"github.com/google/uuid"
)
// Workers struct
type Workers struct {
workers []worker
workQueue chan WorkerTask
workerQueue chan chan WorkerTask
opts Opts
}
// WorkerTask struct
type WorkerTask struct {
Name string
Do func()
}
// Opts options for logging, etc
type Opts... |
package routes
import (
"log"
"net/http"
"github.com/coopernurse/gorp"
"github.com/zachlatta/southbayfession/models"
)
func GetTweets(enc Encoder, db gorp.SqlExecutor) (int, string) {
var tweets []models.Tweet
_, err := db.Select(&tweets, "select * from Tweet order by Id desc limit 20")
if err != nil {
log.... |
package main
import (
"encoding/json"
"fmt"
"io/ioutil"
"net/http"
"strings"
)
type dictResponse struct {
name string
success bool
defs []struct {
Fl string
Shortdef []string `json:"shortdef"`
}
alternatives []string
}
func divideLine(l string) []string {
if len([]rune(l)) <= 80 {
return... |
package sns_test
import (
"github.com/aws/aws-sdk-go/aws"
sns2 "github.com/aws/aws-sdk-go/service/sns"
. "github.com/golang/mock/gomock"
"github.com/pkg/errors"
"github.com/utilitywarehouse/go-pubsub"
"github.com/utilitywarehouse/go-pubsub/sns"
"github.com/utilitywarehouse/go-pubsub/sns/mocks"
"testing"
)
con... |
package _const
const (
ResCodeError = 400
)
|
package main
import (
"os"
)
type config struct {
blogMdPath string
listenAt string
}
var confs = map[string]*config{
"dev": &config{
blogMdPath: "/Users/liqiang/Documents/_personal/code/programming_note",
listenAt: ":8000",
},
"prod": &config{
blogMdPath: "/root/programming_note",
listenAt: ":70... |
// DRUNKWATER TEMPLATE(add description and prototypes)
// Question Title and Description on leetcode.com
// Function Declaration and Function Prototypes on leetcode.com
//503. Next Greater Element II
//Given a circular array (the next element of the last element is the first element of the array), print the Next Greate... |
package controller
import (
"fmt"
"path/filepath"
"github.com/Sirupsen/logrus"
"github.com/andygrunwald/perseus/config"
"github.com/andygrunwald/perseus/downloader"
)
// UpdateController reflects the business logic and the Command interface to update all packages that were added or mirrored in the past.
// This... |
package wshub
import (
"bytes"
"log"
"github.com/gorilla/websocket"
)
var (
newline = []byte{'\n'}
space = []byte{' '}
)
type Client struct {
Hub *Hub
Conn *websocket.Conn
}
func (c *Client) ReadMsg() {
_, message, err := c.Conn.ReadMessage()
if err != nil {
if websocket.IsUnexpectedCloseError(err, w... |
package client
import (
"context"
"net/http"
"time"
"github.com/terra-money/terra.go/key"
"github.com/terra-money/terra.go/msg"
"github.com/terra-money/terra.go/tx"
sdkerrors "github.com/cosmos/cosmos-sdk/types/errors"
terraapp "github.com/terra-money/core/app"
terraappparams "github.com/terra-money/core/a... |
// web service api
package main
/*
DONE:
- api: sns page entry, download
TODO:
- mongodb access
*/
import (
"github.com/go-martini/martini"
)
const (
TYPE_SMS_PAGE = "sms_page"
TYPE_SNS_PAGE = "sns_page"
ACTION_ENTRY_PAGE = "entry_page"
ACTION_DOWNLOAD_APP = "download_... |
// Copyright 2018 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 types
// user edit info payload
type UserEditPUTPayload struct {
FirstName string `json:"firstName" form:"firstName" query:"firstName"`
LastName string `json:"lastName" form:"lastName" query:"lastName"`
UserName string `json:"userName" form:"userName" query:"userName"`
Email string `json:"email" form... |
package entity
import "time"
// Video defines fields available on resource Video.
type Video struct {
ID string `json:"id"`
Title string `json:"title"`
Description string `json:"description"`
PublishedAt time.Time `json:"published_at"`
Thumbnail string `json:"thumbnail"`
}
|
//+build !windows
package netutil
// isPacketTooBig reports whether err indicates that a UDP packet didn't
// fit the receive buffer. There is no such error on
// non-Windows platforms.
func isPacketTooBig(err error) bool {
return false
}
|
package api
import (
"crypto/rand"
"encoding/hex"
"fmt"
"log"
"net/http"
"os"
)
const (
LENGTH = 4
)
var welcomeTemplate = `<!DOCTYPE html>
<html lang="en">
<head>
<title>Shortnr</title>
<style>
body {
margin: 60px;
padding: 0;
}
.welcome {
margin: 0;
padding: 0;
font-family: "Helvetica Neue",... |
package main
import (
"bufio"
"fmt"
"github.com/sunzenshen/cgotchas/mpc"
"os"
)
func main() {
scanner := bufio.NewScanner(os.Stdin)
number := mpc.New("number")
operator := mpc.New("operator")
expr := mpc.New("expr")
lispy := mpc.New("lispy")
language := "" +
"number : /-?[0-9]+/ ... |
package exec
import (
"crypto/tls"
"encoding/json"
"fmt"
"io"
"log"
"os"
"strings"
"sync"
"time"
"github.com/mickep76/auth/jwt"
"github.com/pborman/uuid"
"golang.org/x/net/context"
"google.golang.org/grpc"
"google.golang.org/grpc/credentials"
"github.com/mickep76/grpc-exec-example/color"
"github.com/... |
package fracker_test
import (
"github.com/coreos/go-etcd/etcd"
. "github.com/onsi/ginkgo"
. "github.com/onsi/gomega"
f "github.com/shopkeep/fracker"
"bytes"
"errors"
)
var _ = Describe("Fracker", func() {
var out *bytes.Buffer
var fracker f.Fracker
var client *TestClient
var err error
BeforeEach(func() {... |
/*
Copyright 2015 Fastly 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 wr... |
package character
import (
"strings"
)
// DTO character DTO
type DTO struct {
Character
Groups []string `json:"groups"`
}
// CreatedResponse to be returned as json
type CreatedResponse struct {
CharactersCount int `json:"characters_added"`
Characters []DTO `json:"characters"`
}
// NewDTO creates a DTO w... |
package day1
import (
"bufio"
"io/ioutil"
"strconv"
"strings"
)
// O(nlogn)
func Solve1() int {
nums := loadData()
// O(n)
numsMap := map[int]bool{} // mimic set datastructure
for _, n := range nums {
// O(logn)
numsMap[n] = true
}
// O(n)
for _, n := range nums {
diff := 2020 - n
// O(logn)
if... |
package debug
import (
"fmt"
"log"
"os"
"strings"
)
var printer func(...interface{})
func SetPrinter(newPrinter func(...interface{})) (teardown func()) {
currentPrinter := printer
printer = newPrinter
return func() { printer = currentPrinter }
}
const warningMessage = ` ... |
package auth
/*
|* API:
\************************************/
import (
"encoding/json"
"net/http"
"github.com/gorilla/context"
"gitlab.com/NagByte/Palette/service/common"
)
type handlerFunc func(http.ResponseWriter, *http.Request)
func (as *authService) DeviceTokenNeededMiddleware(f handlerFunc) handlerFunc ... |
package router
import (
"github.com/gin-gonic/contrib/gzip"
"github.com/gin-gonic/gin"
"sub_account_service/app_server_v2/api"
"sub_account_service/app_server_v2/config"
"sub_account_service/app_server_v2/controllers"
)
func Init() {
router := gin.Default()
router.Use(gzip.Gzip(gzip.DefaultCompression))
rout... |
package lib
import (
"errors"
"flag"
"net/url"
"os"
"github.com/mayflower/docker-ls/lib/auth"
)
var DEFAULT_REGISTRY_URL url.URL
var DEFAULT_REGISTRY_URL_STRING string
func init() {
initRegistryURL()
}
func initRegistryURL() {
DEFAULT_REGISTRY_URL_STRING = os.Getenv("DOCKER_REGISTRY_URL")
if DEFAULT_REGIST... |
package app
import (
"context"
"fmt"
"github.com/gin-gonic/gin"
_ "github.com/go-sql-driver/mysql"
"github.com/jinzhu/gorm"
"google.golang.org/appengine"
"google.golang.org/appengine/log"
)
type appengineLogger struct {
context context.Context
}
func (l appengineLogger) Print(v ...interface{}) {
log.Debugf... |
package inmem_test
import (
"testing"
"time"
chat "github.com/greatchat/gochat/transport"
"github.com/greatchat/gochat/transport/inmem"
)
func TestSendReceiveInMemMessage(t *testing.T) {
client := inmem.NewClient(100)
message := chat.Message{
Body: "this is a test",
Author: "go devs",
Timestamp: ... |
package models
import (
"database/sql/driver"
"fmt"
"time"
"yuelng.com/explorer/api/services"
)
type JSONTime struct {
Time time.Time
}
const TimeFmt = "2006-01-02T15:04:05Z"
func (t *JSONTime) Scan(src interface{}) error {
t.Time = src.(time.Time)
return nil
}
func (t JSONTime) Value() (driver.Value, error... |
package crypto
import "testing"
func TestSha1String(t *testing.T) {
s := Sha1String([]byte("aaa"))
if len(s) != 40 {
t.Error(s)
}
t.Log(s)
}
|
package day11
import (
"fmt"
"strings"
"time"
"github.com/kdeberk/advent-of-code/2019/internal/config"
"github.com/kdeberk/advent-of-code/2019/internal/utils"
)
type direction byte
type state byte
type color int64
const (
white = 1
black = 0
)
const (
north direction = iota
south = iota
east ... |
package skeleton
import "hub000.xindong.com/rookie/rookie-framework/logic"
//Skeleton is the system that control the process in modules.
type Skeleton struct {
LogicBlock logic.LogicBlock
}
//NewSkeleton creates a new skeleton, the block in it is the base logic block.
func NewBaseSkeleton() Skeleton{
return Skele... |
// generated by jsonenums -type=ChargeStatus; DO NOT EDIT
package client
import (
"encoding/json"
"fmt"
)
var (
_ChargeStatusNameToValue = map[string]ChargeStatus{
"REQUIRED": Required,
"SUCCESS": Success,
"FAILURE": Failure,
}
_ChargeStatusValueToName = map[ChargeStatus]string{
Required: "REQUIRED",... |
package main
import "time"
type AlexaRequest struct {
Version string `json:"version"`
Session struct {
New bool `json:"new"`
SessionID string `json:"sessionId"`
Application struct {
ApplicationID string `json:"applicationId"`
} `json:"application"`
User struct {
UserID string `json:"user... |
// Licensed to Elasticsearch B.V. under one or more contributor
// license agreements. See the NOTICE file distributed with
// this work for additional information regarding copyright
// ownership. Elasticsearch B.V. licenses this file to you under
// the Apache License, Version 2.0 (the "License"); you may
// not use ... |
package models
type User struct {
UserName string
School string
Gphoto string
} |
/*
Given a pattern (string or array format) of Bits : [0,1,1,1,0,1,1,0,0,0,1,1,1,1,1,1]
The tasks is to replace any number of consecutive 1-Bits with an ascending number sequence starting at 1.
Input
Pattern (can be received as an string or array) Example:
String: 1001011010110101001
Array: [1, 0, 0, 1, 0, 1, 1, 0,... |
package main
import (
"fmt"
"net"
"os"
"strconv"
"sync"
"time"
)
var WorkGroup sync.WaitGroup;
func ScanPort(port int, Target string, Timeout int) string {
Time, _ := time.ParseDuration(os.Args[5] + "s")
conn, err := net.DialTimeout("tcp", Target+":"+strconv.Itoa(port), Time... |
/*
Copyright 2017, Yoshiki Shibukawa
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 jobsv1
import (
"github.com/centrifuge/go-centrifuge/errors"
"github.com/centrifuge/go-centrifuge/identity"
"github.com/centrifuge/go-centrifuge/jobs"
"github.com/centrifuge/gocelery"
logging "github.com/ipfs/go-log"
)
var log = logging.Logger("jobs")
// BaseTask holds the required details and helper fu... |
// DO NOT EDIT. This file was generated by "github.com/frk/gosql".
package testdata
import (
"time"
"github.com/frk/gosql/internal/testdata/common"
)
var _FilterBasic2Records_colmap = map[string]string{
"id": `"id"`,
"email": `"email"`,
"fullName": `"full_name"`,
"isActive": `"is_active"`,
"crea... |
package unarchive
import (
"log"
"os"
"strings"
)
/*
нужно запускать от админа т.к. нужно проставлять расширение
*/
func CheckExtension(path,ext string)string{
if strings.HasSuffix(path,ext){
return path
}
err := os.Rename(path, path+ext)
if err != nil {
log.Println(err)
}
return path+ext
}
|
package main
import "fmt"
func main() {
fmt.Println("voil\u0061\u0300 \u1F609")
}
|
package fifth
import "testing"
func TestStack(t *testing.T) {
s := &Stack{}
if _, err := s.Pop(); err == nil {
t.Error(`Can't detect stack underflow`)
}
}
|
package divide_conquer
import (
"fmt"
"testing"
)
func Test_addOperators(t *testing.T) {
res := addOperators("123", 6)
res2 := addOperators("232", 8)
fmt.Println(res, res2)
}
|
package leetcode
func longestPalindrome(s string) string {
n := len(s)
ret := ""
dp := make([][]bool, n)
for i := 0; i < n; i++ {
dp[i] = make([]bool, n)
}
for l := 0; l < n; l++ {
for i := 0; i+l < n; i++ {
j := i + l
if i == j {
dp[i][j] = true
} else if i+1 == j {
if s[i] == s[j] {
... |
package main
import (
"fmt"
"log"
"github.com/snapiz/go-vue-starter/packages/cgo"
"github.com/spf13/cobra"
)
func init() {
root.AddCommand(&cobra.Command{
Use: "db:setup",
Short: "Create database schema and migrate",
Run: func(cmd *cobra.Command, args []string) {
db, err := cgo.NewDB("", true)
dbn... |
package httputils
import (
"bytes"
"fmt"
"io"
"mime/multipart"
"net/http"
"os"
"path/filepath"
"stayreal/cryptoutils"
"stayreal/ioutils"
"strconv"
)
const (
ChunckSizeDefault int64 = 4 * 1024 * 1024
)
type MultipartUploader struct {
userId string
url string
localFile string
fileName ... |
package circular
import (
"io"
)
const testVersion = 4
// Implement a circular buffer of bytes supporting both overflow-checked writes
// and unconditional, possibly overwriting, writes.
// We chose the below API so that Buffer implements io.ByteReader
// and io.ByteWriter and can be used (size permitting) as a dr... |
package main
import (
"fmt"
"math"
)
func Cbrt(x complex128) complex128 {
var z complex128 = 1
for i := 0; i < 1000; i++ {
z = z - ((z*z*z - x) / (3 * z * z))
}
return z
}
func main() {
fmt.Println(Cbrt(2))
fmt.Println(math.Cbrt(2))
}
|
package cmd
import (
"errors"
"fmt"
"strings"
"time"
"golang.org/x/crypto/ssh"
)
type RemoteCommand struct {
BaseCommand
client *ssh.Client
}
func NewRemoteCmd(cmd string, timeout int, client *ssh.Client) (*RemoteCommand, error) {
c := &RemoteCommand{}
c.Cmd = cmd
c.Timeout = time.Duration(timeout) * time... |
package translator
// NullTestType is Null test type
type NullTestType int
const (
// EqualNull corresponds to `IS NULL` operation
EqualNull NullTestType = iota
// NotEqualNull corresponds to `IS NOT NULL` operation
NotEqualNull
)
// MathOp express SQL mathemathical operators
type MathOp int
// ref: translator... |
package card
import (
"math/rand"
)
type Deck struct {
Cards []*Card
}
func (d *Deck) DealCard() *Card {
position := rand.Intn(len(d.Cards))
returnable := d.Cards[position]
if position == len(d.Cards)-1 {
d.Cards = d.Cards[:position]
} else {
d.Cards = append(d.Cards[:position], d.Cards[position+1:]...)
}... |
package domain
import (
"fmt"
"net/http"
"github.com/miguelhun/go-microservices/mvc/utils"
)
var (
users = map[int64]*User{
123: {Id: 123, FirstName: "Miguel", LastName: "Hun", Email: "email@gmail.com"},
}
UserDao userDaoInterface
)
func init() {
UserDao = &userDao{}
}
type userDaoInterface interface {
... |
//DOES THE CARRIER_FREQ ACTUALLY NEED TO BE A MULTIPLE OF DATA_FREQ??? YOU SHOULD PROBABLY KNOW THAT
package main
import "wav"
import "fmt"
import "os"
var DATA_FREQ = 100 //frequency that the data is sent in in hz
var CARRIER_FREQ = 4000 //frequency of carrier signal
var SAMPLE_RATE = 40000 //sample rate ... |
package main
import (
"errors"
"fmt"
)
var FeesNotSubmitted = errors.New("fees not submitted")
var AdmissionCancelled = errors.New("admission not possible")
var foo = errors.New("foo")
func fees() error {
return fmt.Errorf("%w", FeesNotSubmitted)
}
func admission() error {
return fmt.Errorf("%w %v ", fees(), Ad... |
//
// Copyright (c) 2016 Intel Corporation
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or... |
package main
import (
"fmt"
"os"
"time"
prometheus "github.com/ryotarai/prometheus-query/client"
)
func main() {
client, _ := prometheus.NewClient("http://localhost:9091")
timeout := time.After(7 * time.Minute)
tick := time.Tick(10 * time.Second)
// Keep trying until we're timed out, got a result or got an ... |
package gremlin
import (
"bytes"
"encoding/json"
"errors"
"fmt"
"sort"
"strings"
"sync/atomic"
"github.com/eonpatapon/gremlin"
"github.com/google/go-cmp/cmp"
logging "github.com/op/go-logging"
)
var (
log = logging.MustGetLogger("gremlin")
// ErrIncompleteVertex indicates that the vertex is missing prope... |
package main
import (
"fmt"
"os"
"time"
"github.com/naposproject/go-utorrent"
)
func main() {
c, err := utorrent.NewClient(&utorrent.Client{
API: "http://192.168.1.163:8085/gui",
Username: "admin",
Password: os.Getenv("TORRENT_PASSWORD"),
})
if err != nil {
fmt.Printf("%s\n", err.Error())
}
fm... |
package readconfig
import "testing"
func TestReadConfIni(t *testing.T) {
path := "../conf.ini"
res := ReadConfIni(path)
t.Log(res.Enabled,res.Path,res.Section.Enabled,res.Section.Path)
}
|
package main
import (
"fmt"
"html/template"
"io"
"os"
"path"
"github.com/kr/pretty"
)
func render(viewName string, viewModel interface{}, w io.Writer) error {
layoutAsset, err := Asset("layout.go.html")
if err != nil {
return err
}
layoutString := string(layoutAsset)
contentAsset, err := Asset(viewName... |
package ardupilotmega
/*
Generated using mavgen - https://github.com/ArduPilot/pymavlink/
Copyright 2020 queue-b <https://github.com/queue-b>
Permission is hereby granted, free of charge, to any person obtaining a copy
of the generated software (the "Generated Software"), to deal
in the Generated Software without re... |
/*
* Copyright 2017 StreamSets Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed... |
package main
import (
"fmt"
"reflect"
)
type Person1 struct {
Name string
age int
}
func (p Person1) SayName() {
fmt.Println("my name is ", p.Name)
}
func (p *Person1) SayAge() {
fmt.Println("my age is ", p.age)
}
func main() {
p := Person1{"aa", 18}
v := reflect.ValueOf(&p)
v.MethodByName("SayName").Call... |
package sv
import (
"bufio"
"bytes"
"errors"
"fmt"
"os"
"os/exec"
"strconv"
"strings"
"time"
"github.com/Masterminds/semver/v3"
)
const (
logSeparator = "###"
endLine = "~~~"
)
// Git commands.
type Git interface {
LastTag() string
Log(lr LogRange) ([]GitCommitLog, error)
Commit(header, body, fo... |
package http
import (
"bytes"
"fmt"
"github.com/marsmay/golib/strings2"
"io/ioutil"
"net/http"
"net/http/cookiejar"
"time"
)
type Client struct {
client *http.Client
}
func (c *Client) Do(url string, header map[string]string, body []byte) ([]byte, error) {
method := strings2.IIf(body == nil, "GET", "POST")
... |
package cfrida
func Frida_application_get_identifier(obj uintptr) string {
r, _, _ := frida_application_get_identifier.Call(obj)
return CStrToGoStr(r)
}
func Frida_application_get_name(obj uintptr) string {
r, _, _ := frida_application_get_name.Call(obj)
return CStrToGoStr(r)
}
func Frida_application_get_pid(ob... |
/*
Copyright 2019 Packet 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, software
dis... |
package types
import (
sdkerrors "github.com/cosmos/cosmos-sdk/types/errors"
)
var (
ErrEmptyRelayerAddr = sdkerrors.Register(ModuleName, 1, "relayer address is empty")
ErrBadRatesCount = sdkerrors.Register(ModuleName, 2, "bad rates count")
ErrBadResolveTimesCount = sdkerrors.Register(ModuleName, 3, "b... |
//go:generate goversioninfo -icon=icon.ico -manifest=goversioninfo.exe.manifest
package main
import (
"fmt"
"io/ioutil"
"os"
"github.com/sirupsen/logrus"
"github.com/ChristianAEDev/reap/actions"
"github.com/ChristianAEDev/reap/config"
"github.com/desertbit/grumble"
log "github.com/sirupsen/logrus"
)
var app... |
//gcloud_destroy_vpc.go
package main
import (
"fmt"
)
func gcloud_destroy_vpc(region string, environment string) {
fmt.Println("Destroying GCloud vpc in region: " + region + " for environment: " + environment)
}
|
// Copyright 2020, Homin Lee <homin.lee@suapapa.net>. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
package pcf8574clcd
import (
"fmt"
"time"
"periph.io/x/conn/v3"
"periph.io/x/conn/v3/i2c"
)
// DefaultAddr is defulat address of pcf8... |
package controller
import (
"encoding/json"
"fmt"
"github.com/gin-gonic/gin"
"github.com/go-redis/redis"
"github.com/haithanh079/go-leaderboard/model"
"github.com/haithanh079/go-leaderboard/model/response"
"net/http"
"sort"
"strconv"
"time"
)
type LeaderboardController struct {
}
// HandleAddUser godoc
//... |
package main
import (
"fmt"
)
func quickSort(array []int, l, r int) {
if l < r {
pos := partition(array, l, r)
// 递归的时候去掉pos位置的元素
quickSort(array, l, pos-1)
quickSort(array, pos+1, r)
}
}
func partition(array []int, l, r int) int {
key := array[l]
for l < r {
// 从右边开始比较,从左边的话会丢失最后一个数字,可以画一下
// 需要判断相... |
package test
import (
"testing"
"github.com/icrowley/fake"
)
func TestLoremIpsum(t *testing.T) {
for _, lang := range fake.GetLangs() {
fake.SetLang(lang)
v := fake.Character()
if v == "" {
t.Errorf("Character failed with lang %s", lang)
}
v = fake.CharactersN(2)
if v == "" {
t.Errorf("Charact... |
package testdata
import (
"time"
"github.com/frk/gosql"
"github.com/frk/gosql/internal/testdata/common"
)
type DeleteWithReturningIteratorAfterScanQuery struct {
Iter common.User2Iterator `rel:"test_user:u"`
Where struct {
CreatedBefore time.Time `sql:"u.created_at <"`
}
_ gosql.Return `sql:"*"`
}
|
package onepage
import (
"github.com/maprost/application/generator/genmodel"
"github.com/maprost/application/generator/internal/style/onepage/texmodel"
"github.com/maprost/application/generator/internal/util"
"github.com/maprost/application/generator/lang"
)
func initData(application *genmodel.Application) (data ... |
//+build windows
package main
import (
"flag"
"fmt"
"log"
"os"
"os/signal"
"runtime"
"time"
"github.com/b-2019-apt-test/divider/internal/divider"
"github.com/b-2019-apt-test/divider/internal/divider/csvrep"
"github.com/b-2019-apt-test/divider/internal/divider/jsonprov"
"github.com/b-2019-apt-test/divider... |
package jdatabase
import (
"database/sql"
"encoding/json"
"fmt"
"github.com/ijidan/jgo/jgo/jconfig"
"github.com/ijidan/jgo/jgo/jlogger"
"github.com/ijidan/jgo/jgo/jutils"
"strconv"
"strings"
)
//默认连接
const defaultConnectionName = "default"
//增删改查常量
const _select = "select"
const _update = "update"
const _del... |
package main
import "fmt"
func main() {
// closure คือ ฟังก์ชันที่ไม่ต้องมีชื่อเรียก
add := func(x, y int) int {
return x * y
}
fmt.Println(add(1, 1))
// return function
nextEven := makeEvenGenerator()
// result = 0
fmt.Println(nextEven())
// result = 2
fmt.Println(nextEven())
// result = 4
fmt.Println... |
package main
import (
"bufio"
"fmt"
"log"
"net"
)
func main() {
var name string
fmt.Print("what's your name? ")
fmt.Scanln(&name)
fmt.Printf("Hello %v\n", name)
li, err := net.Listen("tcp", ":8080")
if err != nil {
panic(err)
}
defer li.Close()
fmt.Println("Listening on localhost:8080")
for {
conn... |
package main
import (
"fmt"
"github.com/radyatamaa/loyalti-go-echo/src/router"
//"github.com/spf13/viper"
)
// func init() {
// viper.SetConfigFile(`config.json`)
// err := viper.ReadInConfig()
// if err != nil {
// panic(err)
// }
// }
func main() {
fmt.Println("Welcome to the webserver")
e := router.Ne... |
package main
import "fmt"
import "sync"
func Par(processes ...*func()) {
var wg sync.WaitGroup
wg.Add(len(processes))
for _, v := range processes {
go func(v func()) {
defer wg.Done()
v()
}(*v)
}
wg.Wait()
}
func Producer(c chan int) {
c <- 2
}
func Consumer(c chan int) {
v := <-c
fmt.Println(... |
package main
import "fmt"
func main() {
//asignment and variables
a := 5
b := 3.141592653
c := 7
fmt.Println(float64(a) + b)
fmt.Println(c % a)
// simple function
newline()
//loops
// for loop
for i := 0; i < 10; i++ {
fmt.Println("Hello world: ", i)
}
newline()
// while loop
i := 0
for i < 10 ... |
/*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be use... |
/*
* @lc app=leetcode id=82 lang=golang
*
* [82] Remove Duplicates from Sorted List II
*/
/**
* Definition for singly-linked list.
* type ListNode struct {
* Val int
* Next *ListNode
* }
*/
// next 메소드는 파라미터로 넘어온 노드를 기준으로 다음 항목을 리턴해 준다.
// 파라미터의 노드 가 닐이거나 다음 노드가 닐이 일때는 자기 자신을 리턴한다.
// 노드가 다음 노드와 값이... |
// GENERATED BY THE COMMAND ABOVE; DO NOT EDIT
// This file was generated by swaggo/swag at
// 2019-07-11 18:23:21.687891999 +0800 CST m=+0.063924090
package docs
import (
"bytes"
"encoding/json"
"github.com/alecthomas/template"
"github.com/swaggo/swag"
)
var doc = `{
"schemes": {{ marshal .Schemes }},
... |
/*
Copyright 2021 Cortex Labs, 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, softwa... |
package denvlib
import (
"os"
pathlib "path"
"github.com/buckhx/pathutil"
"gopkg.in/yaml.v2"
)
type Config struct {
DenvHome string
IgnoreFile string
InfoFile string
RestoreDenv string
PreScript string
PostScript string
}
var Settings Config
//TODO move to a util file
func check(errs ...erro... |
package main
import (
"encoding/binary"
"fmt"
"math"
"net"
"time"
"github.com/gordonklaus/portaudio"
)
const sampleRate = 44100
const seconds = 0.01
const myIP = "192.168.25.21"
const connport = 1234
const secondIP = "192.168.25.30"
func main() {
/** INIT */
portaudio.Initialize()
defer portaudio.Terminat... |
package taskTimer
import (
"context"
"fmt"
"sync"
"time"
)
type LEVEL string
const (
Manager = "manager"
INFO = "info"
WARN = "warn"
)
type TaskManagerInterface interface {
AddTask(string, func())
Start()
}
func NewTaskManager(options ...TaskManagerOption) *TaskManager {
m := &TaskManager{
Tasks:... |
package main
import (
"flag"
"fmt"
)
type Config struct {
User string `toml:"user,omitempty"`
Pass string `toml:"pass,omitempty"`
Token string `toml:"token,omitempty"`
Auth string `toml:"auth"`
Catalog string `toml:"catalog,omitempty"`
Register bool `toml:"register"`
QRCode bool ... |
/*
* Copyright 2017 StreamSets Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed... |
package e2e
import (
"context"
_ "embed"
"encoding/json"
"github.com/ghodss/yaml"
corev1 "k8s.io/api/core/v1"
apiextensionsv1 "k8s.io/apiextensions-apiserver/pkg/apis/apiextensions/v1"
apierrors "k8s.io/apimachinery/pkg/api/errors"
"k8s.io/apimachinery/pkg/apis/meta/v1/unstructured"
. "github.com/onsi/ginkg... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.