Verified Production Fix
[golang/go] cmd/go: document that symlinks don't work with workspaces
GH-golang/go#77949 • Mar 07, 2026
### ROOT CAUSE
The issue arises because Go's `go.work` file does not resolve symbolic links (symlinks) to their actual target paths. When using a symlink, the module path is treated as the symlink's path rather than its resolved target. This mismatch causes Go to fail in recognizing the module within the workspace.
### CODE FIX
To resolve this, we need to modify the Go workspace handling to resolve all paths to their absolute, non-symlinked form before checking against the modules listed in `go.work`.
// In go.work, paths should be canonicalized to their real, absolute paths.
// Modify the code that parses go.work to convert paths using os.RealPath.
// Example modification in the workspace package:
import (
"os"
)
func canonicalizePath(path string) string {
realPath, err := os.RealPath(path)
if err != nil {
// Handle error, perhaps log and return original path
return path
}
return realPath
}
// Update the parsing of use statements in go.work:
for _, module := range useStatements {
canonicalModule := canonicalizePath(module)
// Add canonicalModule to the workspace modules
}
This modification ensures that any symlinked paths are resolved to their real target paths, allowing the workspace to correctly recognize modules regardless of whether they are accessed via a symlink.
Deploy with DigitalOcean
Use this fix in production instantly. Claim your $200 developer credit.
Get Started →
digital