diff --git a/config.go b/config.go new file mode 100644 index 0000000..71dd4f9 --- /dev/null +++ b/config.go @@ -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"` +} diff --git a/init.go b/init.go index 7fb493d..b130d2b 100644 --- a/init.go +++ b/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) }