@@ -20,12 +20,11 @@ package configs
2020import (
2121 "fmt"
2222 "os"
23- "os/user"
2423 "runtime"
2524
26- "github.com/arduino/go-paths-helper"
27-
28- "github.com/arduino /go-win32-utils "
25+ paths "github.com/arduino/go-paths-helper"
26+ win32 "github.com/arduino/go-win32-utils"
27+ homedir "github.com/mitchellh /go-homedir "
2928)
3029
3130// getDefaultConfigFilePath returns the default path for .cli-config.yml,
@@ -39,11 +38,11 @@ func getDefaultConfigFilePath() *paths.Path {
3938}
4039
4140func getDefaultArduinoDataDir () (* paths.Path , error ) {
42- usr , err := user . Current ()
41+ homedir , err := homedir . Dir ()
4342 if err != nil {
4443 return nil , fmt .Errorf ("retrieving user home dir: %s" , err )
4544 }
46- arduinoDataDir := paths .New (usr . HomeDir )
45+ arduinoDataDir := paths .New (homedir )
4746
4847 switch runtime .GOOS {
4948 case "linux" :
@@ -63,16 +62,16 @@ func getDefaultArduinoDataDir() (*paths.Path, error) {
6362}
6463
6564func getDefaultSketchbookDir () (* paths.Path , error ) {
66- usr , err := user . Current ()
65+ homedir , err := homedir . Dir ()
6766 if err != nil {
6867 return nil , fmt .Errorf ("retrieving home dir: %s" , err )
6968 }
7069
7170 switch runtime .GOOS {
7271 case "linux" :
73- return paths .New (usr . HomeDir ).Join ("Arduino" ), nil
72+ return paths .New (homedir ).Join ("Arduino" ), nil
7473 case "darwin" :
75- return paths .New (usr . HomeDir ).Join ("Documents" , "Arduino" ), nil
74+ return paths .New (homedir ).Join ("Documents" , "Arduino" ), nil
7675 case "windows" :
7776 documentsPath , err := win32 .GetDocumentsFolder ()
7877 if err != nil {
0 commit comments