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)
|
ColorError = color.New(color.FgRed, color.Bold)
|
||||||
ColorInProgress = color.New(color.FgBlue)
|
ColorInProgress = color.New(color.FgBlue)
|
||||||
ColorDone = color.New(color.FgGreen, color.Bold)
|
ColorDone = color.New(color.FgGreen, color.Bold)
|
||||||
|
|
||||||
|
ColorWarn = color.New(color.FgYellow, color.Bold)
|
||||||
)
|
)
|
||||||
|
|
||||||
func (s CompileState) String() string {
|
func (s CompileState) String() string {
|
||||||
|
28
main.go
28
main.go
@ -1,8 +1,10 @@
|
|||||||
package main
|
package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"errors"
|
||||||
"flag"
|
"flag"
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"os"
|
||||||
"os/exec"
|
"os/exec"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
"runtime"
|
"runtime"
|
||||||
@ -31,16 +33,34 @@ func main() {
|
|||||||
var err error
|
var err error
|
||||||
flag.Parse()
|
flag.Parse()
|
||||||
|
|
||||||
if err := FillCompileConfigs(); err != nil {
|
|
||||||
panic(err)
|
|
||||||
}
|
|
||||||
|
|
||||||
ModulePath, err = filepath.Abs(flag.Arg(0))
|
ModulePath, err = filepath.Abs(flag.Arg(0))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
panic(err)
|
panic(err)
|
||||||
}
|
}
|
||||||
ProjectName = filepath.Base(ModulePath)
|
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))
|
ch := make(chan *CompileReport, len(CompileConfigs))
|
||||||
wg := new(sync.WaitGroup)
|
wg := new(sync.WaitGroup)
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user