diff --git a/cmd/add.go b/cmd/add.go index b70d06c..1994881 100644 --- a/cmd/add.go +++ b/cmd/add.go @@ -53,12 +53,9 @@ 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("goproject") - _, errr := os.Open(filEnv + "/path.json") + _, errr := os.OpenFile(filEnv+"\\path.json", os.O_APPEND|os.O_WRONLY|os.O_CREATE, 0600) if errr != nil { - _, errs := os.Create(filEnv + "/path.json") - if errs != nil { - panic(errs) - } + panic(errr) } vp := viper.New() diff --git a/cmd/go.go b/cmd/go.go index 49c3dfd..8c81039 100644 --- a/cmd/go.go +++ b/cmd/go.go @@ -46,15 +46,14 @@ func goPath(project *string) { os.Chdir(path) dir, err := os.Getwd() if err != nil { - panic("ca existe pas") + panic(err) } //We pass the value of the path in the writeBash function writeBash(&dir) //We execute the script contained in the file: script.sh - pathEnv := os.Getenv("gproject") - if err := exec.Command("cmd", "/C", "start", pathEnv+`\script.sh`).Run(); err != nil { + if err := exec.Command("cmd", "/C", "start", filEnv+`/script.sh`).Run(); err != nil { log.Fatal(err) } } @@ -63,9 +62,9 @@ func goPath(project *string) { func writeBash(dir *string) { //the command command := "cd " + *dir + "\n bash \n" - pathEnv := os.Getenv("gproject") + pathEnv := os.Getenv("goproject") data := []byte(command) - err := ioutil.WriteFile(pathEnv+`\script.sh`, data, 0666) + err := ioutil.WriteFile(pathEnv+`/script.sh`, data, 0666) if err != nil { log.Fatal(err) } diff --git a/cmd/ls.go b/cmd/ls.go index ffd332d..c693960 100644 --- a/cmd/ls.go +++ b/cmd/ls.go @@ -17,7 +17,7 @@ var lsCmd = &cobra.Command{ Run: func(cmd *cobra.Command, args []string) { //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("goproject") - file, err := os.ReadFile(filEnv + "/path.json") + file, err := os.ReadFile(filEnv + "\\path.json") if err != nil { panic(err) }