Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improved installation #475

Merged
merged 4 commits into from Jan 24, 2019
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
13 changes: 13 additions & 0 deletions scripts/check-go-version.sh
@@ -0,0 +1,13 @@
#!/bin/bash -e
# Ensure we use Go installed
if ! (hash go 2>/dev/null) ; then
echo "Could not find a Go installation, please install Go and try again."
exit 1;
fi

# Ensure we use Go version 1.11+
read major minor patch <<< $(go version | sed 's/go version go\([0-9]*\)\.\([0-9]*\)\.\(.*\) .*/\1 \2 \3/')
if [[ ${major} -ne 1 || ${minor} -lt 11 ]]; then
echo "Go 1.11+ is required (v$major.$minor.$patch is installed at `which go`)"
exit 1;
fi
17 changes: 17 additions & 0 deletions scripts/win/check-go-version.ps1
@@ -0,0 +1,17 @@
if(-not (Get-Command "go" -errorAction SilentlyContinue))
{
$host.ui.WriteErrorLine("Could not find a Go installation, please install Go and try again.")
exit 1
}

$null = ((go version) -match "go version go(\d+)\.(\d+)\.([^ ]+)")
$major = $Matches[1]
$minor = $Matches[2]
$patch = $Matches[3]
$loc = (gcm go).Path

if($major -ne 1 -or $minor -lt 11)
{
$host.ui.WriteErrorLine("Go 1.11+ is required (v$major.$minor.$patch is installed at $loc)")
exit 1
}
3 changes: 3 additions & 0 deletions setup_env.bat
@@ -1,4 +1,7 @@
@echo off
PowerShell.exe -NoProfile -ExecutionPolicy Bypass -Command "& './scripts/win/check-go-version.ps1'"
if %ERRORLEVEL% GTR 0 exit /B 1

call ./scripts/win/install-protobuf.bat

go get github.com/golang/protobuf/protoc-gen-go
Expand Down
2 changes: 2 additions & 0 deletions setup_env.sh
@@ -1,6 +1,8 @@
#!/bin/bash -e
./scripts/check-go-version.sh
./scripts/install-protobuf.sh

go mod download
protobuf_path=$(go list -m -f '{{.Dir}}' github.com/golang/protobuf)
echo "installing protoc-gen-go..."
go install $protobuf_path/protoc-gen-go
Expand Down