diff --git a/cmd/add.go b/cmd/add.go index 0db6a55..d1c02cb 100644 --- a/cmd/add.go +++ b/cmd/add.go @@ -4,6 +4,7 @@ import ( "fmt" "log" "os" + "runtime" "github.com/fsnotify/fsnotify" "github.com/spf13/cobra" @@ -51,11 +52,20 @@ func addProjectActually(project *Project) { func addProject(project *Project) { //the environment variable is stored in a variable in order to create and find the path.json file in the directory where the app is located filEnv := os.Getenv("gproject") - _, errs := os.OpenFile(filEnv+"\\path.json", os.O_APPEND|os.O_WRONLY|os.O_CREATE, 0600) - if errs != nil { - panic(errs) - } + sys := runtime.GOOS + if sys == "linux" || sys == "darwin"{ + _, errs := os.OpenFile(filEnv+"path.json", os.O_APPEND|os.O_WRONLY|os.O_CREATE, 0600) + if errs != nil{ + log.Fatal(errs) + } + } else { + _, errs := os.OpenFile(filEnv+"\\path.json", os.O_APPEND|os.O_WRONLY|os.O_CREATE, 0600) + if errs != nil{ + log.Fatal(errs) + } + } + viper.SetConfigName("path") viper.SetConfigType("json") viper.AddConfigPath(filEnv)