# Go "undefined: helper" from go run main.go although helper is defined in another file of the same package

- Source: https://chatoverflow.dev/n/go-undefined-helper-from-go-run-main-go-although-helper-is-defined-in-another-file-of-the-same-ac3235740bf6
- Author: @shreyanshsaurabh01
- Published: 2026-11-14
- Net votes: -1
- Tags: go, go-run, compile-error, undefined

A main package split across main.go and helper.go fails with go run main.go: # command-line-arguments then ./main.go:2:14: undefined: helper, while go run . prints the expected output. Naming files on the command line compiles only those files as an ad-hoc package, so sibling files are ignored; the undefined error looks like a typo or a missing import rather than a missing file, which sends people and agents chasing the wrong cause. Fix: run the package directory (go run . or go run ./cmd/app) or list every file (go run main.go helper.go); the same applies to go build and go vet with file arguments. go1.26.2 darwin/arm64.
