text stringlengths 11 4.05M |
|---|
/*********************************************
*
* (C) 2019
* Fabian Salamanca - fabian@nuo.com.mx
*
*********************************************/
package main
// Network for unmarshalling
type Network struct {
Services []Services `json:"services"`
Networks []Networks `json:"networks"`
}
// Services for unm... |
package cmd
import (
"io"
"github.com/jpnauta/remote-structure-test/pkg/version"
"github.com/pkg/errors"
"github.com/sirupsen/logrus"
"github.com/spf13/cobra"
)
var (
v string
)
func NewRootCommand(out, err io.Writer) *cobra.Command {
var rootCmd = &cobra.Command{
Use: "remote-structure-test",
Short: ... |
package main
import (
"encoding/json"
"flag"
"fmt"
"io/ioutil"
"net/http"
"sync"
"time"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/client-go/kubernetes"
apiv1 "k8s.io/client-go/pkg/api/v1"
"k8s.io/client-go/rest"
"k8s.io/client-go/tools/clientcmd"
"errors"
"github.com/golang/glog"
"github.c... |
package models
import(
"encoding/json"
)
/**
* Type definition for FileTypeEnum enum
*/
type FileTypeEnum int
/**
* Value collection for FileTypeEnum enum
*/
const (
FileType_KROWS FileTypeEnum = 1 + iota
FileType_KLOG
FileType_KFILESTREAM
FileType_KNOTSUPPORTEDTYPE
Fil... |
package core
import (
"github.com/I-Reven/Hexagonal/src/application/core/service"
request "github.com/I-Reven/Hexagonal/src/domain/http"
"github.com/I-Reven/Hexagonal/src/framework/logger"
"github.com/gin-gonic/gin"
"github.com/juju/errors"
"net/http"
)
type Tracker struct {
log logger.Log
service service... |
/* Copyright 2020 by n3o33 <discord n3o33#2384>
* Not proprietary and confidential,
* feel free to share, copy and change
*/
/*
* VERSION 1.0
*/
/* DESCRIPTION
This script will repatriate resources from planet to homeworld if a storage is full
@sendAllRes, true will send all res of planet, false just the r... |
package main
import (
_ "embed"
"flag"
"fmt"
"image"
"image/color"
"image/png"
"log"
"math/rand"
"os"
"strings"
"time"
"github.com/golang/freetype"
)
var cnt = flag.Int("cnt", 120, "总共的计算题数量")
//go:embed arabtype.ttf
var fontBytes []byte
func main() {
flag.Parse()
createImage()
}
func createImage() {... |
package gube
import (
"fmt"
"io/ioutil"
"sync"
"github.com/ghodss/yaml"
"github.com/mandelsoft/filepath/pkg/filepath"
"k8s.io/apimachinery/pkg/runtime"
"k8s.io/apimachinery/pkg/runtime/schema"
)
type GardenSetConfig interface {
GetConfig(name string) (GardenConfig, error)
GetNames() []string
GetConfigs() m... |
package main
import (
"gorm.io/driver/mysql"
"gorm.io/gorm"
)
func freak(err error) {
if err != nil {
panic(err)
}
}
func main() {
dsn := "n9e2tq4wo6uhxslh:jmm9tpr4pjtkyazi@tcp(ao9moanwus0rjiex.cbetxkdyhwsb.us-east-1.rds.amazonaws.com:3306)/apc4exudm9mlh3ul"
db, err := gorm.Open(mysql.Open(dsn), &gorm.Config... |
package seed
import (
crypto_rand "crypto/rand"
"encoding/binary"
math_rand "math/rand"
)
func init() {
var b [8]byte
_, err := crypto_rand.Read(b[:])
if err != nil {
panic("cannot seed math/rand package with cryptographically secure random number generator")
}
math_rand.Seed(i... |
package main
import (
"bufio"
"fmt"
"io"
"os"
"path/filepath"
"runtime"
"github.com/bborbe/stringutil"
)
func main() {
runtime.GOMAXPROCS(runtime.NumCPU())
err := do(os.Stdout, os.Stdin, os.Args[1:])
if err != nil {
fmt.Fprintf(os.Stderr, "dirof failed: %v", err)
os.Exit(1)
}
}
func do(writer io.Wr... |
package main
import (
"encoding/json"
"expvar"
"fmt"
"net"
"net/http"
)
var (
counts = expvar.NewMap("counters")
)
func init() {
counts.Add("a", 10)
counts.Add("b", 10)
}
func main() {
a := make(map[string]string)
a["name"] = "zyf"
b, _ := json.Marshal(a)
fmt.Println(string(b))
sock, err := net.Listen... |
package main
//731. 我的日程安排表 II
//实现一个 MyCalendar 类来存放你的日程安排。如果要添加的时间内不会导致三重预订时,则可以存储这个新的日程安排。
//
//MyCalendar 有一个 book(int start, int end)方法。它意味着在 start 到 end 时间内增加一个日程安排,注意,这里的时间是半开区间,即 [start, end), 实数x 的范围为, start <= x < end。
//
//当三个日程安排有一些时间上的交叉时(例如三个日程安排都在同一时间内),就会产生三重预订。
//
//每次调用 MyCalendar.book方法时,如果可以将日程安排成功... |
package reader
import (
"encoding/csv"
"io"
"os"
)
// CsvFromFileWithBreak 从文件中读取,允许中断 true为中断信号
func CsvFromFileWithBreak(name string, f func(rcs []string) bool) error {
file, err := os.Open(name)
if err != nil {
return err
}
defer file.Close()
return CsvWithBreak(file, f)
}
// CsvWithBreak 从csv io.Reader... |
package cmd
import "github.com/bwmarrin/discordgo"
// Command works as an interface for other commands
type Command interface {
Execute(s *discordgo.Session, m *discordgo.MessageCreate)
GetCommons() CommandCommon
}
// Commands is a struct to hold all bot commands by type
type Commands struct {
DummyCommands ... |
package main
import (
"encoding/json"
"fmt"
"log"
"net/http"
)
//Post 格式
type Post struct {
User string
Sex string
}
type PostArr struct {
Post []*Post
}
func reloactionExample(w http.ResponseWriter, r *http.Request) {
w.Header().Set("Location", "http://127.0.0.1:8080/json")
w.WriteHeader(302)
}
func jso... |
package datastructs
type Queue struct {
array []interface{}
tail, head int
fixSize int
}
func NewQueue(capacity int) *Queue {
q := new(Queue)
if capacity <= 0 {
panic("Queue must have Capacity")
}
q.array = make([]interface{}, capacity)
q.fixSize = capacity
return q
}
func (q *Queue) Enqueue(x int... |
package main
import (
"context"
vine "github.com/lack-io/vine/service"
log "github.com/lack-io/vine/service/logger"
"github.com/lack-io/vine/service/server"
"github.com/lack-io/vine/util/context/metadata"
proto "github.com/lack-io/vine-example/pubsub/proto"
)
// All methods of Sub will be executed when
// a m... |
package main
import (
"flag"
"net/http"
"os"
"os/user"
"runtime"
"github.com/fabric8-services/fabric8-common/log"
"github.com/fabric8-services/fabric8-common/metric"
"github.com/fabric8-services/fabric8-common/sentry"
"github.com/fabric8-services/fabric8-webhook/app"
"github.com/fabric8-services/fabric8-web... |
package rst
import "testing"
func TestLastLineIndexOfFieldLists(t *testing.T) {
path := "../userpages/content/articles/2012/07/13/javascript-drag-and-drop-draggable-movable-element%en.rst"
r, err := NewRstStateMachine(path)
if err != nil {
t.Error(err)
}
r.Run()
//r.DebugPrintRstBlocks()
rfls, err := r.GetF... |
// 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 rdbms
import (
"fmt"
domEntity "github.com/d3ta-go/ddd-mod-account/modules/account/domain/entity"
"github.com/d3ta-go/system/system/handler"
migRDBMS "github.com/d3ta-go/system/system/migration/rdbms"
"github.com/d3ta-go/system/system/utils"
"gorm.io/gorm"
)
// Seed20201119001InitTable type
type Seed20... |
package LeetCode
import "fmt"
func Code37() {
board := [][]byte{
{'5', '3', '.', '.', '7', '.', '.', '.', '.'},
{'6', '.', '.', '1', '9', '5', '.', '.', '.'},
{'.', '9', '8', '.', '.', '.', '.', '6', '.'},
{'8', '.', '.', '.', '6', '.', '.', '.', '3'},
{'4', '.', '.', '8', '.', '3', '.', '.', '1'},
{'7',... |
package main
import (
"fmt"
"math/rand"
"time"
"xpfunds"
"xpfunds/simulate"
)
var (
funds []*xpfunds.Fund
maxDuration int
maxMonths = 60
numFunds = 1
)
func main() {
rand.Seed(time.Now().UnixNano())
funds = xpfunds.ReadFunds()
for _, f := range funds {
if f.Duration() > maxDuration {
maxD... |
// 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 firmware
import (
"bufio"
"context"
"regexp"
"time"
"github.com/golang/protobuf/ptypes/empty"
"chromiumos/tast/errors"
"chromiumos/tast/remote/firmware"
"c... |
package testCommon
import (
"encoding/json"
"fmt"
"io/ioutil"
"os"
"path"
"path/filepath"
)
// TestConfig is the configuration used for unit tests
type TestConfig struct {
ProjectRoot string
}
// Config is the instance of test config object loaded form default locations
var Config TestConfig
// MultiStageExa... |
package es
import (
"context"
"fmt"
"github.com/olivere/elastic/v7"
"strings"
)
type LogData struct {
Topic string `json:"topic"`
Data string `json:"data"`
}
var (
client *elastic.Client
esCh = make(chan *LogData, 10000)
)
// 初始化es,准备接收kafka那边发过来的数据
func Init(addr string) (err error){
if !strings.HasPrefix... |
package renderer
import (
"fmt"
"math"
"runtime"
"github.com/gmacd/rays/core"
"github.com/gmacd/rays/geom"
"github.com/gmacd/rays/raytracer"
)
const (
chunkSizeX int = 16
chunkSizeY int = 16
)
type Camera struct {
wx1, wy1 float64
wx2, wy2 float64
dx, dy float64
origin core.Vec3
}
func NewCamera(wx... |
/*
* @Author: Sy.
* @Create: 2019-11-01 20:54:15
* @LastTime: 2019-11-16 17:09:35
* @LastEdit: Sy.
* @FilePath: \server\controllers\admin_controllers\admin_role_controller.go
* @Description: 角色
*/
package admin_controllers
import (
"strconv"
"strings"
"time"
"github.com/astaxie/beego"
"vue-typescript-bee... |
package model
// Instance ...
type Instance struct {
ID uint `db:"id"`
ProducerID uint `db:"producer_id"`
BookID uint `db:"book_id"`
Year string `db:"year"`
}
|
/**
条件语句
*/
package main
import "fmt"
func main() {
//if else
a:=false
if a{
fmt.Println(a)
}else{
fmt.Println(!a)
}
//for
for i:=0;i<10 ;i++ {
fmt.Print(i)
if i%2==0{
//可用于结束循环
goto breaks
}
}
//goto标签
breaks:
fmt.Println("结束循环")
//switch 变量
b:="bb"
switch b {
case "bb":
f... |
package crane
// Event describes an event sent to crane to trigger an action.
// Crane uses event category to find relevant event handler.
type Event struct {
Category string `json:"category"`
Commit string `json:"commit"`
}
|
package cryptoAPI
import (
"crypto/sha256"
"encoding/hex"
)
func GenerateSHA256Hash(data string) string{
hash := sha256.New()
hash.Write([]byte(data))
sum := hash.Sum(nil)
return hex.EncodeToString(sum)
}
|
package consul
import (
"fmt"
"github.com/saileifeng/pepsi/registry/consul/register"
"github.com/saileifeng/pepsi/registry/consul/resolver"
"google.golang.org/grpc"
"google.golang.org/grpc/balancer/roundrobin"
"google.golang.org/grpc/health/grpc_health_v1"
"log"
"net"
"os"
"os/signal"
"strconv"
"strings"
... |
package main
import (
"context"
"fmt"
pb "go-postgres/bidaspin"
"go-postgres/bidaspin/gift"
"go-postgres/bidaspin/redis"
"google.golang.org/grpc"
"log"
"net"
"strconv"
)
const (
port = ":50050"
)
type BidaSpinServer struct {
pb.BidaSpinServer
}
func (s *BidaSpinServer) UpdateTotalSpin(ctx context.Context... |
package family
import (
"familyTree/src/person"
"testing"
"github.com/stretchr/testify/assert"
)
type peopleStub struct {
name string
gender string
father string
mother string
spouse string
}
var people = []peopleStub{
{"King Shan", "Male", "", "", "Queen Anga"},
{"Chit", "Male", "King Shan", "Queen Ang... |
--- src/vendor/golang.org/x/net/route/zsys_dragonfly.go.orig 2019-10-17 22:02:09 UTC
+++ src/vendor/golang.org/x/net/route/zsys_dragonfly.go
@@ -46,8 +46,6 @@ const (
sysRTM_REDIRECT = 0x6
sysRTM_MISS = 0x7
sysRTM_LOCK = 0x8
- sysRTM_OLDADD = 0x9
- sysRTM_OLDDEL = 0xa
sysRTM_RESOLVE = 0... |
package routes
import (
"encoding/json"
"net/http"
"github.com/cjburchell/survey/database"
"github.com/cjburchell/survey/models"
"github.com/cjburchell/uatu-go"
"github.com/gorilla/mux"
)
// Setup the routes
func Setup(router *mux.Router, log log.ILog) {
surveyRoute := router.PathPrefix("/survey").Subrouter()... |
package main
import (
"encoding/csv"
"fmt"
"io"
"os"
"strings"
"github.com/fatih/color"
)
func generateFromFile(file string) {
isCSV := strings.HasSuffix(file, ".csv")
if !isCSV {
color.Red("el archivo de importación de paquetes debe tener extensión .csv")
os.Exit(1)
}
f, err := os.Open(file)
if err... |
package main
import "fmt"
type Name string
const (
NA Name = "1"
YA Name = "2"
)
func ceshi(n string) {
switch Name(n) {
case NA:
fmt.Println("aNa")
case YA:
fmt.Println(2)
}
}
func main() {
s := "1"
ceshi(s)
}
|
//go:build !boringcrypto
// +build !boringcrypto
package noiseutil
import (
"github.com/flynn/noise"
)
// EncryptLockNeeded indicates if calls to Encrypt need a lock
const EncryptLockNeeded = false
// CipherAESGCM is the standard noise.CipherAESGCM when boringcrypto is not enabled
var CipherAESGCM noise.CipherFunc... |
package clair
import (
"encoding/json"
"fmt"
"net/http"
v1 "github.com/coreos/clair/api/v1"
)
func getErrorFromResponse(resp *http.Response) error {
var errorStruct struct {
Error v1.Error
}
errMsg := "(no message returned)"
// attempt to unmarshal the body into a JSON structure, ignoring any errors if t... |
package main
import "fmt"
func generate(numRows int) [][]int {
if numRows == 0 {
return [][]int{}
}
result := [][]int{{1}}
for i := 1; i < numRows; i++ {
temp := make([]int, i+1)
temp[0] = 1
temp[i] = 1
for j := 1; j < i; j++ {
temp[j] = result[i-1][j-1] + result[i-1][j]
}
result = append(result,... |
package testing
import (
"os"
"testing"
)
// PreCheckAcc only allows acceptance tests to run in explicitly enabled via OF_ACC
// environment variable
func PreCheckAcc(t *testing.T) {
if os.Getenv("OF_ACC") == "" {
t.Skip("To enable acceptance tests please set environment variable OF_ACC=1")
}
}
|
// Copyright 2018 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 main
import (
"log"
"github.com/go-rod/rod/lib/utils"
)
func main() {
log.Println("npx eslint --ext .js,.html .")
utils.Exec("npx", "eslint", "--ext", ".js,.html", ".")
log.Println("npx prettier --loglevel error --write .")
utils.Exec("npx", "prettier", "--loglevel", "error", "--write", ".")
log.Pri... |
package dispatcher
import (
"fmt"
"reflect"
"sync"
)
// BadListenerError is raised when AddListener is called with an invalid listener function.
type BadListenerError string
func (err BadListenerError) Error() string {
return fmt.Sprintf("Bad listener func: %s", string(err))
}
// New returns a new dispatcher
fu... |
package commands
import (
"context"
"github.com/loft-sh/devspace/pkg/devspace/context/values"
"mvdan.cc/sh/v3/interp"
)
func IsDependency(ctx context.Context, args []string) error {
if len(args) > 0 {
return interp.NewExitStatus(1)
}
isDependency, ok := values.IsDependencyFrom(ctx)
if isDependency && ok {
... |
package main
import "github.com/m7shapan/my-http/cmd"
func main() {
var c cmd.CMD
c.Start()
}
|
package main
import (
"encoding/json"
"log"
"github.com/bmob/bmob-go-sdk"
)
var (
appConfig = bmob.RestConfig{"b18cda25d056ac3a6e22f6a304cb37b8",
"f60c9cd10b04fa2a5fd6f914c64c6528"}
)
func BmobPushOrder(order *Order) error {
bytes, _ := json.Marshal(order)
header, err := bmob.DoRestReq(appConfig,
bmob.Res... |
package main
import (
"io/ioutil"
"os"
)
func main() {
f, err := os.Open("file")
defer f.Close() // defer 语句应该放在 if() 语句后面,先判断 err,再 defer 关闭文件句柄。
if err != nil {
return
}
b, err := ioutil.ReadAll(f)
println(string(b))
}
|
package main
import "testing"
func TestMorseCode(t *testing.T) {
for k, v := range map[string]string{
".- ...- ..--- .-- .... .. . -.-. -..- ....- .....": "AV2WHIECX 45",
"-... .... ...--": "BH3",
"-----": "0"} {
if r := morseCo... |
package reflectUtil
import (
//"fmt"
"moqikaka.com/Test/src/Model"
//"reflect"
"fmt"
"testing"
)
func TestReflect(context *testing.T) {
// 反射调用方法
//tempFunc := func(i int) int {
// return i
//}
//reflectResult := reflect.ValueOf(tempFunc)
//fmt.Println("fv is reflect.Func ?", value.Kind() == reflect.Func)
... |
package motion
import (
"fmt"
"net/http"
"os/exec"
"github.com/andreacioni/motionctrl/config"
"github.com/andreacioni/motionctrl/version"
"github.com/kpango/glg"
"github.com/parnurzeal/gorequest"
)
var (
motionConfigFile string
)
func Init(configFile string, autostart bool, detection bool) error {
if err ... |
package controllers
import (
"fmt"
"github.com/revel/revel"
"html/template"
"io/ioutil"
"log"
)
type App struct {
*revel.Controller
}
func (c App) Index() revel.Result {
model := c.Params.Route.Get("model")
log.Printf("model=%s", model)
title := model
moreStyles := []string{
"css/style.css",
}
moreSc... |
package graph
type Graph map[int][]int
func NewGraph() Graph {
g := make(Graph)
return g
}
|
package main
import (
"sync"
"time"
)
type _TgapFilter_ReceCntX struct{}
type _TgapFilter_ReceCnt struct {
gfrCnt int
gfrUnr _TudpNodeDataRece
gfrUnb []byte
}
type _TgapFilter_ReceStX struct{}
type _TgapFilter_ReceSt struct { // _TudpNodeDataReceX
now_ map[string]_TgapFilter_ReceCnt
last map[string]_TgapFilte... |
package meerkat
import (
"encoding/json"
"flag"
"fmt"
"io/ioutil"
"log"
"net/http"
"os"
"strconv"
"strings"
"time"
"github.com/ahmdrz/goinsta"
"gopkg.in/yaml.v2"
)
func exists(path string) bool {
_, err := os.Stat(path)
return os.IsExist(err)
}
type Meerkat struct {
Interval int
SleepTime int
... |
// 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... |
// 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 db
import (
"context"
"github.com/LILILIhuahuahua/ustc_tencent_game/db/databaseGrpc"
"time"
)
var playerService databaseGrpc.PlayerServiceClient
func getService() (databaseGrpc.PlayerServiceClient, error) {
if playerService == nil {
service, err := GetPlayerService()
if err != nil {
return nil, er... |
package ravendb
import (
"reflect"
"time"
)
// Note: Java's IDocumentQueryBase is DocumentQuery
// Note: Java's IDocumentQueryBaseSingle is DocumentQuery
// Note: Java's IDocumentQuery is DocumentQuery
// Note: Java's IFilterDocumentQueryBase is DocumentQuery
// DocumentQuery describes a query
type DocumentQuery s... |
package limiter
import (
"sync"
"time"
)
const (
default_counter_limit_num = 10
default_counter_interval_nano = 10
)
//计数限流
type CounterLimit struct {
counterNum int64 //计数器
limitNum int64 //指定时间窗口内允许的最大请求数
intervalNano int64 //指定时间窗口
lastNano int64 //unix时间戳,单位为纳秒
lock sync.... |
package builder
import (
"database/sql"
"fmt"
"github.com/astaxie/beego/orm"
"strings"
"github.com/chenwj93/utils"
)
type Update struct {
table string
cols []string
args []interface{}
Where
}
func NewUpdate() *Update {
return &Update{}
}
func (o *Update) Tb(tb string) *Update {
if o.table == utils.EMPT... |
package cregexp
import "regexp"
const langRus = "rus"
const langEng = "eng"
// Checking the correctness of the telephone number
// Pattern: ^(\s*)?(\+)?([- _():=+]?\d[- _():=+]?){10,14}(\s*)?$
// Examples: +7(903)888-88-88, +79161234567, 8(999)99-999-99, +380(67)777-7-777
func CheckPhone(someString string) bool {
v... |
package rotateimage
import "testing"
const urlString = "http://farm1.static.flickr.com/122/263784734_c262172550.jpg"
func TestRotate(t *testing.T) {
rotateImageBy90(urlString)
}
|
package controllers
import (
"github.com/aws/aws-lambda-go/events"
jsoniter "github.com/json-iterator/go"
"goscrum/server/models"
"goscrum/server/services"
"goscrum/server/util"
"net/http"
"time"
)
type GitlabController struct {
gitlab *services.GitlabService
}
func NewGitlabController(gitlab *services.Gitla... |
package arrays
import (
"fmt"
)
func sudoku2(grid [][]string) bool {
for i := range grid{
for j := range grid[i] {
if grid[i][j] != "." {
for k := 0; k < len(grid); k++ {
if grid[i][k] == grid[i][j] && j != k {
return false
}
if grid[k][j] == grid[i][j] && i != k {
return false
... |
package main
import (
"flag"
"fmt"
"go/ast"
"go/format"
"go/importer"
"go/parser"
"go/token"
"go/types"
"io/ioutil"
"os"
"path/filepath"
"sort"
"strings"
)
const exprgenSuffix = "_exprgen.go"
func main() {
flag.Parse()
filenames := flag.Args()
if len(filenames) == 0 {
flag.Usage()
os.Exit(1)
}
... |
package player
import (
"fmt"
"testing"
)
func TestPlayerName(t *testing.T) {
playerName := "Test Name"
p := NewPlayer("Name")
p.SetName(playerName)
if p.GetName() != playerName {
t.Errorf("Error setting player name")
}
if fmt.Sprintf("%v", p) != playerName {
t.Errorf("Player name should be in string con... |
package main
import (
"fmt"
"os"
"gocv.io/x/gocv"
)
func main() {
if len(os.Args) < 2 {
fmt.Println("How to run:\n\tcapwindow [camera ID]")
return
}
// parse args
deviceID := os.Args[1]
webcam, err := gocv.OpenVideoCapture(deviceID)
if err != nil {
fmt.Printf("Error opening video capture device: %v\... |
// Copyright 2018 NetApp, Inc. All Rights Reserved.
package persistentstore
import (
"fmt"
log "github.com/sirupsen/logrus"
)
type EtcdDataMigrator struct {
SourceClient EtcdClient
DestClient EtcdClient
}
func NewEtcdDataMigrator(SourceClient, DestClient EtcdClient) *EtcdDataMigrator {
return &EtcdDataMigra... |
// Copyright (C) 2019 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 day13
import (
"testing"
"github.com/wistler/aoc-2020/internal/io"
)
func TestSampleData(t *testing.T) {
input := []string{
"939",
"7,13,x,x,59,x,31,19",
}
got := part1(input)
want := 295
if got != want {
t.Fatalf("Part 1: Got: %v, but wanted: %v", got, want)
}
}
func TestPart2(t *testing.T) ... |
// 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 network
import (
"context"
"chromiumos/tast/errors"
"chromiumos/tast/local/bundles/cros/network/shillscript"
"chromiumos/tast/local/chrome"
"chromiumos/tast/lo... |
package updating
// Service provides adding operations.
type Service interface{
SetArtistName(id int64, name string) (int64, error)
SetArtworkTitle(id int64, title string) (int64, error)
SetArtworkArtist(id int64, artistID int64) (int64, error)
}
// Repository provides access to the repository.
type Repository i... |
package supervisor_test
import (
"bytes"
"encoding/json"
"fmt"
"github.com/gorilla/securecookie"
"github.com/gorilla/sessions"
"github.com/markbates/goth"
"github.com/markbates/goth/gothic"
"io"
"io/ioutil"
"net/http"
"net/http/httptest"
"strings"
. "github.com/onsi/gomega"
"github.com/onsi/gomega/ghttp... |
// Attempted the following name for package:
// - authenticator: this sounds more like a verb
// - authentication: too long
// - userlogin: is too specific, since user can also register
// - loginUser: breaks the convention, since package name is preferable a noun.
// - authz and authn is better.
package authnsvc
imp... |
package brewerydb
import (
"encoding/json"
"fmt"
"io/ioutil"
"net/http"
"net/url"
"strconv"
)
const defaultBaseUrl string = "http://api.brewerydb.com/v2"
type breweryDBClient struct {
apiKey string
baseUrl string
VerboseMode bool
}
type SearchResponse struct {
CurrentPage int
NumberOfPages int... |
package main
import (
"fmt"
"unicode"
)
func main() {
str := "123vfa`1545`1XZVP; [ 215;1"
for _, r := range str {
fmt.Printf("%s, IsDigit %v\n", string(r), unicode.IsDigit(r))
fmt.Printf("%s, IsLzetter %v\n", string(r), unicode.IsLetter(r))
fmt.Printf("%s, IsLozwer %v\n", string(r), unicode.IsLower(r))
f... |
package deleting_test
import (
"testing"
"time"
"github.com/elhamza90/lifelog/internal/domain"
"github.com/elhamza90/lifelog/internal/store"
)
func TestDeleteExpense(t *testing.T) {
repo.Expenses = map[domain.ExpenseID]domain.Expense{
9: {
ID: 9,
Label: "Exp",
Value: 10,
Unit: ... |
package main
func datatype() {
var real bool = true
var number int = 0
var duble complex64 = 0
/*
byte == unit : type mismatched error
byte == uint8 : 바이트 코드에 사용
Go의 경우 묵시적 형 변환은 발생 X 명시적 O
명시적 형변환 : type(value)
*/
var byt byte = 0
var uni uint8 = 0
println(real)
println(number)
println(duble)
print... |
package node
import (
"bufio"
"bytes"
"io"
"io/ioutil"
)
func readFile(file string, handler func(string) error) error {
contents, err := ioutil.ReadFile(file)
if err != nil {
return err
}
reader := bufio.NewReader(bytes.NewBuffer(contents))
for {
line, _, err := reader.ReadLine()
if err == io.EOF {
... |
package main
import (
"fmt"
"github.com/vlasove/algs/deque"
)
func isSaller(name string) bool {
runeName := []rune(name)
return runeName[len(runeName)-1] == 'm'
}
func checkIn(name string, names []string) bool {
for _, val := range names {
if val == name {
return true
}
}
return false
}
func search(... |
package charger
import (
"fmt"
"net/http"
"strconv"
"time"
"github.com/evcc-io/evcc/api"
"github.com/evcc-io/evcc/charger/daheimladen"
"github.com/evcc-io/evcc/provider"
"github.com/evcc-io/evcc/util"
"github.com/evcc-io/evcc/util/request"
"golang.org/x/oauth2"
)
// DaheimLaden charger implementation
type ... |
package ogg
/********************************************************************
* *
* THIS FILE IS PART OF THE Ogg CONTAINER SOURCE CODE. *
* USE, DISTRIBUTION AND REPRODUCTION OF THIS LIBRARY SOURCE IS *
* GOVERNED BY A BSD-STYLE SOUR... |
package main
import (
"antalk-go/internal/auth"
"antalk-go/internal/auth/config"
"flag"
"fmt"
"log"
)
var (
configName = flag.String("config_name", "auth", "config name")
configType = flag.String("config_type", "toml", "config type")
configPath = flag.String("config_path", ".", "config path")
)
func init() ... |
// Package ratsnest provides simple validation for deeply-nested (or not deeply-nested), arbitrary maps in Golang.
package ratsnest
|
package minisentinel
import "github.com/alicebob/miniredis/v2/server"
func commandsPing(s *Sentinel) {
s.srv.Register("PING", s.cmdPing)
}
// cmdPing
func (s *Sentinel) cmdPing(c *server.Peer, cmd string, args []string) {
if len(args) != 0 {
c.WriteError(errWrongNumber(cmd))
return
}
if !s.handleAuth(c) {
... |
package game
import (
"bytes"
"encoding/json"
"github.com/dchest/uniuri"
"github.com/gorilla/websocket"
. "github.com/qaisjp/studenthackv-go-gameserver/structs"
"log"
"time"
)
type CharacterID int
const (
UnassignedCharacter CharacterID = iota
MonsterCharacter
KingCharacter
ServantCharacter
)
type Player... |
package props
import (
"strconv"
"sort"
)
// Source 定义了配置数据来源.
// 一个数据来源必须提供一个 Find 方法用于支持从该来源读取配置数据
type Source interface {
Find(key string) (string, bool)
}
// Props 定义了配置数据的操作集合.
// 该接口提供了添加配置数据源,配置项查找,配置项读取,使用配置项扩展变量等多个函数.
type Props interface {
// Add 用于将配置数据源 s,以优先级 priority,添加到 Props 对象中去.
Add(priority u... |
package nosql
import (
"context"
"errors"
"fmt"
"net/url"
"strings"
"go.mongodb.org/mongo-driver/mongo"
"go.mongodb.org/mongo-driver/mongo/options"
)
const sectionName = "mongodb"
const schemePrefix = "mongodb://"
var errorVariable = errors.New("variable not found")
const sides = 2
// IniFile is interface ... |
package k8sconv
import (
"context"
"fmt"
"k8s.io/apimachinery/pkg/types"
"github.com/tilt-dev/tilt/pkg/apis"
"github.com/tilt-dev/tilt/pkg/model/logstore"
"github.com/tilt-dev/tilt/pkg/apis/core/v1alpha1"
v1 "k8s.io/api/core/v1"
"github.com/tilt-dev/tilt/internal/k8s"
"github.com/tilt-dev/tilt/pkg/logge... |
package main
import (
"bufio"
"context"
"database/sql"
"flag"
"fmt"
"io/ioutil"
"log"
"os"
"os/signal"
"reflect"
"sync"
"syscall"
"time"
impala "github.com/bippio/go-impala"
)
func main() {
var timeout int
var verbose bool
opts := impala.DefaultOptions
flag.StringVar(&opts.Host, "host", "", "impal... |
package main
//Valid
//Tries to resolve all types of exxpressions within print to base type
func f () {
type num int
type fl float64
type s string
type b bool
var a1 num
var a2 fl
var a3 s
var a4 b
print (a1, a2, a3, a4)
} |
package main
import "log"
// Check ...
func Check(e error) {
if e != nil {
log.Println(e)
EnterToExit()
}
}
|
package macgen
import (
"bytes"
"context"
"encoding/binary"
"errors"
"macaddress_io_grabber/models"
"macaddress_io_grabber/utils/redispool"
"math/big"
"math/rand"
"strings"
"time"
)
var (
ErrInconsistentAdminType = errors.New("macgen: inconsistent administration type")
ErrInconsistentTransType = errors.Ne... |
package serve_test
import (
"flag"
"fmt"
"log"
"net/http"
"net/http/httptest"
"os"
"path/filepath"
"strings"
"testing"
"github.com/kirubasankars/serve/driver"
"github.com/kirubasankars/serve/serve"
)
type CommonSiteHandler struct{}
func (csh *CommonSiteHandler) Build(module serve.Module) {
module.Handle... |
/*
Copyright 2019 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... |
// Patches to normalize the proto types
package proto
import (
"time"
)
// TimeSinceEpoch UTC time in seconds, counted from January 1, 1970.
// To convert a time.Time to TimeSinceEpoch, for example:
//
// proto.TimeSinceEpoch(time.Now().Unix())
//
// For session cookie, the value should be -1.
type TimeSinceEpoch f... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.