@@ -3,7 +3,6 @@ package cmd
33import (
44 "bufio"
55 "encoding/json"
6- "errors"
76 "fmt"
87 "io"
98 "os"
@@ -286,7 +285,7 @@ func getDefaultData(fs vfs.FS) (map[string]interface{}, error) {
286285 return nil , err
287286 }
288287
289- homedir , err := userHomeDir ()
288+ homedir , err := os . UserHomeDir ()
290289 if err != nil {
291290 return nil , err
292291 }
@@ -387,31 +386,3 @@ func upperSnakeCaseToCamelCaseMap(m map[string]string) map[string]string {
387386 }
388387 return result
389388}
390-
391- // userHomeDir returns the current user's home directory.
392- //
393- // On Unix, including macOS, it returns the $HOME environment variable.
394- // On Windows, it returns %USERPROFILE%.
395- // On Plan 9, it returns the $home environment variable.
396- //
397- // FIXME this is copied from https://tip.golang.org/src/os/file.go?s=11606:11640#L379.
398- // Replace it with os.UserHomeDir when Go 1.12 is released.
399- func userHomeDir () (string , error ) {
400- env , enverr := "HOME" , "$HOME"
401- switch runtime .GOOS {
402- case "windows" :
403- env , enverr = "USERPROFILE" , "%userprofile%"
404- case "plan9" :
405- env , enverr = "home" , "$home"
406- case "nacl" , "android" :
407- return "/" , nil
408- case "darwin" :
409- if runtime .GOARCH == "arm" || runtime .GOARCH == "arm64" {
410- return "/" , nil
411- }
412- }
413- if v := os .Getenv (env ); v != "" {
414- return v , nil
415- }
416- return "" , errors .New (enverr + " is not defined" )
417- }
0 commit comments