From cb16cfa183c5584d266f3ba3f7ced477f77a0823 Mon Sep 17 00:00:00 2001 From: Kyle Isom Date: Thu, 16 Nov 2017 08:32:05 -0800 Subject: [PATCH] golint cleanups. --- assert/assert.go | 2 +- cmd/utc/main.go | 8 ++++---- logging/file.go | 13 ++++++++++--- logging/levels.go | 1 + logging/log.go | 4 ++-- tee/tee.go | 1 + 6 files changed, 19 insertions(+), 10 deletions(-) diff --git a/assert/assert.go b/assert/assert.go index 1b3edc6..aee0ee3 100644 --- a/assert/assert.go +++ b/assert/assert.go @@ -16,7 +16,7 @@ import ( "testing" ) -// NoDebug, if set to true, will cause all asserts to be ignored. +// NoDebug can be set to true to cause all asserts to be ignored. var NoDebug bool func die(what string, a ...string) { diff --git a/cmd/utc/main.go b/cmd/utc/main.go index 3b88ff2..a46c98d 100644 --- a/cmd/utc/main.go +++ b/cmd/utc/main.go @@ -14,9 +14,9 @@ var ( format = "2006-01-02 15:04" // Format that will be used for times. outFormat = format + " MST" // Output format. tz = "Local" // String descriptor for timezone. - fromLoc *time.Location = time.Local // Go time.Location for the named timezone. + fromLoc = time.Local // Go time.Location for the named timezone. fromUnix bool // Input times are Unix timestamps. - toLoc *time.Location = time.UTC // Go time.Location for output timezone. + toLoc = time.UTC // Go time.Location for output timezone. ) func usage(w io.Writer) { @@ -84,7 +84,7 @@ PST8PDT time zone): 2016-06-14 21:30 PDT = 2016-06-15 04:30 UTC + Converting a local EST timestamp to UTC (on a machine set to PST8PDT): - $ utc -z EST '2016-06-14 21:30' + $ utc -z EST '2016-06-14 21:30' 2016-06-14 21:30 EST = 2016-06-15 02:30 UTC + Converting timestamps in the form '14-06-2016 3:04PM': $ utc -f '02-01-2006 3:04PM' '14-06-2016 9:30PM' @@ -101,7 +101,7 @@ PST8PDT time zone): $ utc -u -z EST '2016-06-14 21:30' 2016-06-14 21:30 UTC = 2016-06-14 16:30 EST + Using a different output format: - $ utc -o '2006-01-02T15:03:04-0700' '2016-06-14 21:30' + $ utc -o '2006-01-02T15:03:04-0700' '2016-06-14 21:30' 2016-06-14T21:09:30-0700 = 2016-06-15T04:04:30+0000 + Converting a Unix timestamp to a UTC time: $ utc -t 1466052938 diff --git a/logging/file.go b/logging/file.go index 48d3b1b..7af8622 100644 --- a/logging/file.go +++ b/logging/file.go @@ -8,10 +8,17 @@ type File struct { *LogWriter } -func (fl *File) Close() { - fl.fo.Close() +// Close calls close on the underlying log files. +func (fl *File) Close() error { + if fl.fo != nil { + if err := fl.fo.Close(); err != nil { + return err + } + fl.fo = nil + } + if fl.fe != nil { - fl.fe.Close() + return fl.fe.Close() } } diff --git a/logging/levels.go b/logging/levels.go index 2b81c6b..2881272 100644 --- a/logging/levels.go +++ b/logging/levels.go @@ -29,6 +29,7 @@ const ( LevelFatal ) +// DefaultLevel is the default logging level when none is provided. const DefaultLevel = LevelInfo // Cheap integer to fixed-width decimal ASCII. Give a negative width diff --git a/logging/log.go b/logging/log.go index b16dd68..c122239 100644 --- a/logging/log.go +++ b/logging/log.go @@ -228,7 +228,7 @@ func (lw *LogWriter) Fatal(actor, event string, attrs map[string]string) { os.Exit(1) } -// Fatal emits a message indicating that the system is in an unsuable +// FatalCode emits a message indicating that the system is in an unsuable // state, and cannot continue to run. The program will exit with the // exit code speicfied in the exitcode argument. // @@ -244,7 +244,7 @@ func (lw *LogWriter) FatalCode(exitcode int, actor, event string, attrs map[stri os.Exit(exitcode) } -// Fatal emits a message indicating that the system is in an unsuable +// FatalNoDie emits a message indicating that the system is in an unsuable // state, and cannot continue to run. The program will not exit; it is // assumed that the caller has some final clean up to perform. // diff --git a/tee/tee.go b/tee/tee.go index 1b502b3..6a4b7dd 100644 --- a/tee/tee.go +++ b/tee/tee.go @@ -23,6 +23,7 @@ func (t *Tee) Write(p []byte) (int, error) { return n, nil } +// Close calls Close on the underlying file. func (t *Tee) Close() error { return t.f.Close() }