-
-
Notifications
You must be signed in to change notification settings - Fork 24
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add setup-util-golint: fix compilation on macos
- Loading branch information
Showing
3 changed files
with
215 additions
and
31 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,160 @@ | ||
#!/usr/bin/env bash | ||
|
||
# https://github.com/golangci/golangci-lint/releases | ||
|
||
# golangci-lint-1.55.2-darwin-amd64.tar.gz | ||
# golangci-lint-1.55.2-darwin-arm64.tar.gz | ||
# golangci-lint-1.55.2-freebsd-386.tar.gz | ||
# golangci-lint-1.55.2-freebsd-amd64.tar.gz | ||
# golangci-lint-1.55.2-freebsd-armv6.tar.gz | ||
# golangci-lint-1.55.2-freebsd-armv7.tar.gz | ||
# golangci-lint-1.55.2-illumos-amd64.tar.gz | ||
# golangci-lint-1.55.2-linux-386.deb | ||
# golangci-lint-1.55.2-linux-386.rpm | ||
# golangci-lint-1.55.2-linux-386.tar.gz | ||
# golangci-lint-1.55.2-linux-amd64.deb | ||
# golangci-lint-1.55.2-linux-amd64.rpm | ||
# golangci-lint-1.55.2-linux-amd64.tar.gz | ||
# golangci-lint-1.55.2-linux-arm64.deb | ||
# golangci-lint-1.55.2-linux-arm64.rpm | ||
# golangci-lint-1.55.2-linux-arm64.tar.gz | ||
# golangci-lint-1.55.2-linux-armv6.deb | ||
# golangci-lint-1.55.2-linux-armv6.rpm | ||
# golangci-lint-1.55.2-linux-armv6.tar.gz | ||
# golangci-lint-1.55.2-linux-armv7.deb | ||
# golangci-lint-1.55.2-linux-armv7.rpm | ||
# golangci-lint-1.55.2-linux-armv7.tar.gz | ||
# golangci-lint-1.55.2-linux-loong64.deb | ||
# golangci-lint-1.55.2-linux-loong64.rpm | ||
# golangci-lint-1.55.2-linux-loong64.tar.gz | ||
# golangci-lint-1.55.2-linux-mips64.deb | ||
# golangci-lint-1.55.2-linux-mips64.rpm | ||
# golangci-lint-1.55.2-linux-mips64.tar.gz | ||
# golangci-lint-1.55.2-linux-mips64le.deb | ||
# golangci-lint-1.55.2-linux-mips64le.rpm | ||
# golangci-lint-1.55.2-linux-mips64le.tar.gz | ||
# golangci-lint-1.55.2-linux-ppc64le.deb | ||
# golangci-lint-1.55.2-linux-ppc64le.rpm | ||
# golangci-lint-1.55.2-linux-ppc64le.tar.gz | ||
# golangci-lint-1.55.2-linux-riscv64.deb | ||
# golangci-lint-1.55.2-linux-riscv64.rpm | ||
# golangci-lint-1.55.2-linux-riscv64.tar.gz | ||
# golangci-lint-1.55.2-linux-s390x.deb | ||
# golangci-lint-1.55.2-linux-s390x.rpm | ||
# golangci-lint-1.55.2-linux-s390x.tar.gz | ||
# golangci-lint-1.55.2-netbsd-386.tar.gz | ||
# golangci-lint-1.55.2-netbsd-amd64.tar.gz | ||
# golangci-lint-1.55.2-netbsd-armv6.tar.gz | ||
# golangci-lint-1.55.2-netbsd-armv7.tar.gz | ||
# golangci-lint-1.55.2-source.tar.gz | ||
# golangci-lint-1.55.2-windows-386.zip | ||
# golangci-lint-1.55.2-windows-amd64.zip | ||
# golangci-lint-1.55.2-windows-arm64.zip | ||
# golangci-lint-1.55.2-windows-armv6.zip | ||
# golangci-lint-1.55.2-windows-armv7.zip | ||
|
||
function setup_util_golint() ( | ||
source "$DOROTHY/sources/bash.bash" | ||
local arch options=() | ||
|
||
# only install official linting tools | ||
# https://github.com/golang/vscode-go/blob/master/docs/tools.md | ||
|
||
# ensure dev tools are installed | ||
setup-util-devel --quiet | ||
|
||
# https://github.com/golang/tools/blob/master/gopls/README.md | ||
# _cgo_export.c:3:10: fatal error: 'stdlib.h' file not found | ||
options=( | ||
--cli='gopls' | ||
"$@" | ||
GO='golang.org/x/tools/gopls' | ||
) | ||
setup-util "${options[@]}" | ||
|
||
# https://github.com/go-delve/delve/tree/master/Documentation/installation | ||
# _cgo_export.c:3:10: fatal error: 'stdlib.h' file not found | ||
options=( | ||
--name='Delve' | ||
--cli='dlv' | ||
"$@" | ||
GO='github.com/go-delve/delve/cmd/dlv' | ||
) | ||
setup-util "${options[@]}" | ||
|
||
# golangci-lint | ||
options=( | ||
--cli='golangci-lint' | ||
"$@" | ||
BREW='golangci-lint' | ||
) | ||
function get_github_asset_url { | ||
github-download \ | ||
--dry \ | ||
--slug='golangci/golangci-lint' \ | ||
--release='latest' \ | ||
--asset-filter="$(echo-escape-regex -- "$1")$" | echo-first-line || : | ||
} | ||
function add_download_option { | ||
options+=( | ||
DOWNLOAD="$(get_github_asset_url "$1")" | ||
DOWNLOAD_UNZIP_FILTER="*/$2" | ||
) | ||
} | ||
function add_deb_option { | ||
options+=( | ||
DEB="$(get_github_asset_url "$1")" | ||
) | ||
} | ||
function add_rpm_option { | ||
options+=( | ||
RPM="$(get_github_asset_url "$1")" | ||
) | ||
} | ||
arch="$(get-arch)" | ||
if is-mac; then | ||
if test "$arch" = 'a64'; then | ||
add_download_option '-darwin-arm64.tar.gz' 'golangci-lint' | ||
elif test "$arch" = 'x64'; then | ||
add_download_option '-darwin-amd64.tar.gz' 'golangci-lint' | ||
fi | ||
elif is-linux; then | ||
if test "$arch" = 'a64'; then | ||
add_deb_option '-linux-arm64.deb' | ||
add_rpm_option '-linux-arm64.rpm' | ||
add_download_option '-linux-arm64.tar.gz' 'golangci-lint' | ||
elif test "$arch" = 'a32'; then | ||
add_deb_option '-linux-armv7.deb' | ||
add_rpm_option '-linux-armv7.rpm' | ||
add_download_option '-linux-armv7.tar.gz' 'golangci-lint' | ||
elif test "$arch" = 'x64'; then | ||
add_deb_option '-linux-amd64.deb' | ||
add_rpm_option '-linux-amd64.rpm' | ||
add_download_option '-linux-amd64.tar.gz' 'golangci-lint' | ||
elif test "$arch" = 'x32'; then | ||
add_deb_option '-linux-386.deb' | ||
add_rpm_option '-linux-386.rpm' | ||
add_download_option '-linux-386.tar.gz' 'golangci-lint' | ||
elif test "$arch" = 'r64'; then | ||
add_deb_option '-linux-riscv64.deb' | ||
add_rpm_option '-linux-riscv64.rpm' | ||
add_download_option '-linux-riscv64.tar.gz' 'golangci-lint' | ||
fi | ||
elif is-wsl; then | ||
if test "$arch" = 'a64'; then | ||
add_download_option '-windows-arm64.zip' 'golangci-lint.exe' | ||
elif test "$arch" = 'a32'; then | ||
add_download_option '-windows-armv7.zip' 'golangci-lint.exe' | ||
elif test "$arch" = 'x64'; then | ||
add_download_option '-windows-amd64.zip' 'golangci-lint.exe' | ||
elif test "$arch" = 'x32'; then | ||
add_download_option '-windows-386.zip' 'golangci-lint.exe' | ||
fi | ||
fi | ||
setup-util "${options[@]}" | ||
) | ||
|
||
# fire if invoked standalone | ||
if test "$0" = "${BASH_SOURCE[0]}"; then | ||
setup_util_golint "$@" | ||
fi |