Compare commits

..

No commits in common. "33c099ae4fdbddc588387de90c0ccf61ece65caf" and "0c316672305028d119f6708f3532a12fccb6aa16" have entirely different histories.

2 changed files with 8 additions and 21 deletions

View File

@ -6,7 +6,7 @@ Installs common Go development tools at pinned versions.
```bash
# current as of 2025-12-18
go install sneak.berlin/go/gosetup@30b1cebd02df4e683b7034e1f0ecbf87baa0ecf8 ; hash -r ; gosetup
go install sneak.berlin/go/gosetup@cf739a6e93c44e9ed094ea5bf4ec0afd841fe1ec ; hash -r ; gosetup
```
## Usage

21
main.go
View File

@ -8,7 +8,6 @@ import (
"os"
"os/exec"
"sync"
"time"
)
//go:embed tools.json
@ -58,8 +57,6 @@ func main() {
sem := make(chan struct{}, *parallel)
results := make(chan result, len(tf.Tools))
startTime := time.Now()
for _, t := range tf.Tools {
wg.Add(1)
go func(tool Tool) {
@ -71,12 +68,11 @@ func main() {
fmt.Printf("Installing %s@%s...\n", tool.Name, tool.Version)
}
toolStart := time.Now()
pkg := fmt.Sprintf("%s@%s", tool.Package, tool.Version)
cmd := exec.Command("go", "install", pkg)
cmd.Env = os.Environ()
output, err := cmd.CombinedOutput()
results <- result{tool: tool, err: err, output: string(output), duration: time.Since(toolStart)}
results <- result{tool: tool, err: err, output: string(output)}
}(t)
}
@ -88,19 +84,18 @@ func main() {
var succeeded, failed int
for r := range results {
if r.err != nil {
fmt.Printf("✗ %s@%s: %v (%s)\n", r.tool.Name, r.tool.Version, r.err, formatDuration(r.duration))
fmt.Printf("✗ %s@%s: %v\n", r.tool.Name, r.tool.Version, r.err)
if *verbose && r.output != "" {
fmt.Printf(" %s\n", r.output)
}
failed++
} else {
fmt.Printf("✓ %s@%s (%s)\n", r.tool.Name, r.tool.Version, formatDuration(r.duration))
fmt.Printf("✓ %s@%s\n", r.tool.Name, r.tool.Version)
succeeded++
}
}
totalDuration := time.Since(startTime)
fmt.Printf("\nDone: %d succeeded, %d failed in %s\n", succeeded, failed, formatDuration(totalDuration))
fmt.Printf("\nDone: %d succeeded, %d failed\n", succeeded, failed)
if failed > 0 {
os.Exit(1)
}
@ -110,12 +105,4 @@ type result struct {
tool Tool
err error
output string
duration time.Duration
}
func formatDuration(d time.Duration) string {
if d < time.Second {
return fmt.Sprintf("%dms", d.Milliseconds())
}
return fmt.Sprintf("%.1fs", d.Seconds())
}