fix(platform): store value in cache

resolves #1601
This commit is contained in:
Jan De Dobbeleer 2022-01-18 20:19:16 +01:00 committed by Jan De Dobbeleer
parent 3cca2104bb
commit 0a09924685

View file

@ -53,11 +53,18 @@ func (env *environment) getTerminalWidth() (int, error) {
} }
func (env *environment) getPlatform() string { func (env *environment) getPlatform() string {
if wsl := env.getenv("WSL_DISTRO_NAME"); len(wsl) != 0 { const key = "environment_platform"
return strings.ToLower(wsl) if val, found := env.cache().get(key); found {
return val
} }
p, _, _, _ := host.PlatformInformation() var platform string
return p defer env.cache().set(key, platform, -1)
if wsl := env.getenv("WSL_DISTRO_NAME"); len(wsl) != 0 {
platform = strings.ToLower(wsl)
return platform
}
platform, _, _, _ = host.PlatformInformation()
return platform
} }
func (env *environment) getCachePath() string { func (env *environment) getCachePath() string {