{"record":{"id":"04f25d650526c0b4","repo":"rtk-ai/rtk","slug":"go-no-subcommand-specified","errorCode":null,"errorMessage":"go: no subcommand specified","messagePattern":"go: no subcommand specified","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"src/cmds/go/go_cmd.rs","lineNumber":129,"sourceCode":"        cmd.arg(arg);\n    }\n\n    if verbose > 0 {\n        eprintln!(\"Running: go vet {}\", args.join(\" \"));\n    }\n\n    runner::run_filtered(\n        cmd,\n        \"go vet\",\n        &args.join(\" \"),\n        filter_go_vet,\n        crate::core::runner::RunOptions::with_tee(\"go_vet\"),\n    )\n}\n\npub fn run_other(args: &[OsString], verbose: u8) -> Result<i32> {\n    if args.is_empty() {\n        anyhow::bail!(\"go: no subcommand specified\");\n    }\n\n    // Intercept: `go tool <known>` invocations for filtered output\n    if let Some((tool, tool_args)) = match_go_tool(args) {\n        match tool {\n            GoTool::GolangciLint => return run_go_tool_golangci_lint(tool_args, verbose),\n        }\n    }\n\n    let timer = tracking::TimedExecution::start();\n\n    let subcommand = args[0].to_string_lossy();\n    let mut cmd = resolved_command(\"go\");\n    cmd.arg(&*subcommand);\n\n    for arg in &args[1..] {\n        cmd.arg(arg);\n    }","sourceCodeStart":111,"sourceCodeEnd":147,"githubUrl":"https://github.com/rtk-ai/rtk/blob/0924356b4caba4989607227b7c8824d3d8098719/src/cmds/go/go_cmd.rs#L111-L147","documentation":"rtk's `go` proxy refuses to execute when invoked with no subcommand at all (e.g. bare `rtk go`). The filter layer needs at least one argument to decide which go subcommand to intercept and compress, so an empty argument list is rejected up front with anyhow::bail! in run_other.","triggerScenarios":"Calling `rtk go` with zero trailing arguments, or programmatically dispatching to go_cmd::run_other(&[], verbose) with an empty OsString slice.","commonSituations":"Shell scripts that build a go command from variables where the subcommand variable is unset/empty (`rtk go $GO_CMD` with GO_CMD=\"\"), wrappers that forward args incorrectly and drop them, or users typing `rtk go` expecting it to behave like `go` alone (which prints usage rather than failing).","solutions":["Pass a go subcommand: `rtk go build ./...`, `rtk go test ./...`, `rtk go vet`.","Check the script/wrapper for an empty variable that was supposed to hold the subcommand (e.g. `${GO_CMD:-}`) and guard against unset values.","Use `rtk proxy go` if you truly want raw passthrough behavior of `go` with no subcommand.","Call `go` directly (without rtk) when you only want go's own usage output."],"exampleFix":"// before\nrtk go $SUBCMD   # SUBCMD unset -> go: no subcommand specified\n// after\nrtk go \"${SUBCMD:-build}\" ./...   # or: [ -n \"$SUBCMD\" ] && rtk go \"$SUBCMD\"","handlingStrategy":"validation","validationCode":"if [ -z \"$SUBCMD\" ]; then echo \"usage: rtk go <subcommand> [args]\" >&2; exit 2; fi\nrtk go \"$SUBCMD\" \"$@\"","typeGuard":"fn has_args(args: &[OsString]) -> bool { !args.is_empty() }","tryCatchPattern":"match rtk_result {\n    Err(e) if e.to_string().contains(\"no subcommand specified\") => {\n        eprintln!(\"supply a go subcommand, e.g. rtk go build ./...\");\n        std::process::exit(2);\n    }\n    other => other?,\n}","preventionTips":["Never invoke `rtk go` with a potentially empty variable; use ${VAR:-default} or ${VAR:?msg}.","Quote and validate all interpolated args in wrapper scripts.","Prefer `rtk proxy go` when you want unfiltered pass-through of arbitrary go invocations."],"tags":["cli","go","missing-argument"],"backgroundTag":"missing-cli-argument","analyzedSha":"0924356b4caba4989607227b7c8824d3d8098719","analyzedAt":"2026-09-19T19:25:29.612Z","contentChangedAt":"2026-09-19T19:25:29.612Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}