1
0
mirror of https://github.com/docker-library/golang.git synced 2025-02-06 09:06:57 +00:00

Remove now-unnecessary conditionals in templates

This commit is contained in:
Tianon Gravi 2022-03-28 13:48:46 -07:00
parent e92bd5116b
commit 9f431d40c9
3 changed files with 5 additions and 40 deletions

View File

@ -5,39 +5,20 @@ SHELL ["cmd", "/S", "/C"]
# no Git installed (intentionally)
# -- Nano Server is "Windows Slim"
{{
def install_directory:
if [ "1.15", "1.16" ] | index(env.version) then
"C:\\go"
else
"C:\\Program Files\\Go"
end
-}}
{{ if install_directory == "C:\\go" then ( -}}
# ideally, this would be C:\go to match Linux a bit closer, but C:\go was the default install path for Go itself on Windows
ENV GOPATH C:\\gopath
# (https://golang.org/cl/283600)
{{ ) else ( -}}
# for 1.17+, we'll follow the (new) Go upstream default for install (https://golang.org/cl/283600), which frees up C:\go to be the default GOPATH and thus match the Linux images more closely (https://github.com/docker-library/golang/issues/288)
ENV GOPATH C:\\go
# HOWEVER, please note that it is the Go upstream intention to remove GOPATH support entirely: https://blog.golang.org/go116-module-changes
{{ ) end -}}
# PATH isn't actually set in the Docker image, so we have to set it from within the container
USER ContainerAdministrator
RUN setx /m PATH "%GOPATH%\bin;{{ install_directory }}\bin;%PATH%"
RUN setx /m PATH "%GOPATH%\bin;C:\Program Files\Go\bin;%PATH%"
USER ContainerUser
# doing this first to share cache across versions more aggressively
ENV GOLANG_VERSION {{ .version }}
# Docker's Windows path parsing is absolutely *cursed*; please just trust me on this one -Tianon
COPY --from=golang:{{ .version }}-windowsservercore-{{ env.windowsRelease }} {{
install_directory
| gsub("\\\\"; "\\\\")
| [ . , . ]
| @json
}}
COPY --from=golang:{{ .version }}-windowsservercore-{{ env.windowsRelease }} ["C:\\\\Program Files\\\\Go","C:\\\\Program Files\\\\Go"]
RUN go version
WORKDIR $GOPATH

View File

@ -37,26 +37,12 @@ RUN Write-Host ('Downloading {0} ...' -f $env:GIT_DOWNLOAD_URL); \
\
Write-Host 'Complete.';
{{
def install_directory:
if [ "1.15", "1.16" ] | index(env.version) then
"C:\\go"
else
"C:\\Program Files\\Go"
end
-}}
{{ if install_directory == "C:\\go" then ( -}}
# ideally, this would be C:\go to match Linux a bit closer, but C:\go was the default install path for Go itself on Windows
ENV GOPATH C:\\gopath
# (https://golang.org/cl/283600)
{{ ) else ( -}}
# for 1.17+, we'll follow the (new) Go upstream default for install (https://golang.org/cl/283600), which frees up C:\go to be the default GOPATH and thus match the Linux images more closely (https://github.com/docker-library/golang/issues/288)
ENV GOPATH C:\\go
# HOWEVER, please note that it is the Go upstream intention to remove GOPATH support entirely: https://blog.golang.org/go116-module-changes
{{ ) end -}}
# PATH isn't actually set in the Docker image, so we have to set it from within the container
RUN $newPath = ('{0}\bin;{{ install_directory }}\bin;{1}' -f $env:GOPATH, $env:PATH); \
RUN $newPath = ('{0}\bin;C:\Program Files\Go\bin;{1}' -f $env:GOPATH, $env:PATH); \
Write-Host ('Updating PATH: {0}' -f $newPath); \
[Environment]::SetEnvironmentVariable('PATH', $newPath, [EnvironmentVariableTarget]::Machine);
# doing this first to share cache across versions more aggressively
@ -77,11 +63,9 @@ RUN $url = '{{ .arches["windows-amd64"].url }}'; \
\
Write-Host 'Expanding ...'; \
Expand-Archive go.zip -DestinationPath C:\; \
{{ if install_directory != "C:\\go" then ( -}}
\
Write-Host 'Moving ...'; \
Move-Item -Path C:\go -Destination '{{ install_directory }}'; \
{{ ) else "" end -}}
Move-Item -Path C:\go -Destination 'C:\Program Files\Go'; \
\
Write-Host 'Removing ...'; \
Remove-Item go.zip -Force; \

View File

@ -70,7 +70,7 @@ goVersions="$(
{ GOOS: .os, GOARCH: .arch }
+ if .arch == "386" and .os == "linux" then
# i386 in Debian is non-SSE2, Alpine appears to be similar (but interesting, not FreeBSD?)
{ GO386: (if $major == "1.15" then "387" else "softfloat" end) }
{ GO386: "softfloat" }
elif $bashbrewArch | startswith("arm32v") then
{ GOARCH: "arm", GOARM: ($bashbrewArch | ltrimstr("arm32v")) }
else {} end