added various error messages and warnings
This commit is contained in:
parent
97a3c7ab71
commit
a5861ca989
@ -27,6 +27,8 @@ var (
|
||||
ColorError = color.New(color.FgRed, color.Bold)
|
||||
ColorInProgress = color.New(color.FgBlue)
|
||||
ColorDone = color.New(color.FgGreen, color.Bold)
|
||||
|
||||
ColorWarn = color.New(color.FgYellow, color.Bold)
|
||||
)
|
||||
|
||||
func (s CompileState) String() string {
|
||||
|
28
main.go
28
main.go
@ -1,8 +1,10 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"flag"
|
||||
"fmt"
|
||||
"os"
|
||||
"os/exec"
|
||||
"path/filepath"
|
||||
"runtime"
|
||||
@ -31,16 +33,34 @@ func main() {
|
||||
var err error
|
||||
flag.Parse()
|
||||
|
||||
if err := FillCompileConfigs(); err != nil {
|
||||
panic(err)
|
||||
}
|
||||
|
||||
ModulePath, err = filepath.Abs(flag.Arg(0))
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
ProjectName = filepath.Base(ModulePath)
|
||||
|
||||
if _, err := exec.LookPath("go"); err != nil {
|
||||
ColorError.Fprintln(os.Stderr, "go not found in PATH. compilation not possible")
|
||||
return
|
||||
}
|
||||
|
||||
if !*NoCompress {
|
||||
if _, err := exec.LookPath("upx"); err != nil {
|
||||
ColorWarn.Fprintln(os.Stderr, "upx not found in PATH. file compression not possible")
|
||||
*NoCompress = true
|
||||
}
|
||||
}
|
||||
|
||||
if err := FillCompileConfigs(); err != nil {
|
||||
ColorError.Fprintln(os.Stderr, fmt.Errorf("target architectures could not be determined: %w", err))
|
||||
return
|
||||
}
|
||||
|
||||
if _, err := os.Stat(filepath.Join(ModulePath, "go.mod")); errors.Is(err, os.ErrNotExist) {
|
||||
ColorError.Fprintf(os.Stderr, "no Go module found at '%s'\n", ModulePath)
|
||||
return
|
||||
}
|
||||
|
||||
ch := make(chan *CompileReport, len(CompileConfigs))
|
||||
wg := new(sync.WaitGroup)
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user