diff --git a/MONOREPO/tools/setupgo b/MONOREPO/tools/setupgo deleted file mode 100755 index 1150f3a081..0000000000 --- a/MONOREPO/tools/setupgo +++ /dev/null @@ -1,37 +0,0 @@ -#!/bin/bash - -#doc: -#doc: # MONOREPO/tools/setupgo -#doc: -#doc: Installs the required golang version in $HOME. - -set -euo pipefail - -reporoot=$(dirname $(dirname $(dirname $(realpath $0)))) - -source $reporoot/MONOREPO/tools/libcore.bash - -golang_version=$(cd $reporoot && cat GOVERSION) -golang_tarball=go${golang_version}.$(goos)-$(goarch).tar.gz -golang_tarball_url=https://dl.google.com/go/${golang_tarball} -golang_sha256=${golang_tarball}.sha256 -golang_sha256_url=${golang_tarball_url}.sha256 - -if [[ ! -d $HOME/sdk/go${golang_version} ]]; then - run curl -f#SLO $golang_tarball_url - run curl -f#SLO $golang_sha256_url - echo "$(cat $golang_sha256) $golang_tarball" >SHA256SUMS - run sha256sum -c SHA256SUMS - run rm -f SHA256SUMS $golang_sha256 - run mkdir -p $HOME/sdk - run tar -C $HOME/sdk -xf $golang_tarball - run mv $HOME/sdk/go $HOME/sdk/go$golang_version - run rm -f $golang_tarball -fi - -if [[ -d $HOME/bin ]]; then - run rm -f $HOME/bin/go - run ln -s $HOME/sdk/go${golang_version}/bin/go $HOME/bin/go -fi - -run $reporoot/CLI/check-go-version diff --git a/Readme.md b/Readme.md index a60d508d16..0a351887ba 100644 --- a/Readme.md +++ b/Readme.md @@ -81,7 +81,8 @@ mingw-w64 cross-compiler. The following commands show how to setup a development environment using Debian 12 ("bookworm"). The same instructions -should also work for Debian-based distribution (e.g., Ubuntu). +should also work for Debian-based distribution (e.g., Ubuntu) +as long as you're using Go >= 1.19. ```bash # install the compilers, git, and the root CA @@ -97,10 +98,13 @@ go install -v golang.org/dl/go1.20.12@latest $HOME/go/bin/go1.20.12 download ``` +You can automate the last two steps by using `./script/go.bash` as your +Go compiler, as explained below. + ### Fedora developer setup The following commands show how to setup a development -environment using Fedora. +environment using Fedora, as long as your Fedora uses Go >= 1.19. ```bash # install the compilers and git @@ -116,6 +120,9 @@ go install -v golang.org/dl/go1.20.12@latest $HOME/go/bin/go1.20.12 download ``` +You can automate the last two steps by using `./script/go.bash` as your +Go compiler, as explained below. + ### macOS developer setup The following commands show how to setup a development @@ -136,7 +143,15 @@ go install -v golang.org/dl/go1.20.12@latest $HOME/go/bin/go1.20.12 download ``` -### Build instructions +You can automate the last two steps by using `./script/go.bash` as your +Go compiler, as explained below. + +### Build instructions without using `./script/go.bash` + +This section describe how to manually use the correct version of Go you have +installed. You can alternatively use the `./script/go.bash` wrapper to automatically +use the correct Go version (provided you have Go >= 1.19 installed), as described +in a subsequent section of this file. Once you have installed the correct Go version and a C compiler, you can compile `ooniprobe` using: @@ -166,6 +181,23 @@ $HOME/go/bin/go1.20.12 build -v -ldflags '-s -w' ./internal/cmd/oohelperd This command will generate a stripped binary called `oohelperd` in the toplevel directory. +### Alternative: using the `./script/go.bash` script + +The `./script/go.bash` script requires Go >= 1.19 and automates installing and +using the correct version of Go. Running this script as follows: + +```bash +./script/go.bash build -v -ldflags '-s -w' ./internal/cmd/miniooni +``` + +Is equivalent to running these commands: + +```bash +go install -v golang.org/dl/go1.20.12@latest +$HOME/go/bin/go1.20.12 download +$HOME/sdk/go1.20.12/bin/go build -v -ldflags '-s -w' ./internal/cmd/miniooni +``` + ## Contributing Please, see [CONTRIBUTING.md](CONTRIBUTING.md).