aboutsummaryrefslogtreecommitdiffstats
path: root/pkg/tool/tool.go
diff options
context:
space:
mode:
authorDmitry Vyukov <dvyukov@google.com>2020-12-16 08:57:04 +0100
committerDmitry Vyukov <dvyukov@google.com>2020-12-25 10:12:41 +0100
commit3bcdec13657598f6a6163c7ddecff58c2d3a2a71 (patch)
tree3ff27333aeecc6eb7be333bc4407647792968ff1 /pkg/tool/tool.go
parent80795712865ca86bb21ebb9841598ccbcbd375c9 (diff)
pkg/tool: add package
Package tool contains various helper utilitites useful for implementation of command line tools. Currently it contains Fail/Failf functions that we commonly use and new support for optional command line flags.
Diffstat (limited to 'pkg/tool/tool.go')
-rw-r--r--pkg/tool/tool.go19
1 files changed, 19 insertions, 0 deletions
diff --git a/pkg/tool/tool.go b/pkg/tool/tool.go
new file mode 100644
index 000000000..bb1f436cc
--- /dev/null
+++ b/pkg/tool/tool.go
@@ -0,0 +1,19 @@
+// Copyright 2020 syzkaller project authors. All rights reserved.
+// Use of this source code is governed by Apache 2 LICENSE that can be found in the LICENSE file.
+
+// Package tool contains various helper utilitites useful for implementation of command line tools.
+package tool
+
+import (
+ "fmt"
+ "os"
+)
+
+func Failf(msg string, args ...interface{}) {
+ fmt.Fprintf(os.Stderr, msg+"\n", args...)
+ os.Exit(1)
+}
+
+func Fail(err error) {
+ Failf("%v", err)
+}