From 0543020038edb5de1162863e7401ea36f8a8584c Mon Sep 17 00:00:00 2001 From: hhvn Date: Tue, 8 Aug 2023 10:46:53 +0100 Subject: Channel-based bspwm communication --- common/common.go | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) (limited to 'common') diff --git a/common/common.go b/common/common.go index 00ac8e6..20c2c0a 100644 --- a/common/common.go +++ b/common/common.go @@ -3,6 +3,7 @@ package common import ( "os" "fmt" + "strconv" ) func Perror(function string, err error) error { @@ -10,5 +11,15 @@ func Perror(function string, err error) error { } func Error(format string, a ... any) (int, error) { - return fmt.Fprintf(os.Stderr, format, a) + fmt.Fprintf(os.Stderr, "error: ") + if (len(a) == 0) { + return fmt.Fprintf(os.Stderr, format) + } else { + return fmt.Fprintf(os.Stderr, format, a) + } +} + +func Intify(s string) (int, error) { + i, err := strconv.ParseInt(s, 0, 0) + return int(i), err } -- cgit v1.2.3