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
b9bef7c2d626f037dc3042758f4f8be61430735c
com_query_response.go
com_query_response.go
package mysqlproto import ( "errors" ) type ResultSet struct { stream *Stream } func (r ResultSet) Row() ([]byte, error) { packet, err := r.stream.NextPacket() if err != nil { return nil, err } if packet.Payload[0] == 0xfe { // EOF return nil, nil } return packet.Payload, nil } func ComQueryResponse(s...
package mysqlproto import ( "errors" ) type ResultSet struct { stream *Stream } func (r ResultSet) Row() ([]byte, error) { packet, err := r.stream.NextPacket() if err != nil { return nil, err } if packet.Payload[0] == PACKET_EOF { return nil, nil } return packet.Payload, nil } func ComQueryResponse(st...
Use constants PACKET_EOF and PACKET_ERR
Use constants PACKET_EOF and PACKET_ERR
Go
mit
pubnative/mysqlproto-go
1508b7ca7250ed81320ad0272b5b98c3d8f25172
api.go
api.go
package main import ( "io/ioutil" "strconv" "github.com/gin-gonic/gin" "github.com/mdeheij/gitlegram/gitlab" log "github.com/mdeheij/logwrap" ) func main() { c := NewConfig() //gin.SetMode(gin.ReleaseMode) r := gin.Default() r.POST("/", func(c *gin.Context) { body, ioerr := ioutil.ReadAll(c.Request.Body)...
package main import ( "io/ioutil" "strconv" "github.com/gin-gonic/gin" "github.com/mdeheij/gitlegram/gitlab" log "github.com/mdeheij/logwrap" ) func main() { c := NewConfig() //gin.SetMode(gin.ReleaseMode) r := gin.Default() r.POST("/", func(c *gin.Context) { body, ioerr := ioutil.ReadAll(c.Request.Body)...
Change 500 Internal Server Error to 400 Bad Request
Change 500 Internal Server Error to 400 Bad Request
Go
mit
mdeheij/gitlegram
cca69fe3b6ffa7a6049d68d85e73507927c29a27
app.go
app.go
package main import ( "fmt" "os" "net" "time" "sync" ) var ( host string // The host address to scan ) func init() { if len(os.Args) != 2 { fmt.Fprintf(os.Stderr, "Usage: %s host\n", os.Args[0]) os.Exit(1) } host = os.Args[1] } func main() { d := net.Dialer{Timeout: 10 * time.Second} p...
package main import ( "fmt" "net" "os" "sync" "time" ) var ( host string // The host address to scan ) func init() { if len(os.Args) != 2 { fmt.Fprintf(os.Stderr, "Usage: %s host\n", os.Args[0]) os.Exit(1) } host = os.Args[1] } func main() { d := net.Dialer{Timeout: 10 * time.Second} p := make(chan b...
Reformat code use golang standard format
Reformat code use golang standard format
Go
mit
redforks/portscan
a9435a9180a073655cbe4caa43ce2ba1b6d1d063
core/image_png.go
core/image_png.go
package core import ( "errors" "fmt" "image" "image/png" "io" "os" "os/exec" ) type PNGHandler struct { } func (p *PNGHandler) ImageType() string { return "image/png" } func (p *PNGHandler) Decode(reader io.Reader) (image.Image, error) { return png.Decode(reader) } func (p *PNGH...
package core import ( "errors" "fmt" "image" "image/png" "io" "os" "os/exec" ) type PNGHandler struct { } func (p *PNGHandler) ImageType() string { return "image/png" } func (p *PNGHandler) Decode(reader io.Reader) (image.Image, error) { return png.Decode(reader) } func (p *PNGH...
Use .png as extension on conversion
Use .png as extension on conversion
Go
mit
lotrekagency/piuma,lotrekagency/piuma
470f338da0105f37c0e7b66a2ca63fea5da5138e
cli.go
cli.go
package cli import "flag" const DoubleMinus = "--" //ParameterFlagMode determines how arguments are parsed for SubCommands. type ParameterFlagMode int const ( //ModeInterspersed allows command parameters and flags to be mixed with eachother //in their ordering. ModeInterspersed ParameterFlagMode = iota //ModeF...
package cli import "flag" //DoubleMinus is the argument to determine if the flag package has stopped parsing //after seeing this argument. const DoubleMinus = "--" //Output values that affect error and help output. // //These variables may be changed to affect the output of this package. var ( //UsageFormat is used...
Update package level variable documentation
Update package level variable documentation
Go
mit
gogolfing/cli,gogolfing/cli
d055743a71b2fff55a8506ab5ea00c861e61a813
agent/resources_test.go
agent/resources_test.go
package agent import ( "testing" ) func TestConstructResource(t *testing.T) { r := ConstructResources(1, 1, 1, 1, 1, 1) if r.CpuTotal != 1 || r.CpuUsage != 1 || r.MemoryTotal != 1 || r.MemoryUsage != 1 || r.DiskTotal != 1 || r.DiskUsage != 1 { t.Fatal("disk stat read fail") } }
package agent import ( "testing" ) func TestConstructResource(t *testing.T) { r := ConstructResources(1, 1, 1, 1, 1, 1) if r.CpuTotal != 1 || r.CpuUsage != 1 || r.MemoryTotal != 1 || r.MemoryUsage != 1 || r.DiskTotal != 1 || r.DiskUsage != 1 { t.Fatal("Fail to construct resources struct") } }
Fix log in resources test
Fix log in resources test
Go
mit
longan/litchi
db0a4854563e1f7f0416e98f523dafefd0cf249d
core/publishers.go
core/publishers.go
package core import ( "github.com/projectjane/jane/connectors" "github.com/projectjane/jane/models" "log" "strings" ) func Publishers(publishMsgs <-chan models.Message, config *models.Config) { log.Print("Initializing Publishers") for { message := <-publishMsgs for _, route := range message.Routes { if s...
package core import ( "github.com/projectjane/jane/connectors" "github.com/projectjane/jane/models" "github.com/projectjane/jane/parse" "log" "strings" ) func Publishers(publishMsgs <-chan models.Message, config *models.Config) { log.Print("Initializing Publishers") for { message := <-publishMsgs for _, ro...
Fix to publisher matching logic
Fix to publisher matching logic
Go
mit
mmcquillan/jane,projectjane/jane,hexbotio/hex
b3f07a70dc8de716f99b0a8e8b9fc0c25585dd32
src/pkg/os/signal/signal_test.go
src/pkg/os/signal/signal_test.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 signal import ( "syscall" "testing" ) func TestSignal(t *testing.T) { // Send this process a SIGHUP. syscall.Syscall(syscall.SYS_KILL, uintptr(sys...
// 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 signal import ( "syscall" "testing" ) func TestSignal(t *testing.T) { // Send this process a SIGHUP. syscall.Syscall(syscall.SYS_KILL, uintptr(sys...
Use t.Errorf for formatted error output.
Use t.Errorf for formatted error output. R=dsymonds1 CC=golang-dev http://codereview.appspot.com/183049
Go
bsd-3-clause
pombredanne/go-deleteme,gnanderson/go,pombredanne/go-deleteme,nightlyone/golang,dsriram/golang,tianon/debian-golang,tv42/old-go,h8liu/golang,ssrl/go,ssrl/go,dsriram/golang,bdwalton/debian-golang,tianon/debian-golang,nightlyone/golang,ssrl/go,gnanderson/go,pombredanne/go-deleteme,nightlyone/golang,dsriram/golang,ssrl/go...
662b53fd8eac2f2b0d5e8187e72a1ac17dd8e86d
passhash.go
passhash.go
package spritz // InsecurePasswordHash calculates a CPU- and memory-hard hash of the given // password and salt. It takes a linear parameter, m, which determines both CPU // and memory cost. It also takes the length of the hash in bytes. // // N.B.: THIS IS A TOTALLY EXPERIMENTAL ALGORITHM WHICH I WROTE BEFORE I'D HAD...
package spritz // InsecurePasswordHash calculates a CPU- and memory-hard hash of the given // password and salt. It takes a linear parameter, m, which determines both CPU // and memory cost. It also takes the length of the hash in bytes. // // N.B.: THIS IS A TOTALLY EXPERIMENTAL ALGORITHM WHICH I WROTE BEFORE I'D HAD...
Drop the extra shuffle and stop.
Drop the extra shuffle and stop. It now more resembles the IV key setup.
Go
mit
codahale/spritz
c5dbd750f6e1d3e3018d960c8904bc3f239aac99
all_test.go
all_test.go
package gosseract_test import "github.com/otiai10/gosseract" import . "github.com/otiai10/mint" import "testing" func Test_Greet(t *testing.T) { Expect(t, gosseract.Greet()).ToBe("Hello,Gosseract.") } func Test_Must(t *testing.T) { params := map[string]string{ "src": "./samples/hoge.png", } Expect(t, gosseract...
package gosseract_test import "github.com/otiai10/gosseract" import . "github.com/otiai10/mint" import "testing" func Test_Greet(t *testing.T) { Expect(t, gosseract.Greet()).ToBe("Hello,Gosseract.") } func Test_Must(t *testing.T) { params := map[string]string{ "src": "./samples/hoge.png", } Expect(t, gosseract...
Add `Client.Must` (is name `Must` good?)
Add `Client.Must` (is name `Must` good?)
Go
mit
otiai10/gosseract,esiqveland/gosseract,tonycoming/gosseract,trigrass2/gosseract,tonycoming/gosseract,otiai10/gosseract,trigrass2/gosseract,esiqveland/gosseract,trigrass2/gosseract,tonycoming/gosseract,otiai10/gosseract,esiqveland/gosseract,otiai10/gosseract
fa5a4e96b5db2c0ff9a400450b01671c6b20d2a6
fre.go
fre.go
package read // Fre scores the Flesch reading-ease. // See https%3A%2F%2Fen.wikipedia.org%2Fwiki%2FFlesch%E2%80%93Kincaid_readability_tests%23Flesch_reading_ease. func Fre(text string) float64 { sylCnt := float64(CntSyls(text)) wordCnt := float64(CntWords(text)) sentCnt := float64(CntSents(text)) return 206.835 -...
package read // Fre scores the Flesch reading-ease. // See https://en.wikipedia.org/wiki/Flesch%E2%80%93Kincaid_readability_tests%23Flesch_reading_ease. func Fre(text string) float64 { sylCnt := float64(CntSyls(text)) wordCnt := float64(CntWords(text)) sentCnt := float64(CntSents(text)) return 206.835 - 1.015*(wo...
Fix wikipedia url to Flesch reading-ease again
Fix wikipedia url to Flesch reading-ease again Replaces base location with `https://en.wikipedia.org/wiki/`
Go
mit
BluntSporks/readability
166c744fcfee5005cf0dda02fe9aea7fd966795a
cmd/juju/environmentcommand.go
cmd/juju/environmentcommand.go
package main import ( "launchpad.net/gnuflag" "launchpad.net/juju-core/cmd" "os" ) // The purpose of EnvCommandBase is to provide a default member and flag // setting for commands that deal across different environments. type EnvCommandBase struct { cmd.CommandBase EnvName string } func (c *EnvCommandBase) SetF...
package main import ( "launchpad.net/gnuflag" "launchpad.net/juju-core/cmd" "os" ) // The purpose of EnvCommandBase is to provide a default member and flag // setting for commands that deal across different environments. type EnvCommandBase struct { cmd.CommandBase EnvName string } func (c *EnvCommandBase) SetF...
Fix the missing default on the long name.
Fix the missing default on the long name.
Go
agpl-3.0
marcmolla/juju,mhilton/juju-juju,waigani/juju,sinzui/juju,bogdanteleaga/juju,fwereade/juju,dimitern/juju,tsakas/juju,mikemccracken/juju,perrito666/juju,dimitern/juju,frobware/juju,bz2/juju,cherylj/juju,perrito666/juju,frankban/juju,thomnico/juju,cmars/juju,anastasiamac/juju,dooferlad/juju,Altoros/juju-vmware,tsakas/juj...
9682b7065c48648a63ec1822d376f8482a38671c
crane/container_test.go
crane/container_test.go
package crane import "testing" func TestDependencies(t *testing.T) { container := &Container{Run: RunParameters{RawLink: []string{"a:b", "b:d"}}} if deps := container.Dependencies(); deps[0] != "a" || deps[1] != "b" { t.Errorf("Dependencies should have been a and b") } container = &Container{Run: RunParameters{...
package crane import "testing" func TestDependencies(t *testing.T) { container := &Container{Run: RunParameters{RawLink: []string{"a:b", "b:d"}}} if deps := container.Dependencies(); deps[0] != "a" || deps[1] != "b" { t.Error("Dependencies should have been a and b") } container = &Container{Run: RunParameters{R...
Use t.Error if formatting is not needed
Use t.Error if formatting is not needed
Go
mit
rmoorman/crane,inthroxify/crane,michaelsauter/crane,t-suwa/crane,jesper/crane,michaelsauter/crane,stajkowski/crane,tmc/crane,jesper/crane,tmc/crane,inthroxify/crane,dreamcat4/crane,dreamcat4/crane,rmoorman/crane,t-suwa/crane,bjaglin/crane,bjaglin/crane,stajkowski/crane
c69552733a6789e53c87b734742024d839adf1dc
cmd/main.go
cmd/main.go
package main import ( "log" "os" "path/filepath" _ "github.com/jinzhu/gorm/dialects/sqlite" "github.com/spf13/viper" "github.com/swordbeta/trello-burndown/pkg/server" "github.com/swordbeta/trello-burndown/pkg/trello" ) func init() { binaryPath, err := filepath.Abs(filepath.Dir(os.Args[0])) if err != nil { ...
package main import ( "log" "os" "path/filepath" "strings" _ "github.com/jinzhu/gorm/dialects/sqlite" "github.com/spf13/viper" "github.com/swordbeta/trello-burndown/pkg/server" "github.com/swordbeta/trello-burndown/pkg/trello" ) func init() { binaryPath, err := filepath.Abs(filepath.Dir(os.Args[0])) if err...
Allow configuration from environment variables
feat: Allow configuration from environment variables
Go
mit
swordbeta/trello-burndown
5f86efb800160c786be0e593f6b758eefc47a830
cmd/main.go
cmd/main.go
package main import ( "flag" "log" "net/http" "github.com/ant0ine/go-json-rest/rest" "github.com/julienbayle/jeparticipe/app" ) func main() { var ( // Path to the database dbFile = flag.String("db", "jeparticipe.db", "Path to the BoltDB file") // Application port port = flag.String("port", "8090", "S...
package main import ( "flag" "log" "net/http" "github.com/julienbayle/jeparticipe/app" ) func main() { var ( // Path to the database dbFile = flag.String("db", "jeparticipe.db", "Path to the BoltDB file") // Application port port = flag.String("port", "8090", "Server port") // Application base path...
Remove unused imports and rename app "jeparticpe" instead of "app"
Remove unused imports and rename app "jeparticpe" instead of "app"
Go
mit
julienbayle/jeparticipe,julienbayle/jeparticipe
95cfaeb5aa27c690ecf06c595fdfb056c1d86ad6
url_test.go
url_test.go
package main import ( "testing" . "github.com/onsi/gomega" ) func TestNewURL(t *testing.T) { url, err := NewURL("https://github.com/motemen/pusheen-explorer") Expect(url.String()).To(Equal("https://github.com/motemen/pusheen-explorer")) Expect(err).To(BeNil()) url, err = NewURL("git@github.com:motemen/pusheen-...
package main import ( "testing" . "github.com/onsi/gomega" ) func TestNewURL(t *testing.T) { httpsUrl, err := NewURL("https://github.com/motemen/pusheen-explorer") Expect(httpsUrl.String()).To(Equal("https://github.com/motemen/pusheen-explorer")) Expect(err).To(BeNil()) sshUrl, err := NewURL("git@github.com:mo...
Fix test to use `url.String()`
Fix test to use `url.String()`
Go
mit
maoe/ghq,uetchy/ghq,jmatsu/ghq_ss,skatsuta/ghq,motemen/ghq,ngtk/ghq,motemen/ghq,motemen/ghq
fe56731123d96a1d466785458bd3587c8d06f211
key-check/main.go
key-check/main.go
package main import ( "log" "os" "github.com/flynn/flynn-controller/client" ) func main() { key := os.Args[3] client, err := controller.NewClient("", os.Getenv("CONTROLLER_AUTH_KEY")) if err != nil { log.Fatalln("Unable to connect to controller:", err) } keys, err := client.KeyList() if err != nil { lo...
package main import ( "log" "os" "github.com/flynn/flynn-controller/client" ) func main() { key := os.Args[2] client, err := controller.NewClient("", os.Getenv("CONTROLLER_AUTH_KEY")) if err != nil { log.Fatalln("Unable to connect to controller:", err) } keys, err := client.KeyList() if err != nil { lo...
Update number of arguments sent to key-check
Update number of arguments sent to key-check Signed-off-by: Jonathan Rudenberg <3692bfa45759a67d83aedf0045f6cb635a966abf@titanous.com>
Go
bsd-3-clause
flynn-archive/flynn-receive,flynn-archive/flynn-receive
7ec3b887456f286351eba6b66e49538fd729a3cf
commands.go
commands.go
package main import ( "github.com/timakin/ts/loader" "github.com/codegangsta/cli" ) var Commands = []cli.Command{ commandAll, commandBiz, commandHack, } var commandAll = cli.Command{ Name: "pop", Usage: "", Description: ` `, Action: doAll, } var commandBiz = cli.Command{ Name: "biz", Usage: "", Descri...
package main import ( "github.com/timakin/ts/loader" "github.com/codegangsta/cli" ) var Commands = []cli.Command{ commandAll, commandBiz, commandHack, } var commandAll = cli.Command{ Name: "pop", Usage: "", Description: ` `, Action: doAll, } var commandBiz = cli.Command{ Name: "biz", Usage: "", Descri...
Add new GetHatenaFeed func prototype
Add new GetHatenaFeed func prototype
Go
mit
timakin/ts,timakin/ts
577a1de6d9c5cd8ec4cf4f8244a117de9eb33321
examples/count_words.go
examples/count_words.go
package main import ( "fmt" "github.com/discoproject/goworker/jobutil" "github.com/discoproject/goworker/worker" "io" "io/ioutil" "strings" ) func Map(reader io.Reader, writer io.Writer) { body, err := ioutil.ReadAll(reader) jobutil.Check(err) strBody := string(body) words := strings.Fields(strBody) for _,...
package main import ( "bufio" "fmt" "github.com/discoproject/goworker/jobutil" "github.com/discoproject/goworker/worker" "io" "log" "strings" ) func Map(reader io.Reader, writer io.Writer) { scanner := bufio.NewScanner(reader) for scanner.Scan() { text := scanner.Text() words := strings.Fields(text) fo...
Modify the examples to avoid reading the whole input at once.
examples: Modify the examples to avoid reading the whole input at once. This will let the map job operate on the inputs that are larger than the physical memory.
Go
isc
discoproject/goworker
6cb256b8b479cf27788e0e30a3c9d0f66c45735e
utils/buffer.go
utils/buffer.go
package utils import ( "bytes" "os" ) // ClosingBuffer implement Closer interface for Buffer type ClosingBuffer struct { *bytes.Buffer } // Close implement Closer interface for Buffer func (cb *ClosingBuffer) Close() (err os.Error) { return }
package utils import ( "bytes" ) // ClosingBuffer implement Closer interface for Buffer type ClosingBuffer struct { *bytes.Buffer } // Close implement Closer interface for Buffer func (ClosingBuffer) Close() error { return nil }
Update Close method for ClosingBuffer
Update Close method for ClosingBuffer
Go
mit
qor/qor,qor/qor,qor/qor
e377cb3f2d1bd21bccab3d14ac2fcca32c68fe90
dwi_test.go
dwi_test.go
package main import ( "bytes" "testing" ) func TestMainNoArgsShouldPrintUsage(t *testing.T) { out := bytes.NewBufferString("") lf := NewLocalFiles("") Main([]string{""}, out, out, &lf) if out.String() != Usage+"\n" { t.Error("Did not print usage.") } }
package main import ( "bytes" "log" "testing" ) func TestMainNoArgsShouldPrintUsage(t *testing.T) { out := bytes.NewBufferString("") lf := NewLocalFiles("") Main([]string{""}, out, out, &lf) if out.String() != Usage+"\n" { t.Error("Did not print usage.") } } func TestMainMissingFile(t *testing.T) { miss...
Add Test for missing file.
Add Test for missing file.
Go
cc0-1.0
dcbishop/dtt
6b33b2fe8fdc64978703fd74c501ff3c81ef8c9a
service/release.go
service/release.go
package service type Release interface { GetID() int GetTagName() string GetName() string GetBody() string GetHTMLURL() string } type NewRelease struct { ID int TagName string Name string Body string HTMLURL string } func (nr *NewRelease) GetID() int { return nr.ID } func (nr *NewRelease) GetT...
package service type Release interface { GetID() int64 GetTagName() string GetName() string GetBody() string GetHTMLURL() string } type NewRelease struct { ID int TagName string Name string Body string HTMLURL string } func (nr *NewRelease) GetID() int { return nr.ID } func (nr *NewRelease) Ge...
Change return value of Release.GetID
Change return value of Release.GetID from int to int64, to follow github.Release.GetID
Go
mit
mpppk/hlb
27b91ba369542ce1f847db8b8e4af5b8de595ddf
src/cmd/mytweeter/main.go
src/cmd/mytweeter/main.go
package main import ( "dao" "os" "www" "github.com/inconshreveable/log15" ) //sudo docker pull spotify/cassandra //sudo docker run --name cassandra -d -p 9042:9042 spotify/cassandra //sudo docker exec -it cassandra bash //Before you execute the program, Launch `cqlsh` and execute: //create keyspace example with...
package main import ( "dao" "os" "www" "github.com/inconshreveable/log15" ) //sudo docker pull spotify/cassandra //sudo docker run --name cassandra -d -p 9042:9042 spotify/cassandra //sudo docker exec -it cassandra bash //Before you execute the program, Launch `cqlsh` and execute: //create keyspace example with...
Add file and line number where come from log.
Add file and line number where come from log.
Go
apache-2.0
jerome-laforge/mytweeter,jerome-laforge/mytweeter,jerome-laforge/mytweeter
580cf7566a2b63c22ce551f72832e4f8fd5415ac
cmd/mistify-dhcp/main.go
cmd/mistify-dhcp/main.go
package main import ( log "github.com/Sirupsen/logrus" "github.com/mistifyio/mistify-dhcp" logx "github.com/mistifyio/mistify-logrus-ext" ) func main() { log.SetFormatter(&log.JSONFormatter{}) log.AddHook(&logx.ErrorMessageHook{}) conf, err := dhcp.GetConfig() if err != nil { log.WithFields(log.Fields{ "...
package main import ( log "github.com/Sirupsen/logrus" "github.com/mistifyio/mistify-dhcp" logx "github.com/mistifyio/mistify-logrus-ext" ) func main() { log.DefaultSetup("info") conf, err := dhcp.GetConfig() if err != nil { log.WithFields(log.Fields{ "error": err, "func": "dhcp.GetConfig", }).Fatal...
Use the default setup for logrus
[MIST-372] Use the default setup for logrus
Go
apache-2.0
mistifyio/mistify-dhcp,mistifyio/mistify-dhcp
53af5dbfc4a42f967aadbd2856710b281a709d85
controllers/roles/delete_by_id.go
controllers/roles/delete_by_id.go
package roles import ( "net/http" "github.com/ernestio/api-gateway/models" ) // DeleteByID : responds to DELETE /roles/:id: by deleting an // existing role func DeleteByID(au models.User, id string) (int, []byte) { var err error var existing models.Role if err = existing.FindByID(id, &existing); err != nil { ...
package roles import ( "net/http" "github.com/ernestio/api-gateway/models" ) // DeleteByID : responds to DELETE /roles/:id: by deleting an // existing role func DeleteByID(au models.User, id string) (int, []byte) { var err error var existing models.Role if err = existing.FindByID(id, &existing); err != nil { ...
Fix project membership so there is always at least one owner
Fix project membership so there is always at least one owner
Go
mpl-2.0
ErnestIO/api-gateway,ErnestIO/api-gateway
d3f84d8b2f9b3aa392b83d029787a2a452a0ca65
log_test.go
log_test.go
package main import ( "testing" "github.com/stretchr/testify/assert" logrus "github.com/sirupsen/logrus" ) func init() { logger.SetLevel(logrus.PanicLevel) } func TestLogConfig(t *testing.T) { backup := logrus.GetLevel() defer func() { logger.SetLevel(backup) }() c1 := &LogConfig{Level: "debug"} c1.set...
package main import ( "bytes" "fmt" "testing" "github.com/stretchr/testify/assert" logrus "github.com/sirupsen/logrus" ) func init() { logger.SetLevel(logrus.PanicLevel) } func TestLogConfig(t *testing.T) { backup := logrus.GetLevel() defer func() { logger.SetLevel(backup) }() c1 := &LogConfig{Level: ...
Add a test of LogrusWriter
:green_heart: Add a test of LogrusWriter
Go
mit
groovenauts/magellan-gcs-proxy,groovenauts/magellan-gcs-proxy,groovenauts/magellan-gcs-proxy
95431df442eed97dcc6fd45b71bd14ab378346d2
bin/main.go
bin/main.go
package main import ( "encoding/hex" "flag" "log" "github.com/aarbt/bitcoin-base58" "github.com/aarbt/hdkeys" ) var extendedKey = flag.String("extended_key", "", "") func main() { flag.Parse() extended, err := hex.DecodeString(*extendedKey) if err != nil { log.Fatal(err) } if len(extended) != 64 { lo...
package main import ( "crypto/rand" "encoding/hex" "flag" "log" "github.com/aarbt/hdkeys" ) var seedHex = flag.String("seed", "", "hex encoded random seed between 16 and 64 bytes.") func main() { flag.Parse() seed, err := hex.DecodeString(*seedHex) if err != nil { log.Fatal(err) } if len(seed) == 0 { ...
Clean up and improve relevance of example code.
Clean up and improve relevance of example code.
Go
mit
aarbt/hdkeys,aarbt/bitcoin-hdwallet,runeaune/hdkeys
6c3492c268e58e74ee92284c547aac8ee60653ec
security/context.go
security/context.go
package security import ( "net/http" "github.com/goincremental/web" "github.com/goincremental/web/security/models" ) type securityContextKey int const userKey securityContextKey = 0 func SetUser(r *http.Request, val *models.User) { web.SetContext(r, userKey, val) } func GetUser(r *http.Request) *models.User {...
package security import ( "net/http" "github.com/goincremental/web" "github.com/goincremental/web/security/models" ) type securityContextKey int const userKey securityContextKey = 0 func SetUser(r *http.Request, val *models.User) { web.SetContext(r, userKey, val) } func GetUser(r *http.Request) *models.User {...
Fix bug with type assertion
Fix bug with type assertion
Go
apache-2.0
GoIncremental/web
d53db16e9d0e06d14912fec669c0be142744b2f7
cmd/mccli/show_cmd.go
cmd/mccli/show_cmd.go
package mccli import ( "fmt" "github.com/codegangsta/cli" "github.com/materials-commons/config" "github.com/materials-commons/mcstore/server/mcstore" ) var ShowCommand = cli.Command{ Name: "show", Usage: "Show the configuration", Action: showCLI, } func showCLI(c *cli.Context) { apikey := config.GetStrin...
package mccli import ( "fmt" "github.com/codegangsta/cli" "github.com/materials-commons/config" "github.com/materials-commons/mcstore/server/mcstore" ) var ShowCommand = cli.Command{ Name: "show", Aliases: []string{"sh"}, Usage: "Show commands", Subcommands: []cli.Command{ showConfigCommand, }, } va...
Make show a command with sub commands. Add a config command (so: show config) to show the client configuration.
Make show a command with sub commands. Add a config command (so: show config) to show the client configuration.
Go
mit
materials-commons/mcstore,materials-commons/mcstore,materials-commons/mcstore
ea46b63f3836d6a567d4c7c9e7bf4fd989a69ad0
models/reference_ext.go
models/reference_ext.go
package models import ( "encoding/json" "strings" ) type reference Reference func (r *Reference) UnmarshalJSON(data []byte) (err error) { ref := reference{} if err = json.Unmarshal(data, &ref); err == nil { splitURL := strings.Split(ref.Reference, "/") if len(splitURL) >= 2 { ref.ReferencedID = splitURL[l...
package models import ( "encoding/json" "strings" ) func (r *Reference) MarshalJSON() ([]byte, error) { m := map[string]string{ "reference": r.Reference, } if r.Display != "" { m["display"] = r.Display } return json.Marshal(m) } type reference Reference func (r *Reference) UnmarshalJSON(data []byte) (err...
Fix marshalling of references so JSON doesn't have the extra fields we add for IE
Fix marshalling of references so JSON doesn't have the extra fields we add for IE
Go
apache-2.0
intervention-engine/fhir
7e83b51915e81cf442f3818014abf61ac9d85254
irc_test.go
irc_test.go
package irc import ( // irc "github.com/thoj/Go-IRC-Client-Library" "fmt" "testing" ) func TestConnection(t *testing.T) { irccon := IRC("invisible", "invisible") fmt.Printf("Testing connection\n") err := irccon.Connect("irc.freenode.net:6667") fmt.Printf("Connecting...") if err != nil { t.Fatal("Can't ...
package irc import ( // "github.com/thoj/go-ircevent" "testing" ) func TestConnection(t *testing.T) { irccon := IRC("go-eventirc", "go-eventirc") irccon.VerboseCallbackHandler = true err := irccon.Connect("irc.freenode.net:6667") if err != nil { t.Fatal("Can't connect to freenode.") } irccon.AddCallback("00...
Fix tests. Add SSL test.
Fix tests. Add SSL test.
Go
bsd-3-clause
pratikmallya/go-ircevent,iwanbk/ogric,oniichaNj/go-ircevent,DanielOaks/girc-go,Elemental-IRCd/irc,alaska/go-ircevent,HenrySlawniak/go-ircevent,SeanThomasWilliams/go-ircevent,phone/go-ircevent,dainis/go-ircevent
91814d51c6f6d52837963063bc736a1f36225b71
src/main.go
src/main.go
package main import "os" import "github.com/codegangsta/cli" func main() { app := cli.NewApp() app.Name = "exercism" app.Usage = "fight the loneliness!" app.Action = func(c *cli.Context) { println("Hello friend!") } app.Run(os.Args) }
package main import "os" import "github.com/codegangsta/cli" func main() { app := cli.NewApp() app.Name = "exercism" app.Usage = "A command line tool to interact with http://exercism.io" app.Commands = []cli.Command{ { Name: "demo", ShortName: "d", Usage: "Fetch first assignment for each langu...
Add in all basic exercism commands.
Add in all basic exercism commands.
Go
mit
BhanuprakashVc/go-exercism,BhanuprakashVc/go-exercism
670b13c0902c41a38fc81ef8440ac61fe798b370
pkg/beam/core/runtime/api/gen.go
pkg/beam/core/runtime/api/gen.go
package api // NOTE: install protoc as described on grpc.io before running go generate. //go:generate protoc -I. beam_runner_api.proto endpoints.proto --go_out=pipeline_v1 //go:generate protoc -I. beam_fn_api.proto --go_out=Mbeam_runner_api.proto=github.com/apache/beam/sdks/go/pkg/beam/core/runtime/api/pipeline_v1,Me...
// Licensed to the Apache Software Foundation (ASF) under one or more // contributor license agreements. See the NOTICE file distributed with // this work for additional information regarding copyright ownership. // The ASF licenses this file to You under the Apache License, Version 2.0 // (the "License"); you may not...
Add Apache copyright header to files that need it.
Add Apache copyright header to files that need it. Change-Id: I6b4bbfb088f1d2752a509c92915b1a86ae09e61a Reviewed-on: https://team-review.git.corp.google.com/159087 Verified-Style: kokoro <2ac7b1f3fa578934c95181d4272be0d3bca00121@google.com> Verified-BuildAndTest: kokoro <2ac7b1f3fa578934c95181d4272be0d3bca00121@google...
Go
apache-2.0
charlesccychen/beam,markflyhigh/incubator-beam,iemejia/incubator-beam,apache/beam,lukecwik/incubator-beam,apache/beam,chamikaramj/beam,chamikaramj/beam,mxm/incubator-beam,apache/beam,tgroh/incubator-beam,lukecwik/incubator-beam,chamikaramj/beam,RyanSkraba/beam,tgroh/beam,markflyhigh/incubator-beam,lukecwik/incubator-be...
44f3c644b1a9d080d173e528caada50f5c3f208f
cmd/commands-debug.go
cmd/commands-debug.go
package cmd import ( "bytes" "encoding/json" "fmt" ) func (dispatch *Dispatcher) Debug(args []string) { dispatch.BigV.DebugLevel = 1 body, err := dispatch.BigV.Request(args[0], args[1], "") if err != nil { panic(err) } buf := new(bytes.Buffer) json.Indent(buf, body, "", " ") fmt.Printf("%s", buf) }
package cmd import ( "bytes" "encoding/json" "fmt" ) // TODO(telyn): does the URL really have to start with /? // Debug makes an HTTP <method> request to the URL specified in the arguments. // command syntax: debug <method> <url> // URL probably needs to start with a / func (dispatch *Dispatcher) Debug(args []str...
Add more documentation to the debug command
Add more documentation to the debug command
Go
mit
BytemarkHosting/bytemark-client,BytemarkHosting/bytemark-client,BytemarkHosting/bytemark-client
18cb5ae549565b015bd88af63a57c53ca2d33d32
server/server.go
server/server.go
package server import ( "http2-impl/common" ) func Respond(data []byte) (common.Frame, bool) { f := common.GOAWAY{} return f, false }
package server import ( "go-http2-impl/common" ) func Respond(data []byte) (common.Frame, bool) { f := common.GOAWAY{} return f, false }
Change package name to match github repository
Change package name to match github repository Can't figure out how to customize this in Travis
Go
mit
tildedave/go-http2-impl,tildedave/go-hpack-impl
a7a1b211640b563731d66d5296929843ce18e127
duexample.go
duexample.go
package main import ( "./du" "fmt" ) var KB = uint64(1024) func main() { usage := du.NewDiskUsage("C:\\") fmt.Println("Free:", usage.Free()/(KB*KB)) fmt.Println("Available:", usage.Available()/(KB*KB)) fmt.Println("Size:", usage.Size()/(KB*KB)) fmt.Println("Used:", usage.Used()/(KB*KB)) fmt.Println("Usage:",...
package main import ( "github.com/ricochet2200/go-disk-usage/du" "fmt" ) var KB = uint64(1024) func main() { usage := du.NewDiskUsage("C:\\") fmt.Println("Free:", usage.Free()/(KB*KB)) fmt.Println("Available:", usage.Available()/(KB*KB)) fmt.Println("Size:", usage.Size()/(KB*KB)) fmt.Println("Used:", usage.Us...
Update import path to use github path
Update import path to use github path
Go
unlicense
calmh/du,ricochet2200/go-disk-usage,d4l3k/go-disk-usage
3028ded78c0b1c0c9f4ccd3fce3c481361496161
blog_posts_test.go
blog_posts_test.go
package tumblr import ( "testing" ) func TestPosts(t *testing.T) { b := makeTumblr().NewBlog("lacecard.tumblr.com") // Check for unique post params := PostRequestParams{ Id: int64(76803575816), NotesInfo: true, } posts, err := b.Posts(params) if err != nil { t.Error(err) return } if len(posts) != 1 {...
package tumblr import ( "testing" ) func TestPosts(t *testing.T) { b := makeTumblr().NewBlog("lacecard.tumblr.com") // Check for unique post params := PostRequestParams{ Id: int64(76803575816), NotesInfo: true, } pc, err := b.Posts(params) if err != nil { t.Error(err) return } if len(pc.Posts) != 1 {...
Update test to reflect use of PostCollection
Update test to reflect use of PostCollection
Go
mit
hut8/tumblr-go
62ef15c40b2391cc28188da04ed7fb4f3c4c8f4e
srv/handler/helper.go
srv/handler/helper.go
package handler import ( elasticseach "github.com/Rakanixu/elasticsearch/srv/proto/elasticsearch" "github.com/micro/go-micro/errors" ) // RequiredRecordFieldsExists returns an error if DocRef struct has zero value func DocRefFieldsExists(dr *elasticseach.DocRef) error { if len(dr.Index) <= 0 { return errors.BadR...
package handler import ( elasticseach "github.com/Rakanixu/elasticsearch/srv/proto/elasticsearch" "github.com/micro/go-micro/errors" ) // RequiredRecordFieldsExists returns an error if DocRef struct has zero value func DocRefFieldsExists(dr *elasticseach.DocRef) error { if len(dr.Index) <= 0 { return errors.BadR...
Add Id as optional param
Add Id as optional param
Go
apache-2.0
Rakanixu/elasticsearch,Rakanixu/elastic
dae8c68b753943058aa397947e5c318d8db8cab8
storage/filesystem/internal/dotgit/dotgit_setref_norwfs.go
storage/filesystem/internal/dotgit/dotgit_setref_norwfs.go
// +build norwfs package dotgit import "gopkg.in/src-d/go-git.v4/plumbing" func (d *DotGit) setRef(fileName, content string, old *plumbing.Reference) error { f, err := d.fs.Create(fileName) if err != nil { return err } defer f.Close() _, err = f.Write([]byte(content)) return err }
// +build norwfs package dotgit import "gopkg.in/src-d/go-git.v4/plumbing" // There are some filesystems tha don't support opening files in RDWD mode. // In these filesystems the standard SetRef function can not be used as i // reads the reference file to check that it's not modified before updating it. // // This v...
Add comment to the norwfs version of SetRef
Add comment to the norwfs version of SetRef Signed-off-by: Javi Fontan <bd6f2f0212e303b54f36d84bb19ae60fa8e400a6@gmail.com>
Go
apache-2.0
src-d/go-git,mcuadros/go-git,go-git/go-git,go-git/go-git,src-d/go-git,mcuadros/go-git
b39962bcf776cd2761e585e1becf089c0fa0d0cf
smsd/dbdef.go
smsd/dbdef.go
package main const ( setNames = "SET NAMES utf8" setLocPrefix = "SET @localPrefix='+48'" outboxTable = "SMSd_Outbox" recipientsTable = "SMSd_Recipients" inboxTable = "SMSd_Inbox" ) const createOutbox = `CREATE TABLE IF NOT EXISTS ` + outboxTable + ` ( id int unsigned NOT NULL AUTO_INCREME...
package main const ( setNames = "SET NAMES utf8" setLocPrefix = "SET @localPrefix='+48'" outboxTable = "SMSd_Outbox" recipientsTable = "SMSd_Recipients" inboxTable = "SMSd_Inbox" ) const createOutbox = `CREATE TABLE IF NOT EXISTS ` + outboxTable + ` ( id int unsigned NOT NULL AUTO_INCREME...
Add srcId to db def
Add srcId to db def
Go
bsd-3-clause
ziutek/gogammu
c0f9835ae3e48ee703395248fdfd118f8fd66304
common/csv_test.go
common/csv_test.go
package common import ( "testing" "github.com/stretchr/testify/assert" ) func Test_CSVDump(t *testing.T) { type io struct { Fields []string Rows [][]string Output string } tests := []io{ io{ Fields: []string{"f1", "f2"}, Rows: [][]string{ []string{"11", "12"}, []string{"21", "22"}, }...
package common import ( "testing" "github.com/stretchr/testify/assert" ) func Test_CSVDump(t *testing.T) { type io struct { Fields []string Rows [][]string Output string } tests := []io{ io{ Fields: []string{"f1", "f2"}, Rows: [][]string{ []string{"11", "12"}, []string{"21", "22"}, }...
Test also line feeds in field names
Test also line feeds in field names
Go
mit
yapdns/yapdnsbeat,yapdns/yapdnsbeat
3df4996e33ff6f95b84e6400c77819e4b43ee068
AnimeCharacter.go
AnimeCharacter.go
package arn // Register a list of supported character roles. func init() { DataLists["anime-character-roles"] = []*Option{ {"", "Unknown"}, {"main", "Main character"}, {"supporting", "Supporting character"}, } } // AnimeCharacter ... type AnimeCharacter struct { CharacterID string `json:"characterId" editabl...
package arn // Register a list of supported character roles. func init() { DataLists["anime-character-roles"] = []*Option{ {"main", "Main character"}, {"supporting", "Supporting character"}, } } // AnimeCharacter ... type AnimeCharacter struct { CharacterID string `json:"characterId" editable:"true"` Role ...
Disable "Unknown" option for character roles
Disable "Unknown" option for character roles
Go
mit
animenotifier/arn
57a0d8eaffc364164a7dd1392ddf82055aa10125
internal/main_test.go
internal/main_test.go
package main import ( "errors" "reflect" "testing" ) func TestGetMetadataProvider(t *testing.T) { tests := []struct { desc string name string err error }{ { desc: "supported provider", name: "digitalocean", err: nil, }, { desc: "unknown provider", name: "not-supported", err: erro...
package main import ( "reflect" "testing" ) func TestGetMetadataProvider(t *testing.T) { tests := []struct { desc string name string err error }{ { desc: "supported provider", name: "digitalocean", err: nil, }, { desc: "unknown provider", name: "not-supported", err: ErrUnknownProv...
Use ErrUnknownProvider in tests as well
internal: Use ErrUnknownProvider in tests as well
Go
apache-2.0
coreos/coreos-metadata
054e660f270bc911378150ebce847b5ade5b9366
src/go/floyd_warshall/floyd_warshall.go
src/go/floyd_warshall/floyd_warshall.go
package floydwarshall // Grafos - Algoritmo de Floyd-Warshall em GO // Douglas Oliveira - 2021 // https://github.com/xDouglas90 // link Go PlayGround: https://go.dev/play/p/4fOHMMxWxiy // Algoritmo de Floyd-Warshall func FloydWarshall(graph [][]int) [][]int { // Inicializa a matriz de distancias dist := make([][]in...
package floydwarshall // Grafos - Algoritmo de Floyd-Warshall em GO // Douglas Oliveira - 2022 // https://github.com/xDouglas90 // link Go PlayGround: https://go.dev/play/p/tIRTHkNf7Fz // Algoritmo de Floyd-Warshall func FloydWarshall(graph [][]int) [][]int { // Inicializa a matriz de distancias dist := make([][]in...
Fix year and link in code comment
chore: Fix year and link in code comment
Go
mit
kelvins/Algoritmos-e-Estruturas-de-Dados,kelvins/Algoritmos-e-Estruturas-de-Dados,kelvins/Algoritmos-e-Estruturas-de-Dados,kelvins/Algoritmos-e-Estruturas-de-Dados,kelvins/Algoritmos-e-Estruturas-de-Dados,kelvins/Algoritmos-e-Estruturas-de-Dados,kelvins/Algoritmos-e-Estruturas-de-Dados,kelvins/Algoritmos-e-Estruturas-d...
226a8dfc8e7a6f32a7fffacc7313dea1edc0d3e4
utp_test.go
utp_test.go
package utp import ( "log" "net" "sync" "testing" _ "github.com/anacrolix/envpprof" "golang.org/x/net/nettest" ) func init() { log.SetFlags(log.Flags() | log.Lshortfile) } func TestNettestLocalhostUDP(t *testing.T) { nettest.TestConn(t, func() (c1, c2 net.Conn, stop func(), err error) { s, err := NewSock...
package utp import ( "log" "net" "sync" "testing" _ "github.com/anacrolix/envpprof" "golang.org/x/net/nettest" ) func init() { log.SetFlags(log.Flags() | log.Lshortfile) } func TestNettestLocalhostUDP(t *testing.T) { nettest.TestConn(t, func() (c1, c2 net.Conn, stop func(), err error) { s, err := NewSock...
Use dialer instead of initer, it's clearer
Use dialer instead of initer, it's clearer
Go
mit
anacrolix/go-libutp,anacrolix/go-libutp,anacrolix/go-libutp,anacrolix/go-libutp
d76e75300da746a1f9093509fc24c417ee268596
service/purge.go
service/purge.go
package service import ( "log" "time" ) func (b *Broker) Purge() { now := time.Now() for name, worker := range b.Service.workers { log.Printf("I: Looking at worker %s", name) if worker.Expiry.Before(now) { log.Printf("I: Removing worker %s", name) b.Service.RemoveWorker(worker) b.DisconnectWorker(...
package service import ( "fmt" "log" "time" ) func (b *Broker) Purge() { now := time.Now() for name, worker := range b.Service.workers { log.Printf("I: Looking at worker %s", name) if worker.Expiry.Before(now) { log.Printf("I: Removing worker %s", name) b.Service.RemoveWorker(worker) for _, m := ...
Send placeholder failer reply to requests for an expired worker
Send placeholder failer reply to requests for an expired worker
Go
apache-2.0
radiodan/broker
7329c5f45a7f05244e6b2903d1b91af2fdbf681b
proto_0_0.go
proto_0_0.go
package main import ( "os" "os/exec" ) func proto_0_0(inFlag, outFlag bool, errFlag, workdir string, args []string) error { proc := exec.Command(args[0], args[1:]...) proc.Dir = workdir logger.Printf("Command path: %v\n", proc.Path) done := make(chan bool) done_count := 0 done_count += wrapStdin(proc, os.Std...
package main import ( "os" "os/exec" ) func proto_0_0(inFlag, outFlag bool, errFlag, workdir string, args []string) error { proc := exec.Command(args[0], args[1:]...) proc.Dir = workdir logger.Printf("Command path: %v\n", proc.Path) done := make(chan bool) done_count := 0 done_count += wrapStdin(proc, os.Std...
Handle failure to start a program
Handle failure to start a program
Go
mit
alco/goon,felixbuenemann/goon,alco/goon,felixbuenemann/goon
6fcc9a77e70103972d279e4df6d6856dd2de5c39
parser/oregon_test.go
parser/oregon_test.go
package main import ( "testing" ) func TestParseTHGR122NX(t *testing.T) { var o Oregon res := o.Parse("OS3", "1D20485C480882835") if res.ID != "1D20" { t.Error("Error parsing ID") } if res.Data["Temperature"] != -8.4 { t.Error("Error parsing temperature") } if res.Data["Humidity"] != 28 { t.Error("Error...
package main import ( "testing" ) func TestParseTHGR122NX(t *testing.T) { var o Oregon res := o.Parse("OS3", "1D20485C480882835") if res.ID != "OS3:1D20" { t.Error("Error parsing ID") } if res.Data["Temperature"] != -8.4 { t.Error("Error parsing temperature") } if res.Data["Humidity"] != 28 { t.Error("E...
Update test to include OS3 in ID
Update test to include OS3 in ID
Go
mit
geoffholden/gowx,geoffholden/gowx,geoffholden/gowx
492d808817ec69b30b5ce9fa3c33246a4b4dfa33
juju/testing/utils.go
juju/testing/utils.go
// Copyright 2012, 2013 Canonical Ltd. // Licensed under the AGPLv3, see LICENCE file for details. package testing import ( gc "launchpad.net/gocheck" "launchpad.net/juju-core/instance" "launchpad.net/juju-core/state" ) // AddStateServerMachine adds a "state server" machine to the state so // that State.Addresse...
// Copyright 2012, 2013 Canonical Ltd. // Licensed under the AGPLv3, see LICENCE file for details. package testing import ( gc "launchpad.net/gocheck" "launchpad.net/juju-core/instance" "launchpad.net/juju-core/state" ) // AddStateServerMachine adds a "state server" machine to the state so // that State.Addresse...
Update AddStateServerMachine testing helper for completeness
Update AddStateServerMachine testing helper for completeness
Go
agpl-3.0
reedobrien/store
cb51fb0426137cb746912163225cd5a5c800b599
cmd/yoink-validate/main.go
cmd/yoink-validate/main.go
package main import ( "flag" log "github.com/Sirupsen/logrus" "github.com/fubarhouse/golang-drush/alias" "github.com/fubarhouse/golang-drush/vhost" ) func main() { var WebserverDir = flag.String("vhost-dir", "/etc/nginx/sites-enabled", "Directory containing virtual host file(s)") var Webserver = flag.String("w...
package main import ( "flag" log "github.com/Sirupsen/logrus" "github.com/fubarhouse/golang-drush/alias" "github.com/fubarhouse/golang-drush/vhost" "os" "os/user" ) func main() { var WebserverDir = flag.String("vhost-dir", "/etc/nginx/sites-enabled", "Directory containing virtual host file(s)") var Webserver...
Add commands to verify folder exists for aliases and vhosts
Add commands to verify folder exists for aliases and vhosts Signed-off-by: Karl Hepworth <c14c6f041bb80410635ef9142e07c8627a565b5a@gmail.com>
Go
mit
fubarhouse/golang-drush
7e25de93795124661b734e4d896dc8524e167de7
concourse/api/pipelines.go
concourse/api/pipelines.go
package api import ( "encoding/json" "fmt" "io/ioutil" "net/http" ) const ( apiPrefix = "/api/v1" ) //go:generate counterfeiter . Client type Client interface { Pipelines() ([]Pipeline, error) } type client struct { target string } func NewClient(target string) Client { return &client{ target: target, ...
package api import ( "encoding/json" "fmt" "io/ioutil" "net/http" ) const ( apiPrefix = "/api/v1" ) //go:generate counterfeiter . Client type Client interface { Pipelines() ([]Pipeline, error) } type client struct { target string } func NewClient(target string) Client { return &client{ target: target, ...
Add targetURL when printing error during Pipelines().
Add targetURL when printing error during Pipelines().
Go
mit
robdimsdale/concourse-pipeline-resource,robdimsdale/concourse-pipeline-resource
0aa2f9c1f9d471cfb3aff10620075f3eb1a0845d
common/db.go
common/db.go
package common import ( "fmt" "github.com/jinzhu/gorm" _ "github.com/lib/pq" ) var DB gorm.DB func init() { var err error DB, err = gorm.Open("postgres", "user=govcode password=govcode dbname=govcode_go sslmode=disable") // Connection string parameters for Postgres - http://godoc.org/github.com/lib/pq, if you...
package common import ( "fmt" "github.com/jinzhu/gorm" _ "github.com/lib/pq" "os" ) var DB gorm.DB func init() { var err error DB, err = gorm.Open("postgres", os.Getenv("PG_CONN_STR")) // Connection string parameters for Postgres - http://godoc.org/github.com/lib/pq, if you are using another // database ref...
Use env var for connection string
Use env var for connection string
Go
mit
dlapiduz/govcode.org,dlapiduz/govcode.org,HackAgenda/govcode,dlapiduz/govcode.org,HackAgenda/govcode
36b147fe697e6cb3bbed57fc96a4ab3f74ec1cdb
test/integration/setup_integration_test.go
test/integration/setup_integration_test.go
package main import ( "fmt" "os" "runtime/debug" "testing" . "github.com/onsi/gomega" "github.com/sclevine/agouti" ) const ( PORT = 9009 ) var ( baseUrl = fmt.Sprintf("http://localhost:%v/admin", PORT) driver *agouti.WebDriver page *agouti.Page ) func TestMain(m *testing.M) { var t *testing.T var ...
package main import ( "fmt" "os" "runtime/debug" "testing" . "github.com/onsi/gomega" "github.com/sclevine/agouti" ) const ( PORT = 9009 ) var ( baseUrl = fmt.Sprintf("http://localhost:%v/admin", PORT) driver *agouti.WebDriver page *agouti.Page ) func TestMain(m *testing.M) { var t *testing.T var ...
Mark test as fail in panic recovery function.
Mark test as fail in panic recovery function.
Go
mit
gavinzhs/qor,shaunstanislaus/qor,yanzay/qor,yanzay/qor,amirrpp/qor,amirrpp/qor,codedogfish/qor,trigrass2/qor,qor/qor,codedogfish/qor,shaunstanislaus/qor,insionng/qor,youprofit/qor,strogo/qor,youprofit/qor,shidao-fm/qor,gavinzhs/qor,trigrass2/qor,qor/qor,lance2088/qor,jmptrader/qor,insionng/qor,shidao-fm/qor,qor/qor,str...
adc3c7f16051d51a58d96e32082aaeb051e3da20
client/keys_test.go
client/keys_test.go
package client import ( "reflect" "testing" ) func TestGenerateKeys(t *testing.T) { var tests = []struct { key string size int want string }{ {"ecdsa", 256, "*ecdsa.PrivateKey"}, {"rsa", 1024, "*rsa.PrivateKey"}, {"ed25519", 256, "*ed25519.PrivateKey"}, } for _, tst := range tests { k, _, err :=...
package client import ( "reflect" "testing" ) func TestGenerateKeys(t *testing.T) { var tests = []struct { key string size int want string }{ {"ecdsa", 256, "*ecdsa.PrivateKey"}, {"rsa", 1024, "*rsa.PrivateKey"}, {"ed25519", 256, "*ed25519.PrivateKey"}, } for _, tst := range tests { k, _, err :=...
Use %T instead of reflect.
Use %T instead of reflect.
Go
mit
nsheridan/cashier,fuero/cashier,nsheridan/cashier,lyda/cashier,fuero/cashier,fuero/cashier,lyda/cashier
0dd24f825210ac212691217611db25f9d64b9fe8
cmd/mathcat/mathcat.go
cmd/mathcat/mathcat.go
package main import ( "flag" "fmt" "github.com/soudy/mathcat" "gopkg.in/readline.v1" "os" "runtime" ) var precision = flag.Int("precision", 2, "decimal precision used in results") func getHomeDir() string { if runtime.GOOS == "windows" { home := os.Getenv("HOMEDRIVE") + os.Getenv("HOMEPATH") if home == ""...
package main import ( "flag" "fmt" "github.com/chzyer/readline" "github.com/soudy/mathcat" "os" "runtime" ) var precision = flag.Int("precision", 2, "decimal precision used in results") func getHomeDir() string { if runtime.GOOS == "windows" { home := os.Getenv("HOMEDRIVE") + os.Getenv("HOMEPATH") if home...
Update readline dependency to github so we're up to date
Update readline dependency to github so we're up to date
Go
mit
soudy/eparser,sodoz/mathcat,soudy/mathcat
3e69ca745210ba67f07309c360b87a3c65d3f47f
federation/apis/federation/annotations.go
federation/apis/federation/annotations.go
/* Copyright 2016 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 2017 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, ...
Fix the comments on FederationNameAnnotation
[Federation] Fix the comments on FederationNameAnnotation
Go
apache-2.0
BenTheElder/kubernetes,mYmNeo/kubernetes,lavalamp/kubernetes,mYmNeo/kubernetes,tanshanshan/kubernetes,juanvallejo/kubernetes,deads2k/kubernetes,dchen1107/kubernetes-1,wasylkowski/kubernetes,BenTheElder/kubernetes,ingvagabund/kubernetes,spiffxp/kubernetes,GulajavaMinistudio/kubernetes,appscode/kubernetes,duglin/kubernet...
64b903100d4a8d9615a7bd365888ae4f3be5157c
tools/metrics/acceptance/currency_test.go
tools/metrics/acceptance/currency_test.go
package acceptance import ( . "github.com/onsi/ginkgo" . "github.com/onsi/gomega" ) var _ = Describe("Currency", func() { It("should return currency metrics", func() { Expect(metricFamilies).To(SatisfyAll( HaveKey("paas_currency_real"), HaveKey("paas_currency_configured"), )) }) })
package acceptance import ( . "github.com/onsi/ginkgo" . "github.com/onsi/gomega" ) var _ = Describe("Currency", func() { It("should return currency metrics", func() { Expect(metricFamilies).To(SatisfyAll( HaveKey("paas_currency_real_ratio"), HaveKey("paas_currency_configured_ratio"), )) }) })
Fix acceptance tests for paas-metrics/currency
Fix acceptance tests for paas-metrics/currency Signed-off-by: Toby Lorne <527052641d65eef236eeef9545b2acac74c35d57@digital.cabinet-office.gov.uk>
Go
mit
alphagov/paas-cf,alphagov/paas-cf,alphagov/paas-cf,alphagov/paas-cf,alphagov/paas-cf,alphagov/paas-cf,alphagov/paas-cf,alphagov/paas-cf
0792dca3fcf94bde8e5fb0150d3010a2e56bd6f7
gocontext.go
gocontext.go
package opentracing import "golang.org/x/net/context" type contextKey int const activeSpanKey contextKey = iota // ContextWithSpan returns a new `context.Context` that holds a reference to // the given `Span`. // // The second return value is simply the `span` passed in: // this can save some typing and is only pro...
package opentracing import "golang.org/x/net/context" type contextKey struct{} var activeSpanKey = contextKey{} // ContextWithSpan returns a new `context.Context` that holds a reference to // the given `Span`. // // The second return value is simply the `span` passed in: // this can save some typing and is only pro...
Use struct{} instead of int as context key
Use struct{} instead of int as context key The line val := ctx.Value(activeSpanKey) previously allocated to pass the integer `activeSpanKey` as an interface. With this change, no such allocation is necessary. This showed up during benchmarks in cockroachdb/cockroach.
Go
apache-2.0
opentracing/opentracing-go
4ad79a219fa376bfe31d085ec24948d5c03889a6
chtignore.go
chtignore.go
package main import ( "fmt" "io" "io/ioutil" "log" "net/http" "os" ) func main() { process(os.Args[1:], os.Stdout) } func process(args []string, output io.Writer) { if len(args) == 0 { log.Fatal("Mandatory argument missing: chtignore Java") } candidate := args[0] if candidate == "" { log.Fatal("Manda...
package main import ( "fmt" "io" "io/ioutil" "log" "net/http" "os" ) var logger = log.New(os.Stderr, "", 0) func main() { process(os.Args[1:], os.Stdout) } func process(args []string, output io.Writer) { if len(args) == 0 { missingArgument() } candidate := args[0] if candidate == "" { missingArgumen...
Use a custom logger to not display timestamp
Use a custom logger to not display timestamp
Go
mit
jcgay/chtignore
6e1802fab1fbeceef72dfc9d091a4bd3da78fb70
adfs_config.go
adfs_config.go
package main import "os" type ADFSConfig struct { Username string Password string Hostname string } func newADFSConfig() *ADFSConfig { authVars := &ADFSConfig{ Username: os.Getenv("AD_USER"), Password: os.Getenv("AD_PASS"), Hostname: os.Getenv("AD_HOST"), } return authVars }
package main import ( "fmt" "os" "gopkg.in/ini.v1" ) type ADFSConfig struct { Username string `ini:"user"` Password string `ini:"pass"` Hostname string `ini:"host"` } func newADFSConfig() *ADFSConfig { configPath := fmt.Sprintf("%s/.config/auth-aws/config.ini", os.Getenv("HOME")) adfsConfig := new(ADFSConf...
Add support for a configuration file
Add support for a configuration file
Go
mit
tmiller/auth-aws,tmiller/auth-aws
1e49e2cf8d8218103b051f0092a136392de3da8f
cmd/login.go
cmd/login.go
package cmd import ( "io/ioutil" "log" "github.com/mitchellh/go-homedir" "github.com/mobingilabs/mocli/pkg/util" "github.com/spf13/cobra" ) var loginCmd = &cobra.Command{ Use: "login", Short: "", Long: `Placeholder for the documentation.`, Run: login, } func init() { rootCmd.AddCommand(loginCmd) log...
package cmd import ( "io/ioutil" "log" "github.com/mitchellh/go-homedir" "github.com/mobingilabs/mocli/pkg/util" "github.com/spf13/cobra" ) var loginCmd = &cobra.Command{ Use: "login", Short: "", Long: `Placeholder for the documentation.`, Run: login, } func init() { rootCmd.AddCommand(loginCmd) log...
Add error check for Linux check.
Add error check for Linux check.
Go
mpl-2.0
mobingi/mobingi-cli
38fdbf5b5a1ab56cb8bcd76f129e0dae2900b3de
vat.go
vat.go
/* Package vat helps you deal with European VAT in Go. It offers VAT number validation using the VIES VAT validation API & VAT rates retrieval using jsonvat.com Validate a VAT number validity := vat.Validate("NL123456789B01") Get VAT rate that is currently in effect for a given country c, _ := GetCountryRates("N...
/* Package vat helps you deal with European VAT in Go. It offers VAT number validation using the VIES VAT validation API & VAT rates retrieval using jsonvat.com Validate a VAT number validity := vat.Validate("NL123456789B01") Get VAT rate that is currently in effect for a given country c, _ := vat.GetCountryRate...
Use package prefix in godoc example.
Use package prefix in godoc example.
Go
mit
dannyvankooten/govat
68e8972aa89efb63ed117b46fea44a42bf9d9bc6
pkg/apis/pipeline/v1alpha1/taskrun_defaults.go
pkg/apis/pipeline/v1alpha1/taskrun_defaults.go
/* Copyright 2018 The Knative Authors. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, sof...
/* Copyright 2018 The Knative Authors. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, sof...
Fix nil pointer bug in TaskRun SetDefaults
Fix nil pointer bug in TaskRun SetDefaults If apply TaskRun CR without TaskRef field, webhook will panic. Signed-off-by: mathspanda <94e03d994113c3a6928444ec6d80ede43e0cadf6@gmail.com>
Go
apache-2.0
tektoncd/pipeline,tektoncd/pipeline
4df939f9e31260b3e59eba285ea85330caa86df5
smartprompt.go
smartprompt.go
package main import ( "errors" "fmt" "os" . "github.com/fholiveira/smartprompt/parsers" ) func loadPromptPattern() (string, error) { args := os.Args[1:] if len(args) != 1 { return "", errors.New("Invalid arguments") } return args[0], nil } func main() { promptPattern, err := loadPromptPattern() if nil...
package main import ( "fmt" "os" . "github.com/fholiveira/smartprompt/parsers" ) func loadPromptPattern() string { args := os.Args[1:] if len(args) != 1 { return "{GREEN:bold}{user}@{host} {BLUE:bold}{location:vimstyle} {git} {CYAN:bold}{prompt:symbol} {TEXT:reset}" } return args[0] } func main() { prom...
Set a default prompt pattern
Set a default prompt pattern
Go
mit
fholiveira/smartprompt,fholiveira/smartprompt,julianosaless/smartprompt,julianosaless/smartprompt
30fbdc9c0fe35fb538e83573373db3627feb3030
addr.go
addr.go
package missinggo import ( "net" "strconv" ) // Extracts the port as an integer from an address string. func AddrPort(addr net.Addr) int { switch raw := addr.(type) { case *net.UDPAddr: return raw.Port default: _, port, err := net.SplitHostPort(addr.String()) if err != nil { panic(err) } i64, err :=...
package missinggo import ( "net" "strconv" ) // Extracts the port as an integer from an address string. func AddrPort(addr net.Addr) int { switch raw := addr.(type) { case *net.UDPAddr: return raw.Port default: _, port, err := net.SplitHostPort(addr.String()) if err != nil { panic(err) } i64, err :=...
Return nil if given nil
AddrIP: Return nil if given nil
Go
mit
anacrolix/missinggo
1ff58bfae05ef4b367a73a952e8edb218373f195
aroc.go
aroc.go
package main import ( "fmt" "github.com/sdegutis/go.fsevents" "log" "os" "os/exec" ) func main() { if len(os.Args) < 3 { fmt.Fprintln(os.Stderr, "Usage: aroc DIRECTORY COMMAND [ARGS…]") os.Exit(1) } ch := fsevents.WatchPaths([]string{os.Args[1]}) var cmd *exec.Cmd go func() { for _ = range ch { ...
package main import ( "fmt" "github.com/sdegutis/go.fsevents" "log" "os" "os/exec" ) func main() { if len(os.Args) < 3 { fmt.Fprintln(os.Stderr, "Usage: aroc DIRECTORY|FILE COMMAND [ARGS…]") os.Exit(1) } ch := fsevents.WatchPaths([]string{os.Args[1]}) var cmd *exec.Cmd go func() { for _ = range ch ...
Change output messages to reflect support for single files
Change output messages to reflect support for single files
Go
mit
mxey/aroc
aad51df75de3a018a6668ddbc180964b0fe21b2b
data/validate/validation_error.go
data/validate/validation_error.go
// Copyright 2014 The goyy Authors. All rights reserved. // Use of this source code is governed by a MIT-style // license that can be found in the LICENSE file. package validate import ( "fmt" ) type Error struct { field string typ string message string } func (me *Error) Error() string { return fmt.Spr...
// Copyright 2014 The goyy Authors. All rights reserved. // Use of this source code is governed by a MIT-style // license that can be found in the LICENSE file. package validate import ( "fmt" ) type Error struct { field string typ string message string } func (me *Error) Error() string { return fmt.Spr...
Add a field name to the validation prompt
Add a field name to the validation prompt
Go
mit
goyy/goyy,goyy/goyy,goyy/goyy,goyy/goyy
51f18caa215d797c90eced231c718f193d4601d6
main.go
main.go
/* http://www.apache.org/licenses/LICENSE-2.0.txt Copyright 2015 Intel Coporation 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 b...
/* http://www.apache.org/licenses/LICENSE-2.0.txt Copyright 2015 Intel Coporation 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 b...
Update import for mysql package
Update import for mysql package
Go
apache-2.0
intelsdi-x/snap-plugin-publisher-mysql,mkleina/snap-plugin-publisher-mysql,mkleina/snap-plugin-publisher-mysql,intelsdi-x/snap-plugin-publisher-mysql,intelsdi-x/snap-plugin-publisher-mysql
8adefe828fbab9a9cb9ab84153816c650e99c483
main.go
main.go
package main import "fmt" func main() { fmt.Println("Hello, Slate!") }
package main import ( "encoding/json" "fmt" "io/ioutil" "net/http" ) func main() { schema, err := Load("http://petstore.swagger.io/v2/swagger.json") if err != nil { return } fmt.Printf("%#v\r\n", schema) } func Load(url string) (interface{}, error) { var schema interface{} response, err := http.Get(url) ...
Add 'Load' function to fetch schema
Add 'Load' function to fetch schema
Go
mit
slate-io/slate
a9eb40cee0c4287e8d049acc0c5b5afebfe2d036
io/output.go
io/output.go
package io import ( "bytes" "fmt" "io" ) type Output struct { w io.Writer output *bytes.Buffer } func newOutput(w io.Writer) *Output { return &Output{ w: w, output: &bytes.Buffer{}, } } func (o *Output) Print(a ...interface{}) { fmt.Fprint(o.output, a...) } func (o *Output) Printf(format string, ...
package io import ( "bytes" "fmt" "io" ) type Output struct { w io.Writer output *bytes.Buffer } func newOutput(w io.Writer) *Output { return &Output{ w: w, output: &bytes.Buffer{}, } } func (o *Output) Print(a ...interface{}) { fmt.Fprint(o.output, a...) } func (o *Output) Printf(format string, ...
Check if final newline is necessary.
Check if final newline is necessary.
Go
mit
matematik7/codejam-go,matematik7/codejam-go-v2
71103f65b11f7f9c32a4ed77a10413732869e032
plugins/plugins.go
plugins/plugins.go
package plugins import ( _ "github.com/gengo/goship/plugins/helloworld" )
package plugins // Import plugin packages here import ( // _ "github.com/gengo/goship/plugins/helloworld" )
Add example plugin import as comment
Add example plugin import as comment
Go
apache-2.0
cazacugmihai/goship,gengo/goship,gengo/goship,kgrvamsi/goship,gengo/goship,kgrvamsi/goship,cazacugmihai/goship,cazacugmihai/goship,kgrvamsi/goship
b13028a3f6da77d1e8325ab8719e9d3a703a5a03
entities/spy_report.go
entities/spy_report.go
package entities import ( "fmt" "time" "github.com/Vladimiroff/vec2d" ) type SpyReport struct { Player string Name string Owner string Position *vec2d.Vector ShipCount int32 ValidUntil int64 CreatedAt int64 } // Database key. func (s *SpyReport) Key() string { return fmt.Sprintf("spy_r...
package entities import ( "fmt" "time" "github.com/Vladimiroff/vec2d" ) type SpyReport struct { Player string Name string Owner string Position *vec2d.Vector ShipCount int32 ValidUntil int64 CreatedAt int64 } // Database key. func (s *SpyReport) Key() string { return fmt.Sprintf("spy_r...
Fix the calculation of SpyReport.ValidUntil
Fix the calculation of SpyReport.ValidUntil
Go
mit
WarCluster/warcluster-server,WarCluster/warcluster-server
64b032ba5aab9cd1e90c1db5bd5173a1f5927bd0
main.go
main.go
// Real-time massively multiplayer online space strategy arcade browser game! package main import ( "os" "os/signal" "syscall" "warcluster/config" "warcluster/entities/db" "warcluster/leaderboard" "warcluster/server" ) var cfg config.Config func main() { go final() cfg.Load("config/config.gcfg") db.InitP...
// Real-time massively multiplayer online space strategy arcade browser game! package main import ( "os" "os/signal" "syscall" "warcluster/config" "warcluster/entities/db" "warcluster/leaderboard" "warcluster/server" ) var cfg config.Config func main() { go final() cfg.Load("config/config.gcfg") db.InitP...
Introduce simple sorted slice as a leaderboard
Introduce simple sorted slice as a leaderboard
Go
mit
WarCluster/warcluster-server,WarCluster/warcluster-server
a33fcd6e1bb3586af2104d7fe5acbfc0b85773ea
main.go
main.go
package main import "fmt" import "crypto/md5" // url, gfy-url func convert(input string, n, max int) []int { b := md5.Sum([]byte(input)) // 16 bytes result := make([]int, n) blocksize := (numbits(max) / 8) + 1 j := 0 for i := 0; i < n; i++ { result[i] = getInt(b[j:j+blocksize]) % max j += blocksize } retur...
package main import ( "fmt" "io/ioutil" "math/rand" "strings" "time" ) var ( animals []string adjectives []string ) func readWords(filename string) ([]string, error) { d, err := ioutil.ReadFile(filename) if err != nil { return []string{}, err } words := strings.Split(string(d), "\n") return words, n...
Change method of generating random numbers and add getShortURL() method
Change method of generating random numbers and add getShortURL() method
Go
mit
nindalf/linkto
1d75f3068755f9c2185beecada12c7ee484c7260
library/0.go
library/0.go
package library import ( "sort" "github.com/anaminus/rbxmk" ) // registry contains registered Libraries. var registry []rbxmk.Library // register registers a Library to be returned by All. func register(library rbxmk.Library) { registry = append(registry, library) } // All returns a list of Libraries defined in...
package library import ( "sort" "github.com/anaminus/rbxmk" ) type Libraries []rbxmk.Library func (l Libraries) Len() int { return len(l) } func (l Libraries) Swap(i, j int) { l[i], l[j] = l[j], l[i] } func (l Libraries) Less(i, j int) bool { if l[i].Priority == l[j].Priority { return l[i].Name < l[j].Nam...
Refactor library list as sortable type.
Refactor library list as sortable type.
Go
mit
Anaminus/rbxmk,Anaminus/rbxmk
4cda2c8dc737e1ed9946ce71a018398e62c1290b
line_test.go
line_test.go
// +build !windows package liner import ( "bytes" "strings" "testing" ) func TestHistory(t *testing.T) { input := `foo bar baz quux dingle` var s State num, err := s.ReadHistory(strings.NewReader(input)) if err != nil { t.Fatal("Unexpected error reading history", err) } if num != 5 { t.Fatal("Wrong num...
package liner import ( "bytes" "strings" "testing" ) func TestHistory(t *testing.T) { input := `foo bar baz quux dingle` var s State num, err := s.ReadHistory(strings.NewReader(input)) if err != nil { t.Fatal("Unexpected error reading history", err) } if num != 5 { t.Fatal("Wrong number of history entri...
Enable generic tests on Windows
Enable generic tests on Windows The build line excluding windows was inadvertent.
Go
mit
mvo5/liner,PLWagner/golang-liner,Cofyc/liner,go-delve/liner,platinasystems/liner,moander/liner,glycerine/liner
1c03ff45cda99e5bf750797c2acbeb962b3a8e89
error.go
error.go
// Copyright 2016 Marcel Gotsch. All rights reserved. // Use of this source code is governed by a MIT-style // license that can be found in the LICENSE file. package goserv import ( "errors" "fmt" "net/http" ) var ErrNotFound = errors.New(http.StatusText(http.StatusNotFound)) var StdErrorHandler = ErrorHandlerFun...
// Copyright 2016 Marcel Gotsch. All rights reserved. // Use of this source code is governed by a MIT-style // license that can be found in the LICENSE file. package goserv import ( "errors" "fmt" "net/http" ) // ErrNotFound gets passed to a Router's ErrorHandler if // no route matched the request path or none of...
Document StdErrorHandler and remove StdErrorHandlerFunc
Document StdErrorHandler and remove StdErrorHandlerFunc
Go
bsd-3-clause
gotschmarcel/goserv
60f167f8d15af3b840802b35d5f9919b0377e4b7
main.go
main.go
package stellarbase import "github.com/stellar/go-stellar-base/xdr" //go:generate rake xdr:update //go:generate go fmt ./xdr // AddressToAccountId converts the provided address into a xdr.AccountId func AddressToAccountId(address string) (result xdr.AccountId, err error) { bytes, err := DecodeBase58Check(VersionByt...
package stellarbase import "github.com/stellar/go-stellar-base/xdr" //go:generate rake xdr:update //go:generate go fmt ./xdr // One is the value of one whole unit of currency. Stellar uses 7 fixed digits // for fractional values, thus One is 10 million (10^7) const One = 10000000 // AddressToAccountId converts the...
Add One constant, for easier "amount" creation
Add One constant, for easier "amount" creation
Go
apache-2.0
stellar/go-stellar-base,stellar/go-stellar-base
f768c1f1925bfb84d4fdddf6537b749d3776b590
main.go
main.go
package main import ( "fmt" "log" "net/http" "path/filepath" "github.com/docopt/docopt.go" ) func main() { arguments, _ := docopt.Parse(usage(), nil, true, "0.1", false) port := arguments["--port"].(string) path, _ := filepath.Abs(arguments["<directory>"].(string)) start(path, port) } func usage() strin...
package main import ( "fmt" "log" "net/http" "path/filepath" "github.com/docopt/docopt.go" ) func main() { arguments, _ := docopt.Parse(usage(), nil, true, "0.1", false) port := arguments["--port"].(string) path, _ := filepath.Abs(arguments["<directory>"].(string)) start(path, port) } func usage() strin...
Add logging of request to stdout
Add logging of request to stdout
Go
mit
lminaudier/sws
9e07d85eb0bbb0ea6795aa52191272a5e4fb6ed5
main_test.go
main_test.go
package main import ( "net/http/httptest" "testing" ) func TestHandler(t *testing.T) { server := httptest.NewServer(handler) defer server.Close() }
Add test for main but need to revise.
Add test for main but need to revise.
Go
mit
Code-Craftsmanship-Saturdays/software-security,Code-Craftsmanship-Saturdays/software-security,Code-Craftsmanship-Saturdays/software-security,Code-Craftsmanship-Saturdays/software-security
4d94207434b1153e4359157c06025c56324fff5a
go/libkb/version.go
go/libkb/version.go
package libkb import ( "fmt" ) // NOTE: This file is the source of truth for our version number, but we have a // script that reads it at packaging/version.sh. If you refactor this // file, update that script. // Version as MAJOR.MINOR.PATCH const Version = "1.0.0" // Build number const Build = "39" /...
package libkb import ( "fmt" ) // NOTE: This file is the source of truth for our version number, but we have a // script that reads it at packaging/version.sh. If you refactor this // file, update that script. // Version as MAJOR.MINOR.PATCH const Version = "1.0.0" // Build number const Build = "40" /...
Bump build number to 40
Bump build number to 40
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
be125d66895c8d8a39735cc410bff05c1f8ba30b
lib/memstats/memstats.go
lib/memstats/memstats.go
package memstats import ( "fmt" "github.com/Symantec/Dominator/lib/format" "io" "runtime" ) func writeNamedStat(writer io.Writer, name string, value uint64) { fmt.Fprintf(writer, " %s=%s\n", name, format.FormatBytes(value)) } func WriteMemoryStats(writer io.Writer) { var memStats runtime.MemStats runtime.Rea...
package memstats import ( "fmt" "github.com/Symantec/Dominator/lib/format" "io" "runtime" ) func writeNamedStat(writer io.Writer, name string, value uint64) { fmt.Fprintf(writer, " %s=%s\n", name, format.FormatBytes(value)) } func WriteMemoryStats(writer io.Writer) { var memStats runtime.MemStats runtime.Rea...
Remove unhelpful and confusing TotalAlloc memory metric.
Remove unhelpful and confusing TotalAlloc memory metric.
Go
apache-2.0
keep94/Dominator,Symantec/Dominator,rgooch/Dominator,rgooch/Dominator,rgooch/Dominator,Symantec/Dominator,Symantec/Dominator,keep94/Dominator,keep94/Dominator
d9ddcf4f45f1a3aa4ffad31fcd5ce19274d8a88a
hello.go
hello.go
package main import "fmt" func main() { fmt.Printf("My Hello Golang Program, Hello World\n") }
package main import "fmt" func main() { fmt.Printf("My Hello Golang Program, Hello World 1.0.0\n") }
Add version number in the program output
Add version number in the program output
Go
apache-2.0
rjansen/hello
e6e52ca44512859fb49f019c0aa2ddbdbf394ad3
src/lib/debug/info_test.go
src/lib/debug/info_test.go
package debug import ( "path/filepath" "testing" "github.com/stretchr/testify/assert" ) func TestGoInfo(t *testing.T) { assert.Equal(t, "info_test.go", filepath.Base(NewGoInfo(0).file)) }
package debug import ( "path/filepath" "testing" "github.com/stretchr/testify/assert" ) func TestNewGoInfo(t *testing.T) { assert.Equal(t, "info_test.go", filepath.Base(NewGoInfo(0).file)) } func TestNewGoInfoWithInvalidSkip(t *testing.T) { defer func() { if r := recover(); r == nil { t.Fail() } }() ...
Add more tests of debug package
Add more tests of debug package
Go
mit
tisp-lang/tisp,tisp-lang/tisp,raviqqe/tisp,raviqqe/tisp,raviqqe/tisp
d7c69d7ce23febe4f5ee5a0c0e07865d71dca5fa
userdir_linux_test.go
userdir_linux_test.go
// +build linux package userdir_test import ( "strings" "testing" "github.com/stretchr/testify/require" "github.com/vrischmann/userdir" ) func TestGetDataHome(t *testing.T) { d := userdir.GetDataHome() require.True(t, strings.HasSuffix(d, ".local/share")) } func TestGetConfigHome(t *testing.T) { d := userdi...
// +build linux package userdir_test import ( "os" "strings" "testing" "github.com/stretchr/testify/require" "github.com/vrischmann/userdir" ) func TestGetDataHome(t *testing.T) { d := userdir.GetDataHome() require.True(t, strings.HasSuffix(d, ".local/share")) } func TestGetDataHomeFromVariable(t *testing.T...
Add tests that actually read from the environment variables
Add tests that actually read from the environment variables
Go
mit
vrischmann/userdir
421493e8da1f761d7948372ff13526f7d0ef8423
ilium/scene.go
ilium/scene.go
package ilium type Scene struct { Aggregate Primitive Lights []Light } func MakeScene(config map[string]interface{}) Scene { aggregateConfig := config["aggregate"].(map[string]interface{}) primitives := MakePrimitives(aggregateConfig) if len(primitives) != 1 { panic("aggregate must be a single primitive") ...
package ilium type Scene struct { Aggregate Primitive Lights []Light LightDistribution Distribution1D } func MakeScene(config map[string]interface{}) Scene { aggregateConfig := config["aggregate"].(map[string]interface{}) primitives := MakePrimitives(aggregateConfig) if len(primitives) != 1 {...
Add distribution to Scene to sample lights
Add distribution to Scene to sample lights
Go
bsd-3-clause
akalin/ilium
106fe688c265dca7ec30f5cbe663e639a16d7ec8
monitor/config_test.go
monitor/config_test.go
package monitor_test import ( "testing" "time" "github.com/BurntSushi/toml" "github.com/influxdb/influxdb/monitor" ) func TestConfig_Parse(t *testing.T) { // Parse configuration. var c monitor.Config if _, err := toml.Decode(` store-enabled=true store-database="the_db" store-interval="10m" `, &c); err != nil ...
package monitor_test import ( "testing" "time" "github.com/BurntSushi/toml" "github.com/influxdb/influxdb/monitor" ) func TestConfig_Parse(t *testing.T) { // Parse configuration. var c monitor.Config if _, err := toml.Decode(` store-enabled=true store-database="the_db" store-interval="10m" `, &c); err != nil ...
Fix compile error in monitor unit tests
Fix compile error in monitor unit tests
Go
mit
jipperinbham/influxdb,mnuessler/influxdb,nooproblem/influxdb,lgpeterson/influxdb,benbjohnson/influxdb,GrimDerp/influxdb,imcom/influxdb,jipperinbham/influxdb,apriendeau/influxdb,mcanthony/influxdb,DanielMorsing/influxdb,pablolmiranda/influxdb,pkittenis/influxdb,archsaber/influxdb,mcanthony/influxdb,influxdb/influxdb,ale...
e817a299c4faf29af3b52a17a9e646298a2e9d25
pkg/db/schema/access.go
pkg/db/schema/access.go
package schema import "time" type Access struct { ID string `gorethink:"id,omitempty"` Dataset string `gorethink:"dataset"` Birthtime time.Time `gorethink:"birthtime"` MTime time.Time `gorethink:"mtime"` Permissions string `gorethink:"permissions"` ProjectID string `gorethink:...
package schema import "time" type Access struct { ID string `gorethink:"id,omitempty"` Dataset string `gorethink:"dataset"` Birthtime time.Time `gorethink:"birthtime"` MTime time.Time `gorethink:"mtime"` Permissions string `gorethink:"permissions"` ProjectID string `gorethink:...
Add method to create a new schema.Access item filling in default values.
Add method to create a new schema.Access item filling in default values.
Go
mit
materials-commons/mcstore,materials-commons/mcstore,materials-commons/mcstore
707e5378b00108fa732f15c52c1c7187052c7769
pkg/utils/utils_test.go
pkg/utils/utils_test.go
package utils import ( "math/rand" "sync" "testing" "github.com/stretchr/testify/assert" ) func TestRandomString(t *testing.T) { rand.Seed(42) s1 := RandomString(10) s2 := RandomString(20) rand.Seed(42) s3 := RandomString(10) s4 := RandomString(20) assert.Len(t, s1, 10) assert.Len(t, s2, 20) assert.Le...
package utils import ( "math/rand" "sync" "testing" "github.com/stretchr/testify/assert" ) func TestRandomString(t *testing.T) { rand.Seed(42) s1 := RandomString(10) s2 := RandomString(20) rand.Seed(42) s3 := RandomString(10) s4 := RandomString(20) assert.Len(t, s1, 10) assert.Len(t, s2, 20) assert.Le...
Increase concurrent access in tests
Increase concurrent access in tests
Go
agpl-3.0
nono/cozy-stack,nono/cozy-stack,sebn/cozy-stack,sebn/cozy-stack,nono/cozy-stack,nono/cozy-stack,sebn/cozy-stack,nono/cozy-stack,sebn/cozy-stack
5132a8f2c96dc778614e5a49a3fd1d7ec9be2beb
audit.go
audit.go
package scipipe import ( "time" ) // AuditInfo contains structured audit/provenance logging information to go with an IP type AuditInfo struct { Command string Params map[string]string Keys map[string]string ExecTimeMS time.Duration Upstream map[string]*AuditInfo } // NewAuditInfo returns a new ...
package scipipe import ( "time" ) // AuditInfo contains structured audit/provenance logging information for a // particular task (invocation), to go with all outgoing IPs from that task type AuditInfo struct { ID string Command string Params map[string]string Keys map[string]string ExecTime...
Add an ID field to AuditInfo
Add an ID field to AuditInfo
Go
mit
scipipe/scipipe,scipipe/scipipe,samuell/scipipe
2a528e4492e2284641e8c164dda5aba801f2153a
cmd/sqlite-squish/main.go
cmd/sqlite-squish/main.go
package main import "fmt" func main() { fmt.Println("Hello, world!") }
package main import ( "bufio" "fmt" "log" "os" "github.com/griffithsh/sql-squish/database" ) func main() { scanner := bufio.NewScanner(os.Stdin) var concatted string for scanner.Scan() { concatted = concatted + scanner.Text() } d, err := database.FromString(concatted) if err != nil { log.Fatal(err) ...
Make sqlite-squish accept SQL on stdin
Make sqlite-squish accept SQL on stdin
Go
mit
griffithsh/sqlite-squish
5567f18d6343710291d090828b0e7f3daa244e9d
glaze.go
glaze.go
package main import ( "log" "net/http" "os" ) type Config struct { port string allowedContentTypes string // uncompiled regex } func main() { config := Config{ port: os.Getenv("PORT"), allowedContentTypes: "^image/", } proxy := newProxy(config) http.HandleFunc("/", proxy.h...
package main import ( "log" "net/http" "os" ) type Config struct { port string allowedContentTypes string // uncompiled regex } func envOrDefault(key string, default_value string) string { env := os.Getenv(key) if env != "" { return env } else { return default_value } } func main() { co...
Allow customisation of allowed content type regex via env
Allow customisation of allowed content type regex via env
Go
mit
ryanlower/front,experiment/front
1c90c3abd2cadb746ffe076e9104c27b3c8b5957
config.go
config.go
package goatee import ( "encoding/json" "io/ioutil" "log" "os" ) type configuration struct { Redis Redis Web Web } type Redis struct { Host string } type Web struct { Host string } var ( DEBUG = false Config = new(configuration) ) func getEnv() string { env := os.Getenv("GO_ENV") if env == "" || en...
package goatee import ( "encoding/json" "io/ioutil" "log" "os" ) type configuration struct { Redis Redis Web Web } type Redis struct { Host string } type Web struct { Host string } var ( DEBUG = false Config = new(configuration) ) func getEnv() string { env := os.Getenv("GO_ENV") if env == "" || en...
Remove the file name display when attempting to read
Remove the file name display when attempting to read
Go
mit
johnernaut/goatee,johnernaut/goatee
b036222a738c50f73e9f376da31424f73a58cd79
gocat.go
gocat.go
package main import ( "fmt" "io" "os" ) var ARGV []string func main() { ARGV = os.Args[1:] if len(ARGV) >= 1 { for _, filename := range ARGV { if filename == "--" { continue } // - means read stdin as a special case if filename == "-" { filename = "/dev/stdin" } // Otherwise we're...
package main import ( "fmt" "io" "os" ) var ARGV []string func main() { ARGV = os.Args[1:] if len(ARGV) == 0 { // Read stdin only io.Copy(os.Stdout, os.Stdin) } else { // Read ARGV only for _, filename := range ARGV { if filename == "--" { continue } // - means read stdin as a special c...
Read stdin if no arguments given
Read stdin if no arguments given
Go
mit
caius/gocat
1e4326f15a345fac981f5e295f0049275db5d2d4
certstream.go
certstream.go
package certstream import ( "time" "github.com/gorilla/websocket" "github.com/jmoiron/jsonq" "github.com/pkg/errors" ) func CertStreamEventStream(skipHeartbeats bool) (chan jsonq.JsonQuery, chan error) { outputStream := make(chan jsonq.JsonQuery) errStream := make(chan error) go func() { for { c, _, err...
package certstream import ( "time" "github.com/gorilla/websocket" "github.com/jmoiron/jsonq" "github.com/pkg/errors" ) func CertStreamEventStream(skipHeartbeats bool) (chan jsonq.JsonQuery, chan error) { outputStream := make(chan jsonq.JsonQuery) errStream := make(chan error) go func() { for { c, _, err ...
Remove newline that snuck in
Remove newline that snuck in
Go
mit
CaliDog/certstream-go
11d7be08e4d9e79b55c3181720ce8122dad4c020
createPicHandler.go
createPicHandler.go
package pixur import ( "encoding/json" "mime/multipart" "net/http" ) func (s *Server) uploadHandler(w http.ResponseWriter, r *http.Request) error { if r.Method != "POST" { http.Error(w, "Unsupported Method", http.StatusMethodNotAllowed) return nil } var filename string var filedata multipart.File var fil...
package pixur import ( "encoding/json" "mime/multipart" "net/http" ) func (s *Server) uploadHandler(w http.ResponseWriter, r *http.Request) error { if r.Method != "POST" { http.Error(w, "Unsupported Method", http.StatusMethodNotAllowed) return nil } var filename string var filedata multipart.File var fil...
Allow uploads even if a file was not provided. This happens when a url is provided, but not a file
Allow uploads even if a file was not provided. This happens when a url is provided, but not a file
Go
apache-2.0
carl-mastrangelo/pixur,carl-mastrangelo/pixur
2c12109b0628bc9c5b28724d1276e1bb502996f6
models/object.go
models/object.go
package models type Object interface { //Basic CRUD Method Create() error Read() error Update() error Delete() error //Basic Object Method Has(name string) (bool, string, error) GetById(id string) error GetByName(name string) error Log(action, actionLevel, actionType int64, actionId string, content []string)...
package models type Object interface { Create() error Read() error Update() error Delete() error } type Model interface { Object Has(name string) (bool, string, error) GetById(id string) error GetByName(name string) error Log(action, actionLevel, actionType int64, actionId string, content []string) error }
Change model interface to Object and Model.
Change model interface to Object and Model.
Go
mit
yonh/wharf,maquanyi/wharf,maquanyi/wharf,yonh/wharf
b7bef4feabe2966a326af0d7d0d9508f104e489f
mm/mm.go
mm/mm.go
package mm import ( "fmt" "time" ) type Measurement struct { When time.Time What string Value []byte } func (m *Measurement) String() string { return fmt.Sprintf("when=%s measure=%s val=%s", m.When.Format(time.RFC3339Nano), m.What, m.Value) }
package mm import ( "fmt" "os" "time" ) var ( source = os.Getenv("SHH_SOURCE") ) type Measurement struct { When time.Time What string Value []byte } func (m *Measurement) String() string { msg := fmt.Sprintf("when=%s measure=%s val=%s", m.When.Format(time.RFC3339Nano), m.What, m.Value) if source != "" { ...
Include the source if it exists
Include the source if it exists
Go
bsd-3-clause
heroku/shh,heroku/shh
91520838fc72f4004d65844b8e57df85473808a1
state.go
state.go
package docker import ( "fmt" "github.com/dotcloud/docker/utils" "sync" "time" ) type State struct { sync.Mutex Running bool Pid int ExitCode int StartedAt time.Time Ghost bool } // String returns a human-readable description of the state func (s *State) String() string { if s.Running { if ...
package docker import ( "fmt" "github.com/dotcloud/docker/utils" "sync" "time" ) type State struct { sync.Mutex Running bool Pid int ExitCode int StartedAt time.Time Ghost bool } // String returns a human-readable description of the state func (s *State) String() string { if s.Running { if ...
Make sure container is not marked as ghost when it starts
Make sure container is not marked as ghost when it starts
Go
apache-2.0
xiaods/docker,remh/docker,rsmitty/docker,erikstmartin/docker,VishvajitP/docker,medallia/docker,maxwell92/docker,1HLtd/docker,EricPai/docker,alexisbellido/docker.github.io,docker/docker,allencloud/docker,boite/docker,cezarsa/docker,wzzrd/docker,mtesselH/docker,ZenikaOuest/docker,liaoqingwei/docker,SaiedKazemi/docker,tha...
a2e32be6a119d60bfa069c9775497c3de8e85ed8
hpack/2_3_3_index_address_space.go
hpack/2_3_3_index_address_space.go
package hpack import ( "github.com/summerwind/h2spec/config" "github.com/summerwind/h2spec/spec" "golang.org/x/net/http2" ) func IndexAddressSpace() *spec.TestGroup { tg := NewTestGroup("2.3.3", "Index Address Space") // Indices strictly greater than the sum of the lengths of both // tables MUST be treated as ...
package hpack import ( "github.com/summerwind/h2spec/config" "github.com/summerwind/h2spec/spec" "golang.org/x/net/http2" ) func IndexAddressSpace() *spec.TestGroup { tg := NewTestGroup("2.3.3", "Index Address Space") // Indices strictly greater than the sum of the lengths of both // tables MUST be treated as ...
Use index 126 instead of 70
Use index 126 instead of 70
Go
mit
summerwind/h2spec