diff options
-rw-r--r-- | util/interrupt/cleaner.go | 11 | ||||
-rw-r--r-- | util/interrupt/cleaner_test.go | 4 |
2 files changed, 7 insertions, 8 deletions
diff --git a/util/interrupt/cleaner.go b/util/interrupt/cleaner.go index 76c9d04d..75d6c390 100644 --- a/util/interrupt/cleaner.go +++ b/util/interrupt/cleaner.go @@ -7,13 +7,13 @@ import ( "syscall" ) -// Cleaner type referes to a function with no inputs that returns an error +// Cleaner type refers to a function with no inputs that returns an error type Cleaner func() error var cleaners []Cleaner var active = false -// RegisterCleaner is responsible for regisreting a cleaner function. When a function is registered, the Signal watcher is started in a goroutine. +// RegisterCleaner is responsible for registering a cleaner function. When a function is registered, the Signal watcher is started in a goroutine. func RegisterCleaner(f ...Cleaner) { for _, fn := range f { cleaners = append([]Cleaner{fn}, cleaners...) @@ -25,8 +25,7 @@ func RegisterCleaner(f ...Cleaner) { <-ch // Prevent un-terminated ^C character in terminal fmt.Println() - fmt.Println("Cleaning") - errl := Clean() + errl := clean() for _, err := range errl { fmt.Println(err) } @@ -36,8 +35,8 @@ func RegisterCleaner(f ...Cleaner) { } } -// Clean invokes all registered cleanup functions, and returns a list of errors, if they exist. -func Clean() (errorlist []error) { +// clean invokes all registered cleanup functions, and returns a list of errors, if they exist. +func clean() (errorlist []error) { for _, f := range cleaners { err := f() if err != nil { diff --git a/util/interrupt/cleaner_test.go b/util/interrupt/cleaner_test.go index c4e5c9b3..ebe012be 100644 --- a/util/interrupt/cleaner_test.go +++ b/util/interrupt/cleaner_test.go @@ -22,7 +22,7 @@ func TestRegisterAndErrorAtCleaning(t *testing.T) { RegisterCleaner(f2, f3) // count := 0 - errl := Clean() + errl := clean() if len(errl) != 2 { t.Fatalf("unexpected error count") } @@ -43,7 +43,7 @@ func TestRegisterAndClean(t *testing.T) { } RegisterCleaner(f, f2) - errl := Clean() + errl := clean() if len(errl) != 0 { t.Fatalf("unexpected error count") } |