_id
stringlengths
40
40
text
stringlengths
81
2.19k
title
stringclasses
1 value
d71c56ec372cca2ad812250854efcc68da0e718e
--- +++ @@ -33,8 +33,16 @@ return handle(us.context) } +func (us *UnlockedState) String() string { + return "UnlockedState" +} + func (ls *LockedState) Handle() (TurnstileState, error) { return handle(ls.context) +} + +func (ls *LockedState) String() string { + return "LockedState" } func handle(context T...
2252004e8c6c3fa3bdeb3dfdbda671f4f4e6a7b7
--- +++ @@ -20,7 +20,8 @@ // time duration. func TimeoutAfter(t time.Duration, fn func() error) error { c := make(chan error, 1) - go func() { defer close(c); c <- fn() }() + defer close(c) + go func() { c <- fn() }() select { case err := <-c: return err
b4571a99d363aa2239451e516b21a18d6b83603b
--- +++ @@ -20,9 +20,10 @@ {"Title1", "Body 1"}, {"Title2", "Body 2"}, } - ctx.WriteString(mustache.RenderFile("hello.mustache", - map[string]interface{}{ - "entries": data})) + html ...
994e900c0b4eb6e91236067a6ce97520251fb764
--- +++ @@ -2,8 +2,13 @@ import ( "flag" + "fmt" "log" + "os" ) + +// build number set on during linking +var minversion string type AppConfig struct { verbose bool @@ -12,6 +17,7 @@ interval int user string host string + version bool } func HandleUserOptions() AppConfi...
ca6d60bfdcd711f0ea913b4ea37f979890c4ccd9
--- +++ @@ -19,21 +19,28 @@ if err != nil { log.Fatal(err) } + go func(c net.Conn) { buf := make([]byte, 4096) for { + fmt.Println("here") n, err := c.Read(buf) if err != nil || n == 0 { c.Close() break } + b := buf[:n] s := string(b) s = strings.Tri...
19b02871d27a36a8d1c4aa22cf9257f5593cd4c3
--- +++ @@ -13,8 +13,9 @@ */ func dbConnection() { db.Init() - db.CreateTables() - db.RunFixtures() + //db.CreateTables() + //db.RunFixtures() + //db.Migrate() } /**
298b727472f2de7563955a6e8414ce2502ecca2c
--- +++ @@ -19,18 +19,18 @@ "root": { {`[C*].*\n`, Comment, nil}, {`#.*\n`, CommentPreproc, nil}, - {`[\t ]*!.*\n`, Comment, nil}, + {` {0,4}!.*\n`, Comment, nil}, {`(.{5})`, NameLabel, Push("cont-char")}, {`.*\n`, Using("Fortran"), nil}, }, "cont-char": { - {` `, Text, Push("...
c3901ea2ea5913c711f65f1f3b7fa9d9b5b356e5
--- +++ @@ -5,10 +5,10 @@ func (input PacketChannel) PayloadOnly() <-chan []byte { output := make(chan []byte) go func() { + defer close(output) for packet := range input { output <- packet.Payload } - close(output) }() return output }
9712d06b3674f5e5cd5aeef6a4be1610a393f65f
--- +++ @@ -1,4 +1,8 @@ package hugolib + +import ( + "html/template" +) const Version = "0.13-DEV" @@ -12,7 +16,7 @@ // HugoInfo contains information about the current Hugo environment type HugoInfo struct { Version string - Generator string + Generator template.HTML CommitHash string BuildDate s...
768abf16229eb021af66f57739880a62367101b0
--- +++ @@ -1,11 +1,12 @@ package ast type Output struct { - expr interface{} + expr interface{} + expanded bool } -func NewOutput(expr interface{}) Output { - return Output{expr} +func NewOutput(expr interface{}, expanded bool) Output { + return Output{expr, expanded} } func (o Output) Expr() interfac...
0b7585e2f60b0b710e6dc1e86daff21b9ee20c9a
--- +++ @@ -6,6 +6,8 @@ docker "github.com/fsouza/go-dockerclient" ) + +const VERSION = "0.4.0" func getEnvVar(name, defval string) string { val := os.Getenv(name)
127d22a477f7ed4791d7b97b40adbfe5cafced81
--- +++ @@ -1,9 +1,9 @@ package markdown_test import ( + "log" "os" - "github.com/russross/blackfriday" "github.com/shurcooL/go/markdown" ) @@ -24,7 +24,10 @@ Final paragraph. `) - output := blackfriday.Markdown(input, markdown.NewRenderer(), 0) + output, err := markdown.Process("", input, nil) + if ...
2c915ae40826eea9eb6cc9f2148d4126dd11b29b
--- +++ @@ -5,11 +5,8 @@ "io/ioutil" "runtime" - "github.com/overlordtm/trayhost" + "github.com/shurcooL/trayhost" ) - -// TODO: Factor into trayhost. -func trayhost_NewSeparatorMenuItem() trayhost.MenuItem { return trayhost.MenuItem{Title: ""} } func main() { runtime.LockOSThread() @@ -24,7 +21,7 @@ ...
b74a999a2bb18336ef88b6552d8d93a25fb4353d
--- +++ @@ -18,8 +18,18 @@ } // Sha512Sum will create a sha512sum of the string -func Sha512Sum(content string) string { - sha512Hasher := sha512.New() // Create a new Hash struct - sha512Hasher.Write([]byte(content)) // Write the byte array of the content - return hex.EncodeToStr...
b7c9d3a292dc21878b26e437e4f2ed0e8ce911b9
--- +++ @@ -1,31 +1,32 @@ package golog -import . "github.com/mndrix/golog/term" +import "github.com/mndrix/golog/read" import "testing" func TestFacts (t *testing.T) { + rt := read.Term_ db := NewDatabase(). - Asserta(NewTerm("father", NewTerm("michael"))). - Asserta(NewTerm("f...
019c94bdfe2067142c48ce950e693d6eaaa10cf6
--- +++ @@ -1,5 +1,9 @@ package rest +// compareEtag compares a client provided etag with a base etag. The client provided +// etag may or may not have quotes while the base etag is never quoted. This loose +// comparison of etag allows clients not stricly respecting RFC to send the etag with +// or without quotes...
34c466af0ffc077ffaf6ec6a9d357148f76d8303
--- +++ @@ -1,11 +1,14 @@ package isogram -import "strings" +import ( + "strings" + "unicode" +) // IsIsogram returns whether the provided string is an isogram. // In other words, whether the string does not contain any duplicate characters. func IsIsogram(s string) bool { - parsed := strings.ToLower(removeWh...
57d2e92aa2960640063cab007baaaca12050f960
--- +++ @@ -9,7 +9,7 @@ func GetSink() (Sink, error) { sinkType := os.Getenv("SINK_TYPE") if sinkType == "" { - return nil, fmt.Errorf("Missing SINK_TYPE: amqp, kafka,kinesis or stdout") + return nil, fmt.Errorf("Missing SINK_TYPE: amqp, kafka, kinesis, nsq or stdout") } switch sinkType { @@ -23,7 +23,9 ...
3e1b6d848452ba5f680ecb894884c4d1c542891b
--- +++ @@ -15,4 +15,14 @@ } log.Printf("Decoded base58 string to %s (length %d)", hex.EncodeToString(dec), len(dec)) + + if dec[0] == 0x01 && dec[1] == 0x42 { + log.Printf("EC multiply mode not used") + + } else if dec[0] == 0x01 && dec[1] == 0x43 { + log.Printf("EC multiply mode used") + + } else { + log.F...
7b8803a317794afd4337f9da1e5de740a97c13a2
--- +++ @@ -9,14 +9,7 @@ func (c char) contains(other char) bool { return c == other } func (p pair) contains(c char) bool { - var first, second bool - if s, ok := p[0].(simple); ok { - first = s.contains(c) - } - if s, ok := p[1].(simple); ok { - second = s.contains(c) - } - return first || second + return p[0...
884a64f2cca73bbcf4657168833ccf9d0e610e88
--- +++ @@ -27,7 +27,7 @@ data := &LoginResponse{} data.Session = session - data.Admin = perms.Admin + data.Scopes = perms.ToScopes() c.JSON(http.StatusOK, data) }
25be4d08fe6a1ff50e85e6a2c09a213e2c87953c
--- +++ @@ -3,11 +3,13 @@ package host import ( + "bytes" + "golang.org/x/sys/unix" ) func kernelArch() (string, error) { var utsname unix.Utsname err := unix.Uname(&utsname) - return string(utsname.Machine[:]), err + return string(utsname.Machine[:bytes.IndexByte(utsname.Machine[:], 0)]), err }
130f896e2e3ca78e01794a174382e547ba23adc0
--- +++ @@ -17,29 +17,39 @@ package kvledger import ( + "math/rand" "os" + "path/filepath" + "strconv" "testing" - "github.com/hyperledger/fabric/core/config" "github.com/spf13/viper" ) type testEnv struct { - t testing.TB + t testing.TB + path string } func newTestEnv(t testing.TB) *testEnv { ...
add5260561eef92dbba183921ed616120f178914
--- +++ @@ -2,6 +2,7 @@ import ( "fmt" + "strings" "github.com/deis/helm/log" "github.com/gobuffalo/buffalo" @@ -15,15 +16,22 @@ request := c.Request() request.ParseForm() + remoteAddress := strings.Split(request.RemoteAddr, ":")[0] + err := tx.RawQuery( models.Q["registeruser"], request.Form...
5cb367b394300af15f1e850c7cfcb240b4552e13
--- +++ @@ -20,6 +20,11 @@ DiagIndex int } +// This is a direct translation of the qsort compar function used by PALS. +// However it results in a different sort order (with respect to the non-key +// fields) for FilterHits because of differences in the underlying sort +// algorithms and their respective sort st...
e0a0a1014764145b68e0191f2588886a22f40aaf
--- +++ @@ -12,7 +12,7 @@ ) const ( - PORT = 9009 + PORT = 4444 ) var (
33ebc7856ecfb5fe5b24a3dbc77a13c0a39aa27f
--- +++ @@ -3,8 +3,6 @@ import ( "socialapi/workers/helper" "socialapi/workers/sitemap/common" - - "github.com/koding/redis" ) type FileSelector interface { @@ -24,9 +22,9 @@ item, err := redisConn.PopSetMember(common.PrepareCurrentFileNameCacheKey()) - if err != redis.ErrNil { + if err != nil { ret...
626fe0348385cdb1499af28f90a91c70dc6954e3
--- +++ @@ -1,3 +1,18 @@ package mathgl -import () +import ( + "testing" +) + +func TestProject(t *testing.T) { + obj := Vec3d{1002, 960, 0} + modelview := Mat4d{1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 203, 1, 0, 1} + projection := Mat4d{0.0013020833721384406, 0, 0, 0, -0, -0.0020833334419876337, -0, -0, -0, -0, -1, -...
1de238dc7bf8902f1d210df841eed6426b0928b5
--- +++ @@ -1,4 +1,15 @@ package main + +/* +Results +-- +$ go test -v -bench BenchmarkMap -benchmem +testing: warning: no tests to run +BenchmarkMapLookupKeyStringFromBytes-4 100000000 19.6 ns/op 0 B/op 0 allocs/op +BenchmarkMapSetKeyStringFromBytes-4 20000000...
f2d3d803865df6712a60f2c62109750e77ebc6b0
--- +++ @@ -24,3 +24,24 @@ assert.NotNil(t, sp) assert.Nil(t, err) } + +func TestSetAssetPath(t *testing.T) { + fileutil.BindataDir = AssetDir + fileutil.BindataFn = Asset + _, err := LoadSheet(dir, filepath.Join("16", "jeremy.png"), 16, 16, 0) + assert.Nil(t, err) + UnloadAll() + SetAssetPaths(wd) + _, err = Lo...
c2eb972b432698610958c400ec84faa20de1c016
--- +++ @@ -3,7 +3,7 @@ import ( "fmt" "os" - "jogurto/commands" + "github.com/lapingvino/jogurto/commands" ) func main() {
10735dacff0d670a47abc378c6823ee3398e9cf9
--- +++ @@ -1,6 +1,9 @@ package sensu -import "fmt" +import ( + "encoding/json" + "fmt" +) // GetEvents Return all the current events func (s *Sensu) GetEvents() ([]interface{}, error) { @@ -21,7 +24,12 @@ return s.GetList(fmt.Sprintf("events/%s/%s", client, check), 0, 0) } -// ResolveEvent Resolves an ev...
7bed6a18ea6f00deda4ea0b2797f715c7c555a6c
--- +++ @@ -13,7 +13,7 @@ ) func TestFoo(t *testing.T) { - ctx, done, err := aetest.NewContext(nil) + ctx, done, err := aetest.NewContext() if err != nil { t.Fatal(err) }
95bf065037f2d6ebf7fe59e15361d1e3f4c4ff9e
--- +++ @@ -1,11 +1,17 @@ package cdp import ( + "fmt" + "github.com/mafredri/cdp/rpcc" ) type eventClient interface { rpcc.Stream +} + +type getStreamer interface { + GetStream() rpcc.Stream } // Sync takes two or more event clients and sets them into synchronous operation, @@ -27,7 +33,11 @@ func S...
fe06051ad3acc48b6d386ae0d3308765f4520027
--- +++ @@ -1,6 +1,32 @@ package virtualboxclient + +import ( + "github.com/appropriate/go-virtualboxclient/vboxwebsrv" +) type StorageController struct { virtualbox *VirtualBox managedObjectId string } + +func (sc *StorageController) GetName() (string, error) { + request := vboxwebsrv.IStorageControlle...
dc4007005dabaa1e9284e81d0bedcaba683ea269
--- +++ @@ -10,7 +10,7 @@ ext := filepath.Ext(base) drv := os.Getenv("SystemDrive") - pdDir := "ProgramData" + pdDir := `\ProgramData` name := base[0 : len(base)-len(ext)] return filepath.Join(drv, pdDir, name, name)
15c651b73216daaef24d0b09641511d04cde7970
--- +++ @@ -7,7 +7,7 @@ // RepositoryNameComponentRegexp restricts registtry path components names to // start with at least two letters or numbers, with following parts able to // separated by one period, dash or underscore. -var RepositoryNameComponentRegexp = regexp.MustCompile(`[a-z0-9](?:[a-z0-9]+[._-]?)*[a-z...
a102f95bc8bf2b00c7dd63481a9d629354a82526
--- +++ @@ -11,9 +11,74 @@ PORT = ":8080" ) +func rootHandler(w http.responsewriter, r *http.request) { + +} + +func todoHandler(w http.responsewriter, r *http.request) { + +} + +func addHandler(w http.responsewriter, r *http.request) { + +} + +func editHandler(w http.responsewriter, r *http.request) { + +} + +f...
1be16f01e01f15c4148c7eacf85c9a297e0c038d
--- +++ @@ -11,7 +11,7 @@ // RunPush pushes an image to the registry func RunPush(ctx *context.ExecuteContext, t *Task, _ bool) (bool, error) { pushTag := func(tag string) error { - return pushImage(ctx, t, tag) + return pushImage(ctx, tag) } if err := t.ForEachTag(ctx, pushTag); err != nil { return fals...
cd9d03f6839cfb5583ebf3bad725372347a43537
--- +++ @@ -1,3 +1,17 @@ +// Copyright 2016 Mender Software AS +// +// 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 +//...
2ff019010fc527968c57c1843dbd4c7455619251
--- +++ @@ -36,7 +36,9 @@ // Get returns the first value of the given attribute, if any. func (a *AttributesMap) Get(name string) string { if v, ok := (map[string][]string)(*a)[name]; ok { - return v[0] + if len(v) > 0 { + return v[0] + } } return "" }
0973942020260734e49a59cacb35d78c64aea566
--- +++ @@ -5,7 +5,7 @@ "strings" "testing" - "." + "github.com/ninchat/maxreader" ) func Test(t *testing.T) {
7def621e65be42b0269547de2c62c7b2ebcb84e4
--- +++ @@ -10,7 +10,6 @@ ) func LoadSchema(u *url.URL) (*models.Schema, error) { - var schema models.Schema response, err := http.Get(u.String()) if err != nil { return nil, err @@ -20,6 +19,7 @@ if err != nil { return nil, err } + var schema models.Schema json.Unmarshal(specification, &schema) ...
2266e7f2345c88a8e195fd959550d0d657bec843
--- +++ @@ -16,7 +16,7 @@ // postRunProcessing perfoms any processing needed on the container after it has stopped. func (daemon *Daemon) postRunProcessing(container *container.Container, e libcontainerd.StateInfo) error { - if e.UpdatePending { + if e.ExitCode == 0 && e.UpdatePending { spec, err := daemon.cre...
f0e7b4ade2cf9a2304e5b92258b68c9f3e15fc3d
--- +++ @@ -20,7 +20,7 @@ cc.Use = "install" cc.Short = "install bar support into git repo" - cc.Flags().StringVarP(&c.Log, "log", "", logx.DEBUG, + cc.Flags().StringVarP(&c.Log, "log", "", logx.INFO, "installable logging level") cc.Flags()
2354c5e2bb0c0132cd6f91d7f772fdce481d1950
--- +++ @@ -42,8 +42,6 @@ "Username": currentUser.Name, }) - cmd.UI.DisplayNewline() - if newPassword != verifyPassword { return translatableerror.PasswordVerificationFailedError{} }
147d5555aef0c08495931f9fa2745829abe3b58f
--- +++ @@ -1,7 +1,8 @@ -package moeparser +package moeparser_test import ( "fmt" + "moeparser" "testing" )
bb490c1e2c7deddeeaf230587b0373eb37510e8c
--- +++ @@ -35,7 +35,7 @@ r := mux.NewRouter() r.NotFoundHandler = http.HandlerFunc(notFound) r.HandleFunc("/{server}/{project}/{repo}/{box}.json", boxHandler). - Methods("GET") + Methods("GET", "HEAD") n.UseHandler(r) listenOn := fmt.Sprintf("%v:%v", cfg.Address, cfg.Port)
67d792b9039bf57f47368d3edb9816971eff7ee1
--- +++ @@ -2,37 +2,41 @@ import ( "fmt" + "log" "os" "golang.org/x/crypto/ssh/terminal" ) -//get number of columns of terminal from crypto subdirectory ssh/terminal -func getCols() int { - c, _, err := terminal.GetSize(int(os.Stdout.Fd())) +// getWidth gets number of width of terminal from crypto subdi...
5807fc82c880ac3da3b9348805113b5a35e5a8c3
--- +++ @@ -3,13 +3,14 @@ import ( "crypto/hmac" "crypto/sha1" + "encoding/hex" ) // ComputeHMAC of a message using a specific key func ComputeHMAC(message []byte, key string) []byte { mac := hmac.New(sha1.New, []byte(key)) mac.Write(message) - return mac.Sum(nil) + return []byte(hex.EncodeToString(mac....
56bfaeda70752ff87e8fac957b4c4bad59c4ef17
--- +++ @@ -25,3 +25,17 @@ c.Check(clock().Now(), Equals, realNow) } + +func (s *GomolSuite) TestRealClockNow(c *C) { + // This test is completely pointless because it's not something that can really + // be tested but I was sick of seeing the red for a lack of a unit test. So I created + // this one and figure...
ef775b6a90143374b7d5d99ed8e44a512e3cd162
--- +++ @@ -14,7 +14,7 @@ RS3 = 16299 // RS4 (version 1803, codename "Redstone 4") corresponds to Windows Server - // 1809 (Semi-Annual Channel (SAC)), and Windows 10 (April 2018 Update). + // 1803 (Semi-Annual Channel (SAC)), and Windows 10 (April 2018 Update). RS4 = 17134 // RS5 (version 1809, codename ...
1f6d2ea7f827e3c56a5df7deae5dfbf73e71f0d8
--- +++ @@ -3,6 +3,7 @@ import ( "log" "os" + "fmt" "go/ast" "go/parser" @@ -10,11 +11,11 @@ ) func validator(name string, s *ast.StructType) { - log.Print(name) + fmt.Println(name) for _, fld := range(s.Fields.List) { nam := fld.Names[0].Name typ := fld.Type.(*ast.Ident) - log.Printf("%s %s",...
e8aef4b9bf80da660c0374c6d476c87a3233a35e
--- +++ @@ -1,7 +1,8 @@ package main import ( - "image/color" + "fmt" + "image" "time" "github.com/voxelbrain/pixelpixel/imageutils" @@ -12,15 +13,16 @@ c := protocol.PixelPusher() img := protocol.NewPixel() - dImg := imageutils.DimensionChanger(img, 4, 1) + dImg := imageutils.DimensionChanger(img, 4,...
f8f10d4218610490587cf7df4230bd8602f2b2c7
--- +++ @@ -1,7 +1,7 @@ package read // Fre scores the Flesch reading-ease. -// See https://en.wikipedia.org/wiki/Flesch–Kincaid_readability_tests#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 { ...
ca3450e2ac99d1d79c0b34b6201381cde5afc44d
--- +++ @@ -9,6 +9,8 @@ const VERSION = "0.1.0" func main() { + log.Printf("bitrun api v%s\n", VERSION) + err := LoadLanguages("./languages.json") if err != nil { log.Fatalln(err)
5647a87df12726c2b04bf5a09a89471f91a6c1b8
--- +++ @@ -1,27 +1,72 @@ /* This package is just a collection of test cases - */ +*/ package main import ( - "fmt" - "os" - "ripe-atlas" + "fmt" + "github.com/codegangsta/cli" + "os" + "ripe-atlas" + "strconv" ) +// set args for examples sake + func main() { - p, err := atlas.GetProbe(14037) - if ...
06a6e5bf89d5cfac5330a538395de230489e2d43
--- +++ @@ -24,7 +24,10 @@ func content() []string { filePath := path.Join(home, shortcutFilename) dat, err := ioutil.ReadFile(filePath) - check(err) + if err != nil { + fmt.Println("Unable to open shortcut file. Try doing a search.") + panic(1) + } lines := strings.Split(string(dat), "\n") return lines[0 ...
85337525023b304d71ce16fce35208889acf1be4
--- +++ @@ -5,7 +5,7 @@ "testing" ) -func dummyNewUser() *User { +func dummyNewUser(password string) *User { var letters = []rune("abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ") randSeq := func(n int) string { @@ -16,10 +16,11 @@ return string(b) } - return &User{ + u := &User{ Username: ...
ff758e9bb9ca6a6750d21f17cd9653126c467cef
--- +++ @@ -1,4 +1,8 @@ package radosAPI + +type apiError struct { + Code string `json:"Code"` +} // Usage represents the response of usage requests type Usage struct {
7a9e26edeafc4c2f52faccefaa71c6c92a0d8b33
--- +++ @@ -9,7 +9,7 @@ EnvironmentFile=/etc/environment User=core TimeoutStartSec=0 -ExecStartPre=/usr/bin/docker pull mmmhm/{{.Name}}:{{.Version}} +ExecStartPre=/usr/bin/docker pull {{.DockerHubUsername}}/{{.Name}}:{{.Version}} ExecStartPre=-/usr/bin/docker rm -f {{.Name}}-{{.Version}}-%i ExecStart=/usr/bin/do...
28a4ff944b59d34b868260a1e035aec7f18c3090
--- +++ @@ -9,13 +9,22 @@ s2 := []float64{10, -51.2, 8} s3 := []float64{1, 2, 3, 5, 6} s4 := []float64{} + s5 := []float64{0, 0, 0} - _, err := Correlation(s1, s2) + a, err := Correlation(s5, s5) + if err != nil { + t.Errorf("Should not have returned an error") + } + if a != 0 { + t.Errorf("Should have retu...
c09b3132053225dd3ea720112a0bf8dcfde4a4d6
--- +++ @@ -1,33 +1,21 @@ package main import ( - "bufio" - "fmt" "log" - "os" "github.com/griffithsh/sql-squish/database" ) func main() { - scanner := bufio.NewScanner(os.Stdin) + concatted, err := inputStdin() - var concatted string - for scanner.Scan() { - concatted = concatted + scanner.Text() + ...
ab33ddcbd734e84b273ee508d380e81cf83ae513
--- +++ @@ -2,7 +2,8 @@ // TerminalConnectionTokenParams is the set of parameters that can be used when creating a terminal connection token. type TerminalConnectionTokenParams struct { - Params `form:"*"` + Params `form:"*"` + Location string `form:"location"` // This feature has been deprecated and should...
269ac84b5d1905c513554f6d5d5c5725c172e9f6
--- +++ @@ -2,8 +2,18 @@ import ( "runtime" + + . "github.com/onsi/ginkgo" ) func IsWindows() bool { return runtime.GOOS == "windows" } + +func SkipIfWindows() { + + if IsWindows() { + Skip("the OS is Windows") + } + +}
db1a85cd360a55632d78df9c5e3aad4ec765eeb5
--- +++ @@ -1,14 +1,8 @@ package main -import ( - "testing" - - log "github.com/Sirupsen/logrus" -) +import "testing" func TestLineBreaking(t *testing.T) { - log.SetLevel(log.DebugLevel) - var tests = []struct { text string result string
3165608fb29d17d33ebeb88095e8d4c801b7ed68
--- +++ @@ -6,10 +6,64 @@ func main() { app := cli.NewApp() app.Name = "exercism" - app.Usage = "fight the loneliness!" - app.Action = func(c *cli.Context) { - println("Hello friend!") + app.Usage = "A command line tool to interact with http://exercism.io" + app.Commands = []cli.Command{ + { + Name: "de...
d242ab9b1479a6aebe8e5cbd6b6ae48fb845f950
--- +++ @@ -3,9 +3,10 @@ func main() { Log("main.start") - queryInterval := QueryInterval() databaseUrl := DatabaseUrl() libratoAuth := LibratoAuth() + queryInterval := QueryInterval() + queryTimeout := queryInterval queryFiles := ReadQueryFiles("./queries/*.sql") metricBatches := make(chan []interface...
9e6db73b9cece24d3a5813af5847e8b8390f1d6b
--- +++ @@ -12,9 +12,8 @@ // deliveryAck acknowledges delivery message with retries on error func deliveryAck(delivery amqp.Delivery) { - retryCount := 3 var err error - for retryCount > 0 { + for retryCount := 3; retryCount > 0; retryCount-- { if err = delivery.Ack(false); err == nil { break }
bf739142c88471b434526a898bc32737399aa043
--- +++ @@ -7,22 +7,21 @@ func SetUp() cli.Command { cmd := cli.Command{ - Name: "shell", - Usage: "BQL shell", - Action: Launch, + Name: "shell", + Usage: "BQL shell", + Description: "shell command launches an interactive shell for BQL", + Action: Launch, } cmd.Flags = []cli.Flag...
b3239e49cb77f8dac7bd968d73aab42cfcd51082
--- +++ @@ -1,6 +1,7 @@ /* -Package rmsd implements a version of the Kabsch algorithm that is described -in detail here: http://cnx.org/content/m11608/latest/ +Package rmsd implements a version of the Kabsch algorithm to compute the +minimal RMSD between two equal length sets of atoms. The exact algorithm +implement...
d425954d435d1c30f3e4790c6889c6e709458b7f
--- +++ @@ -11,6 +11,12 @@ _, err := NewClient() assert.NotNil(t, err) assert.Equal(t, "host is required", err.Error()) +} + +func TestSetHostFailsOnBlank(t *testing.T) { + _, err := NewClient(SetHost("")) + assert.NotNil(t, err) + assert.Equal(t, "host cannot be empty", err.Error()) } func TestNewClientAdd...
60b6ed7bf8c22107e407983043adfd59c1a7e5ab
--- +++ @@ -8,9 +8,9 @@ RelativePath string } -// NewDocument creates a document from a relative filepath. +// NewDocument creates a document from the filepath. // The root is typically the root of the exercise, and -// path is the relative path to the file within the root directory. +// path is the absolute pa...
b926d476dff7752973c37631488bca21d498d085
--- +++ @@ -17,6 +17,11 @@ window := mainWindow.GtkWindow window.ShowAll() + config := models.Config() + if config.AccessToken == "" { + fmt.Println("No access token, show authentication window") + } + gtk.Main() }
1081c7d2285a4d66ef67f4639d8248ebfc16d95c
--- +++ @@ -49,8 +49,12 @@ func drawGrid(grid *sudoku.Grid) { for y, line := range strings.Split(grid.Diagram(), "\n") { - for x, ch := range line { + x := 0 + //The first number in range will be byte offset, but for some items like the bullet, it's two bytes. + //But what we care about is that each item is ...
5fee4b4aa750182d42626abf5ee69166b497a3c2
--- +++ @@ -32,7 +32,7 @@ buf := getBuffer() defer putBuffer(buf) io.WriteString(w, "<HTML>\n<BODY>\n") - n, err := io.CopyBuffer(w, DefaultMarkovMap, buf) + n, err := io.CopyBuffer(w, mm, buf) log.Printf("Wrote: %d (%v)", n, err) } }
6978577fdf63f3f02ca9c3ac842abab583811f93
--- +++ @@ -15,31 +15,29 @@ // http://csrc.nist.gov/publications/nistpubs/800-38D/SP-800-38D.pdf var zeroNonce []byte = make([]byte, symmetricNonceLength) -func symmetricDecrypt(aesKey, ciphertext []byte) ([]byte, error) { +func makeAESGCM(aesKey []byte) (cipher.AEAD, error) { blockCipher, err := aes.NewCipher(...
60a6f7c896230d54d7b040d6be332c66d770d703
--- +++ @@ -1,6 +1,8 @@ package main import ( + "encoding/binary" + "io" "log" "os" ) @@ -10,13 +12,53 @@ DATABLOCK_SIZE = 1024 * 4 // 4KB ) +var ( + DatablockByteOrder = binary.BigEndian +) + func main() { + file, err := createDatafile() + if err != nil { + panic(err) + } + + writeInt16(file...
80e5a2ca5170370cd2f0e334498f154a9ccfd4ea
--- +++ @@ -11,6 +11,10 @@ app.Name = "docker-inject" app.Usage = "Copy files/directories from hosts to running Docker containers" app.Version = "0.0.0" + app.HideHelp = true + app.Flags = []cli.Flag{ + cli.HelpFlag, + } app.Action = func(c *cli.Context) { inj, err := newInjector(os.Stderr, c.Args()) i...
36fd44f3b088f9b9f1c75dbcb43bc51ecdcaa2c1
--- +++ @@ -6,6 +6,7 @@ "log" "os" + "github.com/relab/raft/commonpb" "github.com/relab/raft/raftgorums" ) @@ -25,12 +26,18 @@ log.Fatal(err) } - fmt.Printf("Found: %d entries.\n", storage.NumEntries()) + fmt.Printf("Found: %d entries.\n", storage.NextIndex()-storage.FirstIndex()) - entries, err :...
9392b64be713a848aa23bd9010dd2e82280a79d6
--- +++ @@ -20,5 +20,7 @@ api := slack.New(token) r := slackreporter.GetReport(stdin) - slackreporter.NotifyToGroup(*api, r, groupName) + if *r.ExitCode != 0 { + slackreporter.NotifyToGroup(*api, r, groupName) + } }
eae28e37654089792133385b5b0df697beddb098
--- +++ @@ -6,16 +6,18 @@ ) type ParticipantSerialzer struct { - ID uint `json:"id"` - Name string `json:"name"` + ID uint `json:"id"` + Name string `json:"name"` + AvatarURL string `json:"avatar"` } func SerializeParticipant(db *gorm.DB, participant *model.User) *ParticipantSerialzer { owner ...
b9686df0c97c6c029495830042a2aeb52c7d5a0a
--- +++ @@ -5,6 +5,7 @@ "github.com/ibrt/go-oauto/oauto/config" "encoding/json" "fmt" + "github.com/go-errors/errors" ) type ApiHandler func(config *config.Config, r *http.Request, baseURL string) (interface{}, error) @@ -24,7 +25,7 @@ w.WriteHeader(http.StatusOK) json.NewEncoder(w).Encode(resp) ...
b0245d688b93d66794e509d977d444d6f3cc0086
--- +++ @@ -2,47 +2,49 @@ import ( "testing" - - "gopkg.in/redis.v5" ) -var defaultAddr = "127.0.0.1:6379" - func Test_CheckpointLifecycle(t *testing.T) { - client := redis.NewClient(&redis.Options{Addr: defaultAddr}) - - c := &Checkpoint{ - appName: "app", - client: client, + // new + c, err := New("app"...
0197835acc0edd0bd82ea80b92055d85c1566bc4
--- +++ @@ -17,7 +17,7 @@ } func (raw *RawAction) Verify(context *YaibContext) error { - if raw.Source != "rootdir" { + if raw.Source != "filesystem" { return errors.New("Only suppport sourcing from filesystem") }
f6045b9c65448252deb924ff3422fe61b8651d7f
--- +++ @@ -31,3 +31,9 @@ result.Point.Lng()) } } + +func BenchmarkGeocode(b *testing.B) { + for i := 0; i < b.N; i++ { + geocode("1600 amphitheatre parkway", new(geo.GoogleGeocoder)) + } +}
854ef6c2e241d628c6d221b6b015bcfcbe77f3bd
--- +++ @@ -19,7 +19,7 @@ Link("account_transactions", "/accounts/{address}/transactions{?cursor,limit,order}"). Link("transaction", "/transactions/{hash}"). Link("transactions", "/transactions{?cursor,limit,order}"). - Link("orderbook", "/orderbooks{?base_type,base_code,base_issuer,counter_type,counter_cod...
0e85cffe47bf79b03e6e941c93effa39c1005710
--- +++ @@ -3,14 +3,13 @@ import ( "fmt" - "github.com/camd67/moebot/moebot_bot/bot/permissions" - "github.com/camd67/moebot/moebot_bot/util/db" ) type TimerCommand struct { - ComPrefix string - Checker permissions.PermissionChecker +} + +func (tc *TimerCommand) Execute(pack *CommPackage) { } func (t...
9d8192804c0d609eef2d7956348358615720a0f3
--- +++ @@ -3,8 +3,6 @@ import ( "os" "path" - - uuid "github.com/satori/go.uuid" ) // VersionControl is the interface for specific @@ -27,7 +25,7 @@ // AddSource for SystemSCM will gather source code // and then save the files to the local filesystem func (scm SystemSCM) AddSource(repo *SourceRepository)...
565d8da8471ee5149b65b343eb68ff660e45be0a
--- +++ @@ -1,6 +1,7 @@ package server import ( + "errors" "net/http" "github.com/heroku/busl/assets" @@ -8,6 +9,8 @@ "github.com/heroku/busl/storage" "github.com/heroku/busl/util" ) + +var errNoContent = errors.New("No Content") func handleError(w http.ResponseWriter, r *http.Request, err error) { ...
4531cf31257db14549af03dff989cc5c4bc55b55
--- +++ @@ -26,9 +26,9 @@ // Error implements error interface. func (m *MultiError) Error() string { - var formattedError []string - for _, e := range m.errs { - formattedError = append(formattedError, e.Error()) + formattedError := make([]string, len(m.errs)) + for i, e := range m.errs { + formattedError[i] = ...
181e07d329617cc3d30f8dc1d1a56fb830b584d4
--- +++ @@ -1,14 +1,34 @@ 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",...
153ce8b0a263edce819a5df534ff89a100c5454a
--- +++ @@ -4,10 +4,13 @@ "github.com/dustin/go-humanize" "time" "strings" + "math" ) func HumanTime(time time.Time) string { original := humanize.Time(time) parts := strings.Split(original, " ") - return parts[0] + " " + parts[1] + length := int(math.Min(float64(len(parts)), 2))...
27c646fdcceadb08aebec333c75cf17183d9d51b
--- +++ @@ -6,21 +6,21 @@ func TestExtract(t *testing.T) { Seed(123) - outputs := make([]int, 10) - for i := 0; i < 10; i++ { - outputs[i] = Extract() + output0 := Extract() + + Seed(123) + output1 := Extract() + + Seed(321) + output2 := Extract() + + // same seeds should result in same first result + if output...
43da41826b4d1ca50d8fa3a218032c380ef4423f
--- +++ @@ -20,7 +20,9 @@ if rval := recover(); rval != nil { debug.PrintStack() rvalStr := fmt.Sprint(rval) - packet := raven.NewPacket(rvalStr, raven.NewException(errors.New(rvalStr), raven.NewStacktrace(2, 3, nil))) + packet := raven.NewPacket(rvalStr, + raven.NewException(errors.New(rvalSt...
f139d4b750a622b558a5d06d8b8b2ef24da1a600
--- +++ @@ -40,3 +40,15 @@ } return metrics } + +// Return a map of MX4JMetric structs keyed by their human readable name field. +func RegistryGetHRMap() map[string]MX4JMetric { + reglock.RLock() + defer reglock.RUnlock() + + metrics := make(map[string]MX4JMetric) + for _, mm := range registry { + metrics[mm.Hu...
b7bef4feabe2966a326af0d7d0d9508f104e489f
--- +++ @@ -2,7 +2,12 @@ import ( "fmt" + "os" "time" +) + +var ( + source = os.Getenv("SHH_SOURCE") ) type Measurement struct { @@ -12,5 +17,9 @@ } func (m *Measurement) String() string { - return fmt.Sprintf("when=%s measure=%s val=%s", m.When.Format(time.RFC3339Nano), m.What, m.Value) + msg := fmt.S...
6c75828f717b728985782256eb0d22906c8f40d4
--- +++ @@ -4,7 +4,6 @@ "flag" "fmt" "log" - "net" "github.com/umahmood/geoip" ) @@ -13,15 +12,8 @@ var ip string func init() { - flag.StringVar(&ip, "ip", "", "IP to geo locate can be v4 or v6 address.") + flag.StringVar(&ip, "ip", "", "IP to geo locate can be v4/v6 address or domain name.") flag.Pa...
a71884087fbfebe148542030ff6e6ab4bff40d5d
--- +++ @@ -7,7 +7,28 @@ "strings" ) +var version = "0.1.0" +var helpMsg = `NAME: + ext - An interface for command extensions +USAGE: + ext commands... +` + func main() { + if len(os.Args) < 2 { + fmt.Println(helpMsg) + os.Exit(1) + } + + switch os.Args[1] { + case "-h", "--help": + fmt.Println(helpMsg...
17e917ddda383c08ba0a79e006a2659ac93508f9
--- +++ @@ -17,6 +17,16 @@ p.Connection = conn } +// GetDiskConnectionByStr ディスク接続方法 取得 +func (p *propDiskConnection) GetDiskConnectionByStr() string { + return string(p.Connection) +} + +// SetDiskConnectionByStr ディスク接続方法 設定 +func (p *propDiskConnection) SetDiskConnectionByStr(conn string) { + p.Connection = ED...