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
ac76967dbac4e98ffea03a2a1f35a322a4cc88de
opts/ip.go
opts/ip.go
package opts import ( "fmt" "net" ) // IPOpt holds an IP. It is used to store values from CLI flags. type IPOpt struct { *net.IP } // NewIPOpt creates a new IPOpt from a reference net.IP and a // string representation of an IP. If the string is not a valid // IP it will fallback to the specified reference. func N...
package opts import ( "fmt" "net" ) // IPOpt holds an IP. It is used to store values from CLI flags. type IPOpt struct { *net.IP } // NewIPOpt creates a new IPOpt from a reference net.IP and a // string representation of an IP. If the string is not a valid // IP it will fallback to the specified reference. func N...
Convert dockerd to use cobra and pflag
Convert dockerd to use cobra and pflag Signed-off-by: Daniel Nephin <6347c07ae509164cffebfb1e2a0d6ed64958db19@docker.com>
Go
apache-2.0
redpanda/cli,e11137/cli,riyazdf/cli,allencloud/cli,Zebrilee/cli,docker/cli,e11137/cli,docker/cli,cpuguy83/cli,redpanda/cli,riyazdf/cli,thaJeztah/cli,Zebrilee/cli,ashfall/cli,ashfall/cli,cpuguy83/cli,thaJeztah/cli,dnephin/cli,dnephin/cli,allencloud/cli
188a638e568a00a1f4e338a677c0820d5ddbc4a6
parrot.go
parrot.go
package main import "github.com/nsf/termbox-go" import "time" import "flag" func main() { loops := flag.Int("loops", 0, "number of times to loop (default: infinite)") flag.Parse() err := termbox.Init() if err != nil { panic(err) } defer termbox.Close() event_queue := make(chan termbox.Event) go func() { ...
package main import "github.com/nsf/termbox-go" import "time" import "flag" func main() { loops := flag.Int("loops", 0, "number of times to loop (default: infinite)") flag.Parse() err := termbox.Init() if err != nil { panic(err) } defer termbox.Close() event_queue := make(chan termbox.Event) go func() { ...
Add ctrl-c support to quit.
Add ctrl-c support to quit. Closes #4
Go
mit
jmhobbs/terminal-parrot
545cfdd75fed18e70592602ff3fc1214ea165600
code/02/pointers.go
code/02/pointers.go
package main import "fmt" var ( name string = "Чочко" age uint8 = 27 p_name *string ) func main() { p_name = &name fmt.Printf("name е на адрес %p и има стойност %s\n", p_name, name) fmt.Printf("age е на адрес %p и има стойност %d\n", &age, age) }
package main import "fmt" var ( name string = "Чочко" age uint8 = 27 pName *string ) func main() { pName = &name fmt.Printf("name е на адрес %p и има стойност %s\n", pName, name) fmt.Printf("age е на адрес %p и има стойност %d\n", &age, age) }
Use camel case instead of snake case
Use camel case instead of snake case
Go
mit
fmi/go-lectures,fmi/go-lectures,fmi/go-lectures,fmi/go-lectures
9f345e7f4f3e82ac254d5f419ad26a6a0c5ddb68
events/edge.go
events/edge.go
package events import ( "gpio" "time" ) type EdgeEvent struct { BeforeEvent int AfterEvent int Timestamp time.Time } func edgeTrigger(pin gpio.GPIO, eventCh chan EdgeEvent, ctrlCh chan bool) (error) { lastState, err := pin.ReadValue() if err != nil { panic(err) // improve } for true { select { case <...
package events import ( "gpio" "time" ) type EdgeEvent struct { BeforeEvent int AfterEvent int Timestamp time.Time } func edgeTrigger(pin gpio.GPIO, eventCh chan EdgeEvent, ctrlCh chan bool) (error) { lastState, err := pin.ReadValue() if err != nil { panic(err) // improve } for true { select { case <...
Correct minor snafu * SNAFU: Situation Normal. All Fucked Up.
Correct minor snafu * SNAFU: Situation Normal. All Fucked Up.
Go
bsd-3-clause
fraburnham/gpio
f02b706066774ea0c380d11a93049b3ae1e4217a
request.go
request.go
package telegraph import ( gojson "encoding/json" "errors" "fmt" "net/url" json "github.com/pquerna/ffjson/ffjson" http "github.com/valyala/fasthttp" ) // Response represents a response from the Telegram API with the result stored raw. If ok equals true, // the request was successful, and the result of the que...
package telegraph import ( gojson "encoding/json" "errors" "fmt" "net/url" json "github.com/pquerna/ffjson/ffjson" http "github.com/valyala/fasthttp" ) // response represents a response from the Telegram API with the result stored raw. If ok equals true, // the request was successful, and the result of the que...
Hide Response structure because it is not publicly used anywhere
:building_construction: Hide Response structure because it is not publicly used anywhere
Go
mit
toby3d/go-telegraph,toby3d/telegraph
fa58c74213de3b193dfba428c1efd08cb1e2a775
hub/hub.go
hub/hub.go
package hub import ( "sync" "github.com/gorilla/websocket" ) var mutex sync.Mutex type WSClient struct { ID string Channel string Conn *websocket.Conn } var ( pool map[string]map[string]*WSClient ) func init() { pool = map[string]map[string]*WSClient{} } func Add(ID, channel string, conn *websocke...
package hub import ( "sync" "github.com/gorilla/websocket" ) var mutex sync.Mutex type WSClient struct { ID string Channel string Conn *websocket.Conn } var ( pool map[string]map[string]*WSClient ) func init() { pool = map[string]map[string]*WSClient{} } func Add(ID, channel string, conn *websocke...
Fix concurrency write to websocket channels
Fix concurrency write to websocket channels
Go
mit
rafaelsq/roar
a8c97343cf5cc4b4ab4e98cdf415569df427352b
helper/pluginutils/loader/filter_windows.go
helper/pluginutils/loader/filter_windows.go
// +build windows package loader import ( "os" "path/filepath" ) // On windows, an executable can be any file with any extension. To avoid // introspecting the file, here we skip executability checks on windows systems // and simply check for the convention of an `exe` extension. func executable(path string, s os....
// +build windows package loader import ( "os" "path/filepath" ) // On windows, an executable can be any file with any extension. To avoid // introspecting the file, here we skip executability checks on windows systems // and simply check for the convention of an `.exe` extension. func executable(path string, s os...
Fix executable check on windows
Fix executable check on windows
Go
mpl-2.0
burdandrei/nomad,dvusboy/nomad,hashicorp/nomad,hashicorp/nomad,burdandrei/nomad,hashicorp/nomad,dvusboy/nomad,burdandrei/nomad,dvusboy/nomad,dvusboy/nomad,dvusboy/nomad,hashicorp/nomad,hashicorp/nomad,burdandrei/nomad,burdandrei/nomad,dvusboy/nomad,burdandrei/nomad,dvusboy/nomad,hashicorp/nomad,burdandrei/nomad
95f9e1619e44e3025ac1be4e96580256fa5d7966
tsdb/engine/pd1/encoding_test.go
tsdb/engine/pd1/encoding_test.go
package pd1_test import ( // "math/rand" // "reflect" "testing" "time" // "github.com/influxdb/influxdb/tsdb/engine/pd1" ) func TestEncoding_FloatBlock(t *testing.T) { // valueCount := 100 // times := getTimes(valueCount, 60, time.Second) // values := make([]Value, len(times)) // for i, t := range times { ...
package pd1_test import ( // "math/rand" "fmt" "reflect" "testing" "time" "github.com/influxdb/influxdb/tsdb/engine/pd1" ) func TestEncoding_FloatBlock(t *testing.T) { valueCount := 1000 times := getTimes(valueCount, 60, time.Second) values := make(pd1.Values, len(times)) for i, t := range times { values...
Update encoding test to work with new interface.
Update encoding test to work with new interface.
Go
mit
mark-rushakoff/influxdb,pablolmiranda/influxdb,jgeiger/influxdb,mre/influxdb,joaopedrotaveira/influxdb,daachi/influxdb,roobert/influxdb,mvadu/influxdb,n1tr0g/influxdb,otoolep/influxdb,vladlopes/influxdb,bluebreezecf/influxdb,apigee/influxdb,pablolmiranda/influxdb,mvadu/influxdb,daachi/influxdb,linearb/influxdb,mnuessle...
0cfe33a2b9554ff3395dba82cfad5ed7a78bde75
examples/basic.go
examples/basic.go
/* Unmarshal */ package main import ( "go/bandersnatch" "encoding/xml" "fmt" "os" //"strings" ) type Person struct { XMLName Name `xml:"person"` Name Name `xml:"name"` Email []Email `xml:"email"` } type Name struct { Family string `xml:"family"` Personal string `xml:"personal"` } type Em...
package main import ( "bandersnatch" "fmt" ) func main() { boardGames := bandersnatch.GetBoardGame(30000) fmt.Printf("%+v", boardGames) }
Make it a proper library
Make it a proper library
Go
mit
5outh/bandersnatch
98ee5434ef02856cc9289f546c38d12a3244fe15
text_formatter_test.go
text_formatter_test.go
package logrus import ( "bytes" "errors" "testing" ) func TestQuoting(t *testing.T) { tf := new(TextFormatter) checkQuoting := func(q bool, value interface{}) { b, _ := tf.Format(WithField("test", value)) idx := bytes.LastIndex(b, []byte{'='}) cont := bytes.Contains(b[idx:], []byte{'"'}) if cont != q {...
package logrus import ( "bytes" "errors" "testing" ) func TestQuoting(t *testing.T) { tf := &TextFormatter{DisableColors: true} checkQuoting := func(q bool, value interface{}) { b, _ := tf.Format(WithField("test", value)) idx := bytes.Index(b, ([]byte)("test=")) cont := bytes.Contains(b[idx+5:], []byte{'...
Make the test more robust
Make the test more robust
Go
mit
devopstaku/logrus,tianon/debian-golang-logrus,Sirupsen/logrus,orvice/logrus,Barberrrry/logrus,marcosnils/logrus,Dal-Papa/logrus,torfuzx/logrus,yxd-hde/logrus,seatgeek/logrus,ryanfaerman/logrus,penhauer-xiao/logrus,snowsnail/logrus,sirupsen/logrus,lixin9311/logrus,xyliuke/logrus,EmileVauge/logrus,Arkan/logrus,yawn/logru...
ab6c05839f3fb72bec5b0ec3cc2fdac275bc41ed
integration/install_released_test.go
integration/install_released_test.go
package integration import ( "os" . "github.com/onsi/ginkgo" . "github.com/onsi/gomega" ) const previousKismaticVersion = "v1.2.0" // Test a specific released version of Kismatic var _ = Describe("Installing with previous version of Kismatic", func() { BeforeEach(func() { // setup previous version of Kismatic...
package integration import ( "os" . "github.com/onsi/ginkgo" . "github.com/onsi/gomega" ) const previousKismaticVersion = "v1.3.0" // Test a specific released version of Kismatic var _ = Describe("Installing with previous version of Kismatic", func() { BeforeEach(func() { // setup previous version of Kismatic...
Update released_test to use v1.3.0
Update released_test to use v1.3.0
Go
apache-2.0
apprenda/kismatic,apprenda/kismatic,apprenda/kismatic
210cfdfb38a939b723dc8c0746e9ee5250c28e72
helpers/assets.go
helpers/assets.go
package helpers import ( "os" "path" "path/filepath" ) type Assets struct { ServiceBroker string SecurityRules string EmptySecurityRules string } func NewAssets() Assets { pwd, err := os.Getwd() if err != nil { panic(err.Error()) } return Assets{ ServiceBroker: filepath.ToSlash(path.Join...
package helpers import ( "os" "path" "path/filepath" ) type Assets struct { ServiceBroker string SecurityRules string EmptySecurityRules string } func NewAssets() Assets { pwd, err := os.Getwd() if err != nil { panic(err.Error()) } return Assets{ ServiceBroker: filepath.FromSlash(path.Jo...
Change from ToSlash to FromSlash.
Change from ToSlash to FromSlash.
Go
unknown
cloudfoundry/cli-acceptance-tests,cloudfoundry/GATS,cloudfoundry/cli-acceptance-tests,cloudfoundry/cli-acceptance-tests,cloudfoundry/GATS,cloudfoundry/GATS
d5db3591c3c013b9fc575bb7e244bf3435527d6d
gocipher/vigenere_test.go
gocipher/vigenere_test.go
package gocipher import ( "fmt" "testing" ) func TestVigenere(t *testing.T) { text := "TKSYMWRJGHKBPTEIKCYRWXIELQUPSUTLLGYFIKYIAVFNRLQFKVVSMBMJOCZGILSEAPZRGCVVHTVQYKXJSHARVIPCOGHXGZCGLQNEEXLPDQVXWBLVKCTRSVXYWUORPNEJKVYBROGIQRABKZEGZAAJSMQRANLAGZCGLKVATZSUMEAFQICYSXLNPUSJLVORWIQVMULEMVXVJHHPIGIKGPLVWAITMTLJLQPVLJLB...
package gocipher import ( "fmt" "testing" ) func TestVigenere(t *testing.T) { text := "TKSYMWRJGHKBPTEIKCYRWXIELQUPSUTLLGYFIKYIAVFNRLQFKVVSMBMJOCZGILSEAPZRGCVVHTVQYKXJSHARVIPCOGHXGZCGLQNEEXLPDQVXWBLVKCTRSVXYWUORPNEJKVYBROGIQRABKZEGZAAJSMQRANLAGZCGLKVATZSUMEAFQICYSXLNPUSJLVORWIQVMULEMVXVJHHPIGIKGPLVWAITMTLJLQPVLJLB...
Fix test to use changed retvals
Fix test to use changed retvals
Go
mit
andrewarchi/gocipher
f51c211b9d3648d41c37334071669fb2099fa227
model/entry.go
model/entry.go
package model type File struct { ID string Filename string Content []byte } type Entry struct { ID string `json:"id"` Title string `json:"title"` Timestamp int64 `json:"timestamp"` Markdown string // the entry contents }
package model type File struct { ID string Filename string Content []byte } type Entry struct { ID string `json:"id"` Title string `json:"title"` Timestamp int64 `json:"timestamp"` Markdown string `json:"-"` // the entry contents }
Save markdown only in .txt
Save markdown only in .txt
Go
mit
amassanet/gopad
8fa31758f85ff84c4f21071a156e7a5539a93795
go/otgrpc/shared.go
go/otgrpc/shared.go
package otgrpc import ( "strings" opentracing "github.com/opentracing/opentracing-go" "github.com/opentracing/opentracing-go/ext" "google.golang.org/grpc/metadata" ) var ( // Morally a const: gRPCComponentTag = opentracing.Tag{string(ext.Component), "gRPC"} ) // metadataReaderWriter satisfies both the opentra...
package otgrpc import ( "strings" opentracing "github.com/opentracing/opentracing-go" "github.com/opentracing/opentracing-go/ext" "google.golang.org/grpc/metadata" ) var ( // Morally a const: gRPCComponentTag = opentracing.Tag{string(ext.Component), "gRPC"} ) // metadataReaderWriter satisfies both the opentra...
Clarify the rational for the ToLower(key) call
Clarify the rational for the ToLower(key) call
Go
bsd-3-clause
grpc-ecosystem/grpc-opentracing,grpc-ecosystem/grpc-opentracing,grpc-ecosystem/grpc-opentracing
03a13bdbce7440955dab615aa2890338a21271a2
parser/auto.go
parser/auto.go
package parser import "fmt" func auto(input []byte) (interface{}, error) { for _, name := range parseOrder() { if parsed, err := parsers[name].parse(input); err == nil { return parsed, err } } return nil, fmt.Errorf("input format could not be identified") } func parseOrder() []string { order := make([]st...
package parser import "fmt" // Identify tries to figure out the format of the structured data passed in // If the data format could not be identified, an error will be returned func Identify(input []byte) (string, error) { for _, name := range parseOrder() { if parsed, err := parsers[name].parse(input); err == nil...
Add Identify function to parser
Add Identify function to parser
Go
mit
stilvoid/please,stilvoid/please
1af7346ca1dc87df2e9e2eae59f94b504060bda7
v1/credits.go
v1/credits.go
package bitfinex type CreditsService struct { client *Client } type Credit struct { Id int Currency string Status string Rate float64 Period float64 Amount float64 Timestamp string } // Returns an array of Credit func (c *CreditsService) All() ([]Credit, error) { req, err := c.client.n...
package bitfinex type CreditsService struct { client *Client } type Credit struct { Id int Currency string Status string Rate float64 `json:",string"` Period float64 Amount float64 `json:",string"` Timestamp string } // Returns an array of Credit func (c *CreditsService) All() ([]Credit...
Update json tags for Credit to reflect REST response.
Update json tags for Credit to reflect REST response. Some JSON fields are transferred as strings. This will update the struct tags to allow JSON unmarshaling.
Go
mit
bitfinexcom/bitfinex-api-go
74c3706d8e49b5c0bb31425a34d7051a5908bab5
proto/proto.go
proto/proto.go
/* package proto defines a set of structures used to negotiate an update between an an application (the client) and an Equinox update service. */ package proto import "time" type PatchKind string const ( PatchNone PatchKind = "none" PatchBSDiff PatchKind = "bsdiff" ) type Request struct { AppID string ...
/* package proto defines a set of structures used to negotiate an update between an an application (the client) and an Equinox update service. */ package proto import "time" type PatchKind string const ( PatchNone PatchKind = "none" PatchBSDiff PatchKind = "bsdiff" ) type Request struct { AppID string ...
Remove incorrect JSON struct tag
Remove incorrect JSON struct tag
Go
mit
equinox-io/equinox
5d1e17aa1be766623114ba05d35299d926e29445
template/template.go
template/template.go
package template import ( "bytes" "text/template" "github.com/Masterminds/sprig" ) func Apply(contents []byte, variables map[string]string) ([]byte, error) { t, err := template.New("template").Funcs(sprig.TxtFuncMap()).Parse(string(contents)) if err != nil { return nil, err } buf := bytes.Buffer{} t.Execu...
package template import ( "bytes" "strings" "text/template" "github.com/Masterminds/sprig" ) func Apply(contents []byte, variables map[string]string) ([]byte, error) { // Skip templating if contents begin with '# notemplating' trimmedContents := strings.TrimSpace(string(contents)) if strings.HasPrefix(trimmed...
Add the ability to skip templating
Add the ability to skip templating
Go
apache-2.0
carolynhu/rancher-compose-executor,carolynhu/rancher-compose-executor,carolynhu/rancher-compose-executor,rancher/rancher-compose-executor,rancher/rancher-compose-executor,rancher/rancher-compose-executor
619222b5366b34ebc22844e4b61620d3219cefe5
stats.go
stats.go
package main import () type statistics struct { inDummy int inMail int inEnc int inRemFoo int outDummy int outMail int outEnc int outLoop int outRandhop int outPlain int } func (s *statistics) reset() { s.inDummy = 0 s.inMail = 0 s.inEnc = 0 s.inRemFoo = 0 s.outDummy = 0 s...
package main import ( "fmt" ) type statistics struct { inDummy int inMail int inEnc int inRemFoo int outDummy int outMail int outEnc int outLoop int outRandhop int outPlain int } func (s *statistics) reset() { s.inDummy = 0 s.inMail = 0 s.inEnc = 0 s.inRemFoo = 0 s.outDumm...
Correct a string formatting bug
Correct a string formatting bug
Go
mit
crooks/yamn,crooks/yamn
31529fb556841790c5a7d8cdf3c5cf76e98706ba
stringutils/stringutils_test.go
stringutils/stringutils_test.go
package stringutils import ( "testing" ) var forwardStrings = [...]string{`Hello`, `The quick brown 狐 jumped over the lazy 犬`, `1234567890`, `~!@#$%^&*()_+|\`} var backwardStrings = [...]string{`olleH`, `犬 yzal eht revo depmuj 狐 nworb kciuq ehT`, `0987654321`, `\|+_)(*&^%$#@!~`} func TestReverse(t *testing.T) { //...
package stringutils import ( "testing" ) var forwardStrings = [...]string{`Hello`, `The quick bròwn 狐 jumped over the lazy 犬`, `1234567890`, `~!@#$%^&*()_+|\`, `ápplesareágoodfruit`} var backwardStrings = [...]string{`olleH`, `犬 yzal eht revo depmuj 狐 nwòrb kciuq ehT`, `0987654321`, `\|+_)(*&^%$#@!~`, `tiurfdoogáe...
Add new test case for Reverse
Add new test case for Reverse
Go
apache-2.0
rodneyxr/gohelper
30c1973e8b42ba97b1c6cd661183bb29bff58cf5
agent/consul/testing_endpoint.go
agent/consul/testing_endpoint.go
package consul import ( "github.com/hashicorp/consul/agent/structs" ) // Test is an RPC endpoint that is only available during `go test` when // `TestEndpoint` is called. This is not and must not ever be available // during a real running Consul agent, since it this endpoint bypasses // critical ACL checks. type Tes...
package consul import ( "github.com/hashicorp/consul/agent/structs" ) // Test is an RPC endpoint that is only available during `go test` when // `TestEndpoint` is called. This is not and must not ever be available // during a real running Consul agent, since it this endpoint bypasses // critical ACL checks. type Tes...
Fix the testing endpoint's root set op
Fix the testing endpoint's root set op
Go
mpl-2.0
youhong316/consul,hashicorp/consul,scalp42/consul,kingland/consul,vamage/consul,scalp42/consul,youhong316/consul,vamage/consul,vamage/consul,vamage/consul,42wim/consul,scalp42/consul,youhong316/consul,hashicorp/consul,hashicorp/consul,scalp42/consul,scalp42/consul,kingland/consul,calgaryscientific/consul,42wim/consul,k...
82b35fcdfba1184a8d2d176aa52e883ea5dd0afe
utils.go
utils.go
package jsonschema import ( "fmt" "reflect" ) // normalizeNumber accepts any input and, if it is a supported number type, // converts it to either int64 or float64. normalizeNumber raises an error // if the input is an explicitly unsupported number type. func normalizeNumber(v interface{}) (n interface{}, err error...
package jsonschema import ( "encoding/json" "fmt" "reflect" "strings" ) // normalizeNumber accepts any input and, if it is a supported number type, // converts it to either int64 or float64. normalizeNumber raises an error // if the input is an explicitly unsupported number type. func normalizeNumber(v interface{...
Convert json.Numbers into int64 or float64.
Convert json.Numbers into int64 or float64.
Go
bsd-3-clause
cupcake/jsonschema
0d29dc9d4953758779245515e69294d03f327cfc
modules.go
modules.go
package main import ( _ "github.com/gliderlabs/logspout/adapters/raw" _ "github.com/gliderlabs/logspout/adapters/syslog" _ "github.com/gliderlabs/logspout/httpstream" _ "github.com/gliderlabs/logspout/routesapi" _ "github.com/gliderlabs/logspout/transports/tcp" _ "github.com/gliderlabs/logspout/transports/udp" ...
package main import ( _ "github.com/gliderlabs/logspout/adapters/raw" _ "github.com/gliderlabs/logspout/adapters/syslog" _ "github.com/gliderlabs/logspout/httpstream" _ "github.com/gliderlabs/logspout/routesapi" _ "github.com/gliderlabs/logspout/transports/tcp" _ "github.com/gliderlabs/logspout/transports/udp" ...
Revert module name to iamatypeofwalrus for pull request
Revert module name to iamatypeofwalrus for pull request
Go
mit
iamatypeofwalrus/logspout-loggly,tbossert/logspout-loggly,iamatypeofwalrus/logspout-loggly,JohannWeging/logspout-loggly
b3e554e5eaf9454cc02a9f09dc3aab9e132eb0ca
makefont/makefont_test.go
makefont/makefont_test.go
package main import ( "os/exec" "strings" "testing" ) func TestMakefont(t *testing.T) { const expect = "Font definition file successfully generated" out, err := exec.Command("./makefont", "--dst=../font", "--embed", "--enc=../font/cp1252.map", "../font/calligra.ttf").CombinedOutput() if err != nil { t.Fatal...
package main import ( "os/exec" "strings" "testing" ) func TestMakefont(t *testing.T) { var out []byte var err error const expect = "Font definition file successfully generated" // Make sure makefont utility has been built before generating font definition file err = exec.Command("go", "build").Run() if err ...
Make sure makefont utility has been built before running test
Make sure makefont utility has been built before running test
Go
isc
ledongthuc/gofpdf,jelmersnoeck/gofpdf,roblillack/gofpdf,tgulacsi/gofpdf,jung-kurt/gofpdf,jelmersnoeck/gofpdf,StefanSchroeder/ondekoza-contributions,lkesteloot/gofpdf-old,josuehennemann/gofpdf,Lostmyname/gofpdf
298c54b0e0ae32ec2c6674fee8b60d2fefa4ae7e
lock_file_darwin.go
lock_file_darwin.go
// +build darwin package daemon /* #define __DARWIN_UNIX03 0 #define KERNEL #define _DARWIN_USE_64_BIT_INODE #include <dirent.h> #include <fcntl.h> #include <sys/param.h> */ import "C" import ( "syscall" "unsafe" ) func lockFile(fd uintptr) error { err := syscall.Flock(int(fd), syscall.LOCK_EX|syscall.LOCK_NB) ...
// +build darwin package daemon import ( "syscall" "unsafe" ) import "C" // darwin's MAXPATHLEN const maxpathlen = 1024 func lockFile(fd uintptr) error { err := syscall.Flock(int(fd), syscall.LOCK_EX|syscall.LOCK_NB) if err == syscall.EWOULDBLOCK { err = ErrWouldBlock } return err } func unlockFile(fd uin...
Remove unused imports of .h files from implementaion for darwin
Remove unused imports of .h files from implementaion for darwin
Go
mit
sevlyar/go-daemon
a031385a2e67be2ca180abec15a53f8245c9ef8d
jump_test.go
jump_test.go
package jump import "testing" func TestHashInBucketRange(t *testing.T) { h := Hash(1, 1) if h != 0 { t.Error("expected bucket to be 0, got", h) } h = Hash(42, 57) if h != 43 { t.Error("expected bucket to be 43, got", h) } h = Hash(0xDEAD10CC, 1) if h != 0 { t.Error("expected bucket to be 0, got", h) ...
package jump import "testing" func TestHashInBucketRange(t *testing.T) { h := Hash(1, 1) if h != 0 { t.Error("expected bucket to be 0, got", h) } h = Hash(42, 57) if h != 43 { t.Error("expected bucket to be 43, got", h) } h = Hash(0xDEAD10CC, 1) if h != 0 { t.Error("expected bucket to be 0, got", h) ...
Add code example for Godoc.
Add code example for Godoc.
Go
mit
renstrom/go-jump-consistent-hash
2179a20afcb1eb4ea11dc3b130b89b04df3a8a59
endpoints/downloads/downloads_retry.go
endpoints/downloads/downloads_retry.go
package downloads import ( "github.com/itchio/butler/buse" "github.com/itchio/butler/cmd/operate" ) func DownloadsRetry(rc *buse.RequestContext, params *buse.DownloadsRetryParams) (*buse.DownloadsRetryResult, error) { consumer := rc.Consumer download := ValidateDownload(rc, params.DownloadID) if download.Error...
package downloads import ( "github.com/itchio/butler/buse" "github.com/itchio/butler/cmd/operate" ) func DownloadsRetry(rc *buse.RequestContext, params *buse.DownloadsRetryParams) (*buse.DownloadsRetryResult, error) { consumer := rc.Consumer download := ValidateDownload(rc, params.DownloadID) if download.Error...
Clear FInishedAt when retrying, otherwise it just marks it as done
Clear FInishedAt when retrying, otherwise it just marks it as done
Go
mit
itchio/butler,itchio/butler,itchio/butler
403af2e6908dc997cda9731af13af8f5bac107d2
magic_table_test.go
magic_table_test.go
package magicsql import ( "strings" "testing" "./assert" ) type Foo struct { ONE string TwO int `sql:",primary"` Three bool `sql:"tree"` Four int Five int `sql:"-"` six string } func newFoo() interface{} { return &Foo{} } func TestQueryFields(t *testing.T) { var table = NewMagicTable("foos", new...
package magicsql import ( "strings" "testing" "./assert" ) type Foo struct { // ONE turns into "one" for field name, as we auto-lowercase anything not tagged ONE string // TwO is the primary key, but not explicitly given a field name, so it'll be "two" TwO int `sql:",primary"` // Three is explicitly set ...
Add comments explaining Foo tags
Add comments explaining Foo tags
Go
cc0-1.0
Nerdmaster/magicsql
93c5d4600dbb6f41a739a30004876cd70b19b2a5
example/app.go
example/app.go
package main import ( "fmt" "net/http" "github.com/lohmander/webapi" ) func handler(rw http.ResponseWriter, req *http.Request) { fmt.Fprintf(rw, "Hello there") } func main() { api := webapi.NewAPI() api.Apply(Logger) api.Add(`/subscriptions$`, &Subscription{}) api.Add(`/subscriptions/(?P<id>\d+)$`, &Subscri...
package main import ( "fmt" "net/http" "github.com/lohmander/webapi" ) func main() { api := webapi.NewAPI() api.Apply(Logger) api.Add(`/subscriptions$`, &Subscription{}) api.Add(`/subscriptions/(?P<id>\d+)$`, &Subscription{}, Teapot) http.Handle("/api/", api) http.ListenAndServe(":3002", nil) } func Logg...
Remove old test handler in example
Remove old test handler in example
Go
mit
lohmander/webapi
778dd0c3dc2a5428e581ab9c1f7b04d5b49c8ca9
http/proxying.go
http/proxying.go
package http import stdhttp "net/http" // HostProvider describes something which can yield hosts for transactions, // and record transaction success against a yielded host. type HostProvider interface { Get() (host string, err error) Put(host string, success bool) } // Proxying implements host proxying logic. func...
package http import stdhttp "net/http" // HostProvider describes something which can yield hosts for transactions, // and record a given host's success/failure. type HostProvider interface { Get() (host string, err error) Put(host string, success bool) } // Proxying implements host proxying logic. func Proxying(p ...
Fix awkward wording for http.Proxying
Fix awkward wording for http.Proxying
Go
mit
peterbourgon/srvproxy
3c27508400dcf95b4db400ec2cdda76e76899e3e
ruleset.go
ruleset.go
package socks5 import ( "net" ) // RuleSet is used to provide custom rules to allow or prohibit actions type RuleSet interface { // AllowConnect is used to filter connect requests AllowConnect(dstIP *net.IPAddr, dstPort int, srcIP *net.IPAddr, srcPort int) bool // AllowBind is used to filter bind requests Allow...
package socks5 import ( "net" ) // RuleSet is used to provide custom rules to allow or prohibit actions type RuleSet interface { // AllowConnect is used to filter connect requests AllowConnect(dstIP net.IP, dstPort int, srcIP net.IP, srcPort int) bool // AllowBind is used to filter bind requests AllowBind(dstIP...
Use net.IP instead of IPAddr
Use net.IP instead of IPAddr
Go
mit
armon/go-socks5,liuchg5/go-socks5,liuchg5/go-socks5,FlexibleBroadband/go-socks5,terry39/go-socks5,v2e4lisp/go-socks5,xiaokangwang/go-socks5,hvnsweeting/go-socks5
765c4a1e8b12aed5b110e6a0b0dc67a191f8cfd8
select_menu/frontend.go
select_menu/frontend.go
// +build js package select_menu import ( "net/url" "strings" "github.com/gopherjs/gopherjs/js" "github.com/shurcooL/go/gopherjs_http/jsutil" "honnef.co/go/js/dom" ) func init() { js.Global.Set("SelectMenuOnInput", jsutil.Wrap(SelectMenuOnInput)) } func SelectMenuOnInput(event dom.Event, object dom.HTMLEleme...
// +build js package select_menu import ( "fmt" "net/url" "github.com/gopherjs/gopherjs/js" "github.com/shurcooL/go/gopherjs_http/jsutil" "honnef.co/go/js/dom" ) func init() { js.Global.Set("SelectMenuOnInput", jsutil.Wrap(SelectMenuOnInput)) } func SelectMenuOnInput(event dom.Event, selElem dom.HTMLElement,...
Remove extraneous "?" when no queries.
select_menu: Remove extraneous "?" when no queries. Previously, when the last query parameter was removed, the URL was set to "http://example.org/foo?" with a trailing "?" symbol. This is visually displeasing. Make it so that the URL becomes a cleaner "http://example.org/foo" instead. Also remove unneeded blank line...
Go
mit
shurcooL/frontend,shurcooL/frontend
189c4bbc3cb2925cd40ff51af8bc7af6a09c59ab
common.go
common.go
// Copyright 2017 Jayson Grace. All rights reserved // Use of this source code is governed by a MIT-style // license that can be found in the LICENSE file. package main import ( "fmt" "os/exec" "regexp" "strings" "sync" ) // exeCmd executes an input command. // Once the command have successfully ben run, it will...
// Copyright 2017 Jayson Grace. All rights reserved // Use of this source code is governed by a MIT-style // license that can be found in the LICENSE file. package main import ( "fmt" "os/exec" "regexp" "strings" "sync" ) // exeCmd executes an input command. // Once the command have successfully ben run, it will...
Add delimiter param to strToSlice func
Add delimiter param to strToSlice func
Go
mit
l50/mass-wpscan,l50/mass-wpscan
d46b0db199079c884fbca77f5928c0e7c3f2ab0c
crypto.go
crypto.go
package main import ( "crypto" "crypto/ecdsa" "crypto/elliptic" "crypto/rand" "crypto/x509" "encoding/pem" "errors" "io/ioutil" "os" ) func generatePrivateKey(file string) (crypto.PrivateKey, error) { privateKey, err := ecdsa.GenerateKey(elliptic.P384(), rand.Reader) if err != nil { return nil, err } ...
package main import ( "crypto" "crypto/ecdsa" "crypto/elliptic" "crypto/rand" "crypto/x509" "encoding/pem" "errors" "io/ioutil" "os" ) func generatePrivateKey(file string) (crypto.PrivateKey, error) { privateKey, err := ecdsa.GenerateKey(elliptic.P384(), rand.Reader) if err != nil { return nil, err } ...
Fix missing return in loadPrivateKey
Fix missing return in loadPrivateKey
Go
mit
xenolf/lego,fxposter/lego,xenolf/lego
3396a1fd483909794ac12651b6f04541581ae680
util/logger.go
util/logger.go
package util import ( "fmt" "io" "log" "os" ) // Create a logger with the given prefix func CreateLogger(prefix string) *log.Logger { return CreateLoggerWithWriter(os.Stderr, prefix) // return log.New(os.Stderr, fmt.Sprintf("[terragrunt] %s", prefix), log.LstdFlags) } // CreateLoggerWithWriter Create a lgogger...
package util import ( "fmt" "io" "log" "os" ) // Create a logger with the given prefix func CreateLogger(prefix string) *log.Logger { return CreateLoggerWithWriter(os.Stderr, prefix) } // CreateLoggerWithWriter Create a lgogger around the given output stream and prefix func CreateLoggerWithWriter(writer io.Writ...
Remove commented out old logic
Remove commented out old logic
Go
mit
gruntwork-io/terragrunt,gruntwork-io/terragrunt,tamsky/terragrunt,tamsky/terragrunt
16e1cbc2457fc62cc432909b611eb734f48beeab
integration/helpers/images.go
integration/helpers/images.go
/* Copyright IBM Corp All Rights Reserved. SPDX-License-Identifier: Apache-2.0 */ package helpers import ( "encoding/base32" "fmt" "strings" docker "github.com/fsouza/go-dockerclient" "github.com/hyperledger/fabric/common/util" . "github.com/onsi/ginkgo" . "github.com/onsi/gomega" ) func AssertImagesExist(i...
/* Copyright IBM Corp All Rights Reserved. SPDX-License-Identifier: Apache-2.0 */ package helpers import ( "encoding/base32" "fmt" "strings" docker "github.com/fsouza/go-dockerclient" "github.com/hyperledger/fabric/common/util" . "github.com/onsi/ginkgo" . "github.com/onsi/gomega" ) func AssertImagesExist(i...
Update image filter used by integration tests
Update image filter used by integration tests Signed-off-by: Matthew Sykes <89c6e4c9c1046731a9c37abefc223a83de36a5d9@us.ibm.com>
Go
apache-2.0
stemlending/fabric,manish-sethi/fabric-sidedb,manish-sethi/fabric,manish-sethi/fabric,manish-sethi/fabric-sidedb,stemlending/fabric,manish-sethi/fabric-sidedb,jimthematrix/fabric,manish-sethi/fabric-sidedb,manish-sethi/fabric-sidedb,jimthematrix/fabric,hyperledger/fabric,hyperledger/fabric,manish-sethi/fabric-sidedb,ma...
08b1b1da49c386bcb40df117aff00416ea36f392
apis/federation/v1beta1/doc.go
apis/federation/v1beta1/doc.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 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, ...
Add +k8s:openapi-gen tag to API types
Add +k8s:openapi-gen tag to API types
Go
apache-2.0
kubernetes-retired/cluster-registry,kubernetes-retired/cluster-registry
91e0646aa5c401def8a8430b6ffd56b83fe13181
src/cmds/mount/mount.go
src/cmds/mount/mount.go
// Copyright 2012 the u-root Authors. All rights reserved // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. package main import ( "flag" "log" "syscall" ) var ( RO = flag.Bool("r", false, "Read only mount") fsType = flag.String("t", "", "File system ty...
// Copyright 2012-2016 the u-root Authors. All rights reserved // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. package main import ( "flag" "golang.org/x/sys/unix" "log" ) var ( RO = flag.Bool("r", false, "Read only mount") fsType = flag.String("t", "",...
Use golang.org/x/sys/unix package instead of syscall
Use golang.org/x/sys/unix package instead of syscall Change-Id: Ib03a9a98e417aa929b9e91f58666ded532d0c2fe Signed-off-by: mathgamain <c848246abd5d1fb5c3cd8395e13f4e6f630f73a9@openaliasbox.org>
Go
bsd-3-clause
rminnich/u-root,hugelgupf/u-root,u-root/u-root,hugelgupf/u-root,hugelgupf/u-root,rminnich/u-root,GanShun/u-root,rminnich/u-root,GanShun/u-root,GanShun/u-root,rminnich/u-root,u-root/u-root,u-root/u-root,hugelgupf/u-root
585e2465a5cdecf6112f775ad0629299d8dd2ff8
engines/qemu/fetcher.go
engines/qemu/fetcher.go
package qemuengine import ( "fmt" "github.com/taskcluster/taskcluster-worker/runtime" "github.com/taskcluster/taskcluster-worker/runtime/fetcher" ) // A fetcher for downloading images. var imageFetcher = fetcher.Combine( // Allow fetching images from URL fetcher.URL, // Allow fetching images from queue artifac...
package qemuengine import ( "fmt" "github.com/taskcluster/taskcluster-worker/runtime" "github.com/taskcluster/taskcluster-worker/runtime/fetcher" ) // A fetcher for downloading images. var imageFetcher = fetcher.Combine( // Allow fetching images from URL fetcher.URL, // Allow fetching images from queue artifac...
Use URLHash for fetching QEMU images
Use URLHash for fetching QEMU images
Go
mpl-2.0
walac/taskcluster-worker,walac/taskcluster-worker
4c85696bfeba91b47eed13b07be47428920a7cac
octave.go
octave.go
package main import ( "fmt" "os" ) func main() { fmt.Println("Initializing Octave CPU...") file, err := os.Open("hello.bin") if err != nil { return } defer file.Close() stat, err := file.Stat() if err != nil { return } bs := make([]byte, stat.Size()) ...
package main import ( "fmt" "os" ) func main() { fmt.Println("Initializing Octave CPU...") file, err := os.Open(os.Args[1]) if err != nil { return } defer file.Close() stat, err := file.Stat() if err != nil { return } bs := make([]byte, stat.Size()) ...
Read bin from command line arg
Read bin from command line arg
Go
mit
campaul/octave,campaul/octave
34830214ab4a63eb544ba5f1bc2aedc2df219e6c
environs/maas/environprovider.go
environs/maas/environprovider.go
package maas import ( "launchpad.net/juju-core/environs" "launchpad.net/juju-core/environs/config" "launchpad.net/juju-core/log" ) type maasEnvironProvider struct{} var _ environs.EnvironProvider = (*maasEnvironProvider)(nil) var providerInstance maasEnvironProvider func init() { environs.RegisterProvider("maa...
package maas import ( "launchpad.net/juju-core/environs" "launchpad.net/juju-core/environs/config" "launchpad.net/juju-core/log" ) type maasEnvironProvider struct{} var _ environs.EnvironProvider = (*maasEnvironProvider)(nil) var providerInstance maasEnvironProvider func init() { environs.RegisterProvider("maa...
Add InstanceId, also added to EnvironProvider while we were implementing.
Add InstanceId, also added to EnvironProvider while we were implementing.
Go
agpl-3.0
bogdanteleaga/juju,AdamIsrael/juju,kat-co/juju,gabriel-samfira/juju,voidspace/juju,sinzui/juju,thomnico/juju,marcmolla/juju,reedobrien/juju,marcmolla/juju,rogpeppe/juju,marcoceppi/juju,cmars/juju,jrwren/juju,cmars/juju,waigani/juju,fwereade/juju,wwitzel3/juju,ericsnowcurrently/juju,reedobrien/juju,waigani/juju,macgreag...
fc6a90f42586220e08330441c26bbf7028adf3c9
lib/verstr/less_test.go
lib/verstr/less_test.go
package verstr import ( "testing" ) func TestLess(t *testing.T) { var tests = []struct { left, right string want bool }{ {"file.0.ext", "file.1.ext", true}, {"file.1.ext", "file.0.ext", false}, {"file.1.ext", "file.10.ext", true}, {"file.10.ext", "file.1.ext", false}, {"sparse", "sparse.0", tr...
package verstr import ( "testing" ) func TestLess(t *testing.T) { var tests = []struct { left, right string want bool }{ {"file.0.ext", "file.1.ext", true}, {"file.1.ext", "file.0.ext", false}, {"file.1.ext", "file.10.ext", true}, {"file.10.ext", "file.1.ext", false}, {"file.9.ext", "file.10.e...
Add yet another pair to test for lib/verstr.Less().
Add yet another pair to test for lib/verstr.Less().
Go
apache-2.0
Symantec/Dominator,rgooch/Dominator,keep94/Dominator,keep94/Dominator,keep94/Dominator,rgooch/Dominator,Symantec/Dominator,rgooch/Dominator,Symantec/Dominator
1c1c9163721967838cbfe31c425ff134b92d68c8
handlers/get_capacity_handler.go
handlers/get_capacity_handler.go
package handlers import ( "encoding/json" "net/http" "github.com/sirupsen/logrus" "github.com/ivan1993spb/snake-server/connections" ) const URLRouteGetCapacity = "/capacity" const MethodGetCapacity = http.MethodGet type responseGetCapacityHandler struct { Capacity float32 `json:"capacity"` } type getCapacit...
package handlers import ( "encoding/json" "net/http" "github.com/sirupsen/logrus" "github.com/ivan1993spb/snake-server/connections" ) const URLRouteGetCapacity = "/capacity" const MethodGetCapacity = http.MethodGet type responseGetCapacityHandler struct { Capacity float32 `json:"capacity"` } type getCapacit...
Fix getCapacityHandler: write response status code and add nosniff header
Fix getCapacityHandler: write response status code and add nosniff header
Go
bsd-2-clause
ivan1993spb/clever-snake
f5bd9eb728b0ce6a0e68440b37ee2ffd4547762b
helpers/env_id_generator_test.go
helpers/env_id_generator_test.go
package helpers_test import ( "crypto/rand" "errors" . "github.com/onsi/ginkgo" . "github.com/onsi/gomega" "github.com/pivotal-cf-experimental/bosh-bootloader/fakes" "github.com/pivotal-cf-experimental/bosh-bootloader/helpers" ) var _ = Describe("EnvIDGenerator", func() { Describe("Generate", func() { It("g...
package helpers_test import ( "crypto/rand" "errors" . "github.com/onsi/ginkgo" . "github.com/onsi/gomega" "github.com/pivotal-cf-experimental/bosh-bootloader/fakes" "github.com/pivotal-cf-experimental/bosh-bootloader/helpers" ) var _ = Describe("EnvIDGenerator", func() { Describe("Generate", func() { It("g...
Update env id generator test to handle hypenated lake names
Update env id generator test to handle hypenated lake names [#121817095]
Go
apache-2.0
pivotal-cf-experimental/bosh-bootloader,niroyb/bosh-bootloader,niroyb/bosh-bootloader,pivotal-cf-experimental/bosh-bootloader
82aeb4d2bd62f964636ba0b3e69a0354b139780f
pkg/cmd/flagtypes/glog.go
pkg/cmd/flagtypes/glog.go
package flagtypes import ( "flag" "github.com/golang/glog" "github.com/spf13/pflag" ) // GLog binds the log flags from the default Google "flag" package into a pflag.FlagSet. func GLog(flags *pflag.FlagSet) { from := flag.CommandLine if flag := from.Lookup("v"); flag != nil { level := flag.Value.(*glog.Level)...
package flagtypes import ( "flag" "github.com/golang/glog" "github.com/spf13/pflag" ) // GLog binds the log flags from the default Google "flag" package into a pflag.FlagSet. func GLog(flags *pflag.FlagSet) { from := flag.CommandLine if flag := from.Lookup("v"); flag != nil { level := flag.Value.(*glog.Level)...
Support --v and --vmodule silently
Support --v and --vmodule silently Allows compatibility with Kubernetes invocation directly
Go
apache-2.0
rajatchopra/origin,mkumatag/origin,maxamillion/origin,linzhaoming/origin,kargakis/origin,liangxia/origin,goern/origin,goern/origin,hferentschik/origin,imcsk8/origin,ironcladlou/origin,luciddreamz/origin,aveshagarwal/origin,soltysh/origin,mdshuai/origin,liggitt/origin,wjiangjay/origin,csrwng/origin,gabemontero/origin,mi...
57ba39c3a59e02dfc3e6a4001451c7f6927d4467
tests/integration/pkg/defaults/defaults.go
tests/integration/pkg/defaults/defaults.go
package defaults var ( PodTestImage = "rancher/systemd-node:v0.0.2" SomeK8sVersion = "v1.21.1-rc1+k3s1" WatchTimeoutSeconds = int64(60 * 10) CommonClusterConfig = map[string]interface{}{ "service-cidr": "10.45.0.0/16", "cluster-cidr": "10.44.0.0/16", "garbage": "value", } One = int32(1)...
package defaults var ( PodTestImage = "rancher/systemd-node:v0.0.2" SomeK8sVersion = "v1.21.1+k3s1" WatchTimeoutSeconds = int64(60 * 10) CommonClusterConfig = map[string]interface{}{ "service-cidr": "10.45.0.0/16", "cluster-cidr": "10.44.0.0/16", "garbage": "value", } One = int32(1) Tw...
Change provisioning tests to use v1.21.1+k3s1
Change provisioning tests to use v1.21.1+k3s1
Go
apache-2.0
rancher/rancher,rancher/rancher,rancher/rancher,rancher/rancher
397443bc34f1cfa19deb9f393814f427b54ebb37
file.go
file.go
// Copyright 2013 Canonical Ltd. // Licensed under the AGPLv3, see LICENCE file for details. package utils import ( "path" "path/filepath" "strings" "launchpad.net/juju-core/juju/osenv" ) // NormalizePath replaces a leading ~ with $HOME, and removes any .. or . path // elements. func NormalizePath(dir string) s...
// Copyright 2013 Canonical Ltd. // Licensed under the AGPLv3, see LICENCE file for details. package utils import ( "fmt" "os" "path" "path/filepath" "strings" "launchpad.net/juju-core/juju/osenv" ) // NormalizePath replaces a leading ~ with $HOME, and removes any .. or . path // elements. func NormalizePath(...
Move the UniqueDirectory function into utils package.
Move the UniqueDirectory function into utils package.
Go
bsd-3-clause
rogpeppe/juju-utils,dimitern/utils
28269e185376080856b4af26fb3ed069c47f922a
pb_nix.go
pb_nix.go
// +build linux darwin freebsd package pb import ( "runtime" "syscall" "unsafe" ) const ( TIOCGWINSZ = 0x5413 TIOCGWINSZ_OSX = 1074295912 ) func bold(str string) string { return "\033[1m" + str + "\033[0m" } func terminalWidth() (int, error) { w := new(window) tio := syscall.TIOCGWINSZ if runtime.GOOS...
// +build !windows package pb import ( "runtime" "syscall" "unsafe" ) const ( TIOCGWINSZ = 0x5413 TIOCGWINSZ_OSX = 1074295912 ) func bold(str string) string { return "\033[1m" + str + "\033[0m" } func terminalWidth() (int, error) { w := new(window) tio := syscall.TIOCGWINSZ if runtime.GOOS == "darwin"...
Build for all non-windows platforms
Build for all non-windows platforms
Go
bsd-3-clause
charignon/pb,satelliz/pb,sevki/pb,cheggaaa/pb,0x00evil/pb,mvo5/golang-pb,guaiguaihw/pb,gaowenbin/pb,harshavardhana/pb,yh453926638/pb
b2036e9206b61b4546def2ab35b83398e1046c43
cmd/user/internal/domain/user/models.go
cmd/user/internal/domain/user/models.go
package user import ( "encoding/json" "github.com/asaskevich/govalidator" "github.com/vardius/go-api-boilerplate/internal/errors" ) // EmailAddress is an email address value object type EmailAddress string func (e *EmailAddress) UnmarshalJSON(b []byte) error { var value string err := json.Unmarshal(b, &value)...
package user import ( "encoding/json" "github.com/asaskevich/govalidator" "github.com/vardius/go-api-boilerplate/internal/errors" ) // EmailAddress is an email address value object type EmailAddress string // UnmarshalJSON implements Unmarshal interface func (e *EmailAddress) UnmarshalJSON(b []byte) error { var...
Add comments to value object methods
Add comments to value object methods
Go
mit
vardius/go-api-boilerplate,vardius/go-api-boilerplate,vardius/go-api-boilerplate
3b81151cba36032f175d3e21eca47995cb1bd810
database_connection.go
database_connection.go
package main import ( "database/sql" "fmt" _ "github.com/lib/pq" "log" "time" ) func connectToDatabase() { var err error driver := "postgres" connect := fmt.Sprintf("dbname='%s' user='%s' password='%s' host='%s' port='%s' sslmode='%s' connect_timeout='%s'", SomaCfg.Database.Name, SomaCfg.Database.User, ...
package main import ( "database/sql" "fmt" _ "github.com/lib/pq" "log" "time" ) func connectToDatabase() { var err error driver := "postgres" connect := fmt.Sprintf("dbname='%s' user='%s' password='%s' host='%s' port='%s' sslmode='%s' connect_timeout='%s'", SomaCfg.Database.Name, SomaCfg.Database.User, ...
Set database session to UTC
Set database session to UTC
Go
bsd-2-clause
1and1/soma
1e106de4ea1789a593dfc207470e844f7b911e0a
unknown_frame.go
unknown_frame.go
// Copyright 2016 Albert Nigmatzianov. All rights reserved. // Use of this source code is governed by a MIT-style // license that can be found in the LICENSE file. package id3v2 import ( "io" "github.com/bogem/id3v2/util" ) // UnknownFrame is used for frames, which id3v2 so far doesn't know how to // parse and wr...
// Copyright 2016 Albert Nigmatzianov. All rights reserved. // Use of this source code is governed by a MIT-style // license that can be found in the LICENSE file. package id3v2 import ( "io" "github.com/bogem/id3v2/util" ) // UnknownFrame is used for frames, which id3v2 so far doesn't know how to // parse and wr...
Rename uk to uf in UnknownFrame
Rename uk to uf in UnknownFrame
Go
mit
bogem/id3v2
1144b7a41b6c7479d13385ea328148517fa52664
web/renderer/renderer_test.go
web/renderer/renderer_test.go
package renderer_test import ( "testing" "github.com/diyan/assimilator/testutil/fixture" "github.com/stretchr/testify/assert" ) func TestServerSideTemplateRenderer_Get(t *testing.T) { client, factory := fixture.Setup(t) defer fixture.TearDown(t) factory.SaveOrganization(factory.MakeOrganization()) res, body...
package renderer_test import ( "testing" "github.com/diyan/assimilator/testutil/fixture" "github.com/stretchr/testify/assert" ) func TestServerSideRenderer_Get(t *testing.T) { client, factory := fixture.Setup(t) defer fixture.TearDown(t) factory.SaveOrganization(factory.MakeOrganization()) res, bodyStr, err...
Fix typo in renderer test
Fix typo in renderer test
Go
mit
diyan/assimilator,diyan/assimilator,diyan/assimilator
8d7da78a9a3322371bfbd34f6a2451c5a455197e
main.go
main.go
package main import ( "encoding/json" "fmt" "github.com/gwwfps/lolconf-probe/display" "github.com/natefinch/npipe" "log" "net/http" ) type handler func(http.ResponseWriter, *http.Request) type inner func() (interface{}, error) func wrapHandler(h inner) handler { return func(w http.ResponseWriter, r *ht...
package main import ( "encoding/json" "fmt" "github.com/gwwfps/lolconf-probe/display" "log" "net/http" ) type handler func(http.ResponseWriter, *http.Request) type inner func() (interface{}, error) func wrapHandler(h inner) handler { return func(w http.ResponseWriter, r *http.Request) { result, handl...
Revert "switched to using npipe instead of socket"
Revert "switched to using npipe instead of socket" This reverts commit d115fc9c0f2c97e46c216179aea4f4252e7a08bb.
Go
mit
gwwfps/lolconf-probe
322ca405f6f08b72fd36e826b8f650eb7076905a
src/router/util_test.go
src/router/util_test.go
package router import ( "net/http" "log" "io/ioutil" ) func testRequest(targetUrl string, expectedResponse string) { resp, err := http.Get(targetUrl) if (err != nil) { log.Panic("failed make get request") } defer resp.Body.Close() body, err := ioutil.ReadAll(resp.Body) if (err != nil) { log.Panic("faile...
package router import ( "net/http" "log" "io/ioutil" ) func testRequest(targetUrl string, expectedResponse string) { resp, err := http.Get(targetUrl) if (err != nil) { log.Panicf("failed to make get request: %v", err) } defer resp.Body.Close() if (resp.StatusCode != 200) { log.Panicf("response status: %v...
Verify request success while testing http requests
Verify request success while testing http requests
Go
apache-2.0
fission/fission,ktrance/fission,life1347/fission,ktrance/fission,ktrance/fission,life1347/fission,life1347/fission,life1347/fission,fission/fission,fission/fission,life1347/fission,platform9/fission,life1347/fission,fission/fission,platform9/fission,life1347/fission,ktrance/fission,life1347/fission,ktrance/fission,plat...
c4bc3b080eaf57ed3558200d0ca386e18c2331f7
libcontainer/seccomp/patchbpf/enosys_unsupported.go
libcontainer/seccomp/patchbpf/enosys_unsupported.go
// +build !linux !cgo !seccomp package patchbpf import ( "errors" "github.com/opencontainers/runc/libcontainer/configs" libseccomp "github.com/seccomp/libseccomp-golang" ) func PatchAndLoad(config *configs.Seccomp, filter *libseccomp.ScmpFilter) error { if config != nil { return errors.New("cannot patch and ...
// +build !linux !cgo !seccomp package patchbpf
Remove "PatchAndLoad" stub as it's not used without seccomp enabled
Remove "PatchAndLoad" stub as it's not used without seccomp enabled This function is called by `InitSeccomp`, but only when compiled with seccomp (and cgo) enabled, so should not be needed for other situations. Signed-off-by: Sebastiaan van Stijn <64b2b6d12bfe4baae7dad3d018f8cbf6b0e7a044@gone.nl>
Go
apache-2.0
rhatdan/runc,dqminh/runc,dqminh/runc,rhatdan/runc,estesp/runc,kolyshkin/runc,rhatdan/runc,opencontainers/runc,opencontainers/runc,opencontainers/runc,kolyshkin/runc,opencontainers/runc,rhatdan/runc,dqminh/runc,estesp/runc,estesp/runc,kolyshkin/runc,dqminh/runc,kolyshkin/runc
cf19de96d7bd4fb27507457ed5c66d6a88390e40
internal/sh/functions_test.go
internal/sh/functions_test.go
package sh import "testing" func TestFunctionsClosures(t *testing.T) { for _, test := range []execTestCase{ { desc: "simpleClosure", execStr: ` fn func(a) { fn closure() { print($a) } return $closure } x <= func("1") y <= func("2") $x() $y() `, expectedStdo...
package sh import "testing" func TestFunctionsClosures(t *testing.T) { for _, test := range []execTestCase{ { desc: "simpleClosure", execStr: ` fn func(a) { fn closure() { print($a) } return $closure } x <= func("1") y <= func("2") $x() $y() `, expectedStdo...
Add closures with shared state example
Add closures with shared state example
Go
apache-2.0
NeowayLabs/nash,NeowayLabs/nash
0946630715088d486ab8b7204f0945e755e9b934
hugolib/path_separators_windows_test.go
hugolib/path_separators_windows_test.go
// Copyright 2015 The Hugo 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 ...
// Copyright 2015 The Hugo 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 ...
Fix Windows build failure, take 2
hugolib: Fix Windows build failure, take 2
Go
apache-2.0
mitchchn/hugo,mdhender/hugo,gohugoio/hugo,anthonyfok/hugo,fedelibre/hugo,mdhender/hugo,anthonyfok/hugo,mdhender/hugo,fedelibre/hugo,mitchchn/hugo,digitalcraftsman/hugo,gohugoio/hugo,digitalcraftsman/hugo,fedelibre/hugo,gohugoio/hugo,anthonyfok/hugo,mdhender/hugo,fedelibre/hugo
ea9e6806e8f708aee08267b358de0cb6e9990925
uniq.go
uniq.go
package uniq import "sort" type Interface sort.Interface func Ue(data Interface) int { len := data.Len() i, j := 0, 1 // find the first duplicate for j < len && data.Less(i, j) { i++ j++ } // this loop is simpler after the first duplicate is found for ; j < len; j++ { if data.Less(i, j) { i++ data...
package uniq import "sort" type Interface sort.Interface func Ue(data Interface) int { len := data.Len() if len == 0 { return 0 } i, j := 0, 1 // find the first duplicate for j < len && data.Less(i, j) { i++ j++ } // this loop is simpler after the first duplicate is found for ; j < len; j++ { if dat...
Fix Len() == 0 bug
Fix Len() == 0 bug
Go
mit
infogulch/uniq
1f610e66faf5898f8b020be139acb83a3c674175
responsewriter.go
responsewriter.go
package ehttp import ( "net/http" "sync/atomic" ) // ResponseWriter wraps http.ResponseWriter and holds // a flag to know if the headers have been sent as well has // the http code sent. type ResponseWriter struct { http.ResponseWriter code *int32 } // NewResponseWriter instantiates a new ehttp ResponseWriter. f...
package ehttp import ( "bufio" "fmt" "net" "net/http" "sync/atomic" ) // ResponseWriter wraps http.ResponseWriter and holds // a flag to know if the headers have been sent as well has // the http code sent. type ResponseWriter struct { http.ResponseWriter code *int32 } // NewResponseWriter instantiates a new ...
Add better support for hijack
Add better support for hijack
Go
mit
creack/ehttp
54f245822db50a6cbec686250a44e9117109b516
api/sys_health.go
api/sys_health.go
package api func (c *Sys) Health() (*HealthResponse, error) { r := c.c.NewRequest("GET", "/v1/sys/health") // If the code is 400 or above it will automatically turn into an error, // but the sys/health API defaults to returning 5xx when not sealed or // inited, so we force this code to be something else so we pars...
package api func (c *Sys) Health() (*HealthResponse, error) { r := c.c.NewRequest("GET", "/v1/sys/health") // If the code is 400 or above it will automatically turn into an error, // but the sys/health API defaults to returning 5xx when not sealed or // inited, so we force this code to be something else so we pars...
Allow API to return health response when in a custom state
Allow API to return health response when in a custom state
Go
mpl-2.0
hartsock/vault,kingland/vault,naunga/vault,quixoten/vault,quixoten/vault,hartsock/vault,kingland/vault,hashicorp/vault,joelthompson/vault,Aloomaio/vault,Aloomaio/vault,hartsock/vault,Aloomaio/vault,rnaveiras/vault,quixoten/vault,joelthompson/vault,mgk/vault,kingland/vault,hashicorp/vault,joelthompson/vault,hashicorp/va...
4b8ffdd6bf963a376e659dcf415036d24516abaa
integration/v7/isolated/config_test.go
integration/v7/isolated/config_test.go
package isolated import ( helpers "code.cloudfoundry.org/cli/integration/helpers" "code.cloudfoundry.org/cli/util/configv3" . "github.com/onsi/ginkgo" . "github.com/onsi/gomega" ) var _ = Describe("Config", func() { Describe("Version Management", func() { var oldConfig *configv3.Config BeforeEach(func() { ...
package isolated import ( helpers "code.cloudfoundry.org/cli/integration/helpers" "code.cloudfoundry.org/cli/util/configv3" . "github.com/onsi/ginkgo" . "github.com/onsi/gomega" ) var _ = Describe("Config", func() { Describe("Version Management", func() { var oldTarget string var oldVersion int BeforeEach...
Clear config on configVersion change:
Clear config on configVersion change: A v7 test failed when we restore the full config object. Try restoring only the two fields that get changed. [#1702476450](https://www.pivotaltracker.com/story/show/170247645) Authored-by: Eric Promislow <6c389fa4d719bbeec88fea52ca3b2497804923ad@suse.com>
Go
apache-2.0
cloudfoundry/cli,cloudfoundry/cli,cloudfoundry/cli
224bd188d1fb0dab3684f4ddd973b73439b66c86
lang/test/testFunc/lib_test.go
lang/test/testFunc/lib_test.go
package lib import "testing" func TestReverse(t *testing.T) { var got, expect string got = Reverse("asdf") expect = "fdsa" if got != expect { t.Error("Expected ", expect, ", got ", got) } }
package lib import ( "fmt" "testing" ) func TestReverse(t *testing.T) { m := map[string]string{ "asdf": "fdsa", "vU _!12 ?3P": "P3? 21!_ Uv", "": "", } for in, out := range m { got := Reverse(in) if got != out { t.Error("fn(", in, ") =>", got, "!=", out) } else { fmt.Println("...
Update test code for example
Update test code for example
Go
apache-2.0
freiny/go-show
428f6839ba6b1707e80289c611c8f50f1fee2fee
cf_http.go
cf_http.go
package cf_http import ( "net" "net/http" "time" ) var config Config type Config struct { Timeout time.Duration } func Initialize(timeout time.Duration) { config.Timeout = timeout } func NewClient() *http.Client { return newClient(5*time.Second, 0*time.Second, config.Timeout) } func NewStreamingClient() *ht...
package cf_http import ( "crypto/tls" "crypto/x509" "errors" "io/ioutil" "net" "net/http" "time" ) var config Config type Config struct { Timeout time.Duration } func Initialize(timeout time.Duration) { config.Timeout = timeout } func NewClient() *http.Client { return newClient(5*time.Second, 0*time.Seco...
Add support to generate TLS config
Add support to generate TLS config [#98859010]
Go
apache-2.0
cloudfoundry-incubator/cf_http,cloudfoundry-incubator/cf_http
3d1cac313c0a47b82969ebbdca0bec1e0afae10f
config/setup/controllertest.go
config/setup/controllertest.go
package setup import ( "fmt" "net/http" "strings" "github.com/mholt/caddy/config/parse" "github.com/mholt/caddy/middleware" "github.com/mholt/caddy/server" ) // NewTestController creates a new *Controller for // the input specified, with a filename of "Testfile" func NewTestController(input string) *Controller...
package setup import ( "fmt" "net/http" "strings" "github.com/mholt/caddy/config/parse" "github.com/mholt/caddy/middleware" "github.com/mholt/caddy/server" ) // NewTestController creates a new *Controller for // the input specified, with a filename of "Testfile" func NewTestController(input string) *Controller...
Use %v instead of %p to calm vet
Use %v instead of %p to calm vet Signed-off-by: Alexander Morozov <4efb7da3e38416208b41d8021a942884d8a9435c@docker.com>
Go
apache-2.0
hackintoshrao/caddy,mem/caddy,tw4452852/caddy,liufuqiang/caddy,evermax/caddy,Karthic-Hackintosh/caddy,pschlump/caddy,dusty/caddy,yukimochi/caddy,tobya/caddy,cez81/caddy,mem/caddy,guilhermebr/caddy,Karthic-Hackintosh/caddy,pschlump/caddy,pedronasser/caddy,cez81/caddy,pyed/caddy,lukw00/caddy,yukimochi/caddy,dusty/caddy,b...
d5b7459350339706599f3cbf2375399e181a7180
domainr.go
domainr.go
package main import ( "encoding/json" "fmt" "io/ioutil" "log" "net/http" "os" ) type Result struct { Domain string Availability string } type SearchResults struct { Query string Results []Result } func main() { if len(os.Args) < 2 { log.Fatal("Missing search query. Specify a string to search d...
package main import ( "encoding/json" "fmt" "io/ioutil" "net/http" "os" ) const ( apiURL = "https://domai.nr/api/json/search?client_id=domainr_command_line_app&q=" ) type Result struct { Domain string Availability string } type SearchResults struct { Query string Results []Result } func main() { ...
Print and exit on error.
Print and exit on error.
Go
mit
nwjlyons/domainr
27eb7db1c2a947f706dabd967427ffc137c62efc
api/router/options.go
api/router/options.go
package router import ( "github.com/micro/go-micro/v2/api/resolver" "github.com/micro/go-micro/v2/registry" ) type Options struct { Handler string Registry registry.Registry Resolver resolver.Resolver } type Option func(o *Options) func NewOptions(opts ...Option) Options { options := Options{ Handler: "me...
package router import ( "github.com/micro/go-micro/v2/api/resolver" "github.com/micro/go-micro/v2/api/resolver/vpath" "github.com/micro/go-micro/v2/registry" ) type Options struct { Handler string Registry registry.Registry Resolver resolver.Resolver } type Option func(o *Options) func NewOptions(opts ...Opt...
Add default resolver to api router
Add default resolver to api router
Go
apache-2.0
myodc/go-micro,micro/go-micro
899d607a80d53ba648cee816089fddbb00acc9a7
point.go
point.go
package polynomial import ( "fmt" "math/big" "strings" ) type Point struct { x, y *big.Int } type Points []Point func (p Point) String() string { return fmt.Sprintf("(%v, %v)", p.x, p.y) } func (ps Points) String() string { strs := make([]string, len(ps)) for i, p := range ps { strs[i] = fmt.Sprintf("Poin...
package polynomial import ( "fmt" "math/big" "strings" ) // Point type represents a coordinate (x, y) where x and y are big integers type Point struct { x, y *big.Int } // Points type represents a set of Point type type Points []Point func (p Point) String() string { return fmt.Sprintf("(%v, %v)", p.x, p.y) } ...
Add comments for type Point & Points
Add comments for type Point & Points
Go
mit
jongukim/polynomial
a32ab04e934de851e94092b831d8f88531de6371
encoders.go
encoders.go
// Copyright © 2009--2013 The Web.go Authors // Use of this source code is governed by a MIT-style // license that can be found in the LICENSE file. package web import ( "encoding/json" "encoding/xml" "io" ) // Encode arbitrary data to a response type Encoder interface { Encode(data interface{}) error } type Mi...
// Copyright © 2009--2013 The Web.go Authors // Use of this source code is governed by a MIT-style // license that can be found in the LICENSE file. package web import ( "encoding/json" "encoding/xml" "io" ) // Encode arbitrary data to a response type Encoder interface { Encode(data interface{}) error } type Mi...
Fix name of register mime encoder function
Fix name of register mime encoder function
Go
mit
hraban/web
419fdd21b5a201768c880ac88411bc753e3d529a
extension/geocode.go
extension/geocode.go
package extension import ( "fmt" "github.com/kayex/sirius" "golang.org/x/net/context" "googlemaps.github.io/maps" ) type Geocode struct { APIKey string } func (x *Geocode) Run(m sirius.Message, cfg sirius.ExtensionConfig) (sirius.MessageAction, error) { cmd, match := m.Command("geocode") if !match { return...
package extension import ( "fmt" "github.com/kayex/sirius" "golang.org/x/net/context" "googlemaps.github.io/maps" ) type Geocode struct { APIKey string } func (x *Geocode) Run(m sirius.Message, cfg sirius.ExtensionConfig) (sirius.MessageAction, error) { cmd, match := m.Command("address") if !match { return...
Change back extension command name
Change back extension command name
Go
mit
kayex/sirius
11f364e365f79267087c6769ed90969bf4509bf4
src/gospec/location.go
src/gospec/location.go
// Copyright © 2009-2010 Esko Luontola <www.orfjackal.net> // This software is released under the Apache License 2.0. // The license text is at http://www.apache.org/licenses/LICENSE-2.0 package gospec import ( "fmt" filepath "path" "runtime" ) type Location struct { File string Line int } func currentLocatio...
// Copyright © 2009-2010 Esko Luontola <www.orfjackal.net> // This software is released under the Apache License 2.0. // The license text is at http://www.apache.org/licenses/LICENSE-2.0 package gospec import ( "fmt" filepath "path" "runtime" ) type Location struct { File string Line int } func currentLocatio...
Fix bug in runtime.Caller() introduced by release.2010-03-30
Fix bug in runtime.Caller() introduced by release.2010-03-30
Go
apache-2.0
orfjackal/gospec,orfjackal/gospec,orfjackal/gospec
3b51b1092964758473c57e0cf8044bb19ba881cf
cmd/buildah/rmi.go
cmd/buildah/rmi.go
package main import ( "fmt" "github.com/urfave/cli" ) var ( rmiDescription = "Removes one or more locally stored images." rmiCommand = cli.Command{ Name: "rmi", Usage: "Removes one or more images from local storage", Description: rmiDescription, Action: rmiCmd, ArgsUsage: "IMAGE...
package main import ( "fmt" "github.com/urfave/cli" ) var ( rmiDescription = "Removes one or more locally stored images." rmiCommand = cli.Command{ Name: "rmi", Usage: "Removes one or more images from local storage", Description: rmiDescription, Action: rmiCmd, ArgsUsage: "IMAGE...
Fix copy and paste error on container-image
Fix copy and paste error on container-image Closes: #57 Approved by: rhatdan
Go
apache-2.0
TomSweeneyRedHat/buildah,nalind/buildah,projectatomic/buildah,nalind/buildah-1,nalind/buildah-1,nalind/buildah,ipbabble/buildah,rhatdan/buildah,rhatdan/buildah,TomSweeneyRedHat/buildah,nalind/buildah-1,projectatomic/buildah,projectatomic/buildah,rhatdan/buildah,TomSweeneyRedHat/buildah,ipbabble/buildah
5d939572d7fa28f6a95c5d4f2bdd0c6a92181976
cmd/escrow/main.go
cmd/escrow/main.go
package main import ( "flag" "github.com/sirupsen/logrus" ) var ( configPath string ) func init() { flag.StringVar( &configPath, "config", "config.toml", "path to configuration file; supported formats are JSON, YAML, and TOML", ) flag.Parse() } func main() { v, err := parseConfig(configPath) if err...
package main import ( "flag" "github.com/sirupsen/logrus" ) var ( configPath string ) func init() { flag.StringVar( &configPath, "config", "config.toml", "path to configuration file; supported formats are JSON, YAML, and TOML", ) } func main() { flag.Parse() v, err := parseConfig(configPath) if err...
Fix "make test" broken on Go 1.13
Fix "make test" broken on Go 1.13 This fixes the tests being broken on Go 1.13 and up, which is caused by a change in Go 1.13: https://golang.org/doc/go1.13#testing > Testing flags are now registered in the new Init function, which is invoked by > the generated main function for the test. As a result, testing flags a...
Go
apache-2.0
HuKeping/notary,HuKeping/notary,docker/notary,HuKeping/notary,docker/notary,docker/notary
f139d4b750a622b558a5d06d8b8b2ef24da1a600
src/registry.go
src/registry.go
package gowrapmx4j import "sync" var registry = make(map[string]*MX4JMetric) var reglock = &sync.RWMutex{} func RegistrySet(mm MX4JMetric, mb *MBean) { reglock.Lock() defer reglock.Unlock() mm.MBean = mb registry[mm.HumanName] = &mm } func RegistryGet(humanName string) *MX4JMetric { reglock.RLock() defer reg...
package gowrapmx4j import "sync" var registry = make(map[string]*MX4JMetric) var reglock = &sync.RWMutex{} func RegistrySet(mm MX4JMetric, mb *MBean) { reglock.Lock() defer reglock.Unlock() mm.MBean = mb registry[mm.HumanName] = &mm } func RegistryGet(humanName string) *MX4JMetric { reglock.RLock() defer reg...
Return a map of human MBeans keyed by their human readable names
Return a map of human MBeans keyed by their human readable names
Go
apache-2.0
lytics/gowrapmx4j
b816d6dc57896aa718dff4fb1c38b7fb39ad3857
browser/lookup_windows.go
browser/lookup_windows.go
// Copyright 2020 Georg Großberger <contact@grossberger-ge.org> // This is free software; it is provided under the terms of the MIT License // See the file LICENSE or <https://opensource.org/licenses/MIT> for details package browser var files = []string{ "chromium.exe", "chrome.exe", } var paths = []string{ `C:\P...
// Copyright 2020 Georg Großberger <contact@grossberger-ge.org> // This is free software; it is provided under the terms of the MIT License // See the file LICENSE or <https://opensource.org/licenses/MIT> for details package browser var files = []string{ "chromium.exe", "chrome.exe", } var paths = []string{ `C:\P...
Add newer Program Files path to lookup on windows
Add newer Program Files path to lookup on windows Resolves: #13
Go
mit
garfieldius/t3ll,garfieldius/t3ll,garfieldius/t3ll
87cbefb8049aff3dbe761a093ad15e65f9ac6a46
go/kata/game_test.go
go/kata/game_test.go
package kata import "testing" func TestGutterGame(t *testing.T) { var game Game = Game {0} for i := 0; i < 20; i++ { game.roll(0) } if game.score() != 0 { t.Errorf("Game.score() for a 0 pins game expect 0, got %d", game.score()) } } func TestAllOnes(t *testing.T) { var game Game = Game {0} ...
package kata import "testing" var game Game func setUp() { game = Game{} } func rollMany(n, pins int) { for i := 0; i < n; i++ { game.roll(pins) } } func TestGutterGame(t *testing.T) { setUp() rollMany(20, 0) if game.score() != 0 { t.Errorf("Game.score() for a 0 pins game expect 0, got %d", game.score())...
Refactor test in small partial functions
Refactor test in small partial functions
Go
mit
darkrodry/3languages2months,darkrodry/3languages2months,darkrodry/3languages2months,darkrodry/3languages2months
68bf3fd4628479fc945a6f97e8bb7d9652d7df6e
dirtyci.go
dirtyci.go
package main import ( "flag" "github.com/reveliant/dirtyci/server" ) func main() { var mode = "release" var help = flag.Bool("h", false, "Show this help message") var debug = flag.Bool("d", false, "Enable debug mode") var filename = flag.String("c", "config.toml", "Configuration file path") flag.Parse() if *...
package main import ( "fmt" "flag" "github.com/reveliant/dirtyci/server" ) func main() { var mode = "release" var help = flag.Bool("h", false, "Show this help message") var debug = flag.Bool("d", false, "Enable debug mode") var host = flag.String("host", "127.0.0.1", "Hostname to listen on") var port = flag.I...
Add address and port binding customization
Add address and port binding customization
Go
mit
reveliant/dirty-ci
82403a1886b4797fc72b9aea41fa3d6d00c85010
md2ghost.go
md2ghost.go
package main import ( "flag" "fmt" "os" ) var ( flHelp bool ) func main() { flag.BoolVar(&flHelp, "h", false, "Print this message and quit") flag.BoolVar(&flHelp, "-help", false, "Print this message and quit") flag.Parse() if flHelp { showHelp() os.Exit(0) } } func showHelp() { fmt.Fprintf(os.Stderr,...
package main import ( "flag" "fmt" "os" ) var ( flHelp bool ) func main() { flag.BoolVar(&flHelp, "h", false, "Print this message and quit") flag.BoolVar(&flHelp, "help", false, "Print this message and quit") flag.Parse() if flHelp { showHelp() os.Exit(0) } } func showHelp() { fmt.Fprintf(os.Stderr, ...
Change command line option for --help
Change command line option for --help
Go
mit
kubosho/md2ghost
8e113dd2d95953f6035dda3710d03aee1f584053
MySQLProtocol/Context.go
MySQLProtocol/Context.go
package MySQLProtocol type Context struct { capability uint64 }
package MySQLProtocol type Context struct { capability uint64 prepared_statements map[uint32]Packet_COM_STMT_PREPARE_OK }
Add in the session prepared_statements into the context object
Add in the session prepared_statements into the context object
Go
mit
MPjct/GoMP
9db7454fda81b60e657c026ffe0fcfaa517e6053
unit_test.go
unit_test.go
package fnlog_test import ( "github.com/northbright/fnlog" "log" ) func Example() { iLog := fnlog.New("i") wLog := fnlog.New("w") eLog := fnlog.New("e") var noTagLog *log.Logger = fnlog.New("") iLog.Printf("print infos") wLog.Printf("print warnnings") eLog.Printf("print errors") noTagLog.Printf("print mess...
package fnlog_test import ( "github.com/northbright/fnlog" "log" ) func Example() { iLog := fnlog.New("i") wLog := fnlog.New("w") eLog := fnlog.New("e") var noTagLog *log.Logger = fnlog.New("") iLog.Printf("print infos") wLog.Printf("print warnnings") eLog.Printf("print errors") noTagLog.Printf("print mess...
Remove init() to see if Example() works
Remove init() to see if Example() works
Go
mit
vonwenm/fnlog
ea39027b0f11f3d18c30f9107308f940732e1f35
geometry.go
geometry.go
// Copyright 2014 Arne Roomann-Kurrik // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // // http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agree...
// Copyright 2014 Arne Roomann-Kurrik // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // // http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agree...
Add an Overlaps function to Rectangle.
Add an Overlaps function to Rectangle.
Go
apache-2.0
kurrik/twodee,pikkpoiss/twodee,kurrik/twodee,pikkpoiss/twodee
c5d3f318324df370c4d30c249e39cd0675d0d7ae
jfrog-cli/docs/artifactory/nuget/help.go
jfrog-cli/docs/artifactory/nuget/help.go
package nuget const Description = "Run NuGet." var Usage = []string{`jfrog rt nuget [command options] <nuget args> <source repository name>`} const Arguments string = ` nuget args Arguments to run with NuGet command. source repository name The source NuGet repository. Can be a local, remote or virtual NuGet r...
package nuget const Description = "Run NuGet." var Usage = []string{`jfrog rt nuget [command options] <nuget args> <source repository name>`} const Arguments string = ` nuget command The nuget command to run. For example, restore. source repository name The source NuGet repository. Can be a local, remote or vi...
Support for NuGet build info.
Support for NuGet build info.
Go
apache-2.0
JFrogDev/jfrog-cli-go,JFrogDev/jfrog-cli-go,JFrogDev/jfrog-cli-go,JFrogDev/jfrog-cli-go
519db61795ec27a909dd67809e36d63b980ecc83
docker/formatter/swarm.go
docker/formatter/swarm.go
package formatter import ( "fmt" "strings" "github.com/docker/docker/api/types/swarm" ) //FormatPorts returns the string representation of the given PortConfig func FormatPorts(ports []swarm.PortConfig) string { result := []string{} for _, pConfig := range ports { result = append(result, fmt.Sprintf("*:%d->%d...
package formatter import ( "fmt" "strings" "github.com/docker/docker/api/types/swarm" ) //FormatPorts returns the string representation of the given PortConfig func FormatPorts(ports []swarm.PortConfig) string { result := []string{} for _, pConfig := range ports { result = append(result, fmt.Sprintf("*:%d->%d...
Add formatter for Swarm network specs
Add formatter for Swarm network specs
Go
mit
moncho/dry,moncho/dry
e975184bc50944e82a6bf5f4c57bbe970933fdc5
runsc/fsgofer/filter/filter.go
runsc/fsgofer/filter/filter.go
// Copyright 2018 The gVisor Authors. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // // http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agree...
// Copyright 2018 The gVisor Authors. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // // http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agree...
Update InstallUDSFilters documentation to be accurate to functionality.
Update InstallUDSFilters documentation to be accurate to functionality.
Go
apache-2.0
google/gvisor,google/gvisor,google/gvisor,google/gvisor,google/gvisor,google/gvisor,google/gvisor,google/gvisor
4dc0d5b364f9e85d5786e974805dafe2ba1ad8b2
json_enc.go
json_enc.go
// Copyright 2012 Apcera Inc. All rights reserved. package nats import ( "encoding/json" ) // A JSON Encoder implementation for EncodedConn // This encoder will use the builtin encoding/json to Marshal // and Unmarshal most types, including structs. type JsonEncoder struct { // Empty } func (je *JsonEncoder) Enco...
// Copyright 2012 Apcera Inc. All rights reserved. package nats import ( "encoding/json" "strings" "unsafe" ) // A JSON Encoder implementation for EncodedConn // This encoder will use the builtin encoding/json to Marshal // and Unmarshal most types, including structs. type JsonEncoder struct { // Empty } func (...
Allow string and []byte decoding
Allow string and []byte decoding This allows a JSON representation to be received as a simple string or []byte. We special process JSON strings if requested as a string, etc.
Go
mit
ZebinKang/go-nats,wallyqs/go-nats,Lanzafame/nats,ActiveState/nats,apcera/nats,nats-io/go-nats,dnascimento/nats,the-control-group/nats,nats-io/nats,the-control-group/nats,nats-io/nats,apcera/nats,wallyqs/nats,wallyqs/go-nats,ZebinKang/go-nats,nats-io/go-nats,chzyer-dev/nats,aforward/nats,dnascimento/nats,pires/nats,pire...
76763538b8b6665a13640fd448eabf0321676b09
data/entity/core_type_string.go
data/entity/core_type_string.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 entity import ( "gopkg.in/goyy/goyy.v0/util/bytes" ) type String struct { base value []byte } func (me *String) Value() string { return string...
// 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 entity import ( "gopkg.in/goyy/goyy.v0/util/bytes" ) type String struct { base value []byte } func (me *String) Value() string { if me.value =...
Add whether to empty judgments
Add whether to empty judgments
Go
mit
goyy/goyy,goyy/goyy,goyy/goyy,goyy/goyy
181e07d329617cc3d30f8dc1d1a56fb830b584d4
go/spinner/main.go
go/spinner/main.go
package main func main() { for { spin() } } func spin() { sum := 0 for i:=0;i<9999999;i++ { sum += i sum -= i } }
package main import ( "log" "net/http" "time" ) import "expvar" import _ "net/http/pprof" var spinCount = expvar.NewInt("SpinCount") func main() { go func() { log.Println("Starting HTTP") log.Println(http.ListenAndServe("localhost:6060", nil)) }() log.Println("Starting spin...
Add new spinner go app.
Add new spinner go app.
Go
mit
brianrob/coretests,brianrob/coretests
8664658f225982cd152f042af61656129a17105d
lastlog.go
lastlog.go
package main import ( "log" "os/exec" ) func lastlog() (string, error) { users, err := exec.Command("/usr/bin/lastlog", "--time", "365").Output() if err != nil { log.Fatal(err) } return string(users), nil }
package main import ( "log" "os/exec" ) func lastlog() (string, error) { users := exec.Command("/usr/bin/lastlog", "--time", "365") awk := exec.Command("/usr/bin/awk", `{print $1","$3","$4" "$5" "$6" "$7" "$8}`) out, err := users.StdoutPipe() if err != nil { log.Fatal(err) } users.Start() awk.Stdin = out ...
Format command using awk (incomplete)
Format command using awk (incomplete)
Go
mit
adelq/go-dash
e0d4387cf37d6cc3baeb80f61bd24a37e5dfae26
matchers/have_occurred_matcher.go
matchers/have_occurred_matcher.go
package matchers import ( "fmt" "github.com/onsi/gomega/format" ) type HaveOccurredMatcher struct { } func (matcher *HaveOccurredMatcher) Match(actual interface{}) (success bool, err error) { // is purely nil? if actual == nil { return false, nil } // must be an 'error' type if !isError(actual) { return...
package matchers import ( "fmt" "github.com/onsi/gomega/format" ) type HaveOccurredMatcher struct { } func (matcher *HaveOccurredMatcher) Match(actual interface{}) (success bool, err error) { // is purely nil? if actual == nil { return false, nil } // must be an 'error' type if !isError(actual) { return...
Clarify message for unexpected errors
Clarify message for unexpected errors When reading a lot, the phrasing "Expected error" at the start makes me think it *is* expected...then we say "not to have occurred" which is awkward. Let's avoid the double negative.
Go
mit
onsi/gomega
7571155920b16b3715906952b6da53276dd7c6aa
sqlxurl.go
sqlxurl.go
package sqlxurl import ( "os" "fmt" "net/url" "strings" "github.com/jmoiron/sqlx" ) func Connect() (*sqlx.DB, error) { return ConnectToURL(os.Getenv("DATABASE_URL")) } func ConnectToURL(s string) (c *sqlx.DB, err error) { databaseUrl, err := url.Parse(s) if err != nil { return } auth := "" if databas...
package sqlxurl import ( "os" "fmt" "net/url" "strings" "github.com/jmoiron/sqlx" ) func Connect() (*sqlx.DB, error) { return ConnectToURL(os.Getenv("DATABASE_URL")) } func ConnectToURL(s string) (c *sqlx.DB, err error) { databaseUrl, err := url.Parse(s) if err != nil { return } if databaseUrl.Scheme =...
Raise an error if no scheme is set
Raise an error if no scheme is set
Go
mit
josegonzalez/go-sqlxurl
bdf6934665294667d1355baeb2d688cf450b1ed6
config/tests/lint/config_lint_test.go
config/tests/lint/config_lint_test.go
/* 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 agreed to in writing, ...
/* 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 agreed to in writing, ...
Allow for .yml files in vendored code
Allow for .yml files in vendored code
Go
apache-2.0
BenTheElder/test-infra,jessfraz/test-infra,fejta/test-infra,monopole/test-infra,fejta/test-infra,brahmaroutu/test-infra,monopole/test-infra,cblecker/test-infra,brahmaroutu/test-infra,michelle192837/test-infra,cblecker/test-infra,fejta/test-infra,kubernetes/test-infra,pwittrock/test-infra,dims/test-infra,BenTheElder/tes...
e21746925781cf4e1487e291fbb0a0a10421a978
errors.go
errors.go
package database import ( "github.com/juju/errors" ) var ( // ErrNoSuchEntity is returned from a Get operation when there is not a model // that matches the query ErrNoSuchEntity = errors.New("no such entity found in database") )
package database import ( "github.com/juju/errors" ) var ( // ErrNoSuchEntity is returned from a Get operation when there is not a model // that matches the query ErrNoSuchEntity = errors.NotFoundf("no such entity found in database") )
Revert "Do not use the NotFound error type because it triggers a 404 error page in the servers; use a default error type."
Revert "Do not use the NotFound error type because it triggers a 404 error page in the servers; use a default error type." This reverts commit d5fd44bf655d44cad9e82e9e78f45c9c226cce96.
Go
mit
altipla-consulting/database
7dcd6ece9f1eca850a3b0080babc9e79ead42b31
google.go
google.go
package main import ( "flag" "log" "net/url" "os/exec" "runtime" "strings" ) func main() { flag.Parse() //If the number of arguments is zero, exit the main() function if flag.NArg() == 0 { println("give a search query, e.g. \"google hello world\" ") return } s := strings.Join(flag.Args(), "+") //Con...
// Copyright 2014 Hari haran. All rights reserved. // Use of this source code is governed by a MIT // license that can be found in the LICENSE file. package main import ( "flag" "fmt" "log" "net/url" "os/exec" "runtime" "strings" ) func main() { flag.Parse() // If the number of arguments is zero, exit the...
Clean up code, use fmt
Clean up code, use fmt
Go
mit
hariharan-uno/google
96b6a23c8ff08ebf02d3365dde450957029ec02a
lib/go/thrift/metrics.go
lib/go/thrift/metrics.go
package thrift import ( "github.com/cyberdelia/statsd" "log" "os" ) var ( Metrics *Metric = NewMetric(os.Getenv("STATSD_URL")) ) type Metric struct { client *statsd.Client } func NewMetric(statsdURL string) *Metric { var client *statsd.Client var err error if statsdURL != "" { client, err = statsd.Dial(s...
package thrift import ( "log" "os" "time" "github.com/upfluence/goutils/tracing" "github.com/upfluence/goutils/tracing/noop" "github.com/upfluence/goutils/tracing/statsd" ) var ( Metrics *Metric = NewMetric(os.Getenv("STATSD_URL")) ) type Metric struct { tracer tracing.Tracer } func NewMetric(statsdURL str...
Use goutis tracer over plain statsd connection
Use goutis tracer over plain statsd connection
Go
apache-2.0
upfluence/thrift,upfluence/thrift,upfluence/thrift,upfluence/thrift,upfluence/thrift,upfluence/thrift,upfluence/thrift,upfluence/thrift,upfluence/thrift,upfluence/thrift,upfluence/thrift,upfluence/thrift
f89309fd5a7d91c3e05cfb4af328ca20b25ff160
bagutil/files.go
bagutil/files.go
package bagutil import ( "crypto/md5" "crypto/sha1" "crypto/sha256" "crypto/sha512" "errors" "fmt" "hash" "io/ioutil" "os" ) // Takes a filepath as a string and produces a checksum. func FileChecksum(filepath string, algo string) string { hsh, err := newHash(algo) if err != nil { panic(err) } file, err...
package bagutil import ( "crypto/md5" "crypto/sha1" "crypto/sha256" "crypto/sha512" "errors" "fmt" "hash" "io" "os" ) // Takes a filepath as a string and produces a checksum. func FileChecksum(filepath string, algo string) string { hsh, err := newHash(algo) if err != nil { panic(err) } file, err := os....
Update to stream bytes to checksum algo.
Update to stream bytes to checksum algo.
Go
apache-2.0
APTrust/bagins
41ab0aef7a0fe030e84018973a64135b11abcd70
plugins.go
plugins.go
package main import ( "log" "path/filepath" ) // globalPluginDirs returns directories that should be searched for // globally-installed plugins (not specific to the current configuration). // // Earlier entries in this slice get priority over later when multiple copies // of the same plugin version are found, but n...
package main import ( "fmt" "log" "path/filepath" "runtime" ) // globalPluginDirs returns directories that should be searched for // globally-installed plugins (not specific to the current configuration). // // Earlier entries in this slice get priority over later when multiple copies // of the same plugin versio...
Add missing OS_ARCH dir to global plugin paths
Add missing OS_ARCH dir to global plugin paths When the global directory was added, the discovery system still attempted to search for OS_ARCH subdirectories. It has since been changed only search explicit paths.
Go
mpl-2.0
randomvariable/terraform,randomvariable/terraform,fatmcgav/terraform,mafrosis/terraform,justnom/terraform,mattray/terraform,brandontosch/terraform,rnaveiras/terraform,apparentlymart/terraform,ddegoede/terraform,luis-silva/terraform,donaldguy/terraform,brunomcustodio/terraform,paultyng/terraform,mtougeron/terraform,yann...
b061d164bbf304307420c8f546868000338957df
chat/component.go
chat/component.go
package chat type ( TextComponent struct { Text string `json:"text"` Component } TranslateComponent struct { Translate string `json:"translate"` With []string `json:"with"` Component } ScoreComponent struct { Name string `json:"name"` Objective string `json:"objective"` Component ...
package chat type ( TextComponent struct { Text string `json:"text"` Component } TranslateComponent struct { Translate string `json:"translate"` With []string `json:"with"` Component } ScoreComponent struct { Name string `json:"name"` Objective string `json:"objective"` Component ...
Correct field serialization for Strikethrough param
Correct field serialization for Strikethrough param
Go
mit
ttaylorr/minecraft
a4de2c82f0d680f06b9c840ff710d014f75e7e36
src/brandy/conf/config.go
src/brandy/conf/config.go
package conf import ( "github.com/namsral/flag" ) var Port int func Init() { flag.IntVar(&Port, "port", 3000, "port of brandy") flag.IntVar(&Port, "p", 3000, "port of brandy") flag.Parse() }
package conf import ( "github.com/namsral/flag" "log" "os" "path/filepath" ) var Dir string var Port int func Init() { flag.StringVar(&Dir, "dir", "", "dir of brandy") flag.IntVar(&Port, "port", 3000, "port of brandy") flag.Parse() // Get the directory of the currently dir, err := filepath.Abs(filepath.Dir...
Update conf package Init method.
Update conf package Init method.
Go
mit
miclle/brandy
8ae0c20151a2d74b917040d855ab07d7ba1cfe36
cmd/status.go
cmd/status.go
package cmd import ( "fmt" "net/http" "net/url" "os" "github.com/cozy/cozy-stack/config" "github.com/spf13/cobra" "strconv" ) // statusCmd represents the status command var statusCmd = &cobra.Command{ Use: "status", Short: "Check if the HTTP server is running", Long: `Check if the HTTP server has been s...
package cmd import ( "fmt" "net/http" "net/url" "os" "github.com/cozy/cozy-stack/config" "github.com/spf13/cobra" "strconv" ) // statusCmd represents the status command var statusCmd = &cobra.Command{ Use: "status", Short: "Check if the HTTP server is running", Long: `Check if the HTTP server has been s...
Remove unnecessary "/" in path
Remove unnecessary "/" in path
Go
agpl-3.0
sebn/cozy-stack,nono/cozy-stack,sebn/cozy-stack,sebn/cozy-stack,nono/cozy-stack,sebn/cozy-stack,nono/cozy-stack,nono/cozy-stack,nono/cozy-stack
fc009925671c235be04231476629f29118302039
cmd/diffindex.go
cmd/diffindex.go
package cmd import ( "flag" "github.com/driusan/dgit/git" ) func DiffIndex(c *git.Client, args []string) error { flags := flag.NewFlagSet("diff-index", flag.ExitOnError) options := git.DiffIndexOptions{} flags.BoolVar(&options.Cached, "cached", false, "Do not compare the filesystem, only the index") args, er...
package cmd import ( "flag" "fmt" "github.com/driusan/dgit/git" ) func DiffIndex(c *git.Client, args []string) error { flags := flag.NewFlagSet("diff-index", flag.ExitOnError) options := git.DiffIndexOptions{} flags.BoolVar(&options.Cached, "cached", false, "Do not compare the filesystem, only the index") a...
Fix panic when treeish not passed to git diff-index
Fix panic when treeish not passed to git diff-index
Go
mit
driusan/dgit,driusan/dgit