File tree 1 file changed +14
-4
lines changed
1 file changed +14
-4
lines changed Original file line number Diff line number Diff line change 4
4
"fmt"
5
5
"log"
6
6
"os"
7
+ "runtime"
7
8
8
9
"github.com/fsnotify/fsnotify"
9
10
"github.com/spf13/cobra"
@@ -51,11 +52,20 @@ func addProjectActually(project *Project) {
51
52
func addProject (project * Project ) {
52
53
//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
53
54
filEnv := os .Getenv ("gproject" )
54
- _ , errs := os .OpenFile (filEnv + "\\ path.json" , os .O_APPEND | os .O_WRONLY | os .O_CREATE , 0600 )
55
- if errs != nil {
56
- panic (errs )
57
- }
55
+ sys := runtime .GOOS
56
+ if sys == "linux" || sys == "darwin" {
57
+ _ , errs := os .OpenFile (filEnv + "path.json" , os .O_APPEND | os .O_WRONLY | os .O_CREATE , 0600 )
58
+ if errs != nil {
59
+ log .Fatal (errs )
60
+ }
61
+ } else {
62
+ _ , errs := os .OpenFile (filEnv + "\\ path.json" , os .O_APPEND | os .O_WRONLY | os .O_CREATE , 0600 )
63
+ if errs != nil {
64
+ log .Fatal (errs )
65
+ }
58
66
67
+ }
68
+
59
69
viper .SetConfigName ("path" )
60
70
viper .SetConfigType ("json" )
61
71
viper .AddConfigPath (filEnv )
You can’t perform that action at this time.
0 commit comments