Introduce function utils.AppName()

This commit is contained in:
Eric Lippmann 2021-10-04 17:04:49 +02:00
parent 66d34b4a9f
commit 3061e3d0c5

View file

@ -9,6 +9,8 @@ import (
"github.com/pkg/errors"
"golang.org/x/exp/utf8string"
"math"
"os"
"path/filepath"
"strings"
"time"
"unicode"
@ -179,3 +181,13 @@ func ConvertCamelCase(s string, _case int, sep byte) string {
return b.String()
}
// AppName returns the name of the executable that started this program (process).
func AppName() string {
exe, err := os.Executable()
if err != nil {
exe = os.Args[0]
}
return filepath.Base(exe)
}