summaryrefslogtreecommitdiff
path: root/common/common.go
blob: 00d58ee119a44382aa85be561816bfd1d70a5fe3 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
package common

import (
	"os"
	"fmt"
	"strconv"
)

func Perror(function string, err error) error {
	return fmt.Errorf("%s(): %w", function, err)
}

func Error(format string, a ... any) (int, error) {
	fmt.Fprintf(os.Stderr, "error: ")
	return fmt.Fprintf(os.Stderr, format, a...)
}

func Intify(s string) (int, error) {
	i, err := strconv.ParseInt(s, 0, 0)
	return int(i), err
}