From 3bcdec13657598f6a6163c7ddecff58c2d3a2a71 Mon Sep 17 00:00:00 2001 From: Dmitry Vyukov Date: Wed, 16 Dec 2020 08:57:04 +0100 Subject: 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. --- pkg/tool/tool.go | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) create mode 100644 pkg/tool/tool.go (limited to 'pkg/tool/tool.go') 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) +} -- cgit mrf-deployment