cmd/go: make package lookups in vendor directories case-insensitive on case-sensitive filesystems
#38,342 创建于 2020年4月10日
仓库指标
- Star
- (133,883 star)
- PR 合并指标
- (30 天内没有已合并 PR)
描述
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.