From 45e38fab5a74e0835bb8c63b6e61649baea8f3b0 Mon Sep 17 00:00:00 2001 From: AJ ONeal Date: Mon, 8 Aug 2022 10:14:22 +0000 Subject: [PATCH] feat: add go-essentials --- go-essentials/README.md | 33 +++++++++++++++ go-essentials/install.ps1 | 5 +++ go-essentials/install.sh | 87 +++++++++++++++++++++++++++++++++++++++ 3 files changed, 125 insertions(+) create mode 100644 go-essentials/README.md create mode 100644 go-essentials/install.ps1 create mode 100644 go-essentials/install.sh diff --git a/go-essentials/README.md b/go-essentials/README.md new file mode 100644 index 0000000..89a2d81 --- /dev/null +++ b/go-essentials/README.md @@ -0,0 +1,33 @@ +--- +title: go-essentials +homepage: https://webinstall.dev/go-essentials +tagline: | + meta package for go and the de facto standard go tools packages +--- + +To update (replacing the current version) run `webi go-essentials`. + +## Cheat Sheet + +> A collection of extremely useful official and de facto standard go tooling. + +This meta package will install [Go](https://golang.org/) at the specified +version as well as the full set of tooling used by most IDEs and editor plugins, +including: + +- [godoc](https://pkg.go.dev/golang.org/x/tools/cmd/godoc) +- [gopls](https://pkg.go.dev/golang.org/x/tools/gopls) +- [guru](https://pkg.go.dev/golang.org/x/tools/cmd/guru) +- [golint](https://pkg.go.dev/golang.org/x/lint/golint) +- [goimports](https://pkg.go.dev/golang.org/x/tools/cmd/goimports) +- [gomvpkg](https://pkg.go.dev/golang.org/x/tools/cmd/gomvpkg) +- [gorename](https://pkg.go.dev/golang.org/x/tools/cmd/gorename) +- [gotype](https://pkg.go.dev/golang.org/x/tools/cmd/gotype) +- [stringer](https://pkg.go.dev/golang.org/x/tools/cmd/stringer) + +It **DOES NOT** include these, which you may also want: + +- Vim Utilities + - [vim-essentials](/vim-essentials) (de facto standard plugins and one-liners + for vim) + - [vim-go](/vim-go) (golang support for vim, and VSCode) diff --git a/go-essentials/install.ps1 b/go-essentials/install.ps1 new file mode 100644 index 0000000..69046e9 --- /dev/null +++ b/go-essentials/install.ps1 @@ -0,0 +1,5 @@ +#!/bin/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 diff --git a/go-essentials/install.sh b/go-essentials/install.sh new file mode 100644 index 0000000..89db777 --- /dev/null +++ b/go-essentials/install.sh @@ -0,0 +1,87 @@ +#!/bin/sh +set -e +set -u + +__run_go_essentials() { + WEBI__GO_ESSENTIALS='true' + export WEBI__GO_ESSENTIALS + if [ -z "${WEBI__GO_INSTALL:-}" ]; then + webi "golang@${WEBI_TAG}" + fi + + export PATH="$HOME/.local/opt/go/bin:$PATH" + + my_install="install" + # go1.16 is the min version for proper 'go install' + my_version="$( + go version | cut -d' ' -f3 + )" + my_major="$( + echo "${my_version}" | cut -d'.' -f1 || echo '0' + )" + my_minor="$( + echo "${my_version}" | cut -d'.' -f2 || echo '0' + )" + + my_install="get" + if [ "${my_major}" = "go1" ]; then + if [ "${my_minor}" -ge 16 ]; then + my_install="install" + fi + elif [ "${my_major}" = "go2" ]; then + my_install="install" + fi + + # Install x go + echo "Building go language tools..." + export GO111MODULE=on + + # See https://pkg.go.dev/mod/golang.org/x/tools?tab=packages + + echo "" + echo godoc + go "${my_install}" golang.org/x/tools/cmd/godoc@latest > /dev/null #2>/dev/null + + echo "" + echo gopls + go "${my_install}" golang.org/x/tools/gopls@latest > /dev/null #2>/dev/null + + echo "" + echo guru + go "${my_install}" golang.org/x/tools/cmd/guru@latest > /dev/null #2>/dev/null + + echo "" + echo golint + go "${my_install}" golang.org/x/lint/golint@latest > /dev/null #2>/dev/null + + echo "" + echo goimports + go "${my_install}" golang.org/x/tools/cmd/goimports@latest > /dev/null #2>/dev/null + + echo "" + echo gomvpkg + go "${my_install}" golang.org/x/tools/cmd/gomvpkg@latest > /dev/null #2>/dev/null + + echo "" + echo gorename + go "${my_install}" golang.org/x/tools/cmd/gorename@latest > /dev/null #2>/dev/null + + echo "" + echo gotype + go "${my_install}" golang.org/x/tools/cmd/gotype@latest > /dev/null #2>/dev/null + + echo "" + echo stringer + go "${my_install}" golang.org/x/tools/cmd/stringer@latest > /dev/null #2>/dev/null + + echo "" + + printf '\n' + printf 'Suggestion: Also check out these great productivity multipliers:\n' + printf '\n' + printf ' - vim-essentials (sensible defaults for vim)\n' + printf ' - vim-go (golang linting, etc)\n' + printf '\n' +} + +__run_go_essentials