cmd/go: make package lookups in vendor directories case-insensitive on case-sensitive filesystems
#38,342 opened on Apr 10, 2020
Repository metrics
- Stars
- (133,883 stars)
- PR merge metrics
- (No merged PRs in 30d)
Description
What version of Go are you using (go version)?
Does this issue reproduce with the latest release?
Yes
What operating system and processor architecture are you using (go env)?
What did you do?
go mod vendor
What happened?
When vendoring on MacOS, files are written with case sensitivity to a case insensitive filesystem. This can cause two issues, but is only present for vendoring, not the module cache, since modules use ! prefixes to make the module cache case insensitive.
Collision
Because import paths are case sensitive, in the event that two packages share case insensitive , but not case sensitive, prefixes collision can occur. This is infrequent due to alllowercaseoneword package name conventions, and github username and repo name fields being case insensitive (but with case metadata), however the it is a bug and I can provide code samples to produce compilation failures.
Portability
This issue was discovered when sharing the vendor directory between systems that have different case sensitivity (MacOS to Linux) and does not require package collision to reproduce.
Given two modules share a case insensitive prefix, say github.com/Golang/exp and github.com/golang/tools. On MacOS, they will both be written to github.com/[Gg]olang and the first writer will pick the case. Builds work fine because both github.com/Golang and github.com/golang exist, but when you mount the vendor directory in a docker container github.com/Golang stops existing. This also happens for other data sharing mechasisms between filesystems like cp, tar, git, etc.