Skip to content

Commit c34566f

Browse files
committed
fixed error path
1 parent b0f5924 commit c34566f

File tree

3 files changed

+7
-11
lines changed

3 files changed

+7
-11
lines changed

cmd/add.go

+2-5
Original file line numberDiff line numberDiff line change
@@ -53,12 +53,9 @@ func addProjectActually(project *Project) {
5353
func addProject(project *Project) {
5454
//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
5555
filEnv := os.Getenv("goproject")
56-
_, errr := os.Open(filEnv + "/path.json")
56+
_, errr := os.OpenFile(filEnv+"\\path.json", os.O_APPEND|os.O_WRONLY|os.O_CREATE, 0600)
5757
if errr != nil {
58-
_, errs := os.Create(filEnv + "/path.json")
59-
if errs != nil {
60-
panic(errs)
61-
}
58+
panic(errr)
6259
}
6360

6461
vp := viper.New()

cmd/go.go

+4-5
Original file line numberDiff line numberDiff line change
@@ -46,15 +46,14 @@ func goPath(project *string) {
4646
os.Chdir(path)
4747
dir, err := os.Getwd()
4848
if err != nil {
49-
panic("ca existe pas")
49+
panic(err)
5050
}
5151

5252
//We pass the value of the path in the writeBash function
5353
writeBash(&dir)
5454

5555
//We execute the script contained in the file: script.sh
56-
pathEnv := os.Getenv("gproject")
57-
if err := exec.Command("cmd", "/C", "start", pathEnv+`\script.sh`).Run(); err != nil {
56+
if err := exec.Command("cmd", "/C", "start", filEnv+`/script.sh`).Run(); err != nil {
5857
log.Fatal(err)
5958
}
6059
}
@@ -63,9 +62,9 @@ func goPath(project *string) {
6362
func writeBash(dir *string) {
6463
//the command
6564
command := "cd " + *dir + "\n bash \n"
66-
pathEnv := os.Getenv("gproject")
65+
pathEnv := os.Getenv("goproject")
6766
data := []byte(command)
68-
err := ioutil.WriteFile(pathEnv+`\script.sh`, data, 0666)
67+
err := ioutil.WriteFile(pathEnv+`/script.sh`, data, 0666)
6968
if err != nil {
7069
log.Fatal(err)
7170
}

cmd/ls.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ var lsCmd = &cobra.Command{
1717
Run: func(cmd *cobra.Command, args []string) {
1818
//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
1919
filEnv := os.Getenv("goproject")
20-
file, err := os.ReadFile(filEnv + "/path.json")
20+
file, err := os.ReadFile(filEnv + "\\path.json")
2121
if err != nil {
2222
panic(err)
2323
}

0 commit comments

Comments
 (0)