From 286fbc07e985d960209e8443a57e7f95efe60efd Mon Sep 17 00:00:00 2001 From: ᴜɴᴋɴᴡᴏɴ Date: Sat, 22 Feb 2020 20:46:16 +0800 Subject: conf: overhaul security settings --- internal/osutil/osutil.go | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'internal/osutil') diff --git a/internal/osutil/osutil.go b/internal/osutil/osutil.go index 6573cea0..656f2e2a 100644 --- a/internal/osutil/osutil.go +++ b/internal/osutil/osutil.go @@ -16,3 +16,13 @@ func IsFile(path string) bool { } return !f.IsDir() } + +// CurrentUsername returns the current system user via environment variables. +func CurrentUsername() string { + curUserName := os.Getenv("USER") + if len(curUserName) > 0 { + return curUserName + } + + return os.Getenv("USERNAME") +} -- cgit v1.2.3