Fixing test imports (#593)

This commit is contained in:
Denis Makogon 2018-02-05 01:07:47 +02:00 committed by Adam Babik
parent 6728dcf06d
commit 230e4febb1
3 changed files with 5 additions and 17 deletions

View File

@ -250,7 +250,7 @@ Examples:
Options: Options:
` `
fmt.Fprintf(os.Stderr, usage) // nolint: gas fmt.Fprint(os.Stderr, usage) // nolint: gas
flag.PrintDefaults() flag.PrintDefaults()
} }

View File

@ -10,7 +10,6 @@ import (
"os" "os"
"path/filepath" "path/filepath"
"reflect" "reflect"
"runtime"
"runtime/debug" "runtime/debug"
"time" "time"
@ -94,17 +93,6 @@ func PanicAfter(waitSeconds time.Duration, abort chan struct{}, desc string) {
}() }()
} }
// NameOf returns name of caller, at runtime
func NameOf(f interface{}) string {
v := reflect.ValueOf(f)
if v.Kind() == reflect.Func {
if rf := runtime.FuncForPC(v.Pointer()); rf != nil {
return rf.Name()
}
}
return v.String()
}
// MessageIDFromContext returns message id from context (if exists) // MessageIDFromContext returns message id from context (if exists)
func MessageIDFromContext(ctx context.Context) string { func MessageIDFromContext(ctx context.Context) string {
if ctx == nil { if ctx == nil {
@ -143,7 +131,7 @@ func Fatalf(reason interface{}, args ...interface{}) {
// find out whether error or string has been passed as a reason // find out whether error or string has been passed as a reason
r := reflect.ValueOf(reason) r := reflect.ValueOf(reason)
if r.Kind() == reflect.String { if r.Kind() == reflect.String {
fmt.Fprintf(w, "Fatal Failure: "+reason.(string)+"\n", args) //nolint: gas fmt.Fprintf(w, "Fatal Failure: %v\n%v\n", reason.(string), args) //nolint: gas
} else { } else {
fmt.Fprintf(w, "Fatal Failure: %v\n", reason.(error)) //nolint: gas fmt.Fprintf(w, "Fatal Failure: %v\n", reason.(error)) //nolint: gas
} }

View File

@ -10,16 +10,16 @@ import (
// HaltOnPanic recovers from panic, logs issue, sends upward notification, and exits // HaltOnPanic recovers from panic, logs issue, sends upward notification, and exits
func HaltOnPanic() { func HaltOnPanic() {
if r := recover(); r != nil { if r := recover(); r != nil {
err := fmt.Errorf("%v: %v", ErrNodeRunFailure, r) strErr := fmt.Sprintf("%v: %v", ErrNodeRunFailure, r)
// send signal up to native app // send signal up to native app
signal.Send(signal.Envelope{ signal.Send(signal.Envelope{
Type: signal.EventNodeCrashed, Type: signal.EventNodeCrashed,
Event: signal.NodeCrashEvent{ Event: signal.NodeCrashEvent{
Error: err.Error(), Error: strErr,
}, },
}) })
common.Fatalf(err) // os.exit(1) is called internally common.Fatalf(ErrNodeRunFailure, r) // os.exit(1) is called internally
} }
} }