no Go files in directory Go Origin: Application & API Last updated 4 Nov 2026

Go: package app/cmd: no Go files in /app/cmd / build constraints exclude all Go files

The directory you asked Go to build contains no buildable .go files.

Exact message you may see no Go files inbuild constraints exclude all Go files ingo: warning: "./..." matched no packagesno non-test Go files inpackage app/cmd: no Go files in /app/cmd
Seen on: Go

Meaning

Build the right package path (go build ./cmd/server), make sure files have the .go extension and are not excluded by build tags or _GOOS/_GOARCH suffixes, and that _test.go files aren't the only ones. In Docker verify the files were copied.

Common causes

  • Wrong directory (no .go files at that level)
  • Only _test.go files present
  • Build tags / filename suffix excluding all files for this OS/arch
  • Files not copied into the Docker context
  • Package in a subfolder

⚡ Quick fix

  1. Point to the actual main package: go build ./cmd/app
  2. Check //go:build lines and _linux.go style suffixes
  3. Verify .dockerignore and COPY steps

Detailed fix by platform

Go

  1. go list ./... shows all buildable packages

How to diagnose

  1. Path — Contains .go files?
  2. Tags — Exclude them?
  3. Docker — Files present?

🔧 Still not fixed?

Many errors look alike. If the steps above didn’t solve it, one of these is probably what you’re facing:

Where this error sits

Origin: Application & API. Errors that are often confused with or caused by this one (click to open):

assignment mismatch: 1 variable but f returns 2 values — Go: assignment mismatch: 1 variable but os.Open returns 2 values (Go)assignment mismatch: …cannot assign to struct field m[k].f in map — Go: cannot assign to struct field users["bob"].Age in map (Go)cannot assign to stru…cgo: C compiler gcc not found — Go: cgo: C compiler "gcc" not found: exec: "gcc": executable file not found in $PATH (Go)cgo: C compiler gcc n…COPY failed — COPY failed: file not found in build context / "/app/x": not found (Docker)COPY faileddid not complete successfully — failed to solve: process "/bin/sh -c ..." did not complete successfully: exit code: 1 (Docker)did not complete succ…failed to read dockerfile — failed to solve: failed to read dockerfile: open Dockerfile: no such file or directory (Docker)failed to read docker…forbidden path outside the build context — COPY failed: forbidden path outside the build context: ../file (Docker)forbidden path outsid…function main is undeclared in the main package — Go: runtime.main_main·f: function main is undeclared in the main package (Go)function main is unde…no Go fil…

Explore the map of this error Full error map →

🧠 Still stuck? Analyze your error

Paste the full message, response headers or stack trace — we'll detect the platform and point to the most likely cause.

💬 What worked for others

No tips yet — did something else fix this for you?

Share what worked for you

Tips are checked by an editor before they appear. Links are removed.