silent mode fixed
This commit is contained in:
parent
cb1105d4f6
commit
cd24640118
8
config.go
Normal file
8
config.go
Normal file
@ -0,0 +1,8 @@
|
||||
package main
|
||||
|
||||
type Config struct {
|
||||
OS []string `json:"os"`
|
||||
Arch []string `json:"arch"`
|
||||
NoCompress bool `json:"no_compress"`
|
||||
NumThreads int `json:"num_threads"`
|
||||
}
|
32
init.go
32
init.go
@ -16,43 +16,59 @@ func Init() {
|
||||
|
||||
ModulePath, err = filepath.Abs(flag.Arg(0))
|
||||
if err != nil {
|
||||
ColorError.Fprintln(os.Stderr, "determining module path failed")
|
||||
if !*Silent {
|
||||
ColorError.Fprintln(os.Stderr, "determining module path failed")
|
||||
}
|
||||
os.Exit(1)
|
||||
}
|
||||
|
||||
*OutputDir, err = filepath.Abs(*OutputDir)
|
||||
if err != nil {
|
||||
ColorError.Fprintln(os.Stderr, "determining output path failed")
|
||||
if !*Silent {
|
||||
ColorError.Fprintln(os.Stderr, "determining output path failed")
|
||||
}
|
||||
os.Exit(1)
|
||||
}
|
||||
|
||||
if _, err := exec.LookPath("go"); err != nil {
|
||||
ColorError.Fprintln(os.Stderr, "go not found in PATH. compilation not possible")
|
||||
if !*Silent {
|
||||
ColorError.Fprintln(os.Stderr, "go not found in PATH. compilation not possible")
|
||||
}
|
||||
os.Exit(1)
|
||||
}
|
||||
|
||||
if err := FillCompileConfigs(); err != nil {
|
||||
ColorError.Fprintln(os.Stderr, fmt.Errorf("target architectures could not be determined: %w", err))
|
||||
if !*Silent {
|
||||
ColorError.Fprintln(os.Stderr, fmt.Errorf("target architectures could not be determined: %w", err))
|
||||
}
|
||||
os.Exit(1)
|
||||
}
|
||||
|
||||
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)
|
||||
if !*Silent {
|
||||
ColorError.Fprintf(os.Stderr, "no Go module found at '%s'\n", ModulePath)
|
||||
}
|
||||
os.Exit(1)
|
||||
}
|
||||
|
||||
if err := DetermineProjectName(); err != nil {
|
||||
ColorError.Fprintln(os.Stderr, fmt.Errorf("project name could not be determined: %w", err))
|
||||
if !*Silent {
|
||||
ColorError.Fprintln(os.Stderr, fmt.Errorf("project name could not be determined: %w", err))
|
||||
}
|
||||
os.Exit(1)
|
||||
}
|
||||
|
||||
if err := os.MkdirAll(*OutputDir, 0744); err != nil {
|
||||
ColorError.Fprintln(os.Stderr, fmt.Errorf("output folder '%s' could not be made: %w", *OutputDir, err))
|
||||
if !*Silent {
|
||||
ColorError.Fprintln(os.Stderr, fmt.Errorf("output folder '%s' could not be made: %w", *OutputDir, err))
|
||||
}
|
||||
os.Exit(1)
|
||||
}
|
||||
|
||||
if err := CheckDirWritable(*OutputDir); err != nil {
|
||||
ColorError.Fprintf(os.Stderr, "output folder '%s' has insufficient permissions\n", *OutputDir)
|
||||
if !*Silent {
|
||||
ColorError.Fprintf(os.Stderr, "output folder '%s' has insufficient permissions\n", *OutputDir)
|
||||
}
|
||||
os.Exit(1)
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user