Go "malformed module path" / "missing dot in first path element"
Go requires a module path whose first element looks like a domain (it must contain a dot) so it can be fetched remotely. A bare name like myapp has no dot, so Go rejects it as malformed.
What this error means
A build or go get fails with malformed module path "myapp": missing dot in first path element. It commonly appears when a project was go mod init-ed with a short name and later imported as a real dependency.
go: example.com/app imports
myapp/internal/store: malformed module path "myapp":
missing dot in first path elementCommon causes
Module initialized with a non-URL name
Running go mod init myapp gives a path with no domain. It works for a standalone build but cannot be required by another module, which needs a fetchable path.
An import path missing its host
An import that drops the host (util/strings instead of github.com/org/util/strings) has no dotted first element and cannot resolve to a module.
How to fix it
Rename the module to a real path
Set a module path under a domain you control, then update imports to match.
go mod edit -module github.com/yourorg/yourapp
# update import paths across the repo
grep -rl '"myapp/' . | xargs sed -i 's#"myapp/#"github.com/yourorg/yourapp/#g'
go build ./...Fix imports that dropped the host
- Find imports whose first element has no dot.
- Prefix them with the full canonical module path including the host.
- Run
go build ./...to confirm they resolve.
How to prevent it
- Initialize modules with a full path:
go mod init github.com/org/repo. - Use canonical, host-qualified import paths everywhere.
- Avoid short placeholder module names that other modules will import.