From 48d09d19153eedfbf4892fd220749216412cd67b Mon Sep 17 00:00:00 2001 From: codeworm96 Date: Tue, 30 Jan 2018 22:10:24 +0800 Subject: [PATCH] go fmt --- license.go | 7 ++++--- main.go | 8 ++++---- worker/rsync_worker.go | 8 ++++---- worker/shell_script_worker.go | 8 ++++---- worker/utilities.go | 2 +- worker/worker_test.go | 10 +++++----- 6 files changed, 22 insertions(+), 21 deletions(-) diff --git a/license.go b/license.go index d495270..5a3a9b6 100644 --- a/license.go +++ b/license.go @@ -1,6 +1,7 @@ -package main - /* Generated by script scripts/gen_license.sh */ - const licenseText = ` ==> ./vendor/golang.org/x/sys/LICENSE <== +package main + +/* Generated by script scripts/gen_license.sh */ +const licenseText = ` ==> ./vendor/golang.org/x/sys/LICENSE <== Copyright (c) 2009 The Go Authors. All rights reserved. Redistribution and use in source and binary forms, with or without diff --git a/main.go b/main.go index a2658e6..1889b1b 100644 --- a/main.go +++ b/main.go @@ -8,9 +8,9 @@ import ( log "github.com/Sirupsen/logrus" "github.com/bshuster-repo/logrus-logstash-hook" + "github.com/goji/httpauth" "github.com/sjtug/lug/config" "github.com/sjtug/lug/manager" - "github.com/goji/httpauth" ) const ( @@ -114,10 +114,10 @@ func main() { } jsonapi := manager.NewRestfulAPI(m) handler := jsonapi.GetAPIHandler() - if flags.apiUser != "" && flags.apiPassword !="" { + if flags.apiUser != "" && flags.apiPassword != "" { auth := httpauth.BasicAuth(httpauth.AuthOptions{ - Realm: "Require authentication", - User: flags.apiUser, + Realm: "Require authentication", + User: flags.apiUser, Password: flags.apiPassword, }) handler = auth(handler) diff --git a/worker/rsync_worker.go b/worker/rsync_worker.go index bfa89b4..8d3f14b 100644 --- a/worker/rsync_worker.go +++ b/worker/rsync_worker.go @@ -59,11 +59,11 @@ func NewRsyncWorker(status Status, // GetStatus returns a snapshot of current worker status func (w *RsyncWorker) GetStatus() Status { return Status{ - Idle: w.idle, - Result: w.result, + Idle: w.idle, + Result: w.result, LastFinished: w.lastFinished, - Stdout: w.stdout.GetAll(), - Stderr: w.stderr.GetAll(), + Stdout: w.stdout.GetAll(), + Stderr: w.stderr.GetAll(), } } diff --git a/worker/shell_script_worker.go b/worker/shell_script_worker.go index 2bcd84b..f5b5fb0 100644 --- a/worker/shell_script_worker.go +++ b/worker/shell_script_worker.go @@ -57,11 +57,11 @@ func NewShellScriptWorker(status Status, // GetStatus returns a snapshot of current status func (w *ShellScriptWorker) GetStatus() Status { return Status{ - Idle: w.idle, - Result: w.result, + Idle: w.idle, + Result: w.result, LastFinished: w.lastFinished, - Stdout: w.stdout.GetAll(), - Stderr: w.stderr.GetAll(), + Stdout: w.stdout.GetAll(), + Stderr: w.stderr.GetAll(), } } diff --git a/worker/utilities.go b/worker/utilities.go index 09d5694..6c0fc55 100644 --- a/worker/utilities.go +++ b/worker/utilities.go @@ -3,4 +3,4 @@ package worker type utility interface { preHook() error postHook() error -} \ No newline at end of file +} diff --git a/worker/worker_test.go b/worker/worker_test.go index 91f54ff..1568344 100644 --- a/worker/worker_test.go +++ b/worker/worker_test.go @@ -5,8 +5,8 @@ import ( "github.com/sjtug/lug/config" "github.com/stretchr/testify/assert" - "os/exec" "io" + "os/exec" ) var rsyncW Worker @@ -56,13 +56,13 @@ func TestNewShellScriptWorker(t *testing.T) { } type limitReader struct { - cnt int + cnt int limit int } func newLimitReader(limit int) *limitReader { return &limitReader{ - cnt: 0, + cnt: 0, limit: limit, } } @@ -71,7 +71,7 @@ func (i *limitReader) Read(p []byte) (int, error) { return 0, io.EOF } i.cnt += len(p) - for i:=0; i