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
f2d2387cdc7f66706bd27c5b5fdd3f697d0ca592
format/ssh_test.go
format/ssh_test.go
package format import ( "testing" log "github.com/Sirupsen/logrus" "github.com/stretchr/testify/assert" ) func TestSsh(t *testing.T) { log.SetLevel(log.DebugLevel) keys := map[string][]string{ "ernoaapa": []string{ "ssh-rsa AAAAB3NzsshPublicKeyBlah", }, } result := ssh(keys) assert.Equal(t, "ssh-r...
package format import ( "testing" log "github.com/Sirupsen/logrus" "github.com/stretchr/testify/assert" ) func TestSsh(t *testing.T) { log.SetLevel(log.DebugLevel) keys := map[string][]string{ "ernoaapa": { "ssh-rsa AAAAB3NzsshPublicKeyBlah", }, } result := ssh(keys) assert.Equal(t, "ssh-rsa AAAAB...
Fix code style based on feedback from `gofmt -s`
Fix code style based on feedback from `gofmt -s`
Go
apache-2.0
arnested/fetch-ssh-keys,ernoaapa/fetch-ssh-keys
17187685fba4907d90cd545015cff21b8483732a
src/gadget/lexer/lexer.go
src/gadget/lexer/lexer.go
package lexer
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 } return l }
Add Lexer struct and New function for it
Add Lexer struct and New function for it
Go
mit
vkandola/go-go-gadget,vkandola/go-go-gadget
fbc019dd4b60a6b81eccc35a9e2f0f357d293d53
parser/parser_test.go
parser/parser_test.go
package parser import ( "bufio" "fmt" "os" "testing" ) func TestParser(t *testing.T) { r, err := os.Open("monitor") if err != nil { t.Error(err) } br := bufio.NewReader(r) bd := NewBabelDesc() err = bd.Fill(br) if err != nil { t.Error(err) } fmt.Println("Fill\n", bd) err = bd.Fill(br) if err != nil...
package parser import ( "bufio" "fmt" "os" "testing" ) func TestParser(t *testing.T) { r, err := os.Open("monitor") if err != nil { t.Error(err) } br := bufio.NewReader(r) bd := NewBabelDesc() err = bd.Fill(br) if err != nil { t.Error(err) } if testing.Verbose() { fmt.Println("Fill\n", bd) } err ...
Make parser test less verbose by default.
Make parser test less verbose by default.
Go
mit
Vivena/babelweb2,Vivena/babelweb2,Vivena/babelweb2
1c1f2703940c4f5645f1969d57fbc1b3132a9bd0
examples/meddler/main.go
examples/meddler/main.go
package main import ( "log" "time" "github.com/gchaincl/sqlhooks" _ "github.com/mattn/go-sqlite3" "github.com/russross/meddler" ) type Person struct { ID int `meddler:"id,pk"` Name string `meddler:"name"` Age int `meddler:"age"` Created time.Time `meddler:"created,localtime"` } t...
package main import ( "log" "time" "github.com/gchaincl/sqlhooks" _ "github.com/mattn/go-sqlite3" "github.com/russross/meddler" ) type Person struct { ID int `meddler:"id,pk"` Name string `meddler:"name"` Age int `meddler:"age"` Created time.Time `meddler:"created,localtime"` } t...
Remove ID from meddler example
Remove ID from meddler example
Go
mit
gchaincl/sqlhooks
af173743ca07a1d343abe50384378f9155b6a273
stdin/stdin.go
stdin/stdin.go
package stdin import ( "os" ) // This is a tricky problem and we have gone through several iterations before // settling on something that works well for recent golang across windows, // linux and macos. func IsReadable() bool { fi, err := os.Stdin.Stat() if err != nil { return false } // Named pipes on unix...
package stdin import ( "os" ) // This is a tricky problem and we have gone through several iterations before // settling on something that works well for recent golang across windows, // linux and macos. func IsReadable() bool { fi, err := os.Stdin.Stat() if err != nil { return false } // Character devices i...
Use os.ModeCharDevice instead of os.ModeNamedPipe
Use os.ModeCharDevice instead of os.ModeNamedPipe
Go
mit
buildkite/agent,buildkite/agent,buildkite/agent
dcb14c6b23d1ae880d966b0afb335109cae24e3d
test/escape1.go
test/escape1.go
// errchk $G $D/$F.go // Copyright 2009 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 func out_escapes() (x int, p *int) { p = &x; // ERROR "address.*out parameter" return; } func out_escapes() (x int, p *i...
// errchk $G $D/$F.go // Copyright 2009 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 func out_escapes() (x int, p *int) { p = &x; // ERROR "address of out parameter" return; } func out_escapes_2() (x int, ...
Rename function to avoid function redefinition error. Remove .* from regexp since it confuses DejaGNU which runs gcc's testsuite.
Rename function to avoid function redefinition error. Remove .* from regexp since it confuses DejaGNU which runs gcc's testsuite. R=rsc DELTA=3 (0 added, 0 deleted, 3 changed) OCL=24435 CL=24438
Go
bsd-3-clause
nightlyone/golang,apparentlymart/golang,pombredanne/go-deleteme,firebitsbr/golang-old,firebitsbr/golang-old,tv42/old-go,firebitsbr/golang-old,wesolows/golang-old,tv42/old-go,tv42/old-go,firebitsbr/golang-old,ssrl/go,ssrl/go,h8liu/golang,wesolows/golang,firebitsbr/golang-old,wesolows/golang-old,apparentlymart/golang,ssr...
3d24c0529c8fdb5abebaade72859f7dc0e903262
server.go
server.go
package main import ( "log" "net" ) func StartServer() { listener, err := net.Listen("tcp", Config.String("listen")) if err != nil { log.Fatal(err) } defer listener.Close() for { conn, err := listener.Accept() if err != nil { log.Fatal(err) } go communicate(conn) } } func communicate(conn net.Co...
package main import ( "log" "net" ) func StartServer() { listener, err := net.Listen("tcp", Config.String("listen")) if err != nil { log.Fatal(err) } defer listener.Close() for { conn, err := listener.Accept() if err != nil { log.Fatal(err) } go communicate(conn) } } func communicate(conn net.Co...
Change inf command to nfo and remove err messages
Change inf command to nfo and remove err messages
Go
mit
PolyFloyd/ledcubesim,PolyFloyd/ledcubesim,PolyFloyd/ledcubesim
e4fef29dc95c0964573c0bbc19ad2d916ba9b399
main.go
main.go
package main import "html/template" import "log" import "net/http" import "time" import "github.com/stianeikeland/go-rpio" const GPIOPin = 18 const DelaySeconds = 5 type gpioHandler struct { pin rpio.Pin } func GpioHandler(pin rpio.Pin) http.Handler { return &gpioHandler{pin} } func (f *gpioHandler) ServeHTTP...
package main import "html/template" import "log" import "net/http" import "time" import "github.com/stianeikeland/go-rpio" const GPIOPin = 18 const DelaySeconds = 5 type gpioHandler struct { pin rpio.Pin } func GpioHandler(pin rpio.Pin) http.Handler { return &gpioHandler{pin} } func (f *gpioHandler) ServeHTTP...
Use member instead of constant.
Use member instead of constant.
Go
apache-2.0
hatstand/hodoor,hatstand/hodoor,hatstand/hodoor
6436a2abc48e4112ac3c4c5645975e54cd14bd0d
main.go
main.go
package main import ( "bufio" "flag" "log" "os" "github.com/bfontaine/edn" ) func main() { flag.Parse() // buffered I/O makes my 55M-file benchmark go 3x times faster input := bufio.NewReader(os.Stdin) output := bufio.NewWriter(os.Stdout) // This takes ~5.8s on my 55M benchmark file err := edn.PPrintStr...
package main import ( "bufio" "flag" "log" "os" "gopkg.in/bfontaine/edn.v1" ) func main() { flag.Parse() // buffered I/O makes my 55M-file benchmark go 3x times faster input := bufio.NewReader(os.Stdin) output := bufio.NewWriter(os.Stdout) // This takes ~5.8s on my 55M benchmark file err := edn.PPrintSt...
Use a released version of the edn fork
Use a released version of the edn fork
Go
mit
bfontaine/epp,bfontaine/epp
49a19bb69b8f2573ba6630f5e9b564d304d51536
main.go
main.go
package main import ( "github.com/hashicorp/terraform/plugin" "github.com/finn-no/terraform-provider-softlayer/softlayer" ) func main() { plugin.Serve(&plugin.ServeOpts{ ProviderFunc: softlayer.Provider, }) }
package main import ( "github.com/finn-no/terraform-provider-softlayer/softlayer" "github.com/hashicorp/terraform/plugin" ) func main() { plugin.Serve(&plugin.ServeOpts{ ProviderFunc: softlayer.Provider, }) }
Fix formatting to comply with go fmt
Fix formatting to comply with go fmt This means tabs for indentation and spaces for alignment.
Go
apache-2.0
TheWeatherCompany/terraform-provider-softlayer,finn-no/terraform-provider-softlayer
5d1de45e2b26351aa868ad1fb4121f2bcacaa1c3
cl_windowslinux.go
cl_windowslinux.go
// +build windows linux package clw11 /* #cgo LDFLAGS: -lOpenCL #include "CL/opencl.h" */ import "C" import ( "errors" ) const ( GLContext ContextProperties = C.CL_GL_CONTEXT_KHR EGLDisplay ContextProperties = C.CL_EGL_DISPLAY_KHR GLXDisplay ContextProperties = C.CL_GLX_DISPLAY_KHR WGLHDC Conte...
// +build windows linux package clw11 /* #cgo LDFLAGS: -lOpenCL #include "CL/opencl.h" */ import "C" import ( "errors" ) const ( GLContext ContextProperties = C.CL_GL_CONTEXT_KHR EGLDisplay ContextProperties = C.CL_EGL_DISPLAY_KHR GLXDisplay ContextProperties = C.CL_GLX_DISPLAY_KHR WGLHDC Cont...
Fix build issues on darwin.
Fix build issues on darwin.
Go
mit
rdwilliamson/clw11
7db07de599f0cdcccfa3a5d7a788d312e378b9dc
cli/flag_access.go
cli/flag_access.go
package cli import ( "fmt" "github.com/jwaldrip/odin/cli/values" ) // Flag returns the Value interface to the value of the named flag, // returning nil if none exists. func (cmd *CLI) Flag(name string) values.Value { flag := cmd.getFlag(name) value := cmd.flagValues[flag] return value } // Flags returns the fl...
package cli import ( "fmt" "github.com/jwaldrip/odin/cli/values" ) // Flag returns the Value interface to the value of the named flag, // panics if none exists. func (cmd *CLI) Flag(name string) values.Value { flag := cmd.getFlag(name) value := cmd.flagValues[flag] return value } // Flags returns the flags as ...
Clarify behavior documented in tests.
Clarify behavior documented in tests.
Go
mit
jwaldrip/odin
dfc49dce9dfaa813328d352fe4f81d39de179139
lib/x509util/getPermittedMethods.go
lib/x509util/getPermittedMethods.go
package x509util import ( "crypto/x509" "encoding/asn1" "fmt" "github.com/Symantec/Dominator/lib/constants" "strings" ) func getPermittedMethods(cert *x509.Certificate) (map[string]struct{}, error) { methodList := make(map[string]struct{}) for _, extension := range cert.Extensions { if extension.Id.String() ...
package x509util import ( "crypto/x509" "encoding/asn1" "fmt" "github.com/Symantec/Dominator/lib/constants" "strings" ) func getPermittedMethods(cert *x509.Certificate) (map[string]struct{}, error) { methodList := make(map[string]struct{}) for _, extension := range cert.Extensions { if extension.Id.String() ...
Remove deprecated methods encoding in lib/x509util.GetPermittedMethods().
Remove deprecated methods encoding in lib/x509util.GetPermittedMethods().
Go
apache-2.0
Symantec/Dominator,keep94/Dominator,Symantec/Dominator,rgooch/Dominator,Symantec/Dominator,rgooch/Dominator,keep94/Dominator,rgooch/Dominator,keep94/Dominator
e5571f073387496478d9cd8665978d7eb1ce6995
leetcode/6_zigzag_conversion.go
leetcode/6_zigzag_conversion.go
package leetcode // 6. ZigZag Conversion func convert(s string, numRows int) string { if numRows == 1 { return s } strs := make([][]rune, numRows) diff := numRows - 2 for i, c := range s { p := i % (numRows + diff) if p < numRows { strs[p] = append(strs[p], c) } else { p = (p - numRows - diff) * -...
package leetcode // 6. ZigZag Conversion func convert(s string, numRows int) string { if numRows == 1 { return s } bs := make([][]byte, numRows) i := 0 for i < len(s) { for j := 0; i < len(s) && j < numRows; j++ { bs[j] = append(bs[j], s[i]) i++ } for j := numRows - 2; i < len(s) && j > 0; j-- { ...
Fix 6. ZigZag Conversion with inner loop approach
Fix 6. ZigZag Conversion with inner loop approach
Go
mit
motomux/go-algo
bf739142c88471b434526a898bc32737399aa043
cmd/lib/shell/cmd_line_tool.go
cmd/lib/shell/cmd_line_tool.go
package shell import ( "github.com/codegangsta/cli" "strings" ) func SetUp() cli.Command { cmd := cli.Command{ Name: "shell", Usage: "BQL shell", Action: Launch, } cmd.Flags = []cli.Flag{ cli.StringFlag{ Name: "uri", Value: "http://localhost:8090/api", Usage: "target URI to launch", En...
package shell import ( "github.com/codegangsta/cli" "strings" ) func SetUp() cli.Command { cmd := cli.Command{ Name: "shell", Usage: "BQL shell", Description: "shell command launches an interactive shell for BQL", Action: Launch, } cmd.Flags = []cli.Flag{ cli.StringFlag{ Name: "ur...
Remove environment variables having too general names
Remove environment variables having too general names
Go
mit
sensorbee/sensorbee,sensorbee/sensorbee
8583b1af41c7d10833cffeb5dcd1046df29b1f0e
api/endpoints/project_group_index_test.go
api/endpoints/project_group_index_test.go
package api_test func (t *testSuite) TestProjectGroupIndex_Get() { t.T().Skip("Not yet implemented") }
package api_test import "testing" func TestProjectGroupIndex_Get(t *testing.T) { t.Skip("Not yet implemented") }
Change testify/suite to the stdlib *testing.T
Change testify/suite to the stdlib *testing.T
Go
mit
diyan/assimilator,diyan/assimilator,diyan/assimilator
36e09e4c2d209dfbc91cd8879f71b171bbf50b64
fleetspeak/src/server/internal/ftime/retry.go
fleetspeak/src/server/internal/ftime/retry.go
// Copyright 2017 Google Inc. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // // https://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed to in...
// Copyright 2017 Google Inc. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // // https://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed to in...
Reduce the wait time before re-sending a message.
Reduce the wait time before re-sending a message.
Go
apache-2.0
google/fleetspeak,google/fleetspeak,google/fleetspeak
9fdc42d09061f01b3fb86f04d5b545e6338a514d
Sessions.go
Sessions.go
package main import "net" type SessionManager struct { allSessions []Session } func (s *SessionManager) StartSession(conn *net.Conn) { var ses Session ses.Init(conn, s) }
package main import "net" type SessionManager struct { allSessions []Session } func (s *SessionManager) StartSession(conn *net.Conn) { var ses Session ses.Init(conn, s) } func (s *SessionManager) SendRequestToAllSessions(arwServer *ARWServer, obj ARWObject) { for ii := 0; ii < len(s.allSessions); ii++ { arw...
Send request to all sessions
Send request to all sessions
Go
mit
ertrkumut/ARWServer_1.0
1af531ba0ba483974416f16ab65f95c0a9af3753
workload/workers/engine.go
workload/workers/engine.go
// Copyright 2015 Canonical Ltd. // Licensed under the AGPLv3, see LICENCE file for details. package workers import ( "time" "github.com/juju/errors" "github.com/juju/juju/worker/dependency" ) const ( engineErrorDelay = 3 * time.Second engineBounceDelay = 10 * time.Second ) func newEngine() (dependency.Engi...
// Copyright 2015 Canonical Ltd. // Licensed under the AGPLv3, see LICENCE file for details. package workers import ( "time" "github.com/juju/errors" "github.com/juju/juju/worker/dependency" ) const ( engineErrorDelay = 3 * time.Second engineBounceDelay = 10 * time.Second ) func newEngine() (dependency.Engi...
Add doc comments to internal funcs.
Add doc comments to internal funcs.
Go
agpl-3.0
dooferlad/juju,reedobrien/juju,reedobrien/juju,frankban/juju,mikemccracken/juju,wwitzel3/juju,ericsnowcurrently/juju,bogdanteleaga/juju,ericsnowcurrently/juju,bogdanteleaga/juju,bogdanteleaga/juju,perrito666/juju,davecheney/juju,mjs/juju,anastasiamac/juju,bac/juju,dooferlad/juju,anastasiamac/juju,alesstimec/juju,davech...
78ca71857bb7a55e30235367aa12066622148592
cmd/kubeadm/app/constants/constants_windows.go
cmd/kubeadm/app/constants/constants_windows.go
// +build windows /* Copyright 2019 The Kubernetes Authors. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agr...
// +build windows /* Copyright 2019 The Kubernetes Authors. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agr...
Update Windows Pause version to 1.4.0
Update Windows Pause version to 1.4.0
Go
apache-2.0
zhangmingld/kubernetes,andrewsykim/kubernetes,fgimenez/kubernetes,kitt1987/kubernetes,JacobTanenbaum/kubernetes,jessfraz/kubernetes,tengqm/kubernetes,li-ang/kubernetes,yujuhong/kubernetes,mikedanese/kubernetes,saad-ali/kubernetes,tcnghia/kubernetes,pires/kubernetes,warmchang/kubernetes,chrislovecnm/kubernetes,warmchang...
bfa17b16b8c7ac0b081ea2c1ab7e92b052b70907
pkg/chunkymonkey/command/commandframework_test.go
pkg/chunkymonkey/command/commandframework_test.go
package command import ( "testing" ) const ( cmdText = "give" desc = "Gives x y to player z" usage = "Usage text" message = "/give 1 64 admin" ) func TestCommandFramework(t *testing.T) { cf := NewCommandFramework("/") cmdHandler := func(msg string) { if msg != message { t.Errorf("Input message %s is...
package command import ( "testing" ) const ( cmdText = "give" desc = "Gives x y to player z" usage = "Usage text" message = "/give 1 64 admin" ) func TestCommandFramework(t *testing.T) { NewCommandFramework("/") // TODO: Write test cases for CommandFramework and all commands }
Remove old test case of CommandFramework.
Remove old test case of CommandFramework.
Go
mit
huin/chunkymonkey,huin/chunkymonkey
e938a9d55b4cc3c155d9adb4ac547501111cc4e6
deck/conv_test.go
deck/conv_test.go
package deck_test import ( "github.com/whereswaldon/cryptage/deck" "testing" ) func TestBigIntStringConverstion(t *testing.T) { }
package deck_test import ( // "github.com/whereswaldon/cryptage/deck" "testing" ) func TestBigIntStringConverstion(t *testing.T) { }
Fix old test fouling up compilation
Fix old test fouling up compilation
Go
mit
whereswaldon/cryptage
1c2aed608f18a37e41e4a54b6b6da4a48b333533
petfind/petfind.go
petfind/petfind.go
package petfind import ( "errors" "time" ) var ErrNotFound = errors.New("item not found") // Pet holds information about each pet of the application. type Pet struct { ID int64 Name string Age int Added time.Time } // Store describes the operations the application needs for persisting and // retrieving ...
package petfind import ( "errors" "time" ) var ErrNotFound = errors.New("item not found") // Pet holds information about each pet of the application. type Pet struct { ID int64 Name string Age int Added time.Time } // Store describes the operations the application needs for persisting and // retrieving ...
Add article TODO for storing custom types in db
Add article TODO for storing custom types in db
Go
mit
psimika/secure-web-app
ee890b4167bc57fb3b6f5dd4e35fc3418a3cde03
prez-tweet-server/env.go
prez-tweet-server/env.go
package server import ( "errors" "fmt" "log" "os" "strconv" ) var apiHost, jsBundleURL, dynoID, twitterAPIToken string var webPort int func initEnv() (err error) { twitterAPIToken = os.Getenv("TWITTER_TOKEN") webPort, err = strconv.Atoi(os.Getenv("PORT")) if err != nil || webPort == 0 { log.Println("PORT n...
package server import ( "errors" "fmt" "log" "os" "strconv" ) var apiHost, jsBundleURL, herokuAppName, twitterAPIToken string var webPort int func initEnv() (err error) { twitterAPIToken = os.Getenv("TWITTER_TOKEN") webPort, err = strconv.Atoi(os.Getenv("PORT")) if err != nil || webPort == 0 { log.Println(...
Rename variable to make more sense given expected value
Rename variable to make more sense given expected value
Go
mit
fsufitch/prez-tweet,fsufitch/prez-tweet,fsufitch/prez-tweet,fsufitch/prez-tweet,fsufitch/prez-tweet
f9308c5beb7ee4235df0f79f503181655712d3bc
besticon/besticon/cmd.go
besticon/besticon/cmd.go
package main import ( "flag" "fmt" "github.com/mat/besticon/besticon" "os" ) func main() { all := flag.Bool("all", false, "Display all Icons, not just the best.") flag.Parse() if len(os.Args) <= 1 { fmt.Fprintf(os.Stderr, "please provide a URL.\n") os.Exit(100) } url := os.Args[len(os.Args)-1] icons,...
package main import ( "flag" "fmt" "io/ioutil" "os" "github.com/mat/besticon/besticon" ) func main() { besticon.SetLogOutput(ioutil.Discard) // Disable verbose logging all := flag.Bool("all", false, "Display all Icons, not just the best.") flag.Parse() if len(os.Args) <= 1 { fmt.Fprintf(os.Stderr, "plea...
Disable verbose logging in command line tool.
Disable verbose logging in command line tool.
Go
mit
mat/besticon,mat/besticon,mat/besticon
95f5796f338fff910b2e84b9e20c85917bf17208
src/cf/app_files_test.go
src/cf/app_files_test.go
package cf_test import ( . "cf" . "github.com/onsi/ginkgo" . "github.com/onsi/gomega" "path/filepath" ) var _ = Describe("AppFiles", func() { fixturePath := filepath.Join("..", "fixtures", "applications") Describe("AppFilesInDir", func() { It("all files have '/' path separators", func() { files, err := Ap...
package cf_test import ( . "cf" . "github.com/onsi/ginkgo" . "github.com/onsi/gomega" "path/filepath" "path" ) var _ = Describe("AppFiles", func() { fixturePath := filepath.Join("..", "fixtures", "applications") Describe("AppFilesInDir", func() { It("all files have '/' path separators", func() { files, e...
Fix app files test on windows
Fix app files test on windows
Go
apache-2.0
SrinivasChilveri/cli,markstgodard/cli,HuaweiTech/cli,pishro-cc/cli,EngineerBetter/cli,cgvarela/cli,srikanth88infy/cli,saravana76/cli,ReachingOut/cli,rastasheep/trash-can,TomG713/cli,mcowger/cli,fujitsu-cf/cli,markstgodard/cli,xingzhou/cli,18F/cli,saravana76/cli,diatmpravin/cli,SrinivasChilveri/cli,markstgodard/cli,xing...
854c97539720b44d4dbfbad448cae22fd5d1cc1c
fs/stat_linux.go
fs/stat_linux.go
package fs import ( "syscall" "time" ) // StatAtime returns the Atim func StatAtime(st *syscall.Stat_t) syscall.Timespec { return st.Atim } // StatCtime returns the Ctim func StatCtime(st *syscall.Stat_t) syscall.Timespec { return st.Ctim } // StatMtime returns the Mtim func StatMtime(st *syscall.Stat_t) syscal...
package fs import ( "syscall" "time" ) // StatAtime returns the Atim func StatAtime(st *syscall.Stat_t) syscall.Timespec { return st.Atim } // StatCtime returns the Ctim func StatCtime(st *syscall.Stat_t) syscall.Timespec { return st.Ctim } // StatMtime returns the Mtim func StatMtime(st *syscall.Stat_t) syscal...
Add comment about why an int64 conversion is needed in fs.StatATimeAsTime
Add comment about why an int64 conversion is needed in fs.StatATimeAsTime Signed-off-by: Tibor Vass <3f1326dff4d85ad4ec938fb33f64575ace96db26@docker.com>
Go
apache-2.0
containerd/continuity,stevvooe/continuity,stevvooe/continuity
aa787e84483a0004d98de72848b9409a2b22d08b
commands.go
commands.go
package main import ( "log" "os" "github.com/codegangsta/cli" ) var Commands = []cli.Command{ commandAll, commandBiz, commandHack, } var commandAll = cli.Command{ Name: "all", Usage: "", Description: ` `, Action: doAll, } var commandBiz = cli.Command{ Name: "biz", Usage: "", Description: ` `, Actio...
package main import ( "log" "os" "fmt" "github.com/codegangsta/cli" ) var Commands = []cli.Command{ commandAll, commandBiz, commandHack, } var commandAll = cli.Command{ Name: "all", Usage: "", Description: ` `, Action: doAll, } var commandBiz = cli.Command{ Name: "biz", Usage: "", Description: ` `,...
Add test command (*It can be tested with `go install` to get local test cli)
Add test command (*It can be tested with `go install` to get local test cli)
Go
mit
timakin/ts,timakin/ts
15d57b5132a6ea73cb3fbd58dff266359611e2ae
resource/origin.go
resource/origin.go
// Copyright 2015 Canonical Ltd. // Licensed under the AGPLv3, see LICENCE file for details. package resource import ( "github.com/juju/errors" ) // These are the valid kinds of resource origin. const ( OriginKindUnknown OriginKind = "" OriginKindUpload OriginKind = "upload" OriginKindStore OriginKind = "stor...
// Copyright 2015 Canonical Ltd. // Licensed under the AGPLv3, see LICENCE file for details. package resource import ( "github.com/juju/errors" ) // These are the valid kinds of resource origin. const ( OriginKindUnknown OriginKind = "" OriginKindUpload OriginKind = "upload" OriginKindStore OriginKind = "stor...
Return OriginKindUnknown with parsing errors.
Return OriginKindUnknown with parsing errors.
Go
agpl-3.0
frankban/juju,perrito666/juju,kat-co/juju,dooferlad/juju,howbazaar/juju,mjs/juju,ericsnowcurrently/juju,anastasiamac/juju,davecheney/juju,macgreagoir/juju,kat-co/juju,marcmolla/juju,davecheney/juju,alesstimec/juju,dimitern/juju,bz2/juju,marcmolla/juju,mjs/juju,dimitern/juju,kat-co/juju,marcmolla/juju,AdamIsrael/juju,mj...
7ab214657f7f0c4fdb2e9d513151dde09a90c463
librariesio/cmd/librariesio/main.go
librariesio/cmd/librariesio/main.go
package main import ( "fmt" "os" "strings" "github.com/hackebrot/go-librariesio/librariesio" ) func loadFromEnv(keys ...string) (map[string]string, error) { env := make(map[string]string) for _, key := range keys { v := os.Getenv(key) if v == "" { return nil, fmt.Errorf("environment variable %q is req...
package main import ( "fmt" "os" "strings" "github.com/hackebrot/go-librariesio/librariesio" ) func loadFromEnv(keys ...string) (map[string]string, error) { env := make(map[string]string) for _, key := range keys { v := os.Getenv(key) if v == "" { return nil, fmt.Errorf("environment variable %q is req...
Update cmd to accept new return value
Update cmd to accept new return value
Go
mit
hackebrot/go-librariesio
eae6100549932dd145c8fc71afc573c0a4c20da2
handlers.go
handlers.go
package main import ( "net/http" "log" ) func Index(w http.ResponseWriter, r *http.Request) { body := NewRequest(r).GetBody() if config.FastPublish { if len(body) > 0 { servicesQueue.Publish(body) } return } service, err := NewService(body) response := NewResponse(w) if err != nil { response.Bod...
package main import ( "net/http" "log" ) func Index(w http.ResponseWriter, r *http.Request) { body := NewRequest(r).GetBody() if config.FastPublish { if len(body) > 0 { servicesQueue.Publish(body) } return } service, err := NewService(body) response := NewResponse(w) if err != nil { response.Bod...
Set accepted status when successfully published.
Set accepted status when successfully published.
Go
mit
andreiavrammsd/microservices-persistent-communication
8e8f92af1961482e5c0c2e0adb2b3f55c7274833
sockets/sockets.go
sockets/sockets.go
// Package sockets provides helper functions to create and configure Unix or TCP sockets. package sockets import ( "errors" "net" "net/http" "time" ) // Why 32? See https://github.com/docker/docker/pull/8035. const defaultTimeout = 32 * time.Second // ErrProtocolNotAvailable is returned when a given transport pr...
// Package sockets provides helper functions to create and configure Unix or TCP sockets. package sockets import ( "errors" "net" "net/http" "time" ) const defaultTimeout = 10 * time.Second // ErrProtocolNotAvailable is returned when a given transport protocol is not provided by the operating system. var ErrProt...
Reduce default connection time to 10s (from 32s)
Reduce default connection time to 10s (from 32s) This helps to address https://github.com/docker/cli/issues/1739, where an invalid `DOCKER_HOST` setting could result in a 64s delay (that's twice the delay here because the client was trying to hit the `/_ping` endpoint twice, which was addressed in https://github.com/m...
Go
apache-2.0
docker/go-connections
280a0f52c4d78a4b4f80b5603310b479528ca1cb
lib/task_test.go
lib/task_test.go
package henchman import ( "testing" ) func TestPrepareTask(t *testing.T) { task := Task{"fake-uuid", "The {{ vars.variable1 }}", "The {{ vars.variable2 }}", false} vars := make(TaskVars) vars["variable1"] = "foo" vars["variable2"] = "bar" task.Prepare(&vars) if task.Name != "The foo" { t.Errorf("Template exe...
package henchman import ( "testing" ) func TestPrepareTask(t *testing.T) { task := Task{"fake-uuid", "The {{ vars.variable1 }}", "{{ vars.variable2 }}:{{ machine.Hostname }}", false} machine := Machine{"foobar", nil} vars := make(TaskVars) vars["variable1"] = "foo" vars["variable2"] = "bar" task.prepare(&vars...
Test cases for the machine context
Test cases for the machine context
Go
bsd-3-clause
sudharsh/henchman,sudharsh/henchman
8a21b128d4deb874c05eb81ebbc1265175ad69ba
daemon/graphdriver/overlayutils/overlayutils.go
daemon/graphdriver/overlayutils/overlayutils.go
// +build linux package overlayutils // import "github.com/docker/docker/daemon/graphdriver/overlayutils" import ( "fmt" "github.com/docker/docker/daemon/graphdriver" ) // ErrDTypeNotSupported denotes that the backing filesystem doesn't support d_type. func ErrDTypeNotSupported(driver, backingFs string) error { ...
// +build linux package overlayutils // import "github.com/docker/docker/daemon/graphdriver/overlayutils" import ( "fmt" "github.com/docker/docker/daemon/graphdriver" ) // ErrDTypeNotSupported denotes that the backing filesystem doesn't support d_type. func ErrDTypeNotSupported(driver, backingFs string) error { ...
Add additional message when backendfs is extfs without d_type support
Add additional message when backendfs is extfs without d_type support ext4 support d_type by default, but filetype feature is a tunable so there is still a chance to disable it for some reasons. In this case, print additional message to explicitly tell how to support d_type. Signed-off-by: Chengguang Xu <8ebc0bfff0a7...
Go
apache-2.0
thaJeztah/docker,nalind/docker,jthelin/docker,kolyshkin/moby,kolyshkin/moby,paralin/docker,trebonian/docker,tonistiigi/docker,Ramzec/docker,maxamillion/docker,yosifkit/docker,kojiromike/docker,scotttlin/docker,bearstech/moby,SvenDowideit/docker,konstruktoid/docker-upstream,johnstep/moby-moby,jvanz/docker,jwhonce/docker...
bbd63aaf89d17f76df98b44aeb32a3966512d352
memqueue.go
memqueue.go
package litetunes import ( "errors" "fmt" ) // MemoryQueue is an in-memory implementation of the Queue interface type MemoryQueue struct { tracks []*Track } // NewMemoryQueue constructs a new MemoryQueue to use func NewMemoryQueue() *MemoryQueue { return &MemoryQueue{tracks: []*Track{}} } // Queue adds a new tr...
package litetunes import ( "errors" "fmt" ) // MemoryQueue is an in-memory implementation of the Queue interface type MemoryQueue struct { tracks []*Track } // NewMemoryQueue constructs a new MemoryQueue to use func NewMemoryQueue() *MemoryQueue { return &MemoryQueue{tracks: []*Track{}} } // Queue adds a new tr...
Use m.Count() even inside pointer-struct functions
Use m.Count() even inside pointer-struct functions This way the backing datastore can be more easily mucked with
Go
isc
ciarand/litetunes
3c612cbfc86863adce406d105b8df4d1a2502f7c
cmd/torrent-create/main.go
cmd/torrent-create/main.go
package main import ( "io" "log" "os" "path/filepath" "strings" "github.com/docopt/docopt-go" "github.com/anacrolix/torrent/metainfo" ) var ( builtinAnnounceList = [][]string{ {"udp://tracker.openbittorrent.com:80"}, {"udp://tracker.publicbt.com:80"}, {"udp://tracker.istole.it:6969"}, } ) func main(...
package main import ( "log" "os" "github.com/anacrolix/tagflag" "github.com/anacrolix/torrent/metainfo" ) var ( builtinAnnounceList = [][]string{ {"udp://tracker.openbittorrent.com:80"}, {"udp://tracker.publicbt.com:80"}, {"udp://tracker.istole.it:6969"}, } ) func main() { log.SetFlags(log.Flags() | l...
Tidy up flags and remove redundant function calls
cmd/torrent-create: Tidy up flags and remove redundant function calls Issue #80
Go
mpl-2.0
anacrolix/torrent,anacrolix/torrent
64a2d2a3a2234a80b16081958b9dd2cfaad606eb
libnetwork/ipams/builtin/builtin_unix.go
libnetwork/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
cpuguy83/docker,moby/moby,flavio/docker,AkihiroSuda/docker,Ramzec/docker,nalind/docker,paralin/docker,paralin/docker,docker/docker,nalind/docker,nawawi/docker,cpuguy83/docker,cpuguy83/docker,jthelin/docker,Mokolea/docker,jameszhan/docker,vdemeester/docker,moby/moby,yosifkit/docker,konstruktoid/docker-upstream,mahak/doc...
a9642f1e61c63af83e70d191404d80139e4791f5
sudoku/celllist.go
sudoku/celllist.go
package sudoku type CellList []*Cell type intList []int func (self CellList) SameRow() bool { if len(self) == 0 { return true } row := self[0].Row for _, cell := range self { if cell.Row != row { return false } } return true } func (self CellList) CollectNums(fetcher func(*Cell) int) intList { var r...
package sudoku type CellList []*Cell type intList []int func (self CellList) SameRow() bool { return self.CollectNums(func(cell *Cell) int { return cell.Row }).Same() } func (self CellList) CollectNums(fetcher func(*Cell) int) intList { var result intList for _, cell := range self { result = append(result,...
Reimplement samerow in terms of CollectNums.
Reimplement samerow in terms of CollectNums.
Go
apache-2.0
jkomoros/sudoku,jkomoros/sudoku,jkomoros/sudoku
a9e8602b881e3fccb9ab7e72fff75f55b5740bb4
config/config.go
config/config.go
package config import ( "code.google.com/p/gcfg" "path/filepath" ) type Config struct { RabbitMq struct { Host string Username string Password string Port string Vhost string Queue string Compression bool } Prefetch struct { Count int Global bool } Excha...
package config import ( "gopkg.in/gcfg.v1" "path/filepath" ) type Config struct { RabbitMq struct { Host string Username string Password string Port string Vhost string Queue string Compression bool } Prefetch struct { Count int Global bool } Exchange st...
Update new repository for gcfg
Update new repository for gcfg
Go
mit
ricbra/rabbitmq-cli-consumer,ricbra/rabbitmq-cli-consumer
310c08cf58eef25fbda468fb1db97612b396bef6
repo/fsrepo/migrations/mfsr_test.go
repo/fsrepo/migrations/mfsr_test.go
package mfsr import ( "io/ioutil" "os" "testing" "github.com/ipfs/go-ipfs/thirdparty/assert" ) func testVersionFile(v string, t *testing.T) (rp RepoPath) { name, err := ioutil.TempDir("", v) if err != nil { t.Fatal(err) } rp = RepoPath(name) return rp } func TestVersion(t *testing.T) { rp := RepoPath(""...
package mfsr import ( "io/ioutil" "os" "strconv" "testing" "github.com/ipfs/go-ipfs/thirdparty/assert" ) func testVersionFile(v string, t *testing.T) (rp RepoPath) { name, err := ioutil.TempDir("", v) if err != nil { t.Fatal(err) } rp = RepoPath(name) return rp } func TestVersion(t *testing.T) { rp := ...
Update Version to reflect fsrepo change
Update Version to reflect fsrepo change License: MIT Signed-off-by: Zander Mackie <dad6048958a096c4d96d991a47a426a281ad31ed@gmail.com>
Go
mit
chriscool/go-ipfs,MichaelMure/go-ipfs,WilliButz/go-ipfs,Quantomicus/go-ipfs,ianopolous/go-ipfs,JustinDrake/go-ipfs,OpenBazaar/go-ipfs,kyledrake/go-ipfs,chriscool/go-ipfs,Quantomicus/go-ipfs,Luzifer/go-ipfs,ianopolous/go-ipfs,OpenBazaar/go-ipfs,ianopolous/go-ipfs,JustinDrake/go-ipfs,WilliButz/go-ipfs,chriscool/go-ipfs,J...
bb1c4db925a715716fdf7293051fa810858cd4a9
algoliasearch/check_key.go
algoliasearch/check_key.go
package algoliasearch func checkGenerateSecuredAPIKey(params Map) error { if err := checkQuery(params, "restrictIndices", "restrictSources", "userToken", "validUntil", ); err != nil { return err } for k, v := range params { switch k { case "restrictIndices", "restrictSources", "userToken": if _, ...
package algoliasearch func checkGenerateSecuredAPIKey(params Map) error { if err := checkQuery(params, "restrictIndices", "restrictSources", "userToken", "validUntil", "referers", ); err != nil { return err } for k, v := range params { switch k { case "restrictIndices", "restrictSources", "userTok...
Enable `referers` as parameter of GenerateSecuredAPIKey
changed: Enable `referers` as parameter of GenerateSecuredAPIKey
Go
mit
l4u/algoliasearch-client-go,algolia/algoliasearch-client-go,algolia/algoliasearch-client-go,l4u/algoliasearch-client-go
bc7b920406a3f0a142fb57335463628fb9949929
irc_test.go
irc_test.go
package irc import "testing" func TestMessageString(t *testing.T) { type tcase struct { msg Message; expected string; }; cases := []tcase { tcase { Message{Command: "command", Params: []string{}}, "command" }, tcase { Message{Command: "command", Params: []string{"one"}}, "command :one" }, ...
package irc import "testing" func TestMessageString(t *testing.T) { type tcase struct { msg Message; expected string; }; cases := []tcase { tcase { Message{Command: "command", Params: []string{}}, "command" }, tcase { Message{Command: "command", Params: []string{"one"}}, "command :one" }, ...
Remove dummy failure test case
Remove dummy failure test case
Go
mit
stefanha/bouncin
bd43cd097cc4e3d64aa7c47d1ed88a3dcdc6b32e
havenapi/models/models.go
havenapi/models/models.go
package models import ( "log" "github.com/gobuffalo/envy" "github.com/gobuffalo/packr/v2" "github.com/gobuffalo/pop" "github.com/nleof/goyesql" ) // DB is a connection to your database to be used // throughout your application. var DB *pop.Connection // Q is a map of SQL queries var Q goyesql.Queries func ini...
package models import ( "log" "github.com/gobuffalo/envy" "github.com/gobuffalo/packr/v2" "github.com/gobuffalo/pop" "github.com/nleof/goyesql" ) // DB is a connection to your database to be used // throughout your application. var DB *pop.Connection // Q is a map of SQL queries var Q goyesql.Queries func ini...
Fix deprecated API warning in buffalo packr
Fix deprecated API warning in buffalo packr Signed-off-by: Elliot Murphy <014ce8fab4ab9f8a957bfe9f974379093994de97@users.noreply.github.com>
Go
apache-2.0
kindlyops/mappamundi,kindlyops/mappamundi,kindlyops/mappamundi,kindlyops/mappamundi,kindlyops/mappamundi,kindlyops/mappamundi,kindlyops/mappamundi,kindlyops/mappamundi
4deb2609d2d3ca5fbc89496d88cca40a27b40fd9
bot/msgping.go
bot/msgping.go
package bot import ( "strings" "github.com/arachnist/gorepost/irc" ) func ping(output chan irc.Message, msg irc.Message) { if strings.Split(msg.Trailing, " ")[0] != ":ping" { return } output <- irc.Message{ Command: "PRIVMSG", Params: []string{msg.Prefix.Name}, Trailing: "pingity pong", } } func i...
package bot import ( "strings" "github.com/arachnist/gorepost/irc" ) func ping(output chan irc.Message, msg irc.Message) { if strings.Split(msg.Trailing, " ")[0] != ":ping" { return } output <- irc.Message{ Command: "PRIVMSG", Params: []string{msg.Prefix.Name}, Trailing: "pingity pong", } } func i...
Use a different identifier for user :ping command
Use a different identifier for user :ping command
Go
mit
arachnist/gorepost
c49c8f81b34273d842a9920b569a2cf14810a950
go/src/aoc17/problems/p01/p01.go
go/src/aoc17/problems/p01/p01.go
package p01 import ( "strconv" "fmt" ) func Solve(input string) (string, string) { return solve(input, 1), solve(input, len(input)/2) } func solve(input string, lookahead int) string { sum := 0 for i := 0; i < len(input); i += 1 { if input[i] == input[(i+lookahead)%len(input)] { v, err := strconv.ParseInt...
package p01 import ( "fmt" "common" ) func Solve(input string) (string, string) { return solve(input, 1), solve(input, len(input)/2) } func solve(input string, lookahead int) string { sum := 0 for i := 0; i < len(input); i += 1 { if input[i] == input[(i+lookahead)%len(input)] { sum += int(common.ToIntOrPan...
Make 2017.01 shorter by using custom parse function.
Make 2017.01 shorter by using custom parse function.
Go
apache-2.0
shaeberling/euler,shaeberling/euler,shaeberling/euler,shaeberling/euler
91bc49d87ca9c78db6a7e3dfc68e752063fdf1cf
example/large/main.go
example/large/main.go
package main import ( "github.com/sean-duffy/xlsx" "strconv" ) func main() { c := []xlsx.Column{ xlsx.Column{Name: "Col1", Width: 10}, xlsx.Column{Name: "Col2", Width: 10}, } sh := xlsx.NewSheetWithColumns(c, "MySheet") for i := 0; i < 10; i++ { r := sh.NewRow() r.Cells[0] = xlsx.Cell{ Type: xl...
package main import ( "github.com/sean-duffy/xlsx" "strconv" ) func main() { c := []xlsx.Column{ xlsx.Column{Name: "Col1", Width: 10}, xlsx.Column{Name: "Col2", Width: 10}, } sh := xlsx.NewSheetWithColumns(c) sh.Title = "MySheet" for i := 0; i < 10; i++ { r := sh.NewRow() r.Cells[0] = xlsx.Cell{ ...
Change example to conform to API
Change example to conform to API
Go
mit
psmithuk/xlsx,scraperwiki/xlsx
fef72651456546ef604497e028cce74713871741
path.go
path.go
// Copyright 2010 The draw2d Authors. All rights reserved. // created: 21/11/2010 by Laurent Le Goff package draw2d type Path interface { // Return the current point of the path LastPoint() (x, y float64) // Create a new subpath that start at the specified point MoveTo(x, y float64) // Create a new subpath that ...
// Copyright 2010 The draw2d Authors. All rights reserved. // created: 21/11/2010 by Laurent Le Goff package draw2d // PathBuilder define method that create path type Path interface { // Return the current point of the current path LastPoint() (x, y float64) // MoveTo start a new path at (x, y) position MoveTo(x...
Remove unecessary method in Path interface
Remove unecessary method in Path interface
Go
bsd-2-clause
xushiwei/draw2d,julianshen/draw2d,xushiwei/draw2d,sksullivan/draw2d,llgcode/draw2d,ninjasphere/draw2d,hellobond/draw2d,stephenwithav/draw2d
0e20ab7b104b869fef4160c6c876a8ed47318851
export/uploader/s3.go
export/uploader/s3.go
package uploader import ( "fmt" "os" "launchpad.net/goamz/aws" "launchpad.net/goamz/s3" ) const ( defaultS3BufferSize = 5 * 1024 * 1024 ) type S3 struct { Bucket *s3.Bucket BufferSize int64 } func (s3Uploader *S3) Init() error { s3Region := os.Getenv("S3_REGION") region, ok := aws.Regions[s3Region] if...
package uploader import ( "fmt" "os" "launchpad.net/goamz/aws" "launchpad.net/goamz/s3" ) const ( defaultS3BufferSize = 5 * 1024 * 1024 ) type S3 struct { Bucket *s3.Bucket BufferSize int64 } func (s3Uploader *S3) Init() error { s3Region := os.Getenv("S3_REGION") region, ok := aws.Regions[s3Region] i...
Change upload file to public read
Change upload file to public read
Go
mit
jingweno/travisarchive,jingweno/travisarchive,jingweno/travisarchive
f9a8c9a68124f765dbf727e286e4ff56b9d8b5b0
size_test.go
size_test.go
package gstrings import ( "github.com/wallclockbuilder/testify/assert" "testing" ) func TestSize(t *testing.T) { assert := assert.New(t) assert.Equal(5, Size("hello")) }
package gstrings import ( "fmt" "github.com/wallclockbuilder/testify/assert" "testing" ) func ExampleSize(){ fmt.Println(Size("hello")) // Output: 5 } func TestSize(t *testing.T) { assert := assert.New(t) assert.Equal(5, Size("hello")) }
Add documentation example for Size()
Add documentation example for Size()
Go
bsd-2-clause
wallclockbuilder/gstrings,wallclockbuilder/stringutil
d94eafef82a20c26d22ddbdf4def16d3e76e7540
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 { workerFunction func(params ...interface{}) ticker *time.Ticker duration time.Duration doneChannel chan bool } ...
package ActiveObject import ( "errors" "time" ) //ActiveObjectWithInterval implements IActiveObject with behavior running in a specified interval type ActiveObjectWithInterval struct { workerFunction func(params ...interface{}) ticker *time.Ticker duration time.Duration doneChannel chan bool } ...
Make sure the ticker stopped when ActiveObject.ForceStop() called
Make sure the ticker stopped when ActiveObject.ForceStop() called
Go
mit
irwansyahwii/Pattern-Oriented-Software-Architecture-With-Go
612177abbe1815533df4904f7e06544f98bd3a1a
out_test.go
out_test.go
package dragon import ( "bytes" "strings" "testing" ) func TestOut(t *testing.T) { libChan := make(chan lib) go func() { libChan <- lib{ pkg: "dragon", object: "Imports", path: "github.com/monochromegane/dragon-imports", } close(libChan) }() expect := `// AUTO-GENERATED BY dragon-imports ...
package dragon import ( "bytes" "strings" "testing" ) func TestOut(t *testing.T) { libChan := make(chan lib) go func() { libChan <- lib{ object: "Imports", path: "github.com/monochromegane/dragon-imports", } libChan <- lib{ object: "Imports", path: "github.com/someone/dragon-imports", } ...
Add duplicated package pattern test.
Add duplicated package pattern test.
Go
mit
monochromegane/dragon-imports
ef3c10c40305aa2a0ef791abc7cf66506b9573be
builder/amazon/common/regions.go
builder/amazon/common/regions.go
package common import ( "github.com/aws/aws-sdk-go/aws/session" "github.com/aws/aws-sdk-go/service/ec2" ) func listEC2Regions() []string { var regions []string // append regions that are not part of autogenerated list regions = append(regions, "us-gov-west-1", "cn-north-1", "cn-northwest-1") sess := session.Mu...
package common import ( "flag" "github.com/aws/aws-sdk-go/aws/session" "github.com/aws/aws-sdk-go/service/ec2" ) func listEC2Regions() []string { var regions []string sess := session.Must(session.NewSessionWithOptions(session.Options{ SharedConfigState: session.SharedConfigEnable, })) ec2conn := ec2.New(se...
Modify Validate Region for test cases
Modify Validate Region for test cases
Go
mpl-2.0
ricardclau/packer,paulmey/packer,tas50/packer,tas50/packer,dave2/packer,paulmey/packer,youhong316/packer,ricardclau/packer,pecigonzalo/packer,timsutton/packer,grubernaut/packer,ricardclau/packer,hashicorp/packer,paulmey/packer,bryson/packer,hashicorp/packer,mkuzmin/packer,grubernaut/packer,ricardclau/packer,tb3088/pack...
a829a44606a1daf593ff190248a1f8723b4db150
src/ghighlighter/models/highlights.go
src/ghighlighter/models/highlights.go
package models import ( "path" "io/ioutil" "os" "encoding/json" "ghighlighter/utils" ) type GhHighlights struct { items []GhHighlight } func (m *GhHighlights) GetAll() []GhHighlight { m.Read() return m.items } func highlightsFilePath() string { return path.Join(utils.DataDir(), "highlights.json") ...
package models import ( "path" "io/ioutil" "os" "encoding/json" "ghighlighter/utils" ) type GhHighlights struct { Items []GhHighlight } func highlightsFilePath() string { return path.Join(utils.DataDir(), "highlights.json") } func (m *GhHighlights) Read() { data, error := ioutil.ReadFile(highlightsF...
Remove Highlights.GetAll and make Items public
Remove Highlights.GetAll and make Items public
Go
mit
chdorner/ghighlighter
c96e2e1d264d393c7f8f898313c26b58dbb00c8b
cookbook/graceful-shutdown/server.go
cookbook/graceful-shutdown/server.go
package main import ( "context" "net/http" "os" "os/signal" "time" "github.com/labstack/echo" "github.com/labstack/gommon/log" ) func main() { // Setup e := echo.New() e.Logger.SetLevel(log.INFO) e.GET("/", func(c echo.Context) error { time.Sleep(5 * time.Second) return c.JSON(http.StatusOK, "OK") })...
package main import ( "context" "net/http" "os" "os/signal" "time" "github.com/labstack/echo" "github.com/labstack/gommon/log" ) func main() { // Setup e := echo.New() e.Logger.SetLevel(log.INFO) e.GET("/", func(c echo.Context) error { time.Sleep(5 * time.Second) return c.JSON(http.StatusOK, "OK") })...
Use buffered channel for graceful shutdown
Use buffered channel for graceful shutdown According to https://golang.org/pkg/os/signal/#example_Notify buffered channel should be used to avoid missing signal.
Go
mit
labstack/echox,labstack/echox,labstack/echox
a2f72c955e24c3a37d1c6342f8fd4d774eb81896
lfs/util_generic.go
lfs/util_generic.go
// +build !linux,cgo package lfs import ( "io" ) func CloneFile(writer io.Writer, reader io.Reader) (bool, error) { return false, nil }
// +build !linux !cgo package lfs import ( "io" ) func CloneFile(writer io.Writer, reader io.Reader) (bool, error) { return false, nil }
Fix non linux with cgo build condition
Fix non linux with cgo build condition
Go
mit
ttaylorr/git-lfs,Jericho25/-git-lfs_miilkyway,dakotahawkins/git-lfs,github/git-lfs,andyneff/git-lfs,aleb/git-lfs,ttaylorr/git-lfs,Jericho25/-git-lfs_miilkyway,andyneff/git-lfs,bozaro/git-lfs,Jericho25/-git-lfs_miilkyway,ttaylorr/git-lfs,github/git-lfs,larsxschneider/git-lfs,larsxschneider/git-lfs,aleb/git-lfs,aleb/git-...
2517e13a5e7231029477bbfd02835e490c7b4a48
platforms/defaults_test.go
platforms/defaults_test.go
package platforms import ( "reflect" "runtime" "testing" specs "github.com/opencontainers/image-spec/specs-go/v1" ) func TestDefault(t *testing.T) { expected := specs.Platform{ OS: runtime.GOOS, Architecture: runtime.GOARCH, } p := DefaultSpec() if !reflect.DeepEqual(p, expected) { t.Fatalf("...
package platforms import ( "reflect" "runtime" "testing" specs "github.com/opencontainers/image-spec/specs-go/v1" ) func TestDefault(t *testing.T) { expected := specs.Platform{ OS: runtime.GOOS, Architecture: runtime.GOARCH, Variant: cpuVariant, } p := DefaultSpec() if !reflect.DeepEqual...
Add Variant field to default test expected result
ctr: Add Variant field to default test expected result This test case should cover the variant field now, as we have add Variant to default value of spec.platform. Change-Id: I8359007d40a4b8f6a072510fff2ba604a062afa1 Signed-off-by: Wei Chen <7bda119aa2bd1d28c0fb067e862b11d5acc5fc93@arm.com> Signed-off-by: Penny Zheng...
Go
apache-2.0
mikebrow/containerd,crosbymichael/containerd,vdemeester/containerd,miaoyq/containerd,crosbymichael/containerd,miaoyq/containerd,mikebrow/containerd,dmcgowan/containerd,kunalkushwaha/containerd,containerd/containerd,estesp/containerd,dmcgowan/containerd,containerd/containerd,vdemeester/containerd,estesp/containerd,thaJe...
06b21da4606ce5d2b8130eea7b069ebe949346e4
cmd/fsbench/main.go
cmd/fsbench/main.go
package main import ( "fmt" "github.com/Symantec/Dominator/lib/fsbench" "os" ) // Benchmark the read speed of the underlying block device for a given file. func main() { pathname := "/" if len(os.Args) == 2 { pathname = os.Args[1] } bytesPerSecond, blocksPerSecond, err := fsbench.GetReadSpeed(pathname) if e...
package main import ( "fmt" "github.com/Symantec/Dominator/lib/fsbench" "os" ) // Benchmark the read speed of the underlying block device for a given file. func main() { pathname := "/" if len(os.Args) == 2 { pathname = os.Args[1] } bytesPerSecond, blocksPerSecond, err := fsbench.GetReadSpeed(pathname) if e...
Change fsbench utility to write errors to stderr rather than stdout.
Change fsbench utility to write errors to stderr rather than stdout.
Go
apache-2.0
Symantec/Dominator,Symantec/Dominator,keep94/Dominator,keep94/Dominator,keep94/Dominator,Symantec/Dominator,rgooch/Dominator,rgooch/Dominator,rgooch/Dominator
ff5fd25f40f578a47b0c7148bbfc551b2505b87e
exp/12/main.go
exp/12/main.go
package exp12 import ( "sync" "github.com/shurcooL/go/exp/13" "github.com/shurcooL/go/vcs" . "gist.github.com/7802150.git" ) // TODO: Use FileUri or similar type instead of string for clean path to repo root. // rootPath -> *VcsState var repos = make(map[string]*exp13.VcsState) var reposLock sync.Mutex type Di...
package exp12 import ( "sync" "github.com/shurcooL/go/exp/13" "github.com/shurcooL/go/vcs" . "gist.github.com/7802150.git" ) // TODO: Use FileUri or similar type instead of string for clean path to repo root. // rootPath -> *VcsState var repos = make(map[string]*exp13.VcsState) var reposLock sync.Mutex // TODO...
Replace NewDirectory() with LookupDirectory() that reuses *Directory for same path.
Replace NewDirectory() with LookupDirectory() that reuses *Directory for same path.
Go
mit
shurcooL/go
4f14c4995ea5d96d91caeb03bb2e700572c97660
cli/context/store/storeconfig.go
cli/context/store/storeconfig.go
package store // TypeGetter is a func used to determine the concrete type of a context or // endpoint metadata by returning a pointer to an instance of the object // eg: for a context of type DockerContext, the corresponding TypeGetter should return new(DockerContext) type TypeGetter func() interface{} // NamedTypeGe...
package store // TypeGetter is a func used to determine the concrete type of a context or // endpoint metadata by returning a pointer to an instance of the object // eg: for a context of type DockerContext, the corresponding TypeGetter should return new(DockerContext) type TypeGetter func() interface{} // NamedTypeGe...
Add a helper to iterate over all endpoint types in a context store
Add a helper to iterate over all endpoint types in a context store Unused for now. Signed-off-by: Ian Campbell <a8db091655a7f47ecb9c39a2d278e9662e440dc0@docker.com>
Go
apache-2.0
thaJeztah/cli,thaJeztah/cli,docker/cli,cpuguy83/cli,docker/cli,cpuguy83/cli
74b6ce801ce15a1a2b4df6aa51a3005a0c67ab07
cmds/util/callbrowser_windows.go
cmds/util/callbrowser_windows.go
package util import ( "fmt" "os" "os/exec" "strings" "syscall" ) func CallBrowser(url string) error { fmt.Fprintf(os.Stderr, "Running a browser to open %s...\r\n", url) var attr os.ProcAttr attr.Sys = &syscall.SysProcAttr{HideWindow: false} attr.Files = []*os.File{os.Stdin, os.Stdout, os.Stderr} path, err...
package util import ( "fmt" "os" "os/exec" "strings" "syscall" ) func CallBrowser(url string) error { fmt.Fprintf(os.Stderr, "Running a browser to open %s...\r\n", url) var attr os.ProcAttr attr.Sys = &syscall.SysProcAttr{HideWindow: true} attr.Files = []*os.File{os.Stdin, os.Stdout, os.Stderr} path, err ...
Set HideWindow: true for the cmd exe.
Set HideWindow: true for the cmd exe.
Go
mit
BytemarkHosting/bytemark-client,BytemarkHosting/bytemark-client,BytemarkHosting/bytemark-client
d1b62a8af4e7d246223971deadfe6e3b096ed7c9
orm/tests/user_test.go
orm/tests/user_test.go
package orm_test import ( "fmt" "github.com/nerdzeu/nerdz-api/orm" "testing" ) var user orm.User func init() { err := user.New(1) if err != nil { panic(fmt.Sprintf("No error should happen when create existing user, but got: %+v", err)) } } func TestGetContactInfo(t *testing.T) { info := user.GetContactInfo...
package orm_test import ( "fmt" "github.com/nerdzeu/nerdz-api/orm" "testing" ) var user orm.User func init() { err := user.New(1) if err != nil { panic(fmt.Sprintf("No error should happen when create existing user, but got: %+v", err)) } } func TestGetContactInfo(t *testing.T) { info := user.GetContactInfo...
Add tests (check with -v flag)
Add tests (check with -v flag)
Go
agpl-3.0
nerdzeu/nerdz-api,nerdzeu/nerdz-api
7d0fb46d0304cc4f730f6b26334c176e9ae71a2a
btrees/symmetric.go
btrees/symmetric.go
// Copyright (c) 2015, Peter Mrekaj. All rights reserved. // Use of this source code is governed by a MIT-style // license that can be found in the LICENSE.txt file. package btrees // checkSymmetry returns true if the l binary // tree is symmetric to the r binary tree. func checkSymmetry(l, r *BTree) bool { switch {...
// Copyright (c) 2015, Peter Mrekaj. All rights reserved. // Use of this source code is governed by a MIT-style // license that can be found in the LICENSE.txt file. package btrees // IsSymmetric returns true if t is a symmetric binary tree. func IsSymmetric(t *BTree) bool { if t == nil { return true } var chec...
Refactor recursion helper function to use function literal
Refactor recursion helper function to use function literal
Go
mit
mrekucci/epi,mrekucci/epi
569042e6dfe2dcf338cb5d584e4d9b7c170af669
version/version.go
version/version.go
/* Copyright The containerd 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...
/* Copyright The containerd 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...
Prepare release notes for v1.6.0-beta.4
Prepare release notes for v1.6.0-beta.4 Signed-off-by: Derek McGowan <e1c79a582b6629e6b39e9679f4bb964d25db4aa8@mcg.dev>
Go
apache-2.0
dmcgowan/containerd,mikebrow/containerd,thaJeztah/containerd,mikebrow/containerd,dmcgowan/containerd,thaJeztah/containerd,containerd/containerd,estesp/containerd,containerd/containerd,estesp/containerd
0a352ae409d9750665fc10369b72e89b08c9bd90
runner/main.go
runner/main.go
package main import ( "log" "net/http" "github.com/ParadropLabs/node" ) // var client *rabric.Client func main() { node.Log() // Pass certificate here s := node.CreateNode("pd.routers.aardvark") server := &http.Server{ Handler: s, Addr: ":8000", } log.Fatal(server.ListenAndServe()) }
package main import ( "log" "net/http" "os" "github.com/ParadropLabs/node" ) // var client *rabric.Client func main() { node.Log() // Pass certificate here s := node.CreateNode("pd.routers.aardvark") server := &http.Server{ Handler: s, Addr: ":8000", } certFile := os.Getenv("EXIS_CERT") keyFile...
Use TLS if given a key and cert.
Use TLS if given a key and cert.
Go
mit
exis-io/node,exis-io/node
6c75828f717b728985782256eb0d22906c8f40d4
cmd/geoip/main.go
cmd/geoip/main.go
package main import ( "flag" "fmt" "log" "net" "github.com/umahmood/geoip" ) // command line flags. var ip string func init() { flag.StringVar(&ip, "ip", "", "IP to geo locate can be v4 or v6 address.") flag.Parse() if ip != "" { addr := net.ParseIP(ip) if addr == nil { log.Fatalln("not a valid IP a...
package main import ( "flag" "fmt" "log" "github.com/umahmood/geoip" ) // command line flags. var ip string func init() { flag.StringVar(&ip, "ip", "", "IP to geo locate can be v4/v6 address or domain name.") flag.Parse() } func main() { loc, err := geoip.Location(ip) if err != nil { log.Fatalln(err) } ...
Remove check to see if -ip flag is valid address format
Remove check to see if -ip flag is valid address format geoip previously used telize api for lookups, it only accepted ip addresses. Now we have switched to freegeoip the api can accept domain names as well as ip addresses. geoip now allows the user to pass in domain names.
Go
mit
umahmood/geoip
628c92772d72467b9d5172434a259936e7e5d613
type/model/dependency.go
type/model/dependency.go
package model // SourceCD // 0 = unknown // 1 = carthage // 2 = cocoapods // 3 = submodule // Dependency has project dependency and source distination. type Dependency struct { ProjectUUID string `json:"project_uuid"` DependentProjectUUID string `json:"dependent_project_uuid"` SourceCD int `json:"source_...
package model // SourceCD // 0 = unknown // 1 = carthage // 2 = cocoapods // 3 = submodule // Dependency has project dependency and source distination. type Dependency struct { ProjectUUID string `json:"project_uuid" gorm:"ForeignKey:UUID"` DependentProjectUUID string `json:"dependent_project_uuid" gorm:"F...
Set foreign key information to Dependency
Set foreign key information to Dependency
Go
mit
torinos-io/api,torinos-io/api
9fe2514b370f58c5531fd22830713791fac0b3a5
leetcode/019.remove-nth-node-from-end-of-list.go
leetcode/019.remove-nth-node-from-end-of-list.go
package leetcode /** * Definition for singly-linked list. * type ListNode struct { * Val int * Next *ListNode * } */ func removeNthFromEnd(head *ListNode, n int) *ListNode { n1, n2 := head, head for i := 0; i < n; i++ { n2 = n2.Next } if n2 == nil { return head.Next } for n2.Next != nil { n1 ...
package leetcode /** * Definition for singly-linked list. * type ListNode struct { * Val int * Next *ListNode * } */ func removeNthFromEnd(head *ListNode, n int) *ListNode { /* 4 ms var count int for node := head; node != nil; node = node.Next { count++ } if n = count - n + 1; n == 1 { return he...
Remove Nth Node From End of List
Remove Nth Node From End of List
Go
apache-2.0
4396/leetcode
74259226185994025f100c1f6be20a8c1f14b074
service/not_found_test.go
service/not_found_test.go
package service
package service import ( "testing" "github.com/stretchr/testify/assert" ) func TestNotFoundLoginShouldReturnError(t *testing.T) { nf := &NotFound{} token, err := nf.Login() assert.NotNil(t, err) assert.Equal(t, "Service not found", err.Error()) assert.Equal(t, "", token) }
Add test for NotFound Login
Add test for NotFound Login
Go
mit
hoop33/limo
754c347b2aa5923a03c1a9806804c049ea83858d
logging.go
logging.go
// Logging helpers package autosite import ( "net/http" ) // LoggerFunc returns a logger from a http request. type LoggerFunc func(*http.Request) Logger // Logger specifies logging functions. type Logger interface { // Debugf formats its arguments according to the format, analogous to fmt.Printf, // and records t...
// Logging helpers package autosite import ( "net/http" "github.com/golang/glog" ) // LoggerFunc returns a logger from a http request. type LoggerFunc func(*http.Request) Logger // Logger specifies logging functions. // // The methods are chosen to match the logging methods from // appengine.Context, without need...
Add Glogger, Logger that uses package glog
Add Glogger, Logger that uses package glog
Go
mit
hkjn/autosite
2277738c6e61a4f8e4d3343e34281f7397c347e9
cleanhttp.go
cleanhttp.go
package cleanhttp import ( "net" "net/http" "time" ) // DefaultTransport returns a new http.Transport with the same default values // as http.DefaultTransport func DefaultTransport() *http.Transport { return &http.Transport{ Proxy: http.ProxyFromEnvironment, Dial: (&net.Dialer{ Timeout: 30 * time.Second,...
package cleanhttp import ( "net" "net/http" "runtime" "time" ) // DefaultTransport returns a new http.Transport with the same default values // as http.DefaultTransport func DefaultTransport() *http.Transport { transport := &http.Transport{ Proxy: http.ProxyFromEnvironment, Dial: (&net.Dialer{ Timeout: ...
Set a finalizer function on the transport to close idle connections.
Set a finalizer function on the transport to close idle connections. This ensures that we do not leak fds, potentially running out of them.
Go
mpl-2.0
hashicorp/go-cleanhttp
777289c17a05c3271cf62169a5d02411f2ed06cc
data/data.go
data/data.go
package data import ( "time" "github.com/jinzhu/gorm" // DB adapters _ "github.com/lib/pq" _ "github.com/mattn/go-sqlite3" ) var db gorm.DB type Check struct { Id int64 URL string } type Result struct { Timestamp time.Time Status int Success bool IP string } func InitDatabase() (err error...
package data import ( "time" "github.com/jinzhu/gorm" // DB adapters _ "github.com/lib/pq" _ "github.com/mattn/go-sqlite3" ) var db gorm.DB type Check struct { Id int64 URL string `gorm:"column:url"` Status int // status code of last result Success bool // success status of last res...
Make it possible to create and fetch results and checks
Make it possible to create and fetch results and checks
Go
mit
goffee/goffee,goffee/goffee,goffee/goffee,goffee/goffee
edeeb6d6bb90997182e000ba6768391fdadbc459
data/data.go
data/data.go
package data type Command struct { Id string `json:"id"` ProcessId string `json:"processId"` Name string `json:"name"` Body string `json:"body"` }
package data type Command struct { Id string `json:"id"` ProcessId string `json:"processId"` Name string `json:"name"` Body interface{} `json:"body"` }
Add generic behavior to body field, now it can be a simple or complex type
Add generic behavior to body field, now it can be a simple or complex type
Go
mit
rjansen/fivecolors,rjansen/fivecolors,rjansen/fivecolors
d7e68e44d4a48271942f377b5b6c43195b995d40
hellofriends/hellofriends.go
hellofriends/hellofriends.go
package main import ( "fmt" ) func main() { // Declare a variable called myName. var myName string // Now add a variable for your friends name here. // Set the value of myName to your name. // I'll use Owen :) You have to use your name. // You have to use inverted commas because Owen is a string. myName = "O...
package main import ( "fmt" ) func main() { // Declare a variable called myName. var myName string // Now add a variable for your friends name here. // Set the value of myName to your name. // I'll use Owen :) You have to use your name. // You have to use inverted commas because Owen is a string. myName = "O...
Swap from Unicode quote marks to ASCII quote marks
Swap from Unicode quote marks to ASCII quote marks Replace the unicode quote marks with the ASCII ones.
Go
bsd-3-clause
gophercoders/codeclub
8868bbc4ec723dd62f79d36c762f1df0b9aa63e9
proto/proto.go
proto/proto.go
package proto import "time" type Response struct { Available bool `json:"available"` DownloadURL string `json:"download_url"` Checksum string `json:"checksum"` Signature string `json:"signature"` PatchType string `json:"patch_type"` Version string `json:"version"` Release Release `json...
package proto import "time" type PatchKind string const ( PatchRaw PatchKind = "none" PatchBSDIFF PatchKind = "bsdiff" ) type Response struct { Available bool `json:"available"` DownloadURL string `json:"download_url"` Checksum string `json:"checksum"` Signature string `json:"signature...
Make patch a type with two values: none and bsdiff
Make patch a type with two values: none and bsdiff
Go
mit
equinox-io/equinox
b2c0c3382bb939a72c7bd80d6da8cda9a3931e97
v2/jwk_test.go
v2/jwk_test.go
package jwt import ( "net/http" "testing" "github.com/stretchr/testify/assert" ) func TestJWKFetcher(t *testing.T) { assert := assert.New(t) fetcher := &JWKsHTTPFetcher{ Client: &http.Client{}, } jwksresp, err := fetcher.FetchJWKs("https://www.googleapis.com/oauth2/v3/certs") assert.NoError(err) assert.Le...
package jwt import ( "net/http" "testing" "time" "github.com/pmylund/go-cache" "github.com/square/go-jose" "github.com/stretchr/testify/assert" ) func TestJWKsFetcher(t *testing.T) { assert := assert.New(t) fetcher := &JWKsHTTPFetcher{ Client: &http.Client{}, } jwksresp, err := fetcher.FetchJWKs("https:/...
Add a test for JWKsCacher
jwk: Add a test for JWKsCacher
Go
bsd-3-clause
nabeken/jwt.go
1f3f8a7fba81402579fccaafac069d135e0a648c
_examples/2_server/post.go
_examples/2_server/post.go
//go:generate gourd gen service -type=Post -coll=posts $GOFILE package main import ( "time" ) // Post is for blog post // This is a multiple line comment /** * This is another multiple line comment * Just another type */ type Post struct { // This is Id Id int32 `db:"id"` // This is User ID Uid int32 `db:"...
//go:generate gourd gen service -type=Post -coll=posts $GOFILE package main import ( "time" ) // Post is for blog post // This is a multiple line comment /** * This is another multiple line comment * Just another type */ type Post struct { // This is Id Id int32 `db:"id,omitempty" json:"id"` // This is User...
Improve example 2 Post struct
Improve example 2 Post struct Add better database and json tags
Go
apache-2.0
gourd/gourd
7050badc2950a2c9253f7bce4050af7025a438f6
procaddr/glx/glx.go
procaddr/glx/glx.go
package glx // #cgo linux LDFLAGS: -lGL // #include <stdlib.h> // #include <GL/glx.h> import "C" import "unsafe" func GetProcAddress(name string) unsafe.Pointer { var cname *C.GLubyte = (*C.GLubyte)(C.CString(name)) defer C.free(unsafe.Pointer(cname)) return unsafe.Pointer(C.glXGetProcAddress(cname)) }
package glx // #cgo linux LDFLAGS: -lGL // #include <stdlib.h> // #include <GL/glx.h> import "C" import "unsafe" func GetProcAddress(name string) unsafe.Pointer { var cname *C.GLubyte = (*C.GLubyte)(unsafe.Pointer(C.CString(name))) defer C.free(unsafe.Pointer(cname)) return unsafe.Pointer(C.glXGetProcAddress(cname...
Fix the GLX C string conversion.
Fix the GLX C string conversion. Fixes #4.
Go
mit
go-gl/glow,errcw/glow
bbd4133904ea76cc800ecb411986905c6762e141
pkg/web/middleware/cors.go
pkg/web/middleware/cors.go
package middleware import "net/http" type Cors struct{} func (c Cors) Handle(w http.ResponseWriter, req *http.Request, next http.HandlerFunc) { headers := w.Header() if headers.Get("Access-Control-Allow-Origin") == "" { headers.Add("Access-Control-Allow-Origin", "*") } if headers.Get("Access-Control-Allow-Meth...
package middleware import "net/http" type Cors struct{} func (c Cors) Handle(w http.ResponseWriter, req *http.Request, next http.HandlerFunc) { headers := w.Header() if headers.Get("Access-Control-Allow-Origin") == "" { headers.Add("Access-Control-Allow-Origin", "*") } if headers.Get("Access-Control-Allow-Meth...
Include x-app-api-key in allowed headers
Include x-app-api-key in allowed headers
Go
apache-2.0
matzew/mcp-standalone,matzew/mcp-standalone,matzew/mcp-standalone,feedhenry/mcp-standalone,feedhenry/mcp-standalone,feedhenry/mcp-standalone,feedhenry/mcp-standalone,matzew/mcp-standalone
60630c1f6c3ee55fc45adeb633d28952d950aa72
users/password/doc.go
users/password/doc.go
// Package password contains functions for securely storing // and checking passwords. // // Passwords are encoded using a per-password salt and then // hashed with the chosen algorithm (sha256 by default). // Password provides the Check() method for verifying that // the given plaintext matches the encoded password. T...
// Package password contains functions for securely storing // and checking passwords. // // Passwords are encoded using a per-password salt and then // hashed using PBKDF2 with the chosen algorithm (sha256 by default). // Password provides the Check() method for verifying that // the given plaintext matches the encode...
Document that Password uses PBKDF2 internally
Document that Password uses PBKDF2 internally
Go
mpl-2.0
rainycape/gondola,rainycape/gondola,rainycape/gondola,rainycape/gondola
b151d96d5ba52fc8827e638119ff5ad2e090ea76
src/ustackweb/controllers/registrations.go
src/ustackweb/controllers/registrations.go
package controllers import ( "github.com/astaxie/beego" ) type Registration struct { Username string Password string } type RegistrationsController struct { BaseController } func (this *RegistrationsController) Prepare() { this.PrepareXsrf() this.PrepareLayout() this.Layout = "layouts/default.html.tpl" } fu...
package controllers import ( "github.com/astaxie/beego" "ustackweb/models" ) type Registration struct { Username string Password string } type RegistrationsController struct { BaseController } func (this *RegistrationsController) Prepare() { this.PrepareXsrf() this.PrepareLayout() this.Layout = "layouts/def...
Add backend to register form.
Add backend to register form.
Go
mit
UserStack/ustackweb,UserStack/ustackweb,UserStack/ustackweb,UserStack/ustackweb
64f1ed07a5e11070025e664a46786bb17e35b4a9
state/utils.go
state/utils.go
package state import ( "github.com/centurylinkcloud/clc-go-cli/config" "io/ioutil" "os" "path" ) func ReadFromFile(name string) ([]byte, error) { p, err := config.GetPath() if err != nil { return nil, err } return ioutil.ReadFile(path.Join(p, name)) } func WriteToFile(data []byte, name string, perm os.File...
package state import ( "github.com/centurylinkcloud/clc-go-cli/config" "io/ioutil" "os" "path" ) func ReadFromFile(name string) ([]byte, error) { p, err := config.GetPath() if err != nil { return nil, err } return ioutil.ReadFile(path.Join(p, name)) } func WriteToFile(data []byte, name string, perm os.File...
Add GetFileInfo, which is quite self-explanatory
Add GetFileInfo, which is quite self-explanatory
Go
apache-2.0
CenturyLinkCloud/clc-go-cli,CenturyLinkCloud/clc-go-cli
496ea1ca490380d07c6044379813c3893c4f92d4
termios_bsd.go
termios_bsd.go
// +build darwin freebsd netbsd openbsd package fineline import ( "syscall" ) func tcgetattr(fd int, t *termios) { ttyIoctl(0, syscall.TIOCGETA, t) } func tcsetattr(fd int, t *termios) { var cmd int switch op { case TCSANOW: cmd = syscall.TIOCSETA case TCSADRAIN: cmd = syscall.TIOCSETAW case TCSAFLUSH: ...
// +build darwin freebsd netbsd openbsd package fineline import ( "syscall" ) func tcgetattr(fd int, t *termios) { ttyIoctl(0, syscall.TIOCGETA, t) } func tcsetattr(fd, op int, t *termios) { var cmd int switch op { case TCSANOW: cmd = syscall.TIOCSETA case TCSADRAIN: cmd = syscall.TIOCSETAW case TCSAFLUS...
Correct tcsetattr signature for BSD family
Correct tcsetattr signature for BSD family
Go
bsd-3-clause
edsrzf/fineline,davecheney/fineline
c7d6cee7f87ebfcc96c2cbffe4018675532e696d
main_test.go
main_test.go
package main import ( "testing" "github.com/stretchr/testify/assert" ) func TestVesion(t *testing.T) { assert.Equal(t, "unknown", Version()) }
package main import ( "testing" "github.com/stretchr/testify/assert" ) func TestVersion(t *testing.T) { assert.Equal(t, "unknown", Version()) }
Fix a typo in the test method name
Fix a typo in the test method name
Go
apache-2.0
simonswine/kube-lego,jetstack/kube-lego
c0c0357473e58b1bb531b94a6959f1a4d1fada5b
examples/minimal_pipeline_k8s/minimal_k8s.go
examples/minimal_pipeline_k8s/minimal_k8s.go
package main import sp "github.com/scipipe/scipipe" func main() { // -------------------------------- // Set up a pipeline runner // -------------------------------- run := sp.NewPipelineRunner() // -------------------------------- // Initialize processes and add to runner // --------------------------------...
package main import sp "github.com/scipipe/scipipe" func main() { // -------------------------------- // Set up a pipeline runner // -------------------------------- run := sp.NewPipelineRunner() // -------------------------------- // Initialize processes and add to runner // --------------------------------...
Fix wrong default data folder path in k8s example
Fix wrong default data folder path in k8s example
Go
mit
scipipe/scipipe,scipipe/scipipe,samuell/scipipe
379a1445adcacc5c586695e7e17b477e1c4a5d36
exp/14/main.go
exp/14/main.go
package exp14 import ( . "github.com/shurcooL/go/gists/gist7480523" . "github.com/shurcooL/go/gists/gist7802150" "github.com/shurcooL/go/gists/gist8018045" ) type GoPackages struct { SkipGoroot bool // Currently, works on initial run only; changing its value afterwards has no effect. Entries []*GoPackage Dep...
package exp14 import ( . "github.com/shurcooL/go/gists/gist7480523" . "github.com/shurcooL/go/gists/gist7802150" "github.com/shurcooL/go/gists/gist8018045" ) type GoPackageList interface { List() []*GoPackage DepNode2I } type GoPackages struct { SkipGoroot bool // Currently, works on initial run only; changi...
Add exp14.GoPackageList interface for exp14.GoPackages.
Add exp14.GoPackageList interface for exp14.GoPackages.
Go
mit
shurcooL/go
57b7a0920059998e1cc6a8ed7dd194811a1fa2a0
uchiwa_results.go
uchiwa_results.go
package tessen import ( "encoding/json" "fmt" "io/ioutil" "net/http" "strings" ) func FetchUchiwaEvents(endpoint string) ([]map[string]interface{}, error) { resp, err := http.Get(fmt.Sprintf("%s/events", endpoint)) if err != nil { return nil, err } defer resp.Body.Close() contents, err := ioutil.ReadAll...
package tessen import ( "encoding/json" "fmt" "io/ioutil" "net/http" "strings" ) func FetchUchiwaEvents(endpoint string) ([]map[string]interface{}, error) { var contents []byte var err error log.Debugf("FetchUchiwaEvents: %s", endpoint[7:]) if endpoint[:7] == "file://" { contents, err = getUchiwaResultsFro...
Allow for file://{path to json doc} debug endpoint
Allow for file://{path to json doc} debug endpoint Developing this offline is a pain. Make it so that I can supply a pre-downloaded event json file. This may be generally useful, so not just wrapping it with debug logic for now.
Go
apache-2.0
mikepea/tessen
8ba5485db6ebfa824458df98db6df29cbe128332
log/zapadapter/adapter.go
log/zapadapter/adapter.go
// Package zapadapter provides a logger that writes to a go.uber.org/zap.Logger. package zapadapter import ( "github.com/jackc/pgx" "go.uber.org/zap" "go.uber.org/zap/zapcore" ) type Logger struct { logger *zap.Logger } func NewLogger(logger *zap.Logger) *Logger { return &Logger{logger: logger.WithOptions(zap.A...
// Package zapadapter provides a logger that writes to a go.uber.org/zap.Logger. package zapadapter import ( "github.com/jackc/pgx" "go.uber.org/zap" "go.uber.org/zap/zapcore" ) type Logger struct { logger *zap.Logger } func NewLogger(logger *zap.Logger) *Logger { return &Logger{logger: logger.WithOptions(zap.A...
Use zap.Any for handling interface{} -> zap.Field conversion
Use zap.Any for handling interface{} -> zap.Field conversion zap.Any falls back to zap.Reflect, but is better for this case, because it first checks for the types that zap handles specially. For example, time.Duration, or error, which zap.Reflect will just treat as untyped int64 or struct objects, but zap.Any is able...
Go
mit
jackc/pgx,jackc/pgx,jackc/pgx,jackc/pgx
98fd21de2cae4ee1166e6aeb69aaa411dcb23c8d
json_formatter.go
json_formatter.go
package logrus import ( "encoding/json" "fmt" "time" ) type JSONFormatter struct{} func (f *JSONFormatter) Format(entry *Entry) ([]byte, error) { data := make(Fields, len(entry.Data)+3) for k, v := range entry.Data { // Otherwise errors are ignored by `encoding/json` // https://github.com/Sirupsen/logrus/is...
package logrus import ( "encoding/json" "fmt" "time" ) type JSONFormatter struct{} func (f *JSONFormatter) Format(entry *Entry) ([]byte, error) { data := make(Fields, len(entry.Data)+3) for k, v := range entry.Data { switch v := v.(type) { case error: // Otherwise errors are ignored by `encoding/json` ...
Use type-switch for error field
[JSON] Use type-switch for error field
Go
mit
zbindenren/logrus,sirupsen/logrus,penhauer-xiao/logrus,derekdowling/logrus,alecha/logrus,yawn/logrus,upstartmobile/logrus,axiomzen/logrus,gogap/logrus,marcosnils/logrus,Dal-Papa/logrus,Sirupsen/logrus,noxiouz/logrus,therealbill/logrus,Barberrrry/logrus,devopstaku/logrus,noironetworks/logrus,wallclockbuilder/logrus,orvi...
a4276e879139c400159294b32d50f3650a99670b
src/chat/user_conn_test.go
src/chat/user_conn_test.go
package chat_test import ( "testing" "github.com/spring1843/chat-server/src/chat" "github.com/spring1843/chat-server/src/drivers/fake" ) func TestCanWriteToUser(t *testing.T) { fakeWriter := fake.NewFakeConnection() user1 := chat.NewConnectedUser(server, fakeWriter) go user1.SetOutgoing(`foo`) chat.ExpectOut...
package chat_test import ( "testing" "github.com/spring1843/chat-server/src/chat" "github.com/spring1843/chat-server/src/drivers/fake" ) func TestCanWriteToUser(t *testing.T) { user1 := chat.NewUser("bar") msg := "foo" go user1.SetOutgoing(msg) outgoing := user1.GetOutgoing() if outgoing != msg { t.Error...
Test does not need to start a user connection
Test does not need to start a user connection
Go
mit
spring1843/chat-server
36260dd3160d3cc73c2f730ff7845b8a5868e7ff
examples/hello-openshift/hello_openshift.go
examples/hello-openshift/hello_openshift.go
package main import ( "fmt" "net" "net/http" "os" "strconv" ) func helloHandler(w http.ResponseWriter, r *http.Request) { response := os.Getenv("RESPONSE") if len(response) == 0 { response = "Hello OpenShift!" } // Echo back the port the request was received on // via a "request-port" header. addr := r....
package main import ( "fmt" "net" "net/http" "os" "strconv" ) func helloHandler(w http.ResponseWriter, r *http.Request) { response := os.Getenv("RESPONSE") if len(response) == 0 { response = "Hello OpenShift!" } // Echo back the port the request was received on // via a "request-port" header. addr := r....
Make request-port header spec compliant
hello-openshift: Make request-port header spec compliant Change hello-openshift's `request-port` response header to `x-request-port` to be strictly standards compliant.
Go
apache-2.0
soltysh/origin,JacobTanenbaum/origin,jsafrane/origin,akram/origin,spadgett/origin,mahak/origin,spadgett/origin,deads2k/origin,soltysh/origin,gabemontero/origin,spadgett/origin,jeremyeder/origin,mahak/origin,openshift/origin,spadgett/origin,gabemontero/origin,csrwng/origin,bparees/origin,mfojtik/origin,hroyrh/origin,bpa...
f767b7051afee3fe494610d22b31e92d35493218
examples/tas-server.go
examples/tas-server.go
package main import ( "log" "runtime" ) import ( "github.com/chango/tas/tas" ) func main() { runtime.GOMAXPROCS(10) tasConfig := tas.NewDefaultTASConfig() svr, err := tas.NewTASServer(tasConfig) if err != nil { log.Println("Failed to start TAS: %s", err) return } svr.Run() }
package main import ( "log" ) import ( "github.com/chango/tas/tas" ) func main() { tasConfig := tas.NewDefaultTASConfig() svr, err := tas.NewTASServer(tasConfig) if err != nil { log.Println("Failed to start TAS:", err) return } svr.Run() }
Remove runtime GOMAXPROCS from example and fix error print if TAS server cannot be created
Remove runtime GOMAXPROCS from example and fix error print if TAS server cannot be created
Go
mit
oldmantaiter/tas,chango/tas,oldmantaiter/tas,chango/tas
8dca559f101f1291f06416539403e92085c82edc
protocol/encoder_decoder.go
protocol/encoder_decoder.go
package protocol // Kafka Encoding type encoder interface { encode(pe packetEncoder) } func encode(in encoder) ([]byte, error) { if in == nil { return nil, nil } var prepEnc prepEncoder var realEnc realEncoder in.encode(&prepEnc) if prepEnc.err != nil { return nil, prepEnc.err } realEnc.raw = make([]...
package protocol // Kafka Encoding type encoder interface { encode(pe packetEncoder) } func encode(in encoder) ([]byte, error) { if in == nil { return nil, nil } var prepEnc prepEncoder var realEnc realEncoder in.encode(&prepEnc) if prepEnc.err != nil { return nil, prepEnc.err } realEnc.raw = make([]...
Check for unused data when decoding
Check for unused data when decoding
Go
mit
aybabtme/sarama,cep21/sarama,sclasen/sarama,jimmykuo/sarama,scalingdata/sarama,jepst/sarama,VividCortex/sarama,cep21/sarama,raisemarketplace/sarama,rafrombrc/sarama,Neuw84/sarama,yangfan876/sarama,raisemarketplace/sarama,vrischmann/sarama,winlinvip/sarama,kraveio/sarama,rafrombrc/sarama,kraveio/sarama,DataDog/sarama,be...
1239c58e1d843e4eaf67a92de768f74f469aa2db
hack/preload-images/kubernetes.go
hack/preload-images/kubernetes.go
/* Copyright 2020 The Kubernetes Authors 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 ag...
/* Copyright 2020 The Kubernetes Authors 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 ag...
Increase page size to 100 and omit "alpha"
Increase page size to 100 and omit "alpha"
Go
apache-2.0
kubernetes/minikube,kubernetes/minikube,kubernetes/minikube,kubernetes/minikube,kubernetes/minikube,kubernetes/minikube,kubernetes/minikube
acb07d74115cbc6187996446b30e6741e51f8514
resource/cmd/util_test.go
resource/cmd/util_test.go
// Copyright 2015 Canonical Ltd. // Licensed under the AGPLv3, see LICENCE file for details. package status import ( "fmt" "strings" gc "gopkg.in/check.v1" "gopkg.in/juju/charm.v6-unstable" "github.com/juju/juju/resource" ) func NewSpecs(c *gc.C, names ...string) []resource.Spec { var specs []resource.Spec ...
// Copyright 2015 Canonical Ltd. // Licensed under the AGPLv3, see LICENCE file for details. package cmd import ( "strings" jc "github.com/juju/testing/checkers" gc "gopkg.in/check.v1" "gopkg.in/juju/charm.v6-unstable" "github.com/juju/juju/resource" ) func NewSpec(c *gc.C, name, suffix, comment string) resou...
Add the NewSpec testing helper.
Add the NewSpec testing helper.
Go
agpl-3.0
perrito666/juju,anastasiamac/juju,bz2/juju,waigani/juju,macgreagoir/juju,frankban/juju,perrito666/juju,mjs/juju,frankban/juju,bz2/juju,ericsnowcurrently/juju,ericsnowcurrently/juju,dooferlad/juju,reedobrien/juju,mjs/juju,gabriel-samfira/juju,anastasiamac/juju,mjs/juju,howbazaar/juju,anastasiamac/juju,mjs/juju,dimitern/...
16b82629adec18d2ca848aed2a854faad64572d0
terminal/terminal_freebsd.go
terminal/terminal_freebsd.go
package terminal import ( "syscall" ) const ioctlReadTermios = syscall.TIOCGETA /* Go 1.2 doesn't include Termios for FreeBSD. This should be added in 1.3 and th is could be merged with terminal_darwin. */ type termios struct { Iflag uint32 Oflag uint32 Cflag uint32 Lflag uint32 Cc [20]uint8 Ispe...
package terminal import ( "syscall" ) const ioctlReadTermios = syscall.TIOCGETA /* Go 1.2 doesn't include Termios for FreeBSD. This should be added in 1.3 and th is could be merged with terminal_darwin. */ type termios struct { Iflag uint32 Oflag uint32 Cflag uint32 Lflag uint32 Cc [20]uint8 Ispee...
Move Termios note so it isn't taken as package comment.
Move Termios note so it isn't taken as package comment.
Go
mit
BellerophonMobile/logberry
e0dd532d12b6bc448757b2bc0ea22527630c612c
dom_test.go
dom_test.go
package vecty var _ = func() bool { isTest = true return true }()
package vecty import ( "fmt" "testing" ) var _ = func() bool { isTest = true return true }() // TODO(slimsag): TestCore; Core.Context // TODO(slimsag): TestComponent; Component.Render; Component.Context // TODO(slimsag): TestUnmounter; Unmounter.Unmount // TODO(slimsag): TestComponentOrHTML // TODO(slimsag): Tes...
Add unit test for RenderBody expecting "body" tag
Add unit test for RenderBody expecting "body" tag
Go
bsd-3-clause
gopherjs/vecty
7eaf4588f66c1036ce5fe3aa8b16cb16a534b9a2
cmd/conchtestdata/main.go
cmd/conchtestdata/main.go
package main import ( "flag" "fmt" "os" "path/filepath" ) type options struct { qty int dir string } func newOptionsDefault() *options { return &options{ qty: 1024, dir: "./testfiles", } } func main() { opts := newOptionsDefault() { flag.IntVar(&opts.qty, "qty", opts.qty, `quantity of test files`...
package main import ( "flag" "fmt" "os" "path/filepath" ) type options struct { qty int dir string } func newOptionsDefault() *options { return &options{ qty: 1024, dir: "./testfiles", } } func main() { opts := newOptionsDefault() { flag.IntVar(&opts.qty, "qty", opts.qty, `quantity of test files`...
Set conchtestdata directory creation perms to 0775.
Set conchtestdata directory creation perms to 0775.
Go
mit
daved/conch0
b19dc050e5c6c78f4a5cc6264234aab7989ac9c3
transcode/options.go
transcode/options.go
package transcode import ( ) // Options represents an audio codec and its quality settings, and includes methods to // retrieve these settings type Options interface { Codec() string FFmpegCodec() string FFmpegQuality() string Quality() string }
package transcode // Options represents an audio codec and its quality settings, and includes methods to // retrieve these settings type Options interface { Codec() string Ext() string FFmpegCodec() string FFmpegFlags() string FFmpegQuality() string MIMEType() string Quality() string }
Add more necessary methods to Options interface
Add more necessary methods to Options interface
Go
mit
mdlayher/wavepipe,mdlayher/wavepipe
f4b1de70d1ef4a74de7a3e1ab93db00602f9a159
server/directory.go
server/directory.go
package main import ( "fmt" "github.com/gorilla/mux" "io" "net/http" ) func main() { router := mux.NewRouter() router.HandleFunc("/", func(rw http.ResponseWriter, req *http.Request) { fmt.Fprintf(rw, "what's up? you just hit the server\n") }) api := router.PathPrefix("/api/v1").Subrouter() api.HandleFun...
package main import ( "fmt" "github.com/gorilla/mux" "io" "net/http" ) func main() { router := mux.NewRouter() router.HandleFunc("/", func(rw http.ResponseWriter, req *http.Request) { fmt.Fprintf(rw, "what's up? you just hit the server\n") }) api := router.PathPrefix("/api/v1").Subrouter() api.HandleFun...
Move API function to inline call
Move API function to inline call
Go
mit
jagger27/glocal
72c282466e2c9f9564fe4331dafbb50964a3f4c1
store/load.go
store/load.go
package store import ( "fmt" "github.com/Sirupsen/logrus" "github.com/solderapp/solder/config" ) // Load initializes the database connection. func Load(cfg *config.Config) *Store { driver := cfg.Database.Driver connect := "" switch driver { case "mysql": connect = fmt.Sprintf( "%s:%s@(%s)/%s?parseTime=T...
package store import ( "fmt" "github.com/Sirupsen/logrus" "github.com/solderapp/solder/config" ) // Load initializes the database connection. func Load(cfg *config.Config) *Store { driver := cfg.Database.Driver connect := "" switch driver { case "mysql": connect = fmt.Sprintf( "%s:%s@(%s)/%s?charset=utf...
Set charset to utf8 on mysql
Set charset to utf8 on mysql
Go
apache-2.0
kleister/kleister-api,kleister/kleister-api,solderapp/solder-api,solderapp/solder-api