File tree 3 files changed +7
-11
lines changed
3 files changed +7
-11
lines changed Original file line number Diff line number Diff line change @@ -53,12 +53,9 @@ func addProjectActually(project *Project) {
53
53
func addProject (project * Project ) {
54
54
//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
55
55
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 )
57
57
if errr != nil {
58
- _ , errs := os .Create (filEnv + "/path.json" )
59
- if errs != nil {
60
- panic (errs )
61
- }
58
+ panic (errr )
62
59
}
63
60
64
61
vp := viper .New ()
Original file line number Diff line number Diff line change @@ -46,15 +46,14 @@ func goPath(project *string) {
46
46
os .Chdir (path )
47
47
dir , err := os .Getwd ()
48
48
if err != nil {
49
- panic ("ca existe pas" )
49
+ panic (err )
50
50
}
51
51
52
52
//We pass the value of the path in the writeBash function
53
53
writeBash (& dir )
54
54
55
55
//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 {
58
57
log .Fatal (err )
59
58
}
60
59
}
@@ -63,9 +62,9 @@ func goPath(project *string) {
63
62
func writeBash (dir * string ) {
64
63
//the command
65
64
command := "cd " + * dir + "\n bash \n "
66
- pathEnv := os .Getenv ("gproject " )
65
+ pathEnv := os .Getenv ("goproject " )
67
66
data := []byte (command )
68
- err := ioutil .WriteFile (pathEnv + `\ script.sh` , data , 0666 )
67
+ err := ioutil .WriteFile (pathEnv + `/ script.sh` , data , 0666 )
69
68
if err != nil {
70
69
log .Fatal (err )
71
70
}
Original file line number Diff line number Diff line change @@ -17,7 +17,7 @@ var lsCmd = &cobra.Command{
17
17
Run : func (cmd * cobra.Command , args []string ) {
18
18
//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
19
19
filEnv := os .Getenv ("goproject" )
20
- file , err := os .ReadFile (filEnv + "/ path.json" )
20
+ file , err := os .ReadFile (filEnv + "\\ path.json" )
21
21
if err != nil {
22
22
panic (err )
23
23
}
You can’t perform that action at this time.
0 commit comments