Compare commits
No commits in common. "33c099ae4fdbddc588387de90c0ccf61ece65caf" and "0c316672305028d119f6708f3532a12fccb6aa16" have entirely different histories.
33c099ae4f
...
0c31667230
@ -6,7 +6,7 @@ Installs common Go development tools at pinned versions.
|
|||||||
|
|
||||||
```bash
|
```bash
|
||||||
# current as of 2025-12-18
|
# 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
|
## Usage
|
||||||
|
|||||||
21
main.go
21
main.go
@ -8,7 +8,6 @@ import (
|
|||||||
"os"
|
"os"
|
||||||
"os/exec"
|
"os/exec"
|
||||||
"sync"
|
"sync"
|
||||||
"time"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
//go:embed tools.json
|
//go:embed tools.json
|
||||||
@ -58,8 +57,6 @@ func main() {
|
|||||||
sem := make(chan struct{}, *parallel)
|
sem := make(chan struct{}, *parallel)
|
||||||
results := make(chan result, len(tf.Tools))
|
results := make(chan result, len(tf.Tools))
|
||||||
|
|
||||||
startTime := time.Now()
|
|
||||||
|
|
||||||
for _, t := range tf.Tools {
|
for _, t := range tf.Tools {
|
||||||
wg.Add(1)
|
wg.Add(1)
|
||||||
go func(tool Tool) {
|
go func(tool Tool) {
|
||||||
@ -71,12 +68,11 @@ func main() {
|
|||||||
fmt.Printf("Installing %s@%s...\n", tool.Name, tool.Version)
|
fmt.Printf("Installing %s@%s...\n", tool.Name, tool.Version)
|
||||||
}
|
}
|
||||||
|
|
||||||
toolStart := time.Now()
|
|
||||||
pkg := fmt.Sprintf("%s@%s", tool.Package, tool.Version)
|
pkg := fmt.Sprintf("%s@%s", tool.Package, tool.Version)
|
||||||
cmd := exec.Command("go", "install", pkg)
|
cmd := exec.Command("go", "install", pkg)
|
||||||
cmd.Env = os.Environ()
|
cmd.Env = os.Environ()
|
||||||
output, err := cmd.CombinedOutput()
|
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)
|
}(t)
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -88,19 +84,18 @@ func main() {
|
|||||||
var succeeded, failed int
|
var succeeded, failed int
|
||||||
for r := range results {
|
for r := range results {
|
||||||
if r.err != nil {
|
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 != "" {
|
if *verbose && r.output != "" {
|
||||||
fmt.Printf(" %s\n", r.output)
|
fmt.Printf(" %s\n", r.output)
|
||||||
}
|
}
|
||||||
failed++
|
failed++
|
||||||
} else {
|
} 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++
|
succeeded++
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
totalDuration := time.Since(startTime)
|
fmt.Printf("\nDone: %d succeeded, %d failed\n", succeeded, failed)
|
||||||
fmt.Printf("\nDone: %d succeeded, %d failed in %s\n", succeeded, failed, formatDuration(totalDuration))
|
|
||||||
if failed > 0 {
|
if failed > 0 {
|
||||||
os.Exit(1)
|
os.Exit(1)
|
||||||
}
|
}
|
||||||
@ -110,12 +105,4 @@ type result struct {
|
|||||||
tool Tool
|
tool Tool
|
||||||
err error
|
err error
|
||||||
output string
|
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())
|
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user