Skip to content

Commit 28c5bd1

Browse files
committed
bug fixed,
simple errors messages added
1 parent 03e3288 commit 28c5bd1

File tree

3 files changed

+20
-1
lines changed

3 files changed

+20
-1
lines changed

controllers/jsonLoading.go

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@ package controllers
22

33
import (
44
"encoding/json"
5+
"fmt"
6+
"go/build"
57
"godemon/models"
68
"io/ioutil"
79
"os"
@@ -15,5 +17,17 @@ func loadProjectInfo() models.Project {
1517
ErrorHandle(err)
1618
var project models.Project
1719
json.Unmarshal(byteValue, &project)
20+
if project.Name == "" || project.Path == "" {
21+
fmt.Println("Project name or path is empty")
22+
os.Exit(1)
23+
}
24+
if project.OS == "" && project.Arch == "" {
25+
project.OS = build.Default.GOOS
26+
project.Arch = build.Default.GOARCH
27+
} else if project.OS == "" {
28+
project.OS = build.Default.GOOS
29+
} else if project.Arch == "" {
30+
project.Arch = build.Default.GOARCH
31+
}
1832
return project
1933
}

controllers/pv.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ package controllers
22

33
import (
44
"encoding/json"
5+
"fmt"
56
"godemon/models"
67
"io/ioutil"
78
"os"
@@ -53,5 +54,9 @@ func cnfFunc(command string, filepath string, modOrFile string) (string, string)
5354
modOrFile = project.Commands[i].Option
5455
}
5556
}
57+
if filepath == "" || modOrFile == "" {
58+
fmt.Println("Filepath or modOrFile is empty")
59+
os.Exit(1)
60+
}
5661
return filepath, modOrFile
5762
}

main.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ func main() {
1212
cmd.Stdout = os.Stdout
1313
cmd.Stderr = os.Stderr
1414
cmd.Run()
15-
version := "2.2.1"
15+
version := "2.2.2"
1616
doneChan := make(chan bool)
1717
filepath, modOrFile, cnf, command, help, init, name, oso, arch := controllers.LoadCMD("", "")
1818
filepath, modOrFile = controllers.ProgramStarting(&cnf, filepath, modOrFile, command, help, version, init, name, oso, arch)

0 commit comments

Comments
 (0)