commit stringlengths 40 40 | old_file stringlengths 4 264 | new_file stringlengths 4 264 | old_contents stringlengths 0 4.24k | new_contents stringlengths 1 5.44k | subject stringlengths 14 778 | message stringlengths 15 9.92k | lang stringclasses 277
values | license stringclasses 13
values | repos stringlengths 5 127k |
|---|---|---|---|---|---|---|---|---|---|
186537d59c5311864644647ea00c4809a959a347 | http_spiders.go | http_spiders.go | package spider
import "io"
type spinFunc func(*Context) error
type spiderFunc struct {
method string
url string
body io.Reader
fn spinFunc
}
func (s *spiderFunc) Setup(parent *Context) (*Context, error) {
return NewHTTPContext(s.method, s.url, s.body)
}
func (s *spiderFunc) Spin(ctx *Context) error { ... | package spider
import "io"
type spinFunc func(*Context) error
type spiderFunc struct {
method string
url string
body io.Reader
fn spinFunc
}
func (s *spiderFunc) Setup(parent *Context) (*Context, error) {
return NewHTTPContext(s.method, s.url, s.body)
}
func (s *spiderFunc) Spin(ctx *Context) error { ... | Rename methods for creating spiders to be more clear and simple | Rename methods for creating spiders to be more clear and simple
| Go | mit | celrenheit/spider |
1e0b0e6dbfa427afa1772b724f4418dd76313ac1 | schema/anyof.go | schema/anyof.go | package schema
import "errors"
// AnyOf validates if any of the sub field validators validates.
type AnyOf []FieldValidator
// Compile implements Compiler interface.
func (v *AnyOf) Compile() (err error) {
for _, sv := range *v {
if c, ok := sv.(Compiler); ok {
if err = c.Compile(); err != nil {
return
... | package schema
import "errors"
// AnyOf validates if any of the sub field validators validates.
type AnyOf []FieldValidator
// Compile implements Compiler interface.
func (v *AnyOf) Compile() (err error) {
for _, sv := range *v {
if c, ok := sv.(Compiler); ok {
if err = c.Compile(); err != nil {
return
... | Fix incorrect behaviour for AnyOf validator | Fix incorrect behaviour for AnyOf validator
| Go | mit | rs/rest-layer |
6bd2e6e26070cce908540b87951a85f22a275141 | print_tuntap/print_tuntap.go | print_tuntap/print_tuntap.go | // Simple use of the tuntap package that prints packets received by the interface.
package main
import (
"fmt"
"os"
"code.google.com/p/tuntap"
)
func main() {
if len(os.Args) != 3 {
fmt.Println("syntax:", os.Args[0], "tun|tap", "<device name>")
return
}
var typ tuntap.DevKind
switch os.Args[1] {
case "t... | // Simple use of the tuntap package that prints packets received by the interface.
package main
import (
"fmt"
"os"
"github.com/mistsys/tuntap"
)
func main() {
if len(os.Args) != 3 {
fmt.Println("syntax:", os.Args[0], "tun|tap", "<device name>")
return
}
var typ tuntap.DevKind
switch os.Args[1] {
case "... | Kill more code.google.com/p/ references, and update example code to new API | Kill more code.google.com/p/ references, and update example code to new API
(It's been broken for a while)
| Go | apache-2.0 | mistsys/tuntap,mistsys/tuntap |
56388aa39ed3ddbe3df702a709d38a1ad7eaa2a0 | proxy/empty_blacklist_test.go | proxy/empty_blacklist_test.go | package proxy
import (
"net/url"
"testing"
)
func TestEmptyBlacklist(t *testing.T) {
bl := NewEmptyBlacklist()
hostnames := []string{"http://localhost", "http://google.com"}
for i := range hostnames {
url, err := url.Parse(hostnames[i])
if err != nil {
t.Fatalf("error with parsing url '%s'", err)
}
... | package proxy
import (
"net/url"
"testing"
)
func TestEmptyBlacklist(t *testing.T) {
bl := NewEmptyBlacklist()
hostnames := []string{"http://localhost", "http://google.com"}
for i := range hostnames {
url, err := url.Parse(hostnames[i])
if err != nil {
t.Fatalf("error with parsing url '%s'", err)
}
... | Fix 'f' format (from vet) | proxy: Fix 'f' format (from vet)
| Go | apache-2.0 | adamdecaf/go-proxy,adamdecaf/go-proxy,adamdecaf/go-proxy |
57a2a5add1462a4998ec57e22c21acb199e0bcb0 | distro/server.go | distro/server.go | //
// Copyright (c) 2017 Cavium
//
// SPDX-License-Identifier: Apache-2.0
//
package distro
import (
"io"
"net/http"
"github.com/go-zoo/bone"
)
func replyPing(w http.ResponseWriter, r *http.Request) {
w.Header().Set("Content-Type", "application/text; charset=utf-8")
w.WriteHeader(http.StatusOK)
str := `pong`
... | //
// Copyright (c) 2017 Cavium
//
// SPDX-License-Identifier: Apache-2.0
//
package distro
import (
"io"
"net/http"
"github.com/go-zoo/bone"
)
func replyPing(w http.ResponseWriter, r *http.Request) {
w.Header().Set("Content-Type", "application/text; charset=utf-8")
w.WriteHeader(http.StatusOK)
str := `pong`
... | Update notification update api to PUT | Update notification update api to PUT
Signed-off-by: Federico Claramonte <9aaaa8bfe6a7a51765b462c528e1446dcf049286@caviumnetworks.com>
| Go | apache-2.0 | feclare/edgex-export |
f404960e5ed9f69c27b2e34b7ae4fb99c685568e | signer/universal/universal_test.go | signer/universal/universal_test.go | package universal
| package universal
import (
"testing"
"time"
"github.com/cloudflare/cfssl/config"
)
var expiry = 1 * time.Minute
var validLocalConfig = &config.Config{
Signing: &config.Signing{
Profiles: map[string]*config.SigningProfile{
"valid": {
Usage: []string{"digital signature"},
Expiry: expiry,
},
},
... | Add a test for the signer/universal package | Add a test for the signer/universal package
| Go | bsd-2-clause | letsencrypt/cfssl,haneric21/cfssl,j-delaney/cfssl,j-delaney/cfssl,BugRoger/cfssl,rolandshoemaker/cfssl,jmhodges/cfssl,bifurcation/cfssl,mitchcapper/cfssl,sdgdsffdsfff/cfssl,bossjones/cfssl,gtank/cfssl,thesamet/cfssl,geligaoli/cfssl,mitchcapper/cfssl,sdgdsffdsfff/cfssl,APTy/cfssl,wl2002/cfssl,drcapulet/cfssl,mclem/cfssl... |
28dd612e782e624c7e3d3bfdcfb3918f70c18cad | api.go | api.go | // +build !noglobals
package inj
//////////////////////////////////////////////
// Interface definitions
//////////////////////////////////////////////
// A Grapher is anything that can represent an application graph
type Grapher interface {
Provide(inputs ...interface{}) error
Inject(fn interface{}, args ...inter... | // +build !noglobals
package inj
//////////////////////////////////////////////
// Interface definitions
//////////////////////////////////////////////
// A Grapher is anything that can represent an application graph
type Grapher interface {
Provide(inputs ...interface{}) error
Inject(fn interface{}, args ...inter... | Update API to support datasources | Update API to support datasources
| Go | mit | yourheropaul/inj |
e7937ceb09639e3b6dc22be2d69aa59016c5e5d0 | pkg/entity/tag.go | pkg/entity/tag.go | package entity
import (
"github.com/jinzhu/gorm"
)
// Tag is a descriptive identifier given to ease searchability
type Tag struct {
gorm.Model
Value string `sql:"type:text" gorm:"unique;not null"`
Flags []*Flag `gorm:"many2many:flags_tags"`
}
| package entity
import (
"github.com/jinzhu/gorm"
)
// Tag is a descriptive identifier given to ease searchability
type Tag struct {
gorm.Model
Value string `sql:"type:varchar(64);unique_index:idx_tag_value"`
Flags []*Flag `gorm:"many2many:flags_tags;"`
}
| Fix integration issue with mysql | Fix integration issue with mysql
| Go | apache-2.0 | checkr/flagr,checkr/flagr,checkr/flagr,checkr/flagr |
4fc00b203ca16aeed2221d9f5f0f5dea741db840 | golang/server.go | golang/server.go | package main
import "github.com/gin-gonic/gin"
func main() {
r := gin.Default()
r.GET("/ping", func(c *gin.Context) {
c.JSON(200, gin.H{
"message": "pong",
})
})
r.Run() // listen and server on 0.0.0.0:8080
}
| package main
import (
"github.com/gin-gonic/gin"
"strconv"
"strings"
)
func leftPad(str string, ch string, len int) string {
return strings.Repeat(ch, len) + str
}
func main() {
r := gin.Default()
r.GET("/", func(c *gin.Context) {
str := c.DefaultQuery("str", "")
len := c.DefaultQuery("len", "0")
ch := ... | Add preliminary left padding functionality | Add preliminary left padding functionality
| Go | mit | melonmanchan/left-pad-services,melonmanchan/left-pad-services,melonmanchan/left-pad-services,melonmanchan/left-pad-services,melonmanchan/left-pad-services,melonmanchan/left-pad-services,melonmanchan/left-pad-services,melonmanchan/left-pad-services |
77fec7d1e674771f2ce4a7a60510c0c5a36222ea | src/nvim-go/autocmd/bufwritepre.go | src/nvim-go/autocmd/bufwritepre.go | package autocmd
import (
"nvim-go/commands"
"nvim-go/config"
"github.com/garyburd/neovim-go/vim"
"github.com/garyburd/neovim-go/vim/plugin"
)
func init() {
plugin.HandleAutocmd("BufWritePre",
&plugin.AutocmdOptions{Pattern: "*.go", Group: "nvim-go", Eval: "[getcwd(), expand('%:p')]"}, autocmdBufWritePre)
}
t... | package autocmd
import (
"nvim-go/commands"
"nvim-go/config"
"github.com/garyburd/neovim-go/vim"
"github.com/garyburd/neovim-go/vim/plugin"
)
func init() {
plugin.HandleAutocmd("BufWritePre",
&plugin.AutocmdOptions{Pattern: "*.go", Group: "nvim-go", Eval: "[getcwd(), expand('%:p:h'), expand('%:p')]"}, autocmd... | Fix Eval to use current buffer path for GoFmt | Fix Eval to use current buffer path for GoFmt
Signed-off-by: Koichi Shiraishi <13fbd79c3d390e5d6585a21e11ff5ec1970cff0c@zchee.io>
| Go | bsd-3-clause | zchee/nvim-go,zchee/nvim-go |
95b9d73a9c4920e40bd13218a614bbb5cb6bb1ba | testdata/none.go | testdata/none.go | package foo
import (
"io"
)
func Foo(c io.Closer) {
c.Close()
}
func FooArgs(rc io.ReadCloser) {
var b []byte
rc.Read(b)
rc.Close()
}
| package foo
import (
"io"
)
func Foo(c io.Closer) {
c.Close()
}
func FooArgs(rc io.ReadCloser) {
var b []byte
rc.Read(b)
rc.Close()
}
func FooArgsMake(rc io.ReadCloser) {
b := make([]byte, 10)
rc.Read(b)
rc.Close()
}
| Make sure that we also work with make | Make sure that we also work with make
| Go | bsd-3-clause | mvdan/interfacer |
33eb8004e43adafd3a6f43e4e3db115b2c7f5b8c | process/process.go | process/process.go | // Copyright 2015 Canonical Ltd.
// Licensed under the AGPLv3, see LICENCE file for details.
package process
import (
"gopkg.in/juju/charm.v6-unstable"
)
// Status represents the status of a worload process.
type Status string
// Status values specific to workload processes.
const (
StatusPending Status = "pendin... | // Copyright 2015 Canonical Ltd.
// Licensed under the AGPLv3, see LICENCE file for details.
package process
import (
"gopkg.in/juju/charm.v6-unstable"
)
// Status values specific to workload processes.
const (
StatusPending Status = iota
StatusActive
StatusFailed
StatusStopped
)
// Status represents the statu... | Change Status to an int (with a String method). | Change Status to an int (with a String method).
| Go | agpl-3.0 | perrito666/juju,voidspace/juju,makyo/juju,perrito666/juju,dimitern/juju,axw/juju,howbazaar/juju,davecheney/juju,voidspace/juju,reedobrien/juju,bz2/juju,marcmolla/juju,frankban/juju,dimitern/juju,kat-co/juju,gabriel-samfira/juju,mjs/juju,kat-co/juju,howbazaar/juju,axw/juju,ericsnowcurrently/juju,anastasiamac/juju,mjs/ju... |
43cfd7a94eb4c4005ddfaa44afec1f41fc49c07d | projects_commit.go | projects_commit.go | package gerrit
import (
"fmt"
"net/url"
)
// GetCommit retrieves a commit of a project.
// The commit must be visible to the caller.
//
// Gerrit API docs: https://gerrit-review.googlesource.com/Documentation/rest-api-projects.html#get-commit
func (s *ProjectsService) GetCommit(projectName, commitID string) (*Commi... | package gerrit
import (
"fmt"
"net/url"
)
// GetCommit retrieves a commit of a project.
// The commit must be visible to the caller.
//
// Gerrit API docs: https://gerrit-review.googlesource.com/Documentation/rest-api-projects.html#get-commit
func (s *ProjectsService) GetCommit(projectName, commitID string) (*Commi... | Fix GetCommitContent to actually get commit content | Fix GetCommitContent to actually get commit content
The method was accidentally duplicating GetBranchContent. | Go | mit | andygrunwald/diffy,andygrunwald/go-gerrit |
a0819f4e6ae10065dc4ac619622ee0d2f541b7cb | limit_manager.go | limit_manager.go | package limio
import (
"io"
"time"
)
type LimitManager struct {
rmap map[Limiter]<-chan uint64
}
func (rm *LimitManager) run() {
}
func NewReadManager() *LimitManager {
rm := LimitManager{
rmap: make(map[Limiter]<-chan uint64),
}
return &rm
}
func (rm *LimitManager) NewReader(r io.Reader) *Reader {
lr :=... | package limio
import (
"io"
"time"
)
//An EqualLimiter is itself a limiter and will evenly distribute the limits
//it is given across all its managed Limiters.
type EqualLimiter struct {
rmap map[Limiter]chan uint64
rate <-chan uint64
remain uint64
}
func (rm *EqualLimiter) run() {
for {
lim := <-rm.rate... | Add more implementation for EqualLimiter | Add more implementation for EqualLimiter
| Go | mit | andrewstuart/limio |
2e1e8f5b9a29abaacd57b0bfc189dfc8a4e954a3 | ipams/builtin/builtin_unix.go | ipams/builtin/builtin_unix.go | // +build linux freebsd solaris
package builtin
import (
"fmt"
"github.com/docker/libnetwork/datastore"
"github.com/docker/libnetwork/ipam"
"github.com/docker/libnetwork/ipamapi"
"github.com/docker/libnetwork/ipamutils"
)
// Init registers the built-in ipam service with libnetwork
func Init(ic ipamapi.Callback... | // +build linux freebsd solaris darwin
package builtin
import (
"fmt"
"github.com/docker/libnetwork/datastore"
"github.com/docker/libnetwork/ipam"
"github.com/docker/libnetwork/ipamapi"
"github.com/docker/libnetwork/ipamutils"
)
// Init registers the built-in ipam service with libnetwork
func Init(ic ipamapi.C... | Fix ipams builtin package for darwin | Fix ipams builtin package for darwin
Make ipams builtin package work for os x target as ipam
driver developers happen to be using os x as well.
Signed-off-by: Jana Radhakrishnan <045898bda7d4800fe4909a9831e702ab79e266be@docker.com>
| Go | apache-2.0 | abhi/libnetwork,YujiOshima/libnetwork,mavenugo/libnetwork,fcrisciani/libnetwork,kolyshkin/libnetwork,jmzwcn/libnetwork,docker/libnetwork,sainath14/libnetwork,cpuguy83/libnetwork,vdemeester/libnetwork,jimmycmh/libnetwork,curtiszimmerman/libnetwork,sainath14/libnetwork,curtiszimmerman/libnetwork,jmzwcn/libnetwork,allencl... |
3d8690ab3f74598fe606735fb771ebf86f49ce31 | service/discord/dsmessage.go | service/discord/dsmessage.go | package discord
import (
"strings"
"github.com/bwmarrin/discordgo"
)
type dsMessage struct {
*discordgo.Message
session *discordgo.Session
}
func (d dsMessage) GroupID() string {
return d.ChannelID
}
func (d dsMessage) UserName() string {
return d.Author.Username
}
func (d dsMessage) UserID() string {
retu... | package discord
import (
"strings"
"github.com/bwmarrin/discordgo"
)
type dsMessage struct {
*discordgo.Message
session *discordgo.Session
}
func (d dsMessage) GroupID() string {
return "discord"
}
func (d dsMessage) UserName() string {
return d.Author.Username
}
func (d dsMessage) UserID() string {
return... | Change to generic discord user to support N chats | Change to generic discord user to support N chats
| Go | mit | NelsonLeDuc/CalmanBot,NelsonLeDuc/CalmanBot |
1062545f53dfcc78692e9b127bdcecb0ae07c488 | srtp_cipher.go | srtp_cipher.go | package srtp
import "github.com/pion/rtp"
// cipher represents a implementation of one
// of the SRTP Specific ciphers
type srtpCipher interface {
authTagLen() int
aeadAuthTagLen() int
getRTCPIndex([]byte) uint32
encryptRTP([]byte, *rtp.Header, []byte, uint32) ([]byte, error)
encryptRTCP([]byte, []byte, uint32,... | package srtp
import "github.com/pion/rtp"
// cipher represents a implementation of one
// of the SRTP Specific ciphers
type srtpCipher interface {
// authTagLen returns auth key length of the cipher.
// See the note below.
authTagLen() int
// aeadAuthTagLen returns AEAD auth key length of the cipher.
// See the ... | Add note about AEAD auth tag in SRTCP | Add note about AEAD auth tag in SRTCP
Explain the difference between authTagLen() and aeadAuthTagLen().
| Go | mit | pion/srtp |
20a08032808eebab9a968fe127361179e82651cd | taptun_linux.go | taptun_linux.go | package taptun
import (
"bytes"
"os"
"syscall"
"unsafe"
)
type ifreq struct {
name [syscall.IFNAMSIZ]byte // c string
flags uint16 // c short
_pad [24 - unsafe.Sizeof(uint16(0))]byte
}
func createInterface(flags uint16) (string, *os.File, error) {
f, err := os.OpenFile("/dev/net/tun", os.O_... | package taptun
import (
"os"
"syscall"
"unsafe"
)
type ifreq struct {
name [syscall.IFNAMSIZ]byte // c string
flags uint16 // c short
_pad [24 - unsafe.Sizeof(uint16(0))]byte
}
func createInterface(flags uint16) (string, *os.File, error) {
f, err := os.OpenFile("/dev/net/tun", os.O_RDWR, 060... | Fix Linux build by removing unused import | Fix Linux build by removing unused import
| Go | mit | pkg/taptun |
d3282567a68491e4a494e3a028ea1d74f2497b77 | shared/logging/log_posix.go | shared/logging/log_posix.go | // +build linux darwin
package logging
import (
slog "log/syslog"
log "gopkg.in/inconshreveable/log15.v2"
)
// getSystemHandler on Linux writes messages to syslog.
func getSystemHandler(syslog string, debug bool, format log.Format) log.Handler {
// SyslogHandler
if syslog != "" {
if !debug {
return log.Lvl... | // +build linux darwin
package logging
import (
log "gopkg.in/inconshreveable/log15.v2"
)
// getSystemHandler on Linux writes messages to syslog.
func getSystemHandler(syslog string, debug bool, format log.Format) log.Handler {
// SyslogHandler
if syslog != "" {
if !debug {
return log.LvlFilterHandler(
l... | Revert "Temporary workaround for log15 API breakage" | Revert "Temporary workaround for log15 API breakage"
This reverts commit 30c859499e24ba6255508cd664c09cf4c1731bbe.
Signed-off-by: Stéphane Graber <089afc6d81f66f1168a9849e15660feae286e024@ubuntu.com>
| Go | apache-2.0 | lxc/lxd,hallyn/lxd,stgraber/lxd,pcdummy/lxd,jsavikko/lxd,lxc/lxd,Skarlso/lxd,stgraber/lxd,jsavikko/lxd,erikmack/lxd,hallyn/lxd,erikmack/lxd,hallyn/lxd,hallyn/lxd,mjeanson/lxd,atxwebs/lxd,lxc/lxd,stgraber/lxd,pcdummy/lxd,stgraber/lxd,pcdummy/lxd,mjeanson/lxd,erikmack/lxd,hallyn/lxd,atxwebs/lxd,atxwebs/lxd,lxc/lxd,Skarls... |
79c5011fb58aa1111c3f81bd41dd50d8ced5f282 | player/player.go | player/player.go | package player
import (
"io"
"os/exec"
"log"
"github.com/aws/aws-sdk-go/service/polly"
)
func Play(resp *polly.SynthesizeSpeechOutput, logger *log.Logger) error {
cmd := exec.Command("play", "-t", "mp3", "-")
wr, err := cmd.StdinPipe()
if err != nil {
return err
}
err = cmd.Start()
if err != nil {
log... | // +build !windows
package player
import (
"io"
"os/exec"
"log"
"github.com/aws/aws-sdk-go/service/polly"
)
func Play(resp *polly.SynthesizeSpeechOutput, logger *log.Logger) error {
cmd := exec.Command("play", "-t", "mp3", "-")
wr, err := cmd.StdinPipe()
if err != nil {
return err
}
err = cmd.Start()
i... | Fix depending OS build error | Fix depending OS build error
| Go | mit | bamchoh/nagome-polly |
cf958f83f31387251fda6aedcc24506bf4c83c2b | service/openvpn/client/helper/executable_finder_darwin.go | service/openvpn/client/helper/executable_finder_darwin.go | package helper
var guessExecutableName = "openvpn"
var guessExecutablePaths = []string{
"/Applications/Tunnelblick.app/Contents/Resources/openvpn/default",
}
var guessExecutableSuggestions = `
If you use Homebrew, you can install the openvpn formula...
brew install openvpn
Alternatively, the following applicati... | package helper
var guessExecutableName = "openvpn"
var guessExecutablePaths = []string{
"/Applications/Tunnelblick.app/Contents/Resources/openvpn/default",
"/Applications/Shimo.app/Contents/MacOS/openvpn",
"/Applications/Viscosity.app/Contents/MacOS/openvpn",
}
var guessExecutableSuggestions = `
If you use Homebrew... | Add Viscosity/Shimo embedded openvpn paths | Add Viscosity/Shimo embedded openvpn paths
| Go | mit | dpb587/ssoca,dpb587/ssoca,dpb587/ssoca |
03f02c00edf62b8e44ad3d99a9216fdbbdf90fc5 | py/module.go | py/module.go | // Module objects
package py
import (
"fmt"
)
var (
// Registry of installed modules
modules = make(map[string]*Module)
// Builtin module
Builtins *Module
)
// A python Module object
type Module struct {
Name string
Doc string
Globals StringDict
// dict Dict
}
var ModuleType = NewType("module", "mo... | // Module objects
package py
import (
"fmt"
)
var (
// Registry of installed modules
modules = make(map[string]*Module)
// Builtin module
Builtins *Module
)
// A python Module object
type Module struct {
Name string
Doc string
Globals StringDict
// dict Dict
}
var ModuleType = NewType("module", "mo... | Set __name__, __doc__ and __package__ in Module | Set __name__, __doc__ and __package__ in Module
| Go | bsd-3-clause | go-python/gpython,go-python/gpython,go-python/gpython,go-python/gpython,go-python/gpython,go-python/gpython |
6a8ccc9615f97aed7985317718398c1619cc81d5 | api/document.go | api/document.go | /*
Copyright 2021 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, ... | /*
Copyright 2021 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, ... | Add interface directives for counterfeiter | api: Add interface directives for counterfeiter
Signed-off-by: Stephen Augustus <0beec7b5ea3f0fdbc95d0dd47f3c5bc275da8a33@auggie.dev>
| Go | apache-2.0 | kubernetes/enhancements,kubernetes/enhancements,kubernetes/enhancements |
919e17af9fabd8520e38922fadc9484e6a1234a5 | sss_test.go | sss_test.go | package sss
import (
"testing"
)
func TestRoundtrip(t *testing.T) {
n := 30
k := 2
expected := "well hello there!"
shares, err := Split(n, k, []byte(expected))
if err != nil {
t.Error(err)
}
subset := make(map[int][]byte, k)
for x, y := range shares {
subset[x] = y
if len(subset) == k {
break
}
... | package sss
import (
"fmt"
)
func Example() {
// split into 30 shares, of which only 2 are required to combine
n := 30
k := 2
secret := "well hello there!"
shares, err := Split(n, k, []byte(secret))
if err != nil {
fmt.Println(err)
}
// select a random subset of the total shares
subset := make(map[int][... | Change round-trip test to an example. | Change round-trip test to an example.
| Go | mit | codahale/sss |
3dc730433b51b5c0632e303f639b1754347a387b | examples/forceHTTPS.go | examples/forceHTTPS.go | package main
import (
"fmt"
"github.com/codedust/go-httpserve"
"net/http"
)
func main() {
http.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) {
fmt.Fprintf(w, "<!DOCTYPE html><html><h1>It works!</h1></html>")
})
// add authentication
salt, err := httpserve.RandomString(32)
if err != nil {
p... | /* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
package main
import (
"fmt"
"github.com/codedust/go-httpserve"
"net/http"
)
func main() {
http.HandleFunc("/"... | Add MPL header to examples/forceHTTPs.go | Add MPL header to examples/forceHTTPs.go
| Go | mpl-2.0 | codedust/go-httpserve |
5b29de3ff7c457c6fc5e399e420133968c1773bc | examples/ollie_roll.go | examples/ollie_roll.go | package main
import (
"os"
"time"
"github.com/hybridgroup/gobot"
"github.com/hybridgroup/gobot/platforms/ble"
)
func main() {
gbot := gobot.NewGobot()
bleAdaptor := ble.NewBLEClientAdaptor("ble", os.Args[1])
ollie := ble.NewSpheroOllieDriver(bleAdaptor, "ollie")
work := func() {
ollie.SetRGB(255, 0, 255)... | package main
import (
"os"
"time"
"github.com/hybridgroup/gobot"
"github.com/hybridgroup/gobot/platforms/ble"
)
func main() {
gbot := gobot.NewGobot()
bleAdaptor := ble.NewBLEClientAdaptor("ble", os.Args[1])
ollie := ble.NewSpheroOllieDriver(bleAdaptor, "ollie")
work := func() {
ollie.SetRGB(255, 0, 255)... | Speed up Ollie example roll speed | [ble] Speed up Ollie example roll speed
Signed-off-by: deadprogram <b937b287f61b7a223d4aac55072db1a5381d3bb3@hybridgroup.com>
| Go | apache-2.0 | nzmichaelh/gobot,nzmichaelh/gobot |
38735f5c76acc3b7e88bce7e59b1b0d05d3857f3 | model/reference.go | model/reference.go | package model
import (
"encoding/json"
"fmt"
)
type Reference struct {
ObjectId *ObjectID `json:",omitempty"`
Id string `json:",omitempty"`
Type string `json:",omitempty"`
}
func NewReference(objectId ObjectID) *Reference {
return &Reference{ObjectId: &objectId}
}
func (reference *Reference) G... | package model
import "encoding/json"
type Reference struct {
ObjectId *ObjectID `json:",omitempty"`
Id string `json:",omitempty"`
Type string `json:",omitempty"`
}
func NewReference(objectId ObjectID) *Reference {
return &Reference{ObjectId: &objectId}
}
func (reference *Reference) GetSha1() str... | Remove unused method in Reference | Remove unused method in Reference
| Go | apache-2.0 | af83/edwig,af83/edwig,af83/edwig |
88727775d69e9b33df72c4e6648d09bcb3c346c5 | command/today.go | command/today.go | package command
import (
"fmt"
"time"
"github.com/igungor/tlbot"
)
func init() {
register(cmdToday)
}
var cmdToday = &Command{
Name: "bugun",
ShortLine: "bugün günlerden ne?",
Run: runToday,
}
type weekday time.Weekday
var days = [...]string{
"pazar",
"pazartesi",
"sali",
"carsamba",
"perse... | package command
import (
"fmt"
"time"
"github.com/igungor/tlbot"
)
func init() {
register(cmdToday)
}
var cmdToday = &Command{
Name: "bugun",
ShortLine: "bugün günlerden ne?",
Run: runToday,
}
type weekday time.Weekday
var days = [...]string{
"pazar",
"pazartesi",
"salı",
"çarşamba",
"perşe... | Use proper turkish words for days | Use proper turkish words for days
| Go | mit | igungor/ilberbot,igungor/ilber |
cb768af90bfb759f133a18a7212ddaf07b1c8ed6 | transaction/manager_test.go | transaction/manager_test.go | package transaction
import (
"runtime"
"testing"
)
// Tests we can start/stop a transaction manager repeatedly on the same port.
func TestStop(t *testing.T) {
loops := 5
goroutines := runtime.NumGoroutine()
for i := 0; i < loops; i++ {
m, err := NewManager("tcp", "localhost:12345")
if err != nil {
t.Fatal... | package transaction
import (
"testing"
"time"
)
// Tests we can start/stop a transaction manager repeatedly on the same port.
func TestStop(t *testing.T) {
loops := 5
for i := 0; i < loops; i++ {
m, err := NewManager("tcp", "localhost:12345")
if err != nil {
t.Fatalf("Failed to start manager on loop %v: %v... | Remove goroutine check from manager test, it's not consistent | Remove goroutine check from manager test, it's not consistent
| Go | lgpl-2.1 | orenmazor/gossip,weave-lab/gossip,StefanKopieczek/gossip |
046c90047faaffb81e082632168667592a29e34d | engine/engine.go | engine/engine.go | package engine
import (
"github.com/coreos/coreinit/machine"
"github.com/coreos/coreinit/registry"
)
type Engine struct {
dispatcher *Dispatcher
watcher *JobWatcher
registry *registry.Registry
machine *machine.Machine
}
func New(reg *registry.Registry, events *registry.EventStream, mach *machine.Machin... | package engine
import (
"github.com/coreos/coreinit/machine"
"github.com/coreos/coreinit/registry"
)
type Engine struct {
dispatcher *Dispatcher
watcher *JobWatcher
registry *registry.Registry
machine *machine.Machine
}
func New(reg *registry.Registry, events *registry.EventStream, mach *machine.Machin... | Call Dispatcher.Listen last in Engine.Run | fix(Engine): Call Dispatcher.Listen last in Engine.Run
| Go | apache-2.0 | flandr/fleet,mookjp/fleet,improbable-io/fleet,improbable-io/fleet,endocode/fleet,mookjp/fleet,paveltiunov/fleet,esatterwhite/fleet,bcwaldon/fleet,thepwagner/fleet,mwitkow-io/fleet,bcwaldon/fleet,wuqixuan/fleet,hhoover/fleet,ecnahc515/fleet,jonboulle/fleet,giantswarm/fleet,flandr/fleet,giantswarm/fleet,endocode/fleet,mw... |
91099694c9308ed5a1319587f5f1d9ab27ecf972 | prog/netcheck/netcheck.go | prog/netcheck/netcheck.go | /* netcheck: check whether a given network or address overlaps with any existing routes */
package main
import (
"fmt"
"net"
"os"
weavenet "github.com/weaveworks/weave/net"
)
func fatal(err error) {
fmt.Println(err)
os.Exit(1)
}
func main() {
if len(os.Args) <= 1 {
os.Exit(0)
}
cidrStr := os.Args[1]
ad... | /* netcheck: check whether a given network or address overlaps with any existing routes */
package main
import (
"fmt"
"net"
"os"
weavenet "github.com/weaveworks/weave/net"
)
func fatal(err error) {
fmt.Fprintln(os.Stderr, err)
os.Exit(1)
}
func main() {
if len(os.Args) <= 1 {
os.Exit(0)
}
cidrStr := os... | Send error message to stderr | Send error message to stderr
| Go | apache-2.0 | weaveworks/weave,cgvarela/weave,kidaa/weave,paladin74/weave,achanda/weave,2opremio/weave,dpw/weave,tomwilkie/weave,paulbellamy/weave,dpw/weave,dpw/weave,BWITS/weave,rade/weave,achanda/weave,2opremio/weave,aaam/weave,bboreham/weave,aaam/weave,2opremio/weave,paulbellamy/weave,tomwilkie/weave,OnePaaS/weave,paladin74/weave... |
6f800847ea136c66c6a39c05652e97302200a9f1 | middlewares/auth_required.go | middlewares/auth_required.go | package middlewares
import (
"net/http"
"time"
"github.com/freeusd/solebtc/Godeps/_workspace/src/github.com/gin-gonic/gin"
"github.com/freeusd/solebtc/errors"
"github.com/freeusd/solebtc/models"
)
type authRequiredDependencyGetAuthToken func(authTokenString string) (models.AuthToken, *errors.Error)
// AuthRequ... | package middlewares
import (
"net/http"
"time"
"github.com/freeusd/solebtc/Godeps/_workspace/src/github.com/gin-gonic/gin"
"github.com/freeusd/solebtc/errors"
"github.com/freeusd/solebtc/models"
)
type authRequiredDependencyGetAuthToken func(authTokenString string) (models.AuthToken, *errors.Error)
// AuthRequ... | Check AuthToken header if empty before query database | Check AuthToken header if empty before query database
| Go | mit | solefaucet/sole-server,freeusd/solebtc,freeusd/solebtc,solefaucet/sole-server,solefaucet/sole-server,freeusd/solebtc |
eafd142dfaca8f936f2a991330767d3e97bc19c9 | pkg/healthz/healthz_test.go | pkg/healthz/healthz_test.go | /*
Copyright 2014 Google Inc. 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 applicable law or agreed to in ... | /*
Copyright 2014 Google Inc. 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 applicable law or agreed to in ... | Fix healthz test error handling | Fix healthz test error handling
| Go | apache-2.0 | andrewstuart/kubernetes,amos6224/kubernetes,mindprince/kubernetes,pires/kubernetes,whitlockjc/kubernetes,gluke77/kubernetes,pugna0/kubernetes,bcbroussard/kubernetes-travis,fabriziopandini/kubernetes,zhangmingld/kubernetes,smerrill/kubernetes,shenshouer/kubernetes,vallard/kubernetes,jlz27/kubernetes,wb14123/kubernetes,m... |
043c8fdef7f4caf24105ad1a5d7558f79437df2b | cmd/sniff/main.go | cmd/sniff/main.go | package main
import (
"log"
"time"
"github.com/ecc1/medtronic"
"github.com/ecc1/medtronic/packet"
)
const (
verbose = true
)
func main() {
if verbose {
log.SetFlags(log.Ltime | log.Lmicroseconds | log.LUTC)
}
pump := medtronic.Open()
defer pump.Close()
for pump.Error() == nil {
p, rssi := pump.Radio.R... | package main
import (
"log"
"time"
"github.com/ecc1/medtronic"
"github.com/ecc1/medtronic/packet"
)
const (
verbose = true
)
func main() {
if verbose {
log.SetFlags(log.Ltime | log.Lmicroseconds | log.LUTC)
}
pump := medtronic.Open()
defer pump.Close()
for pump.Error() == nil {
p, rssi := pump.Radio.R... | Print packet lengths in sniff | Print packet lengths in sniff
| Go | mit | ecc1/medtronic,ecc1/medtronic |
1a8177afe77d78022865b32b1df2fddcf17bf1d3 | metrics/pairwise/pairwise.go | metrics/pairwise/pairwise.go | // Package pairwise implements utilities to evaluate pairwise distances or inner product (via kernel).
package pairwise
| // Package pairwise implements utilities to evaluate pairwise distances or inner product (via kernel).
package pairwise
import (
"github.com/gonum/matrix/mat64"
)
type PairwiseDistanceFunc interface {
Distance(vectorX *mat64.Dense, vectorY *mat64.Dense) float64
}
| Add distanceFunc interface to metrics. | Add distanceFunc interface to metrics.
| Go | mit | jmptrader/golearn,gitforhf/golearn,jacobxk/golearn,thedadams/golearn,elkingtonmcb/golearn,beni55/golearn,tempbottle/golearn,thedadams/golearn,ghs11/golearn,jacobxk/golearn,tempbottle/golearn,liudhzhyym/golearn,sjwhitworth/golearn,dboyliao/golearn,gitforhf/golearn,hsavit1/golearn,hsavit1/golearn,EtienneBruines/golearn,g... |
2d8a89ad3e455785fe579a8950cc8a50dc9568e0 | ReverseStr.go | ReverseStr.go | /*
Write a function that takes a string as input and returns the string reversed.
Example:
Given s = "hello", return "olleh".
*/
package main
import (
"fmt"
)
func main() {
tests := [][]string{{"", ""}, {" ", " "}, {" ", " "}, {"a", "a"}, {"ab", "ba"}, {"hello", "olleh"}, {"Hello, 世界!", "!界世 ,olleH"}}
for _... | /*
Write a function that takes a string as input and returns the string reversed.
Example:
Given s = "hello", return "olleh".
*/
package main
import (
"fmt"
)
func main() {
tests := [][]string{{"", ""}, {" ", " "}, {" ", " "}, {"a", "a"}, {"ab", "ba"}, {"hello", "olleh"}, {"Hello, 世界!", "!界世 ,olleH"}}
for _... | Update char swap operation without temp character | Update char swap operation without temp character | Go | mit | astdb/Misc,astdb/Misc,astdb/Misc,astdb/Misc,astdb/TB_ShortProbs,astdb/TB_ShortProbs,astdb/Misc,astdb/Misc,astdb/TB_ShortProbs |
b47f8e0dc217f7eedc855e69f621d1a259c430e8 | pkg/shell/shell_unix_test.go | pkg/shell/shell_unix_test.go | //go:build !windows && !plan9 && !js
package shell
import (
"strings"
"syscall"
"testing"
"src.elv.sh/pkg/must"
. "src.elv.sh/pkg/prog/progtest"
"src.elv.sh/pkg/testutil"
)
func TestSignal_USR1(t *testing.T) {
Test(t, &Program{},
ThatElvish("-c", "kill -USR1 $pid").WritesStderrContaining("src.elv.sh/pkg/sh... | //go:build !windows && !plan9 && !js
package shell
import (
"fmt"
"strings"
"syscall"
"testing"
"time"
"src.elv.sh/pkg/must"
. "src.elv.sh/pkg/prog/progtest"
"src.elv.sh/pkg/testutil"
)
func TestSignal_USR1(t *testing.T) {
Test(t, &Program{},
ThatElvish("-c", killCmd("USR1")).WritesStderrContaining("src.... | Add a short delay in signal handling test. | pkg/shell: Add a short delay in signal handling test.
| Go | bsd-2-clause | elves/elvish,elves/elvish,elves/elvish,elves/elvish,elves/elvish |
e4dbfeb8d773865f87e97607a453d3e6324def53 | cmd/server/main.go | cmd/server/main.go | package main
import (
"github.com/itsankoff/gotcha/server"
"log"
)
func main() {
s := server.New()
wss := server.NewWebSocket()
s.AddTransport("127.0.0.1:9000", &wss)
done := make(chan interface{})
err := s.Start(done)
if err != nil {
log.Fatal("Failed to start server")
}
}
| package main
import (
"flag"
"github.com/itsankoff/gotcha/server"
"log"
)
func main() {
config := server.NewConfig()
config.ListenHost = *flag.String("host", ":9000", "host to listen")
config.FileServerHost = *flag.String("file_host", ":9000", "host to server files")
config.FileServerPath = *flag.String("file_... | Add flag params for server | Add flag params for server
| Go | mit | itsankoff/gotcha,itsankoff/gotcha |
1ca9abdcc6d3b9ef9e0afb2125b64ee52fe2ff09 | server/util/cors_handler.go | server/util/cors_handler.go | package util
import (
"net/http"
"github.com/rs/cors"
)
// NewCorsHandler creates a new http.Handler to support CORS
func NewCorsHandler(handler http.Handler, allowOrigins []string) http.Handler {
mw := cors.New(cors.Options{
AllowedOrigins: allowOrigins,
AllowCredentials: true,
AllowedMethods: []string... | package util
import (
"net/http"
"github.com/rs/cors"
)
// NewCorsHandler creates a new http.Handler to support CORS
func NewCorsHandler(handler http.Handler, allowOrigins []string) http.Handler {
mw := cors.New(cors.Options{
AllowedOrigins: allowOrigins,
AllowCredentials: true,
AllowedMethods: []string... | Add authorization header to accepted headers | Add authorization header to accepted headers
| Go | mit | torinos-io/api,torinos-io/api |
e8d448bfc9abdcc0bf231b08f254cb11a69e4302 | api/middleware/middleware.go | api/middleware/middleware.go | // Copyright 2017 Mathew Robinson <mrobinson@praelatus.io>. All rights reserved.
// Use of this source code is governed by the AGPLv3 license that can be found in
// the LICENSE file.
// Package middleware contains the HTTP middleware used in the api as
// well as utility functions for interacting with them
package mi... | // Copyright 2017 Mathew Robinson <mrobinson@praelatus.io>. All rights reserved.
// Use of this source code is governed by the AGPLv3 license that can be found in
// the LICENSE file.
// Package middleware contains the HTTP middleware used in the api as
// well as utility functions for interacting with them
package mi... | Rename headers and add doc comment | Rename headers and add doc comment
| Go | agpl-3.0 | praelatus/praelatus,praelatus/backend,praelatus/backend,praelatus/backend,praelatus/praelatus,praelatus/praelatus |
c791c7bca4549d9a96bddd4a363a1363c9542e87 | pkg/storage/storage.go | pkg/storage/storage.go | package storage
import (
"bytes"
"errors"
"io"
)
type Storage struct {
data map[string][]byte
}
func (storage *Storage) CopyObjectToWriter(w io.Writer, bucket string, object string) error {
// TODO synchronize access
// get object
key := bucket + ":" + object
if val, ok := storage.data[key]; ok {
objectBuf... | package storage
import (
"bytes"
"errors"
"io"
)
type Storage struct {
data map[string][]byte
}
func (storage *Storage) CopyObjectToWriter(w io.Writer, bucket string, object string) error {
// TODO synchronize access
// get object
key := bucket + ":" + object
if val, ok := storage.data[key]; ok {
objectBuf... | Store objects in memory map | Store objects in memory map
| Go | agpl-3.0 | flandr/minio,koolhead17/minio,flandr/minio,dutchcoders/minio,abperiasamy/minio,rajivm/minio,hackintoshrao/minio,rushenn/minio,hackintoshrao/minio,harshavardhana/minio,jimjag/minio,vadmeste/minio,harshavardhana/minio,jimjag/minio,aead/minio,dvstate/minio,solderzzc/minio,flandr/minio,dvstate/minio,balamurugana/minio,abpe... |
b88d00beea94ab3aaf3f25e9c34f9433584e0b4e | tests/integration/vars.go | tests/integration/vars.go | /*
Copyright 2016 Mirantis
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
distri... | /*
Copyright 2016 Mirantis
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
distri... | Use CirrOS image for integration tests | Use CirrOS image for integration tests
| Go | apache-2.0 | Mirantis/virtlet,vefimova/virtlet,vefimova/virtlet,Mirantis/virtlet,nhlfr/virtlet,vefimova/virtlet,nhlfr/virtlet,vefimova/virtlet,nhlfr/virtlet,nhlfr/virtlet |
bd03e49fd1444f2a7b664907d5f438f0fb26558b | checker/xpath.go | checker/xpath.go | package checker
import (
"gokogiri/xpath"
"butler/null"
tp "tritium/proto"
)
func (result *CheckResult) CheckXpath(script *tp.ScriptObject) {
iterate(script, func(ins *tp.Instruction) {
if *ins.Type == tp.Instruction_FUNCTION_CALL {
name := null.GetString(ins.Value)
if name == "$" || name == "select" {
... | package checker
import (
"gokogiri/xpath"
"butler/null"
tp "tritium/proto"
)
func (result *CheckResult) CheckXpath(script *tp.ScriptObject) {
iterate(script, func(ins *tp.Instruction) {
if *ins.Type == tp.Instruction_FUNCTION_CALL {
name := null.GetString(ins.Value)
if name == "$" || name == "select" || n... | Include fetch and better error message format | Include fetch and better error message format
| Go | mpl-2.0 | moovweb/tritium,moovweb/tritium,moovweb/tritium,moovweb/tritium,moovweb/tritium |
3c7e2c032e16ea15e34758567c9c839b5a3f910f | serialize/serialize.go | serialize/serialize.go | package serialize
import (
"encoding/json"
"encoding/xml"
"net/http"
"strconv"
)
type Serializer int
const (
Json Serializer = iota
Xml
)
func Write(w http.ResponseWriter, value interface{}, s Serializer) (int, error) {
var contentType string
var data []byte
var err error
if s == Json {
data, err = json... | package serialize
import (
"encoding/json"
"encoding/xml"
"io"
"net/http"
"strconv"
)
type SerializationFormat int
const (
Json SerializationFormat = iota
Xml
)
func Write(w io.Writer, value interface{}, f SerializationFormat) (int, error) {
var contentType string
var data []byte
var err error
switch f {... | Allow serialization to an io.Writer | Allow serialization to an io.Writer
If w is also an http.ResponseWriter, write the headers too
| Go | mpl-2.0 | rainycape/gondola,rainycape/gondola,rainycape/gondola,rainycape/gondola |
7bf766d085e819b35806564c9b7557c151e91c00 | ConcurrencyPatterns/ActiveObject/ActiveObjectWithInterval.go | ConcurrencyPatterns/ActiveObject/ActiveObjectWithInterval.go | package ActiveObject
import (
"errors"
"time"
)
//ActiveObjectWithInterval implements IActiveObject with behavior running in a specified interval
type ActiveObjectWithInterval struct {
ticker *time.Ticker
doneChannel chan bool
ActiveObjectRunningOnce
}
func NewActiveObjectWithInterval(duration time.Durati... | package ActiveObject
import (
"errors"
"time"
)
//ActiveObjectWithInterval implements IActiveObject with behavior running in a specified interval
type ActiveObjectWithInterval struct {
ticker *time.Ticker
doneChannel chan bool
ActiveObjectRunningOnce
}
func NewActiveObjectWithInterval(duration time.Durati... | Make sure the isStopped always set correctly in running once active object | Make sure the isStopped always set correctly in running once active object
| Go | mit | irwansyahwii/Pattern-Oriented-Software-Architecture-With-Go |
4b6a948ecf7aef05db618e5e82fbe323f707182c | consts/consts.go | consts/consts.go | /*
Package consts implements constants for the entire project
*/
package consts
// ConfigurationFileName is the configuration file name of Goyave
const ConfigurationFileName = ".goyave"
| /*
Package consts implements constants for the entire project
*/
package consts
// ConfigurationFileName is the configuration file name of Goyave
const ConfigurationFileName = ".goyave"
// GitFileName is the name of the git directory, in a git repository
const GitFileName = ".git"
| Add the name of a Git directory | Add the name of a Git directory
| Go | mit | k0pernicus/goyave |
f1362d902b038e1f36d77999fd4d3d63c000ab9e | main.go | main.go | package main
import (
"flag"
"fmt"
"os"
)
func main() {
var input string
flag.StringVar(&input, "input", "", "input file")
flag.Parse()
if input == "" {
flag.Usage()
os.Exit(1)
}
var err error
f, err := os.Open(input)
if err != nil {
panic(err)
}
p := NewParser(f)
col, err := p.Parse()
if e... | package main
import (
"crypto/md5"
"crypto/sha1"
"encoding/hex"
"encoding/json"
"flag"
"fmt"
"io"
"os"
"strings"
)
func main() {
var (
input string
datset string
)
flag.StringVar(&input, "f", "", "input file")
flag.StringVar(&datset, "d", "", "datset")
flag.Parse()
if input == "" || datset == ""... | Add flag to check if file is in datset | Add flag to check if file is in datset
| Go | mit | marcusolsson/gointro |
dafdbc0508f7052c5c32e92413a88289597d39f5 | main.go | main.go | package main
import (
"os"
"time"
tm "github.com/buger/goterm"
)
func main() {
command := os.Args[1:]
tm.Clear()
loop(1*time.Second, func() {
render(command)
})
}
func render(command []string) {
tm.MoveCursor(0,0)
tm.Println(command)
tm.Flush()
}
func loop(d time.Duration, fn func()) {
ti... | package main
import (
"bytes"
"fmt"
"io"
"log"
"os"
"os/exec"
"time"
tm "github.com/buger/goterm"
)
func main() {
command := os.Args[1:]
tm.Clear()
tm.MoveCursor(0,0)
loop(1*time.Second, func() {
output, err := run(command)
safe(err)
render(output)
})
}
func run(command []... | Print output on each run by copying buffers around | Print output on each run by copying buffers around
| Go | mit | ostera/watch,ostera/watch |
2db9ada0e417d18b6660d5f9640973eeaf9dfe17 | cmd/export.go | cmd/export.go | package cmd
import (
"io"
"log"
"net/url"
"os"
"github.com/bkittelmann/pinboard-checker/pinboard"
"github.com/spf13/cobra"
)
func init() {
exportCmd.Flags().StringP("token", "t", "", "The pinboard API token")
exportCmd.Flags().String("endpoint", pinboard.DefaultEndpoint.String(), "URL of pinboard API endpoin... | package cmd
import (
"fmt"
"io"
"log"
"net/url"
"os"
"github.com/bkittelmann/pinboard-checker/pinboard"
"github.com/spf13/cobra"
)
func init() {
exportCmd.Flags().StringP("token", "t", "", "The pinboard API token")
exportCmd.Flags().String("endpoint", pinboard.DefaultEndpoint.String(), "URL of pinboard API ... | Validate that token parameter is set and abort program if it is not | Validate that token parameter is set and abort program if it is not
| Go | mit | bkittelmann/pinboard-checker,bkittelmann/pinboard-checker |
ddc800d8efad8a5be5fa8f329f4ce261b9b79330 | lib/clean/main.go | lib/clean/main.go | package clean
import (
"fmt"
"os"
"path/filepath"
"strings"
"github.com/littledot/mockhiato/lib"
"github.com/littledot/mockhiato/lib/plugin/github.com/stretchr/testify"
)
// Run executes the command.
func Run(config lib.Config) {
projectPath, err := filepath.Abs(config.ProjectPath)
if err != nil {
panic(er... | package clean
import (
"os"
"path/filepath"
"strings"
"github.com/littledot/mockhiato/lib"
"github.com/littledot/mockhiato/lib/plugin/github.com/stretchr/testify"
log "github.com/sirupsen/logrus"
)
// Run executes the command.
func Run(config lib.Config) {
projectPath, err := filepath.Abs(config.ProjectPath)
... | Replace `fmt` with `log` in clean. | Replace `fmt` with `log` in clean.
| Go | apache-2.0 | littledot/mockhiato,littledot/mockhiato |
dd5457f5ab1f60db3c5e53a1e0a23c3c3817c2b6 | geoip_test.go | geoip_test.go | package geoip
import (
"fmt"
. "launchpad.net/gocheck"
"testing"
)
// Hook up gocheck into the gotest runner.
func Test(t *testing.T) { TestingT(t) }
type GeoIPSuite struct {
}
var _ = Suite(&GeoIPSuite{})
func (s *GeoIPSuite) Testv4(c *C) {
gi, err := Open()
if gi == nil || err != nil {
fmt.Printf("Could n... | package geoip
import (
"fmt"
. "launchpad.net/gocheck"
"testing"
)
// Hook up gocheck into the gotest runner.
func Test(t *testing.T) { TestingT(t) }
type GeoIPSuite struct {
}
var _ = Suite(&GeoIPSuite{})
func (s *GeoIPSuite) Testv4(c *C) {
gi, err := Open()
if gi == nil || err != nil {
fmt.Printf("Could n... | Update netmask test to something that GeoIP and GeoLite (hopefully) agrees on | Update netmask test to something that GeoIP and GeoLite (hopefully) agrees on
| Go | mit | abh/geoip,abh/geoip,etix/geoip,aziontech/geoip,davemarchevsky/geoip,davemarchevsky/geoip,etix/geoip,mailgun/geoip,aziontech/geoip,mailgun/geoip |
3b27d8ab0a04150427faacf7507e1536c7f7ee6d | utils/log/log.go | utils/log/log.go | // Copyright © 2015 The Things Network
// Use of this source code is governed by the MIT license that can be found in the LICENSE file.
// Package log provides some handy types and method to activate and deactivate specific log
// behavior within files in a transparent way.
package log
import (
"fmt"
)
// Logger is... | // Copyright © 2015 The Things Network
// Use of this source code is governed by the MIT license that can be found in the LICENSE file.
// Package log provides some handy types and method to activate and deactivate specific log
// behavior within files in a transparent way.
package log
import (
"fmt"
"testing"
)
/... | Create a new Logger that goes well with the test environment | [router] Create a new Logger that goes well with the test environment
| Go | mit | LoRaWanSoFa/ttn,jvanmalder/ttn,TheThingsNetwork/ttn,mgranberry/ttn,jvanmalder/ttn,mgranberry/ttn,TheThingsNetwork/ttn,mgranberry/ttn,TheThingsNetwork/ttn,jvanmalder/ttn,LoRaWanSoFa/ttn |
f6d8190e8f62ce239158be8ffeb9ca63432c28b3 | initialize/user_data_test.go | initialize/user_data_test.go | package initialize
import (
"testing"
)
func TestParseHeaderCRLF(t *testing.T) {
configs := []string{
"#cloud-config\nfoo: bar",
"#cloud-config\r\nfoo: bar",
}
for i, config := range configs {
_, err := ParseUserData(config)
if err != nil {
t.Errorf("Failed parsing config %d: %v", i, err)
}
}
scr... | package initialize
import (
"testing"
)
func TestParseHeaderCRLF(t *testing.T) {
configs := []string{
"#cloud-config\nfoo: bar",
"#cloud-config\r\nfoo: bar",
}
for i, config := range configs {
_, err := ParseUserData(config)
if err != nil {
t.Errorf("Failed parsing config %d: %v", i, err)
}
}
scr... | Add test that parses user-data with carriage returns | test(crlf): Add test that parses user-data with carriage returns
| Go | apache-2.0 | sigma/coreos-cloudinit,endocode/coreos-cloudinit,mischief/coreos-cloudinit,endocode/coreos-cloudinit,snailwalker/coreos-cloudinit,rancher/coreos-cloudinit,crawford/coreos-cloudinit,cusspvz/coreos-cloudinit,rancher/coreos-cloudinit,davidwalter0/coreos-cloudinit,mischief/coreos-cloudinit,packethost/coreos-cloudinit,david... |
ad053987e5f1ce62787228478dc056986fb9f248 | api/sys_health.go | api/sys_health.go | package api
func (c *Sys) Health() (*HealthResponse, error) {
r := c.c.NewRequest("GET", "/v1/sys/health")
// If the code is 400 or above it will automatically turn into an error,
// but the sys/health API defaults to returning 5xx when not sealed or
// inited, so we force this code to be something else so we pars... | package api
func (c *Sys) Health() (*HealthResponse, error) {
r := c.c.NewRequest("GET", "/v1/sys/health")
// If the code is 400 or above it will automatically turn into an error,
// but the sys/health API defaults to returning 5xx when not sealed or
// inited, so we force this code to be something else so we pars... | Add replication mode sys health information to Go API | Add replication mode sys health information to Go API
| Go | mpl-2.0 | Aloomaio/vault,mgk/vault,Aloomaio/vault,hashicorp/vault,mgk/vault,hashicorp/vault,hartsock/vault,joelthompson/vault,rnaveiras/vault,quixoten/vault,mgk/vault,joelthompson/vault,hartsock/vault,Aloomaio/vault,rnaveiras/vault,kingland/vault,hartsock/vault,rnaveiras/vault,joelthompson/vault,hashicorp/vault,hartsock/vault,na... |
8ece3997df405eff6df0120a7d3d7b24bf4ec3a2 | configuration/configuration.go | configuration/configuration.go | package configuration
import (
"flag"
"log"
"github.com/FogCreek/mini"
)
type iagoConfiguration struct {
Hostname string
Protocol string
Port string
Path string
}
var (
Iago iagoConfiguration
)
func Process() {
path := flag.String("config", "/etc/miloud.ini", "Configuration file path")
flag.Parse... | package configuration
import (
"flag"
"log"
"github.com/FogCreek/mini"
)
type iagoConfiguration struct {
Hostname string
Protocol string
Port string
Path string
}
var (
Iago iagoConfiguration
)
func Process() {
path := flag.String("config", "/etc/miloud.ini", "Configuration file path")
flag.Parse... | Set the default Iago hostname to localhost | Set the default Iago hostname to localhost
| Go | unlicense | citruspi/milou |
2278c3bb5d33bb2676838161c8cc023e70d5d2d5 | cipher_generic.go | cipher_generic.go | // Copyright 2012 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.
// +build !amd64,!s390x
package aes12
// newCipher calls the newCipherGeneric function
// directly. Platforms with hardware accelerated
// implementations of ... | // Copyright 2012 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.
// +build !amd64
package aes12
// newCipher calls the newCipherGeneric function
// directly. Platforms with hardware accelerated
// implementations of AES sho... | Use generic implementation for s390x | Use generic implementation for s390x | Go | mit | lucas-clemente/aes12 |
f96173cbe4129124e6cbf66804e06dbabc9066c3 | src/constants_unix.go | src/constants_unix.go | // +build !windows
package fzf
const (
// Reader
defaultCommand = `find . -path '*/\.*' -prune -o -type f -print -o -type l -print 2> /dev/null | sed s/^..//`
)
| // +build !windows
package fzf
const (
// Reader
defaultCommand = `find -L . -path '*/\.*' -prune -o -type f -print -o -type l -print 2> /dev/null | sed s/^..//`
)
| Add -L flag to the default find command | Add -L flag to the default find command
Close #781
| Go | mit | tomfitzhenry/pkg-fzf,junegunn/fzf,janlazo/fzf,wilywampa/fzf,wilywampa/fzf,janlazo/fzf,tomfitzhenry/pkg-fzf,infokiller/fzf,junegunn/fzf,tomfitzhenry/pkg-fzf,stuha/wbr-zsh,infokiller/fzf,infokiller/fzf,wilywampa/fzf,janlazo/fzf,junegunn/fzf |
438f6c96cdc56e1bb3cc12daa16ae08b2ccae18b | src/util/util_windows.go | src/util/util_windows.go | // +build windows
package util
import (
"os"
"os/exec"
"syscall"
)
// ExecCommand executes the given command with cmd
func ExecCommand(command string) *exec.Cmd {
return ExecCommandWith("cmd", command)
}
// ExecCommandWith executes the given command with cmd. _shell parameter is
// ignored on Windows.
func Exec... | // +build windows
package util
import (
"fmt"
"os"
"os/exec"
"syscall"
)
// ExecCommand executes the given command with cmd
func ExecCommand(command string) *exec.Cmd {
return ExecCommandWith("cmd", command)
}
// ExecCommandWith executes the given command with cmd. _shell parameter is
// ignored on Windows.
fu... | Fix compilation error of Windows binary | Fix compilation error of Windows binary
| Go | mit | infokiller/fzf,wilywampa/fzf,stuha/wbr-zsh,infokiller/fzf,janlazo/fzf,wilywampa/fzf,infokiller/fzf,junegunn/fzf,junegunn/fzf,janlazo/fzf,junegunn/fzf,janlazo/fzf,wilywampa/fzf |
7de0c75ebf23b40a4b3d2fd95a59ce28f9551f33 | app/app.go | app/app.go | package app
import (
"fmt"
"os"
"path/filepath"
"regexp"
"sync"
"github.com/stevenjack/cig/output"
"github.com/stevenjack/cig/repo"
)
func Handle(repoList map[string]string, projectTypeToCheck string, filter string, output_channel chan output.Payload) {
var wg sync.WaitGroup
for projectType, path := range ... | package app
import (
"fmt"
"os"
"path/filepath"
"regexp"
"sync"
"github.com/stevenjack/cig/output"
"github.com/stevenjack/cig/repo"
)
func Handle(repoList map[string]string, projectTypeToCheck string, filter string, output_channel chan output.Payload) {
var wg sync.WaitGroup
for projectType, path := range ... | Fix crash/panic when in wrong directory. | Fix crash/panic when in wrong directory.
Resolves #26, closes #32 and closes #27
| Go | mit | stevenjack/cig,stevenjack/cig |
843949d477ac9d038a4a320c005e0b58ed5c052b | go/libkb/secret_store_other.go | go/libkb/secret_store_other.go | // Copyright 2015 Keybase, Inc. All rights reserved. Use of
// this source code is governed by the included BSD license.
// +build !darwin,!android
package libkb
import "os"
func NewSecretStoreAll(g *GlobalContext) SecretStoreAll {
// In order to not break production build releases, only
// use the SecretStoreFil... | // Copyright 2015 Keybase, Inc. All rights reserved. Use of
// this source code is governed by the included BSD license.
// +build !darwin,!android
package libkb
func NewSecretStoreAll(g *GlobalContext) SecretStoreAll {
return NewSecretStoreFile(g.Env.GetDataDir())
}
| Remove env flag around NewSecretStoreFile | Remove env flag around NewSecretStoreFile
| Go | bsd-3-clause | keybase/client,keybase/client,keybase/client,keybase/client,keybase/client,keybase/client,keybase/client,keybase/client,keybase/client,keybase/client,keybase/client,keybase/client |
045e5f482cfb44bd40ca0750d8ff67bbaabd5fbc | src/gadget/lexer/lexer.go | src/gadget/lexer/lexer.go | package lexer
type Lexer struct {
input string
position int // current position in input (points to current char)
readPosition int // current reading position in input (after current char)
ch byte // current char being looked at
}
func New(input string) *Lexer {
l := &Lexer{input: input}
... | package lexer
import "gadget/token"
type Lexer struct {
input string
position int // current position in input (points to current char)
readPosition int // current reading position in input (after current char)
ch byte // current char being looked at
}
func New(input string) *Lexer {
l :=... | Implement remaining Lexer functions for tests to pass. | Implement remaining Lexer functions for tests to pass.
| Go | mit | vkandola/go-go-gadget,vkandola/go-go-gadget |
0a3f4daa47c97f8ceef5662839364c4c8b2f041a | system/fakes/fake_ps_runner.go | system/fakes/fake_ps_runner.go | package fakes
import boshsys "github.com/cloudfoundry/bosh-utils/system"
type FakePSRunner struct {
RunCommands []boshsys.PSCommand
RunCommandErr error
}
func NewFakePSRunner() *FakePSRunner {
return &FakePSRunner{
RunCommands: []boshsys.PSCommand{},
}
}
func (r *FakePSRunner) RunCommand(cmd boshsys.PSComma... | package fakes
import (
"fmt"
boshsys "github.com/cloudfoundry/bosh-utils/system"
)
type FakePSRunner struct {
RunCommands []boshsys.PSCommand
RunCommandErr error
runCommandErrors map[string]error
}
func NewFakePSRunner() *FakePSRunner {
return &FakePSRunner{
RunCommands: []boshsys.PSCommand{},
... | Add a way to trigger specific errors on the PSRunner | Add a way to trigger specific errors on the PSRunner
Signed-off-by: Ben Moss <80bec717c12290923c80384e0a5fc28cdf75a97e@pivotal.io>
| Go | apache-2.0 | cloudfoundry/bosh-utils,cloudfoundry/bosh-utils |
a9d7dee03864dcea888e4ed0700af40a8d45d1ce | locket_client.go | locket_client.go | package locket
import (
"code.cloudfoundry.org/cfhttp"
"code.cloudfoundry.org/lager"
"code.cloudfoundry.org/locket/models"
"google.golang.org/grpc"
"google.golang.org/grpc/credentials"
)
type ClientLocketConfig struct {
LocketAddress string `json:"locket_address,omitempty"`
LocketCACertFile string `... | package locket
import (
"code.cloudfoundry.org/cfhttp"
"code.cloudfoundry.org/lager"
"code.cloudfoundry.org/locket/models"
"google.golang.org/grpc"
"google.golang.org/grpc/credentials"
)
type ClientLocketConfig struct {
LocketAddress string `json:"locket_address,omitempty" yaml:"locket_address,omitempty"... | Add YAML serialization to ClientLocketConfig | Add YAML serialization to ClientLocketConfig
[#139885407]
Signed-off-by: Edwin Xie <6bc24e9c160281972837d9e13287696d26612564@pivotal.io>
| Go | apache-2.0 | cloudfoundry-incubator/locket |
52268cfeb67eb48c79d77a539e8dc790d1a6a9bb | version/version.go | version/version.go | // The version package provides a location to set the release versions for all
// packages to consume, without creating import cycles.
//
// This package should not import any other terraform packages.
package version
import (
"fmt"
version "github.com/hashicorp/go-version"
)
// The main version number that is bei... | // The version package provides a location to set the release versions for all
// packages to consume, without creating import cycles.
//
// This package should not import any other terraform packages.
package version
import (
"fmt"
version "github.com/hashicorp/go-version"
)
// The main version number that is bei... | Fix the Filesystem state manager tests | states/statemgr: Fix the Filesystem state manager tests
Now that we're verifying the Terraform version during state loading, we
need to force a particular Terraform version to use during these tests.
| Go | mpl-2.0 | hashicorp/terraform-plugin-sdk,hashicorp/terraform-plugin-sdk |
aad1da3724f93a8a77557ad84658171bc5860828 | turbulence/manifest_v2.go | turbulence/manifest_v2.go | package turbulence
import "github.com/pivotal-cf-experimental/destiny/ops"
type ConfigV2 struct {
Name string
AZs []string
DirectorHost string
DirectorUsername string
DirectorPassword string
DirectorCACert string
}
func NewManifestV2(config ConfigV2) (string, error) {
return ops... | package turbulence
import "github.com/pivotal-cf-experimental/destiny/ops"
type ConfigV2 struct {
Name string
AZs []string
DirectorHost string
DirectorUsername string
DirectorPassword string
DirectorCACert string
}
func NewManifestV2(config ConfigV2) (string, error) {
return ops... | Fix ops file for turbulence manifest | Fix ops file for turbulence manifest
Signed-off-by: Rowan Jacobs <f6a1b0cdf5ee40839db77d8af28f9a0cbe9aba71@pivotal.io>
| Go | apache-2.0 | pivotal-cf-experimental/destiny,pivotal-cf-experimental/destiny |
426b9479126683191fa286f6f55450b1e10b68ae | operator/cmd/vault-operator/main.go | operator/cmd/vault-operator/main.go | package main
import (
"context"
"runtime"
stub "github.com/banzaicloud/bank-vaults/operator/pkg/stub"
sdk "github.com/operator-framework/operator-sdk/pkg/sdk"
sdkVersion "github.com/operator-framework/operator-sdk/version"
"github.com/sirupsen/logrus"
)
func printVersion() {
logrus.Infof("Go Version: %s", ru... | package main
import (
"context"
"os"
"runtime"
stub "github.com/banzaicloud/bank-vaults/operator/pkg/stub"
sdk "github.com/operator-framework/operator-sdk/pkg/sdk"
sdkVersion "github.com/operator-framework/operator-sdk/version"
"github.com/sirupsen/logrus"
)
const operatorNamespace = "OPERATOR_NAMESPACE"
fu... | Configure the operator namespace over an environment variable | Configure the operator namespace over an environment variable
| Go | apache-2.0 | banzaicloud/bank-vaults,banzaicloud/bank-vaults |
1df89be624ae8c286ba36f203ec9d76e419ffd55 | backends/file_store.go | backends/file_store.go | package backends
type FileStore interface {
// create new file at path
CreateFile(path string, content []byte) (err error)
// update existing file at path
UpdateFile(path string, content []byte) (err error)
// create dir at path
CreateDir(path string) (err error)
// read content of file at path
ReadFile(pat... | package backends
type FileStore interface {
// create new file at path
CreateFile(path string, content []byte) (err error)
// update existing file at path
UpdateFile(path string, content []byte) (err error)
// create dir at path
CreateDir(path string) (err error)
// read content of file at path
ReadFile(pat... | Add ReadDirTree to file store interface. | Add ReadDirTree to file store interface.
| Go | mit | Marktown/frontend,Marktown/frontend,Marktown/frontend |
8060673a31c99276896618c0e62714b107404c84 | app.go | app.go | package main
import (
"github.com/codegangsta/martini"
"github.com/codegangsta/martini-contrib/render"
)
func main() {
m := martini.Classic()
m.Use(render.Renderer())
m.Get("/", func() string {
return "Merry Christmas!"
})
m.Get("/wishes", func(r render.Render) {
r.HTML(200, "l... | package main
import (
"github.com/codegangsta/martini"
"github.com/codegangsta/martini-contrib/binding"
"github.com/codegangsta/martini-contrib/render"
"gopkg.in/mgo.v2"
)
type Wish struct {
Name string `form:"name"`
Description string `form:"name"`
}
// DB Returns a martini.Handler
func DB() marti... | Add MongoDB + post route handling | Add MongoDB + post route handling
| Go | mit | xasos/Christmas |
426a5b361c3846b006889462a4d80290e7dd70f6 | events/uuid.pb.go | events/uuid.pb.go | // Code generated by protoc-gen-gogo.
// source: uuid.proto
// DO NOT EDIT!
package events
import proto "github.com/gogo/protobuf/proto"
import math "math"
// Reference imports to suppress errors if they are not otherwise used.
var _ = proto.Marshal
var _ = math.Inf
// / Type representing a 128-bit UUID.
type UUID ... | // Code generated by protoc-gen-gogo.
// source: uuid.proto
// DO NOT EDIT!
package events
import proto "github.com/gogo/protobuf/proto"
import math "math"
// Reference imports to suppress errors if they are not otherwise used.
var _ = proto.Marshal
var _ = math.Inf
// / Type representing a 128-bit UUID.
//
// The ... | Update dropsonde-protocol to revision 9057f01 | Update dropsonde-protocol to revision 9057f01
* Documentation-only change, but docs are compiled through to generated Go code.
[#93019308]
Signed-off-by: John Tuley <b62d404e513eecfa92cb060d3427723b1e04fc4e@pivotal.io>
| Go | apache-2.0 | cloudfoundry/noaa,cloudfoundry/noaa |
a73298789497065a8581142160d97533e4c76735 | player.go | player.go | package TF2RconWrapper
type Player struct {
UserID string
Username string
SteamID string
Ping int
State string
Ip string
}
| package TF2RconWrapper
type Player struct {
UserID string
Username string
SteamID string
//Ping int
//State string
Ip string
}
| Comment out ping and state fields (for now) | Comment out ping and state fields (for now)
| Go | mit | TF2Stadium/TF2RconWrapper |
39ee639934ece9a764d4191b4d90f93dc9044d3f | ouitools_test.go | ouitools_test.go | // Package go-oui provides functions to work with MAC and OUI's
package ouitools
import (
"fmt"
"log"
"testing"
)
func Test(*testing.T) {
d := &OuiDb{}
err := d.Load("oui.txt")
if err != nil {
log.Fatal("Error %v", err)
}
address, _ := ParseMAC("60:03:08:a0:ec:a6")
block := d.Lookup(address)
fmt.Printl... | // Package go-oui provides functions to work with MAC and OUI's
package ouidb
import (
"fmt"
"log"
"testing"
)
func Test(*testing.T) {
d := &OuiDb{}
err := d.Load("oui.txt")
if err != nil {
log.Fatal("Error %v", err)
}
address, _ := ParseMAC("60:03:08:a0:ec:a6")
block := d.Lookup(address)
fmt.Println("... | Change test file package to match main package name | Change test file package to match main package name
Signed-off-by: Claudio Matsuoka <ef7f691d9947ca9adbfeb1538a53a661ec9f041b@gmail.com>
| Go | mit | dutchcoders/go-ouitools,cmatsuoka/ouidb |
e64d309c09406a91de28a52767d5eae99dec5218 | wall_street_test.go | wall_street_test.go | package wall_street_test
import (
. "github.com/onsi/ginkgo"
. "github.com/onsi/gomega"
)
var _ = Describe("Wall Street", func() {
It("is not fully implemented", func() {
Expect(true).To(BeFalse())
})
})
| package wall_street_test
import (
"io"
"wall_street"
. "github.com/onsi/ginkgo"
. "github.com/onsi/gomega"
)
var _ = Describe("Wall Street", func() {
Describe("Readline", func() {
It("it reads from stdin and returns a string", func() {
simulateSTDIN("The return of the Archons", func(r io.Reader) {
read... | Write a better failing test | Write a better failing test
| Go | mit | tjarratt/wall_street |
eb3f64578a364957cc342f9dc73a54cde948900f | src/github.com/cloudfoundry-incubator/bits-service-performance-tests/app_push_test.go | src/github.com/cloudfoundry-incubator/bits-service-performance-tests/app_push_test.go | package main_test
import (
. "github.com/onsi/ginkgo"
. "github.com/onsi/gomega"
. "github.com/onsi/gomega/gexec"
"github.com/cloudfoundry-incubator/cf-test-helpers/generator"
"time"
"github.com/cloudfoundry-incubator/cf-test-helpers/cf"
)
var _ = Describe("Pushing an app", func() {
It("stops the time for p... | package main_test
import (
. "github.com/onsi/ginkgo"
. "github.com/onsi/gomega"
. "github.com/onsi/gomega/gexec"
"github.com/cloudfoundry-incubator/cf-test-helpers/generator"
"time"
"github.com/cloudfoundry-incubator/cf-test-helpers/cf"
)
var _ = Describe("Pushing an app", func() {
It("stops the time for p... | Add sparse-avg suffix to metrics name | Add sparse-avg suffix to metrics name
This enables us to see this metric even when specifying a time window of more than 24h in logmet.
Signed-off-by: Alexander Egurnov <7763625750474092f7412e5c40b7d702fa97cda8@de.ibm.com>
| Go | apache-2.0 | cloudfoundry-incubator/bits-service-release,cloudfoundry-incubator/bits-service-release,cloudfoundry-incubator/bits-service-release,cloudfoundry-incubator/bits-service-release |
1f6334fbefad5da5ca72fa0df4abb69ba5e62026 | router/file_server_routes.go | router/file_server_routes.go | package router
const (
FS_STATIC = "static"
FS_UPLOAD_DROPLET = "upload_droplet"
FS_UPLOAD_BUILD_ARTIFACTS = "upload_build_artifacts"
FS_DOWNLOAD_BUILD_ARTIFACTS = "download_build_artifacts"
)
func NewFileServerRoutes() Routes {
return Routes{
{Path: "/static/", Method: "GET", Han... | package router
const (
FS_STATIC = "static"
FS_UPLOAD_DROPLET = "upload_droplet"
FS_UPLOAD_BUILD_ARTIFACTS = "upload_build_artifacts"
FS_DOWNLOAD_BUILD_ARTIFACTS = "download_build_artifacts"
)
func NewFileServerRoutes() Routes {
return Routes{
{Path: "/v1/static/", Method: "GET", ... | Update file server routes with API version | Update file server routes with API version
Signed-off-by: Max Brunsfeld <8ee73e75b50cc292b5052b11f2ca25336d3e974e@pivotallabs.com>
| Go | apache-2.0 | cloudfoundry-incubator/runtime-schema |
fb0fbdd9a6959c5fd729a1d64d07474297174b4c | gocat.go | gocat.go | package main
import (
"fmt"
"io"
"os"
)
var ARGV []string
func main() {
ARGV = os.Args[1:]
// If there are no arguments, then we read STDIN
if len(ARGV) == 0 {
ARGV = append(ARGV, "-")
}
// Iterate arguments to read filenames
for _, filename := range ARGV {
// - means read stdin as a special case, we ... | package main
import (
"fmt"
"io"
"os"
)
var ARGV []string
var exitcode int
func main() {
ARGV = os.Args[1:]
exitcode = 0
// If there are no arguments, then we read STDIN
if len(ARGV) == 0 {
ARGV = append(ARGV, "-")
}
// Iterate arguments to read filenames
for _, filename := range ARGV {
// - means re... | Exit with correct code on error | Exit with correct code on error
| Go | mit | caius/gocat |
002dd3ffcf9bc730bc15f8aa62291b61735cd08e | set1/challenge01/hexToBase64/hexToBase64_test.go | set1/challenge01/hexToBase64/hexToBase64_test.go | package hexToBase64
import "testing"
func TestHexToBase64(t *testing.T) {
cases := []struct {
in, want string
fails bool
}{
{
"49276d206b696c6c696e6720796f757220627261696e206c696b65206120706f69736f6e6f7573206d757368726f6f6d",
"SSdtIGtpbGxpbmcgeW91ciBicmFpbiBsaWtlIGEgcG9pc29ub3VzIG11c2hyb29t",
fals... | package hexToBase64
import "testing"
func TestHexToBase64(t *testing.T) {
cases := []struct {
in, want string
fails bool
}{
{
"",
"",
false,
},
{
"49276d206b696c6c696e6720796f757220627261696e206c696b65206120706f69736f6e6f7573206d757368726f6f6d",
"SSdtIGtpbGxpbmcgeW91ciBicmFpbiBsaWtlIGEgc... | Add zero value test case to challenge 1 | Add zero value test case to challenge 1
| Go | mit | eseymour/cryptopals |
2f1cdf25d84bb02018bca7afa3511b543dd5fea0 | challenge46.go | challenge46.go | // Challenge 46 - RSA parity oracle
// http://cryptopals.com/sets/6/challenges/46
package cryptopals
import "math/big"
type challenge46 struct {
}
type parityOracleServer struct {
priv privateKey
}
func (server *parityOracleServer) isOdd(c *big.Int) bool {
m := server.priv.decrypt(c)
mod := big.NewInt(2)
mod ... | // Challenge 46 - RSA parity oracle
// http://cryptopals.com/sets/6/challenges/46
package cryptopals
import "math/big"
type challenge46 struct {
}
type parityOracleServer struct {
priv privateKey
}
func (server *parityOracleServer) isOdd(c *big.Int) bool {
m := server.priv.decrypt(c)
mod := big.NewInt(2)
mod ... | Fix division by two when decrypting (I was actually dividing by 2^e instead of just 2) | Fix division by two when decrypting (I was actually dividing by 2^e instead of just 2)
| Go | mit | Metalnem/cryptopals-go,Metalnem/cryptopals-go,Metalnem/cryptopals-go |
df56314b95e3c8bf44bc17de7d35038843bb71bd | agent/logger/seelog_config.go | agent/logger/seelog_config.go | // Copyright 2014-2015 Amazon.com, Inc. or its affiliates. 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. A copy of the
// License is located at
//
// http://aws.amazon.com/apache2.0/
//
// or in the "license... | // Copyright 2014-2015 Amazon.com, Inc. or its affiliates. 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. A copy of the
// License is located at
//
// http://aws.amazon.com/apache2.0/
//
// or in the "license... | Change log archive to none | Change log archive to none
Logs should be retained for 24 hours and deleted. Previous retention
setting of "zip" unintentionally retained logs in a zip file internal to
the container, causing increased CPU load, memory, and disk usage
related to hourly rotation.
| Go | apache-2.0 | aws/amazon-ecs-agent,aws/amazon-ecs-agent,kiranmeduri/amazon-ecs-agent,swipely/amazon-ecs-agent,aws/amazon-ecs-agent,kiranmeduri/amazon-ecs-agent,swipely/amazon-ecs-agent,kiranmeduri/amazon-ecs-agent,swipely/amazon-ecs-agent,aws/amazon-ecs-agent,kiranmeduri/amazon-ecs-agent,swipely/amazon-ecs-agent |
44a755d8b63abda2ed250414f5b6a1e6d70efbd4 | stove.go | stove.go | package main
import (
"github.com/HearthSim/stove/bnet"
"github.com/HearthSim/stove/pegasus"
)
func main() {
serv := bnet.NewServer()
serv.RegisterGameServer("WTCG", pegasus.NewServer(serv))
serv.ListenAndServe("localhost:1119")
}
| package main
import (
"fmt"
"github.com/HearthSim/stove/bnet"
"github.com/HearthSim/stove/pegasus"
)
const (
CONN_HOST = "localhost"
CONN_PORT = 1119
)
func main() {
serv := bnet.NewServer()
serv.RegisterGameServer("WTCG", pegasus.NewServer(serv))
addr := fmt.Sprintf("%s:%d", CONN_HOST, CONN_PORT)
fmt.Prin... | Add some output on startup | Add some output on startup
| Go | agpl-3.0 | synap5e/stove,oftc-ftw/stove,synap5e/stove,synap5e/stove,oftc-ftw/stove,oftc-ftw/stove |
b2f43945768d7ef24b8cad9666f0a06f0141e8f7 | state/kv_test.go | state/kv_test.go | package state
import (
"os"
"testing"
)
func TestKVStore(t *testing.T) {
kv := KVStore{
DbFileName: "test.db",
BucketName: "Test",
}
kv.Init()
defer kv.Close()
err := kv.Set([]byte("foo"), []byte("bar"))
if err != nil {
t.Error("Counter not incremented")
}
value := kv.Get([]byte("foo"))
if string(v... | package state
import (
"os"
"testing"
)
func TestKVStore(t *testing.T) {
kv := KVStore{
DbFileName: "test.db",
BucketName: "Test",
}
kv.Init()
defer kv.Close()
err := kv.Set([]byte("foo"), []byte("bar"))
if err != nil {
t.Error("Counter not incremented")
}
value := kv.Get([]byte("foo"))
if string(v... | Add test to ensure we actually delete a key | Add test to ensure we actually delete a key
| Go | mit | patrobinson/go-fish,patrobinson/go-fish |
53718c8c91135a823c28eac05c73269fe6491df3 | cache/redis/redis.go | cache/redis/redis.go | package redis
import (
"github.com/DMarby/picsum-photos/cache"
"github.com/mediocregopher/radix/v3"
)
// Provider implements a redis cache
type Provider struct {
pool *radix.Pool
}
// New returns a new Provider instance
func New(address string, poolSize int) (*Provider, error) {
// Use the default pool, which ha... | package redis
import (
"github.com/DMarby/picsum-photos/cache"
"github.com/mediocregopher/radix/v3"
)
// Provider implements a redis cache
type Provider struct {
pool *radix.Pool
}
// New returns a new Provider instance
func New(address string, poolSize int) (*Provider, error) {
// Use the default pool, which ha... | Use radix.MaybeNil for detecting if something doesn't exist in the cache | Use radix.MaybeNil for detecting if something doesn't exist in the cache
| Go | mit | DMarby/unsplash-it,DMarby/unsplash-it |
dc3762a5bcfe060acc06d923ea52ccf5058a271a | listcmd.go | listcmd.go | // Copyright (C) 2017 Damon Revoe. All rights reserved.
// Use of this source code is governed by the MIT
// license, which can be found in the LICENSE file.
package main
func listPackages(workspacedir, pkgpath string) error {
packageIndex, err := buildPackageIndex(pkgpath)
if err != nil {
return err
}
packag... | // Copyright (C) 2017 Damon Revoe. All rights reserved.
// Use of this source code is governed by the MIT
// license, which can be found in the LICENSE file.
package main
import (
"log"
"github.com/spf13/cobra"
)
func listPackages() error {
packageIndex, err := buildPackageIndex(flags.pkgPath)
if err != nil {
... | Add the 'list' command using cobra | Add the 'list' command using cobra
| Go | mit | revl/autoforge |
316208bf23abed1623b2c229884b98fcec482f82 | database_accessor.go | database_accessor.go | package nigronimgosession
import (
"net/http"
"github.com/gorilla/context"
mgo "gopkg.in/mgo.v2"
)
type DatabaseAccessor struct {
*mgo.Session
url string
name string
}
func NewDatabaseAccessor(url, name, string) (*DatabaseAccessor, error) {
session, err := mgo.Dial(url)
if err == nil {
return &DatabaseAc... | package nigronimgosession
import (
"net/http"
"github.com/gorilla/context"
mgo "gopkg.in/mgo.v2"
)
type DatabaseAccessor struct {
*mgo.Session
url string
name string
coll string
}
func NewDatabaseAccessor(url, name, coll string) (*DatabaseAccessor, error) {
session, err := mgo.Dial(url)
if err == nil {
... | Revert the database accessor cahnges | Revert the database accessor cahnges
| Go | mit | joeljames/nigroni-mgo-session |
347325dacf796bc28298fe5fcc73ee84749c023f | client/testutil/driver_compatible.go | client/testutil/driver_compatible.go | package testutil
import (
"os/exec"
"runtime"
"syscall"
"testing"
)
func ExecCompatible(t *testing.T) {
if runtime.GOOS != "windows" && syscall.Geteuid() != 0 {
t.Skip("Must be root on non-windows environments to run test")
}
}
func QemuCompatible(t *testing.T) {
// Check if qemu exists
_, err := exec.Comm... | package testutil
import (
"os/exec"
"runtime"
"syscall"
"testing"
)
func ExecCompatible(t *testing.T) {
if runtime.GOOS != "windows" && syscall.Geteuid() != 0 {
t.Skip("Must be root on non-windows environments to run test")
}
}
func QemuCompatible(t *testing.T) {
// Check if qemu exists
bin := "qemu-system... | Use same binary as Fingerprint in the QemuCompatible function | Use same binary as Fingerprint in the QemuCompatible function
| Go | mpl-2.0 | nak3/nomad,dvusboy/nomad,barnardb/nomad,barnardb/nomad,carlosdp/nomad,mattyr/nomad,dvusboy/nomad,kmalec/nomad,achanda/nomad,martin416/nomad,hashicorp/nomad,xytis/nomad,burdandrei/nomad,savaki/nomad,frundh/nomad,ranjib/nomad,kmalec/nomad,xytis/nomad,achanda/nomad,carlosdp/nomad,diptanu/nomad,achanda/nomad,xytis/nomad,na... |
94920c2b147df8eea7bf4cd1c5fad77c17993bda | app.go | app.go | package main
import (
"html/template"
"log"
"net/http"
)
type Blog struct {
Articles map[string]*Article
}
func (b *Blog) getArticle(slug string) *Article {
if article := b.Articles[slug]; article != nil {
return article
}
return nil
}
func (b *Blog) articleHandler(w http.ResponseWriter, r *http.... | package main
import (
"html/template"
"log"
"net/http"
)
type Blog struct {
Articles map[string]*Article
}
func (b *Blog) getArticle(slug string) *Article {
if article := b.Articles[slug]; article != nil {
return article
}
return nil
}
func (b *Blog) articleHandler(w http.ResponseWriter, r *http.... | Return when the article is not found and avoid render the template | Return when the article is not found and avoid render the template
| Go | mit | andrielfn/blogo |
32ac2e259597f8fad2fda3a85de7ca6ed408be64 | dom.go | dom.go | package dom
/*
* Implements a very small, very non-compliant subset of the DOM Core Level 2
*/
// DOM2: http://www.w3.org/TR/DOM-Level-2-Core/core.html#ID-1950641247
type Node interface {
NodeName() string;
}
// DOM2: http://www.w3.org/TR/DOM-Level-2-Core/core.html#ID-745549614
type Element interface {
Node;
... | package dom
/*
* Implements a very small, very non-compliant subset of the DOM Core Level 2
*/
// DOM2: http://www.w3.org/TR/DOM-Level-2-Core/core.html#ID-1950641247
type Node interface {
NodeName() string;
}
// DOM2: http://www.w3.org/TR/DOM-Level-2-Core/core.html#ID-745549614
type Element interface {
Node;
... | Rename internal structures to shorter names. Change return type of ParseString() to Document instead of *Document | Rename internal structures to shorter names. Change return type of ParseString() to Document instead of *Document
| Go | bsd-3-clause | ErfanAkbarimanesh/godom,grmartin/godom,grmartin/godom,ErfanAkbarimanesh/godom |
d436c4dc053d8e690179fe8dafdccef86d5f1fd8 | pkg/db/schema/schema.go | pkg/db/schema/schema.go | package schema
import "time"
type Service struct {
ID string `gorethink:"id"`
Name string `gorethink:"name"`
Type string `gorethink:"_type"`
Current bool `gorethink:"current"`
CTime time.Time `gorethink:"ctime"`
}
type Service2Template struct {
ID string `gorethink:"id"`
Ser... | package schema
import "time"
// A Service is a named service that has a set of templates associated with it.
type Service struct {
ID string `gorethink:"id"`
Name string `gorethink:"name"`
Type string `gorethink:"_type"` // The type of service.
Current bool `gorethink:"current"` // Is t... | Add comments and documentation to definitions. | Add comments and documentation to definitions.
| Go | apache-2.0 | a2sdl/etcfs |
c367a94e343af3027592a2fb9b9bbeb55ea663aa | repo/identity.go | repo/identity.go | package repo
type Identity struct {
Name string
Email string
}
func (i *Identity) hasName() bool {
return i.Name != ""
}
func (i *Identity) hasEmail() bool {
return i.Email != ""
}
func (i *Identity) String() string {
str := ""
if i.hasName() {
str += "\tName: " + i.Name
}
if i.hasEmail() {
str += "\tE... | package repo
type Identity struct {
Name string
Email string
}
func (i *Identity) hasName() bool {
return i.Name != ""
}
func (i *Identity) hasEmail() bool {
return i.Email != ""
}
func (i *Identity) String() string {
str := ""
if i.hasName() {
str += " Name: " + i.Name + "\n"
}
if i.hasEmail() {
str ... | Improve string representation of Identity | Improve string representation of Identity
| Go | mit | prydonius/karn,howdoicomputer/karn |
f41f372d5a6c29f279f1e3e8901e531e6c5c3c8b | pkg.go | pkg.go | // Define helper / mock for unit testing
//
// Because golang likes return error object instead of exception/panic,
// always handle error return values is a good practise. But sometimes it is
// impossible to got error, such as read from memory buffer, not handler them
// maybe maybe loose error because someday code c... | // Package testing define helper / mock for unit testing
//
// Because golang likes return error object instead of exception/panic,
// always handle error return values is a good practise. But sometimes it is
// impossible to got error, such as read from memory buffer, not handler them
// maybe maybe loose error becaus... | Fix two doc comment format | Fix two doc comment format
| Go | apache-2.0 | redforks/testing |
74934f0aa59141418ee8346d26eba9f36ed2fae3 | parseTime_test.go | parseTime_test.go | package main
import (
"testing"
"time"
)
func TestParseTime(t *testing.T) {
message := []byte{0x24, 0x4b, 0xbb, 0x9a, 0xc9, 0xf0}
utcDate := time.Now().UTC()
wanted := time.Date(utcDate.Year(), utcDate.Month(), utcDate.Day(),
10, 19, 26, 999999984, time.UTC)
result := parseTime(message)
if result != want... | package main
import (
"testing"
"time"
)
func TestParseTime(t *testing.T) {
message := []byte{0x24, 0x4b, 0xbb, 0x9a, 0xc9, 0xf0}
utcDate := time.Now().UTC()
wanted := time.Date(utcDate.Year(), utcDate.Month(), utcDate.Day(),
10, 19, 26, 999999984, time.UTC)
result := parseTime(message)
if result != want... | Add benchmarks for parseTime func | Add benchmarks for parseTime func
| Go | bsd-3-clause | mafonso/go1090 |
3da4e90d4393be281cf409bead9aa3860415a87b | example/shirtsize.go | example/shirtsize.go | // Copyright 2014 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 main
import (
"encoding/json"
"log"
"os"
)
//go:generate jsonenums -type=ShirtSize
type ShirtSize byte
const (
NA ShirtSize = iota
XS
S
M
L
... | // Copyright 2014 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 main
import (
"encoding/json"
"log"
"os"
)
//go:generate jsonenums -type=ShirtSize
type ShirtSize byte
const (
NA ShirtSize = iota
XS
S
M
L
... | Move the go:generate comments one line up to avoid documenting the type | Move the go:generate comments one line up to avoid documenting the type
| Go | apache-2.0 | daved/jsonenums,daved/jsonenums,matryer/jsonenums,matryer/jsonenums,campoy/jsonenums,campoy/jsonenums |
e6190f0d7fc44b4fd5e94da972142604a6142575 | spinner.go | spinner.go | // See LICENSE.txt for licensing information.
package main
import (
"fmt"
"strings"
)
var (
SPINNER_STRINGS = []string{"◢ ", "◣ ", "◤ ", "◥ "}
SPINNER_LEN = len(SPINNER_STRINGS)
)
type Spinner struct {
running bool // indiacte we're actually printing
msg string // current message
pos int ... | // See LICENSE.txt for licensing information.
package main
import (
"fmt"
"strings"
)
var (
SPINNER_STRINGS = []string{"◢ ", "◣ ", "◤ ", "◥ "}
SPINNER_LEN = len(SPINNER_STRINGS)
)
type Spinner struct {
running bool // indiacte we're actually printing
msg string // current message
pos int ... | Fix comment; They were never runes | Fix comment; They were never runes
| Go | bsd-2-clause | drbig/saver |
fb07c82fbcb3627df2f688b7e0cdb0d1f6f80b44 | runtime/decode.go | runtime/decode.go | package runtime
import (
"encoding/json"
"fmt"
"reflect"
"github.com/golang/protobuf/jsonpb"
"github.com/golang/protobuf/proto"
)
// Decode decodes the specified val into the specified target.
func Decode(target interface{}, val string) error {
return decode(reflect.ValueOf(target).Elem(), val)
}
func decode(... | package runtime
import (
"encoding/json"
"fmt"
"reflect"
"github.com/golang/protobuf/jsonpb"
"github.com/golang/protobuf/proto"
)
// Decode decodes the specified val into the specified target.
func Decode(target interface{}, val string) error {
return decode(reflect.ValueOf(target).Elem(), val)
}
func decode(... | Fix support for unmarshaling to string types when the value is valid json otherwise. | Fix support for unmarshaling to string types when the value is valid json otherwise.
| Go | mit | AmandaCameron/protoc-gen-gokit |
912e0b466c04e4ff48bca46f454a75192431fd7e | src/lib/desugar/names_test.go | src/lib/desugar/names_test.go | package desugar
import (
"testing"
"github.com/stretchr/testify/assert"
"github.com/tisp-lang/tisp/src/lib/ast"
)
func TestNamesFind(t *testing.T) {
n := "x"
assert.True(t, newNames(n).find(ast.NewLetVar(n, n)).include(n))
}
| package desugar
import (
"testing"
"github.com/stretchr/testify/assert"
"github.com/tisp-lang/tisp/src/lib/ast"
"github.com/tisp-lang/tisp/src/lib/debug"
)
func TestNamesFindWithLetVar(t *testing.T) {
n := "x"
assert.True(t, newNames(n).find(ast.NewLetVar(n, n)).include(n))
}
func TestNamesFindWithLetFunction... | Test names with let-function nodes | Test names with let-function nodes
| Go | mit | raviqqe/tisp,tisp-lang/tisp,tisp-lang/tisp,raviqqe/tisp,raviqqe/tisp |
96b0edfec51e03d24cd78c8d661d1401b04cd686 | zip/ziputils/SaveReaderToFile.go | zip/ziputils/SaveReaderToFile.go | package ziputils
import (
. "github.com/francoishill/golang-web-dry/errors/checkerror"
"io"
"os"
)
func SaveReaderToFile(logger SimpleLogger, bodyReader io.Reader, saveFilePath string) {
out, err := os.Create(saveFilePath)
CheckError(err)
defer out.Close()
_, err = io.Copy(out, bodyReader)
CheckError(err)
}
| package ziputils
import (
. "github.com/francoishill/golang-web-dry/errors/checkerror"
"io"
"os"
"path/filepath"
"github.com/francoishill/golang-web-dry/osutils"
)
func SaveReaderToFile(logger SimpleLogger, bodyReader io.Reader, saveFilePath string) {
fullDestinationDirPath := filepath.Dir(saveFilePath)
if !o... | Create file parent dir if not exist. | Create file parent dir if not exist.
| Go | mit | francoishill/golang-web-dry |
ee5760bfd3a58d7d45a9cb3c2a12bd9232df96bc | server/logger.go | server/logger.go | package server
import (
"net/http"
"time"
"github.com/influxdata/chronograf"
)
// Logger is middleware that logs the request
func Logger(logger chronograf.Logger, next http.Handler) http.Handler {
fn := func(w http.ResponseWriter, r *http.Request) {
now := time.Now()
logger.
WithField("component", "server... | package server
import (
"net/http"
"time"
"github.com/influxdata/chronograf"
)
type logResponseWriter struct {
http.ResponseWriter
responseCode int
}
func (l *logResponseWriter) WriteHeader(status int) {
l.responseCode = status
l.ResponseWriter.WriteHeader(status)
}
// Logger is middleware that logs the re... | Add HTTP status code to logs | Add HTTP status code to logs
This adds the status code to the response log message to make it easier
to diagnose issues. It also replaces the placeholder "Success" message
with the decoded value of the HTTP Status, resulting in messages like:
INFO[0041] Response: Temporary Redirect code=307
...and s... | Go | mit | mark-rushakoff/influxdb,nooproblem/influxdb,influxdb/influxdb,influxdb/influxdb,influxdb/influxdb,nooproblem/influxdb,mark-rushakoff/influxdb,li-ang/influxdb,li-ang/influxdb,influxdb/influxdb,mark-rushakoff/influxdb,influxdb/influxdb,nooproblem/influxdb,influxdata/influxdb,influxdb/influxdb,nooproblem/influxdb,mark-rus... |
7b680c07ac57d9d6484979301f6f395ede0c36c8 | asciidocgo_test.go | asciidocgo_test.go | package asciidocgo
import "testing"
import . "github.com/smartystreets/goconvey/convey"
func TestAsciidocgo(t *testing.T) {
Load(nil)
Convey("Asciidocgo takes a Reader and return a Document", t, func() {
Convey("A nil Reader must returns a nil Document", func() {
So(Load(nil), ShouldBeNil)
})
})
... | package asciidocgo
import "testing"
import . "github.com/smartystreets/goconvey/convey"
func TestAsciidocgo(t *testing.T) {
Load(nil)
Convey("Asciidocgo load() takes a string and return a Document", t, nil)
Convey("Asciidocgo load() takes a array and return a Document", t, nil)
Convey("Asciidocgo load() ... | Add input entry test declaration for Asciidocgo. | Add input entry test declaration for Asciidocgo.
| Go | mit | bep/asciidocgo,VonC/asciidocgo |
44598ef2a9f1dc8051ab8dd256e7dde1921088cb | loader.go | loader.go | package main
import (
"io/ioutil"
)
// Reader defines an interface that implements the
// methods to read files from some resource and translate
// it to File instances
type Reader interface {
Read(path string) ([]File, error)
}
// DiskReader defines a implementation of the
// Reader interface to read files from D... | package main
import (
"fmt"
"io/ioutil"
)
// Reader defines an interface that implements the
// methods to read files from some resource and translate
// it to File instances
type Reader interface {
Read(path string) ([]File, error)
}
// DiskReader defines a implementation of the
// Reader interface to read files... | Fix on Loader (missing "/") | Fix on Loader (missing "/")
| Go | mit | mauricioklein/text-search-engine |
941d11815088934c10a4e17066dcaeb432e54a90 | handlers/metrics.go | handlers/metrics.go | package handlers
import (
"github.com/prometheus/client_golang/prometheus"
)
var (
RedirectHandlerRedirectCountMetric = prometheus.NewCounterVec(
prometheus.CounterOpts{
Name: "router_redirect_handler_redirect_total",
Help: "Number of redirects handled by router redirect handlers",
},
[]string{
"redi... | package handlers
import (
"github.com/prometheus/client_golang/prometheus"
)
var (
RedirectHandlerRedirectCountMetric = prometheus.NewCounterVec(
prometheus.CounterOpts{
Name: "router_redirect_handler_redirect_total",
Help: "Number of redirects handled by router redirect handlers",
},
[]string{
"redi... | Adjust histogram buckets for faster responses | Adjust histogram buckets for faster responses
At the moment, router's metrics bucket response times into:
* Less than 250ms
* 250ms - 500ms
* 500ms - 1s
* 1s - 2s
* 2s - 4s
* 4s - 8s
* More than 8s
From looking at our metrics, the majority of our responses complete in
less than 250ms, so this is not a particularly u... | Go | mit | alphagov/router |
7fec1ff26cc47f08782af65831815339014d49d1 | server/auth/handler.go | server/auth/handler.go | package auth
import (
"encoding/json"
"fmt"
"github.com/gorilla/mux"
"net/http"
)
const (
tokenCookieName = "access_token"
)
func AddRoutes(r *mux.Router, service Service) {
// Explicitly only serve login over https.
r.HandleFunc("/login", func(w http.ResponseWriter, r *http.Request) {
decoder := json.NewD... | package auth
import (
"encoding/json"
"fmt"
"github.com/gorilla/mux"
"net/http"
)
const (
tokenCookieName = "access_token"
)
func AddRoutes(r *mux.Router, service Service) {
// Do not serve these routes over http.
r.HandleFunc("/login", func(w http.ResponseWriter, r *http.Request) {
decoder := json.NewDeco... | Remove schemes matcher from auth routes. It seems broken | Remove schemes matcher from auth routes. It seems broken
| Go | mit | DiscoViking/website,DiscoViking/website,DiscoViking/website,DiscoViking/website,DiscoViking/website |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.