From ada5d9f6259231a5f3a98af1f33c79486994da18 Mon Sep 17 00:00:00 2001 From: Ri Xu Date: Sun, 9 Oct 2016 12:51:16 +0800 Subject: [PATCH] go vet format. --- beanstalk/example_test.go | 2 +- currentTubeJobsActionsRow.go | 7 ++++-- currentTubeJobsShowcase.go | 12 ++++++--- currentTubeJobsSummaryTable.go | 2 +- lib.go | 45 +++++++++++++++++++++++++++------- sampleJobUtils.go | 5 +++- tplNav.go | 5 +++- utils.go | 2 +- 8 files changed, 61 insertions(+), 19 deletions(-) diff --git a/beanstalk/example_test.go b/beanstalk/example_test.go index d73fa40..c3e0ba0 100755 --- a/beanstalk/example_test.go +++ b/beanstalk/example_test.go @@ -36,7 +36,7 @@ func Example_put() { } func Example_putOtherTube() { - tube := &beanstalk.Tube{conn, "mytube"} + tube := &beanstalk.Tube{Conn: conn, Name: "mytube"} id, err := tube.Put([]byte("myjob"), 1, 0, time.Minute) if err != nil { panic(err) diff --git a/currentTubeJobsActionsRow.go b/currentTubeJobsActionsRow.go index a72fb33..2b8dce3 100644 --- a/currentTubeJobsActionsRow.go +++ b/currentTubeJobsActionsRow.go @@ -14,7 +14,10 @@ func currentTubeJobsActionsRow(server string, tube string) string { if bstkConn, err = beanstalk.Dial("tcp", server); err != nil { return `` } - tubeStats := &beanstalk.Tube{bstkConn, tube} + tubeStats := &beanstalk.Tube{ + Conn: bstkConn, + Name: tube, + } statsMap, _ := tubeStats.Stats() if statsMap["pause-time-left"] == "0" { pauseTimeLeft = fmt.Sprintf(``, server, tube, selfConf.TubePauseSeconds) } else { pauseTimeLeft = fmt.Sprintf(` Unpause tube`, server, tube, statsMap["pause-time-left"]) + title="Pause seconds left: %s"> Unpause tube`, server, tube, statsMap["pause-time-left"]) } bstkConn.Close() diff --git a/currentTubeJobsShowcase.go b/currentTubeJobsShowcase.go index d5032a4..f82b49a 100644 --- a/currentTubeJobsShowcase.go +++ b/currentTubeJobsShowcase.go @@ -30,7 +30,10 @@ func currentTubeJobsShowcaseReadySection(server string, tube string) string {
empty` } tubes, _ := bstkConn.ListTubes() - tubeStats := &beanstalk.Tube{bstkConn, tube} + tubeStats := &beanstalk.Tube{ + Conn: bstkConn, + Name: tube, + } jobID, jobBody, err := tubeStats.PeekReady() if err != nil { bstkConn.Close() @@ -153,7 +156,10 @@ func currentTubeJobsShowcaseDelayedSection(server string, tube string) string {
empty` } tubes, _ := bstkConn.ListTubes() - tubeStats := &beanstalk.Tube{bstkConn, tube} + tubeStats := &beanstalk.Tube{ + Conn: bstkConn, + Name: tube, + } jobID, jobBody, err := tubeStats.PeekDelayed() if err != nil { bstkConn.Close() @@ -276,7 +282,7 @@ func currentTubeJobsShowcaseBuriedSection(server string, tube string) string {
empty` } tubes, _ := bstkConn.ListTubes() - tubeStats := &beanstalk.Tube{bstkConn, tube} + tubeStats := &beanstalk.Tube{Conn: bstkConn, Name: tube} jobID, jobBody, err := tubeStats.PeekBuried() if err != nil { bstkConn.Close() diff --git a/currentTubeJobsSummaryTable.go b/currentTubeJobsSummaryTable.go index 5a0cb01..d242b0e 100644 --- a/currentTubeJobsSummaryTable.go +++ b/currentTubeJobsSummaryTable.go @@ -25,7 +25,7 @@ func currentTubeJobsSummaryTable(server string, tube string) string { if v != tube { continue } - tubeStats := &beanstalk.Tube{bstkConn, v} + tubeStats := &beanstalk.Tube{Conn: bstkConn, Name: v} statsMap, err := tubeStats.Stats() if err != nil { continue diff --git a/lib.go b/lib.go index 7bb0bf6..b604595 100644 --- a/lib.go +++ b/lib.go @@ -29,7 +29,10 @@ func addJob(server string, tube string, data string, priority string, delay stri if bstkConn, err = beanstalk.Dial("tcp", server); err != nil { return } - bstkTube := &beanstalk.Tube{bstkConn, tube} + bstkTube := &beanstalk.Tube{ + Conn: bstkConn, + Name: tube, + } bstkTube.Put([]byte(data), uint32(tubePriority), time.Duration(tubeDelay)*time.Second, time.Duration(tubeTTR)*time.Second) bstkConn.Close() } @@ -57,7 +60,10 @@ func deleteAll(server string, tube string) { if bstkConn, err = beanstalk.Dial("tcp", server); err != nil { return } - bstkTube := &beanstalk.Tube{bstkConn, tube} + bstkTube := &beanstalk.Tube{ + Conn: bstkConn, + Name: tube, + } for { readyJob, _, err := bstkTube.PeekReady() if err != nil { @@ -94,7 +100,10 @@ func kick(server string, tube string, count string) { if bstkConn, err = beanstalk.Dial("tcp", server); err != nil { return } - bstkTube := &beanstalk.Tube{bstkConn, tube} + bstkTube := &beanstalk.Tube{ + Conn: bstkConn, + Name: tube, + } bstkTube.Kick(bound) bstkConn.Close() } @@ -122,7 +131,10 @@ func pause(server string, tube string, count string) { if bstkConn, err = beanstalk.Dial("tcp", server); err != nil { return } - bstkTube := &beanstalk.Tube{bstkConn, tube} + bstkTube := &beanstalk.Tube{ + Conn: bstkConn, + Name: tube, + } if count == "-1" { bstkTube.Pause(3600 * time.Second) // Pause tube bstkConn.Close() @@ -149,7 +161,10 @@ func moveReadyJobsTo(server string, tube string, destTube string, destState stri if bstkConn, err = beanstalk.Dial("tcp", server); err != nil { return } - bstkTube := &beanstalk.Tube{bstkConn, tube} + bstkTube := &beanstalk.Tube{ + Conn: bstkConn, + Name: tube, + } switch destState { case "buried": tubeSet := beanstalk.NewTubeSet(bstkConn, tube) @@ -168,7 +183,10 @@ func moveReadyJobsTo(server string, tube string, destTube string, destState stri bstkConn.Close() return } - bstkDestTube := &beanstalk.Tube{bstkConn, destTube} + bstkDestTube := &beanstalk.Tube{ + Conn: bstkConn, + Name: destTube, + } for { readyJob, readyBody, err := bstkTube.PeekReady() if err != nil { @@ -194,8 +212,14 @@ func moveBuriedJobsTo(server string, tube string, destTube string, destState str if bstkConn, err = beanstalk.Dial("tcp", server); err != nil { return } - bstkTube := &beanstalk.Tube{bstkConn, tube} - bstkDestTube := &beanstalk.Tube{bstkConn, destTube} + bstkTube := &beanstalk.Tube{ + Conn: bstkConn, + Name: tube, + } + bstkDestTube := &beanstalk.Tube{ + Conn: bstkConn, + Name: destTube, + } for { buriedJob, buriedBody, err := bstkTube.PeekBuried() if err != nil { @@ -234,7 +258,10 @@ func searchTube(server string, tube string, limit string, searchStr string) stri return currentTubeJobsSummaryTable(server, tube) } result := []SearchResult{} - bstkTube := &beanstalk.Tube{bstkConn, tube} + bstkTube := &beanstalk.Tube{ + Conn: bstkConn, + Name: tube, + } tubeStat, err := bstkTube.Stats() if err != nil { bstkConn.Close() diff --git a/sampleJobUtils.go b/sampleJobUtils.go index 2ce7d88..ec81ba4 100644 --- a/sampleJobUtils.go +++ b/sampleJobUtils.go @@ -211,7 +211,10 @@ func loadSample(server string, tube string, key string) { if bstkConn, err = beanstalk.Dial("tcp", server); err != nil { return } - bstkTube := &beanstalk.Tube{bstkConn, tube} + bstkTube := &beanstalk.Tube{ + Conn: bstkConn, + Name: tube, + } bstkTube.Put([]byte(data), uint32(DefaultPriority), time.Duration(DefaultDelay)*time.Second, time.Duration(DefaultTTR)*time.Second) bstkConn.Close() return diff --git a/tplNav.go b/tplNav.go index 7e3ea1b..b792e31 100644 --- a/tplNav.go +++ b/tplNav.go @@ -48,7 +48,10 @@ func getServerTubes(server string) string { th += fmt.Sprintf(`%s`, v, v) } for _, v := range tubes { - tubeStats := &beanstalk.Tube{bstkConn, v} + tubeStats := &beanstalk.Tube{ + Conn: bstkConn, + Name: v, + } statsMap, err := tubeStats.Stats() if err != nil { continue diff --git a/utils.go b/utils.go index 00ca9a2..b5b96c2 100644 --- a/utils.go +++ b/utils.go @@ -139,7 +139,7 @@ func parseFlags() { os.Exit(1) } if *helpPtr == true { - fmt.Println("aurora version: 0.1\r\nCopyright (c) 2016 Ri Xu https://xuri.me \r\n\r\nUsage: aurora [OPTIONS] [cmd [arg ...]]\n -c Use config file. (default: aurora.toml)\r\n -h \t\t Output this help and exit.\r\n -v \t\t Output version and exit.\r\n") + fmt.Println("aurora version: 0.1\r\nCopyright (c) 2016 Ri Xu https://xuri.me \r\n\r\nUsage: aurora [OPTIONS] [cmd [arg ...]]\n -c Use config file. (default: aurora.toml)\r\n -h \t\t Output this help and exit.\r\n -v \t\t Output version and exit.") os.Exit(1) } }