From e9a764129f9362599ea49cbf287e287286518b4c Mon Sep 17 00:00:00 2001 From: Alexander Neumann Date: Thu, 30 Aug 2018 22:49:39 +0200 Subject: [PATCH] Update docs for Go 1.11 --- CONTRIBUTING.md | 48 ++++++++++++++++++++++++++++++--------- doc/020_installation.rst | 17 ++++++++++---- doc/090_participating.rst | 4 +++- 3 files changed, 53 insertions(+), 16 deletions(-) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 572cee290..e38500fb3 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -46,12 +46,15 @@ Remember, the easier it is for us to reproduce the bug, the earlier it will be corrected! In addition, you can compile restic with debug support by running -`go run build.go -tags debug` and instructing it to create a debug log by -setting the environment variable `DEBUG_LOG` to a file, e.g. like this: +`go run -mod=vendor build.go -tags debug` and instructing it to create a debug +log by setting the environment variable `DEBUG_LOG` to a file, e.g. like this: $ export DEBUG_LOG=/tmp/restic-debug.log $ restic backup ~/work +For Go < 1.11, you need to remove the `-mod=vendor` option from the build +command. + Please be aware that the debug log file will contain potentially sensitive things like file and directory names, so please either redact it before uploading it somewhere or post only the parts that are really relevant. @@ -60,9 +63,37 @@ uploading it somewhere or post only the parts that are really relevant. Development Environment ======================= -In order to compile restic with the `go` tool directly, it needs to be checked -out at the right path within a `GOPATH`. The concept of a `GOPATH` is explained -in ["How to write Go code"](https://golang.org/doc/code.html). +The repository contains several sets of directories with code: `cmd/` and +`internal/` contain the code written for restic, whereas `vendor/` contains +copies of libraries restic depends on. The libraries are managed with the +command `go mod vendor`. + +Go >= 1.11 +---------- + +For Go version 1.11 or later, you should clone the repo (without having +`$GOPATH` set) and `cd` into the directory: + + $ unset GOPATH + $ git clone https://github.com/restic/restic + $ cd restic + +Then use the `go` tool to build restic: + + $ go build ./cmd/restic + $ ./restic version + restic 0.9.2-dev (compiled manually) compiled with go1.11 on linux/amd64 + +You can run all tests with the following command: + + $ go test ./... + +Go < 1.11 +--------- + +In order to compile restic with Go before 1.11, it needs to be checked out at +the right path within a `GOPATH`. The concept of a `GOPATH` is explained in +["How to write Go code"](https://golang.org/doc/code.html). If you do not have a directory with Go code yet, executing the following instructions in your shell will create one for you and check out the restic @@ -83,12 +114,7 @@ You can then build restic as follows: The following commands can be used to run all the tests: - $ go test ./cmd/... ./internal/... - -The repository contains two sets of directories with code: `cmd/` and -`internal/` contain the code written for restic, whereas `vendor/` contains -copies of libraries restic depends on. The libraries are managed with the -[`dep`](https://github.com/golang/dep) tool. + $ go test ./... Providing Patches ================= diff --git a/doc/020_installation.rst b/doc/020_installation.rst index 7302aba09..1ded4fdf9 100644 --- a/doc/020_installation.rst +++ b/doc/020_installation.rst @@ -221,6 +221,13 @@ In order to build restic from source, execute the following steps: $ cd restic + $ go run -mod=vendor build.go + +For Go versions < 1.11, the option ``-mod=vendor`` needs to be removed, like +this: + +.. code-block:: console + $ go run build.go You can easily cross-compile restic for all supported platforms, just @@ -229,12 +236,14 @@ supply the target OS and platform via the command-line options like this .. code-block:: console - $ go run build.go --goos windows --goarch amd64 + $ go run -mod=vendor build.go --goos windows --goarch amd64 - $ go run build.go --goos freebsd --goarch 386 + $ go run -mod=vendor build.go --goos freebsd --goarch 386 + + $ go run -mod=vendor build.go --goos linux --goarch arm --goarm 6 + +Again, for Go < 1.11 ``-mod=vendor`` needs to be removed. - $ go run build.go --goos linux --goarch arm --goarm 6 - The resulting binary is statically linked and does not require any libraries. diff --git a/doc/090_participating.rst b/doc/090_participating.rst index 04653a7d4..001211c8a 100644 --- a/doc/090_participating.rst +++ b/doc/090_participating.rst @@ -22,7 +22,9 @@ The program can be built with debug support like this: .. code-block:: console - $ go run build.go -tags debug + $ go run build.go -mod=vendor -tags debug + +For Go < 1.11, the option ``-mod=vendor`` needs to be removed. Afterwards, extensive debug messages are written to the file in environment variable ``DEBUG_LOG``, e.g.: