Skip to content

Commit dc51cd0

Browse files
committed
fix: rather try and interpolate $HOME env var instead of native golang
1 parent cf0576d commit dc51cd0

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

config.go

+5-5
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@ package main
33
import (
44
"io"
55
"os"
6-
"os/user"
76
"path/filepath"
7+
"strings"
88

99
"github.com/clipperhouse/typewriter"
1010
)
@@ -22,11 +22,11 @@ var defaultConfig = config{
2222
}
2323

2424
func mustGetConfigCustomName() string {
25-
curUser, err := user.Current()
26-
if err != nil {
27-
panic(err)
25+
homeDir := strings.TrimSpace(os.Getenv("HOME"))
26+
if homeDir == "" {
27+
panic("Home dir (env $HOME) is required")
2828
}
29-
return filepath.Join(curUser.HomeDir, "_user_gen.go")
29+
return filepath.Join(homeDir, "_user_gen.go")
3030
}
3131

3232
// keep in sync with imports.go

0 commit comments

Comments
 (0)