fix: check MkdirAll errors, add gopls to toolchain

- serve.go/cmdAPIDownload: check MkdirAll error, use absolute path
- main.go/cmdDownload,cmdExtract: check MkdirAll errors
- check-toolchain.sh: verify gopls installation
- mise.toml: add gopls install task
- AGENTS.md: document gopls as dev dependency
This commit is contained in:
2026-06-21 22:27:17 -07:00
parent ea2bcde74b
commit 15979d01b5
5 changed files with 30 additions and 7 deletions
+1
View File
@@ -5,6 +5,7 @@
```bash ```bash
mise trust # trust the mise.toml config (first time only) mise trust # trust the mise.toml config (first time only)
mise install # installs go 1.26, node 22 mise install # installs go 1.26, node 22
mise run gopls # install gopls (Go LSP) — one-time dev setup
``` ```
All build/run tasks are defined in `mise.toml`: All build/run tasks are defined in `mise.toml`:
+6 -2
View File
@@ -250,7 +250,9 @@ func cmdDownload(args []string) {
jobs := fs.Int("jobs", 2, "concurrent downloads") jobs := fs.Int("jobs", 2, "concurrent downloads")
_ = fs.Parse(args) _ = fs.Parse(args)
os.MkdirAll(*outDir, 0755) if err := os.MkdirAll(*outDir, 0755); err != nil {
fatal("create %s: %v", *outDir, err)
}
var identifiers []string var identifiers []string
if *identifier != "" { if *identifier != "" {
@@ -383,7 +385,9 @@ func cmdExtract(args []string) {
jobs := fs.Int("jobs", 2, "concurrent extractions") jobs := fs.Int("jobs", 2, "concurrent extractions")
_ = fs.Parse(args) _ = fs.Parse(args)
os.MkdirAll(*outDir, 0755) if err := os.MkdirAll(*outDir, 0755); err != nil {
fatal("create %s: %v", *outDir, err)
}
entries, err := os.ReadDir(*isoDir) entries, err := os.ReadDir(*isoDir)
if err != nil { if err != nil {
+1
View File
@@ -20,3 +20,4 @@ docker-build = "docker build -t akai-fetch ."
check-toolchain = "bash scripts/check-toolchain.sh" check-toolchain = "bash scripts/check-toolchain.sh"
check-docker-toolchain = "bash scripts/check-docker-toolchain.sh" check-docker-toolchain = "bash scripts/check-docker-toolchain.sh"
check-all = { run = "bash scripts/check-toolchain.sh && echo '' && bash scripts/check-docker-toolchain.sh" } check-all = { run = "bash scripts/check-toolchain.sh && echo '' && bash scripts/check-docker-toolchain.sh" }
gopls = "go install golang.org/x/tools/gopls@latest"
+13
View File
@@ -98,6 +98,19 @@ fi
echo "" echo ""
# ─── gopls (Go LSP) ────────────────────────────────────────────────────
echo "gopls (Go language server):"
if command -v gopls &>/dev/null; then
gopls_ver=$(gopls version 2>/dev/null)
ok "gopls found: $gopls_ver"
else
warn "gopls not found (recommended for IDE support)"
echo " Install: go install golang.org/x/tools/gopls@latest"
echo " (ensure $(go env GOPATH)/bin is in PATH)"
fi
echo ""
# ─── Node ────────────────────────────────────────────────────────────── # ─── Node ──────────────────────────────────────────────────────────────
echo "Node:" echo "Node:"
if command -v node &>/dev/null; then if command -v node &>/dev/null; then
+7 -3
View File
@@ -158,7 +158,13 @@ func handleAPIDownload(w http.ResponseWriter, r *http.Request) {
outDir = "." outDir = "."
} }
os.MkdirAll(outDir, 0755) if abs, err := filepath.Abs(outDir); err == nil {
outDir = abs
}
if err := os.MkdirAll(outDir, 0755); err != nil {
writeJSON(w, map[string]any{"error": fmt.Sprintf("create %s: %v", outDir, err)})
return
}
files := getItemFiles(identifier) files := getItemFiles(identifier)
if len(files) == 0 { if len(files) == 0 {
@@ -287,8 +293,6 @@ func handleAPIExtract(w http.ResponseWriter, r *http.Request) {
outDir = "./wavs" outDir = "./wavs"
} }
os.MkdirAll(outDir, 0755)
entries, err := os.ReadDir(isoDir) entries, err := os.ReadDir(isoDir)
if err != nil { if err != nil {
writeJSON(w, map[string]any{"error": err.Error()}) writeJSON(w, map[string]any{"error": err.Error()})