summaryrefslogtreecommitdiff
path: root/common
diff options
context:
space:
mode:
authorhhvn <dev@hhvn.uk>2023-08-08 10:46:53 +0100
committerhhvn <dev@hhvn.uk>2023-08-08 10:49:30 +0100
commit0543020038edb5de1162863e7401ea36f8a8584c (patch)
tree713f77ec14b560a341863fed05502c62e062a593 /common
parent2e3b351c355bd241de4aa4f2bdafd633ccef6eac (diff)
Channel-based bspwm communication
Diffstat (limited to 'common')
-rw-r--r--common/common.go13
1 files changed, 12 insertions, 1 deletions
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
}