
- Replace low-level operations like file existance checks, file io with viper calls. That also allows to get rid of manual config structure initialization. - Split out UserHome() into itil/home.go to reduce code duplicacy. - Better error handling and general readbility.
16 lines
240 B
Go
16 lines
240 B
Go
package util
|
|
|
|
import (
|
|
"log"
|
|
"os"
|
|
)
|
|
|
|
func UserHome() string {
|
|
homeDir, err := os.UserHomeDir()
|
|
if err != nil {
|
|
log.Fatalf("Unable to get current user's home directory. $HOME environment variable issue? %s", err)
|
|
}
|
|
|
|
return homeDir
|
|
}
|