From 98d2cd3af09da79e8f40944d2a68044a4041ef52 Mon Sep 17 00:00:00 2001 From: AJ ONeal Date: Wed, 9 Aug 2023 22:18:48 +0000 Subject: [PATCH] ref!(go): separate go from go-essentials for 1.21 --- go-essentials/install.ps1 | 69 ++++++++++++++++++++++++++++++++++++--- go-essentials/install.sh | 7 ++-- golang/install.ps1 | 28 ---------------- golang/install.sh | 23 ------------- 4 files changed, 69 insertions(+), 58 deletions(-) diff --git a/go-essentials/install.ps1 b/go-essentials/install.ps1 index 69046e9..9a6d5bf 100644 --- a/go-essentials/install.ps1 +++ b/go-essentials/install.ps1 @@ -1,5 +1,66 @@ -#!/bin/pwsh +#!/usr/bin/env pwsh -echo "'go@$Env:WEBI_TAG' is an alias for 'golang@$Env:WEBI_VERSION'" -IF ($Env:WEBI_HOST -eq $null -or $Env:WEBI_HOST -eq "") { $Env:WEBI_HOST = "https://webinstall.dev" } -curl.exe -fsSL "$Env:WEBI_HOST/golang@$Env:WEBI_VERSION" | powershell +if (!(Get-Command "go.exe" -ErrorAction SilentlyContinue)) +{ + & "$Env:USERPROFILE\.local\bin\webi-pwsh.ps1" go + # because we need git.exe to be available to golang immediately + $Env:PATH = "$Env:USERPROFILE\go\bin;$Env:USERPROFILE\.local\opt\go\bin;$Env:PATH" +} + +# Special to go: re-run all go tooling builds +echo "Building go language tools..." + +echo "" +echo godoc +& go install golang.org/x/tools/cmd/godoc@latest + +echo "" +echo gopls +& go install golang.org/x/tools/gopls@latest + +echo "" +echo guru +& go install golang.org/x/tools/guru@latest + +echo "" +echo golint +& go install golang.org/x/lint/golint@latest + +#echo "" +#echo errcheck +#& go install github.com/kisielk/errcheck + +#echo "" +#echo gotags +#& go install github.com/jstemmer/gotags + +echo "" +echo goimports +& go install golang.org/x/tools/cmd/goimports@latest + +echo "" +echo gomvpkg +& go install golang.org/x/tools/cmd/gomvpkg@latest + +echo "" +echo gorename +& go install golang.org/x/tools/cmd/gorename + +echo "" +echo gotype +& go install golang.org/x/tools/cmd/gotype + +echo "" +echo stringer +& go install golang.org/x/tools/cmd/stringer + +echo "" +# literal %USERPROFILE% on purpose +echo 'Installed go "x" tools to GOBIN=%USERPROFILE%/go/bin' + +echo "" +echo "Suggestion: Also check out these great productivity multipliers:" +echo "" +echo " - vim-essentials (sensible defaults for vim)" +echo " - vim-go (golang linting, etc)" +echo "" diff --git a/go-essentials/install.sh b/go-essentials/install.sh index 76b3092..0d810c8 100644 --- a/go-essentials/install.sh +++ b/go-essentials/install.sh @@ -3,9 +3,7 @@ set -e set -u __run_go_essentials() { - WEBI__GO_ESSENTIALS='true' - export WEBI__GO_ESSENTIALS - if [ -z "${WEBI__GO_INSTALL-}" ]; then + if command -v go 2> /dev/null; then "$HOME/.local/bin/webi" "golang@${WEBI_TAG}" fi @@ -75,6 +73,9 @@ __run_go_essentials() { go "${my_install}" golang.org/x/tools/cmd/stringer@latest > /dev/null #2>/dev/null echo "" + # literal $HOME on purpose + # shellcheck disable=SC2016 + echo 'Installed go "x" tools to GOBIN=$HOME/go/bin' printf '\n' printf 'Suggestion: Also check out these great productivity multipliers:\n' diff --git a/golang/install.ps1 b/golang/install.ps1 index dbc2612..0e3d1f2 100644 --- a/golang/install.ps1 +++ b/golang/install.ps1 @@ -17,15 +17,6 @@ if (!(Get-Command "git.exe" -ErrorAction SilentlyContinue)) $Env:PATH = "$Env:USERPROFILE\.local\opt\git\cmd;$Env:PATH" } -Write-Host '' -ForegroundColor red -BackgroundColor white -Write-Host '*********************' -ForegroundColor red -BackgroundColor white -Write-Host '* BREAKING CHANGE *' -ForegroundColor red -BackgroundColor white -Write-Host '*********************' -ForegroundColor red -BackgroundColor white -Write-Host '' -ForegroundColor red -BackgroundColor white -Write-Host ' ''webi golang'' will NOT install go tooling starting with go1.21+' -ForegroundColor red -BackgroundColor white -Write-Host ' use ''webi go-essentials'' to preserve the previous behavior' -ForegroundColor red -BackgroundColor white -Write-Host '' -ForegroundColor red -BackgroundColor white - # Fetch archive IF (!(Test-Path -Path "$pkg_download")) { @@ -65,25 +56,6 @@ Remove-Item -Path "$pkg_dst" -Recurse -ErrorAction Ignore Copy-Item -Path "$pkg_src" -Destination "$pkg_dst" -Recurse IF (!(Test-Path -Path go\bin)) { New-Item -Path go\bin -ItemType Directory -Force | out-null } -# Special to go: re-run all go tooling builds -echo "Building go language tools..." -echo gopls -& "$pkg_dst_cmd" install golang.org/x/tools/gopls -echo golint -& "$pkg_dst_cmd" install golang.org/x/lint/golint -echo errcheck -& "$pkg_dst_cmd" install github.com/kisielk/errcheck -echo gotags -& "$pkg_dst_cmd" install github.com/jstemmer/gotags -echo goimports -& "$pkg_dst_cmd" install golang.org/x/tools/cmd/goimports -echo gorename -& "$pkg_dst_cmd" install golang.org/x/tools/cmd/gorename -echo gotype -& "$pkg_dst_cmd" install golang.org/x/tools/cmd/gotype -echo stringer -& "$pkg_dst_cmd" install golang.org/x/tools/cmd/stringer - # Add to path webi_path_add ~/.local/opt/go/bin diff --git a/golang/install.sh b/golang/install.sh index b797b2f..7c2ff23 100644 --- a/golang/install.sh +++ b/golang/install.sh @@ -15,19 +15,6 @@ pkg_cmd_name="go" # # Their defaults are defined in _webi/template.sh at https://github.com/webinstall/packages -if [ -z "${WEBI__GO_ESSENTIALS-}" ]; then - # TODO nix for go1.21+ - echo >&2 "" - printf >&2 '\e[31m%s:\e[0m\n' '#####################' - printf >&2 '\e[31m%s:\e[0m\n' '# BREAKING CHANGE #' - printf >&2 '\e[31m%s:\e[0m\n' '#####################' - echo >&2 "" - printf >&2 "\e[31m 'webi golang' will NOT install go tooling starting with go1.21+\e[0m\n" - printf >&2 "\e[31m use 'webi go-essentials' to preserve the previous behavior\e[0m\n" - echo >&2 "" - sleep 4 -fi - pkg_get_current_version() { # 'go version' has output in this format: # go version go1.14.2 darwin/amd64 @@ -68,18 +55,8 @@ pkg_post_install() { # "$HOME/.local/opt/go" webi_path_add "$pkg_dst_bin" webi_path_add "$GOBIN/bin" - - if [ -z "${WEBI__GO_ESSENTIALS-}" ]; then - # TODO nix for go1.21+ - WEBI__GO_INSTALL='true' - export WEBI__GO_INSTALL - "$HOME/.local/bin/webi" "go-essentials@${WEBI_TAG}" - fi } pkg_done_message() { echo "Installed 'go v$WEBI_VERSION' to ~/.local/opt/go" - # note: literal $HOME on purpose - #shellcheck disable=SC2016 - echo 'Installed go "x" tools to GOBIN=$HOME/go/bin' }