Go "malformed module path: missing dot" - Fix in CI
By Daniel Zoghalchali·Latchkey
Go requires the first element of a module path to look like a host name, which means it must contain a dot. A bare name like "myapp" is rejected because it cannot be a real import host.
What this error means
A module command fails with malformed module path "myapp": missing dot in first path element. The module directive uses a bare name instead of a domain-style path.
go
go: malformed module path "myapp": missing dot in first path element
Diagnose it: module path, proxy, or checksum?
Go module errors name the module but rarely the layer that failed. Separate the three: the module path does not resolve, the proxy cannot serve it, or the checksum database disagrees with what was downloaded.
Terminal
# what Go resolves and from where
go env GOPROXY GOSUMDB GOPRIVATE GOFLAGS
# does the module resolve at all, bypassing the build?
go list -m -versions github.com/org/module
# verify the module cache against go.sum
go mod verify
# private modules must be excluded from proxy and sumdb
go env -w GOPRIVATE=github.com/yourorg/*
Common causes
Bare module name in go.mod
The module directive names something without a dotted host, which Go cannot treat as an importable path.
go mod init with no domain
go mod init was run with a single word, producing an invalid module path.
How to fix it
Use a domain-style module path
Set the module directive to a host-prefixed path.
go.mod
module github.com/acme/myapp
go 1.22
Re-init with a full path
Re-run go mod init with a domain-prefixed module path.
shell
go mod init github.com/acme/myapp
How to prevent it
Always use a host-prefixed module path even for private repos.
Run go mod init with the full path from the start.
Match the module path to the repo URL so imports resolve.
Frequently asked questions
What causes Go "malformed module path: missing dot"?
There are 2 common causes: bare module name in go.mod and go mod init with no domain. The module directive names something without a dotted host, which Go cannot treat as an importable path.
How do I fix Go "malformed module path: missing dot"?
There are 2 fixes depending on which cause you have: use a domain-style module path and re-init with a full path. Work through them in order, since the first is the most common.
What does Go "malformed module path: missing dot" actually mean?
A module command fails with malformed module path "myapp": missing dot in first path element.
How do I stop Go "malformed module path: missing dot" happening again?
Always use a host-prefixed module path even for private repos. The prevention section lists 3 changes that keep it from recurring.