build: switch to using go1.11 modules for managing dependencies

This commit is contained in:
Nick Craig-Wood 2018-08-28 15:30:47 +01:00
parent da1682a30e
commit 5e75a9ef5c
3 changed files with 57 additions and 30 deletions

View File

@ -33,7 +33,7 @@ page](https://github.com/ncw/rclone).
Now in your terminal Now in your terminal
go get github.com/ncw/rclone go get -u github.com/ncw/rclone
cd $GOPATH/src/github.com/ncw/rclone cd $GOPATH/src/github.com/ncw/rclone
git remote rename origin upstream git remote rename origin upstream
git remote add origin git@github.com:YOURUSER/rclone.git git remote add origin git@github.com:YOURUSER/rclone.git
@ -166,7 +166,7 @@ with modules beneath.
* pacer - retries with backoff and paces operations * pacer - retries with backoff and paces operations
* readers - a selection of useful io.Readers * readers - a selection of useful io.Readers
* rest - a thin abstraction over net/http for REST * rest - a thin abstraction over net/http for REST
* vendor - 3rd party code managed by the dep tool * vendor - 3rd party code managed by `go mod`
* vfs - Virtual FileSystem layer for implementing rclone mount and similar * vfs - Virtual FileSystem layer for implementing rclone mount and similar
## Writing Documentation ## ## Writing Documentation ##
@ -229,37 +229,55 @@ Fixes #1498
## Adding a dependency ## ## Adding a dependency ##
rclone uses the [dep](https://github.com/golang/dep) tool to manage rclone uses the [go
its dependencies. All code that rclone needs for building is stored modules](https://tip.golang.org/cmd/go/#hdr-Modules__module_versions__and_more)
in the `vendor` directory for perfectly reproducable builds. support in go1.11 and later to manage its dependencies.
The `vendor` directory is entirely managed by the `dep` tool. **NB** you must be using go1.11 or above to add a dependency to
rclone. Rclone will still build with older versions of go, but we use
the `go mod` command for dependencies which is only in go1.11 and
above.
To add a new dependency, run `dep ensure` and `dep` will pull in the rclone can be built with modules outside of the GOPATH, but for
new dependency to the `vendor` directory and update the `Gopkg.lock` backwards compatibility with older go versions, rclone also maintains
file. a `vendor` directory with all the external code rclone needs for
building.
You can add constraints on that package in the `Gopkg.toml` file (see The `vendor` directory is entirely managed by the `go mod` tool, do
the `dep` documentation), but don't unless you really need to. not add things manually.
Please check in the changes generated by `dep` including the `vendor` To add a dependency `github.com/ncw/new_dependency` see the
directory and `Godep.toml` and `Godep.lock` in a single commit instructions below. These will fetch the dependency, add it to
separate from any other code changes. Watch out for new files in `go.mod` and `go.sum` and vendor it for older go versions.
`vendor`.
export GO111MODULE=on
go get github.com/ncw/new_dependency
go mod vendor
You can add constraints on that package when doing `go get` (see the
go docs linked above), but don't unless you really need to.
Please check in the changes generated by `go mod` including the
`vendor` directory and `go.mod` and `go.sum` in a single commit
separate from any other code changes with the title "vendor: add
github.com/ncw/new_dependency". Remember to `git add` any new files
in `vendor`.
## Updating a dependency ## ## Updating a dependency ##
If you need to update a dependency then run If you need to update a dependency then run
dep ensure -update github.com/pkg/errors export GO111MODULE=on
go get -u github.com/pkg/errors
go mod vendor
Check in in a single commit as above. Check in in a single commit as above.
## Updating all the dependencies ## ## Updating all the dependencies ##
In order to update all the dependencies then run `make update`. This In order to update all the dependencies then run `make update`. This
just runs `dep ensure -update`. Check in the changes in a single just uses the go modules to update all the modules to their latest
commit as above. stable release. Check in the changes in a single commit as above.
This should be done early in the release cycle to pick up new versions This should be done early in the release cycle to pick up new versions
of packages in time for them to get some testing. of packages in time for them to get some testing.

View File

@ -83,7 +83,6 @@ ifdef FULL_TESTS
go get -u github.com/kisielk/errcheck go get -u github.com/kisielk/errcheck
go get -u golang.org/x/tools/cmd/goimports go get -u golang.org/x/tools/cmd/goimports
go get -u github.com/golang/lint/golint go get -u github.com/golang/lint/golint
go get -u github.com/tools/godep
endif endif
# Get the release dependencies # Get the release dependencies
@ -93,8 +92,9 @@ release_dep:
# Update dependencies # Update dependencies
update: update:
go get -u github.com/golang/dep/cmd/dep GO111MODULE=on go get -u ./...
dep ensure -update -v GO111MODULE=on go tidy
GO111MODULE=on go vendor
doc: rclone.1 MANUAL.html MANUAL.txt doc: rclone.1 MANUAL.html MANUAL.txt

View File

@ -1,7 +1,7 @@
--- ---
title: "Install" title: "Install"
description: "Rclone Installation" description: "Rclone Installation"
date: "2016-03-28" date: "2018-08-28"
--- ---
# Install # # Install #
@ -11,7 +11,7 @@ Rclone is a Go program and comes as a single binary file.
## Quickstart ## ## Quickstart ##
* [Download](/downloads/) the relevant binary. * [Download](/downloads/) the relevant binary.
* Unpack and the `rclone` binary. * Extract the `rclone` or `rclone.exe` binary from the archive
* Run `rclone config` to setup. See [rclone config docs](/docs/) for more details. * Run `rclone config` to setup. See [rclone config docs](/docs/) for more details.
See below for some expanded Linux / macOS instructions. See below for some expanded Linux / macOS instructions.
@ -83,16 +83,25 @@ Run `rclone config` to setup. See [rclone config docs](/docs/) for more details.
## Install from source ## ## Install from source ##
Make sure you have at least [Go](https://golang.org/) 1.6 installed. Make sure you have at least [Go](https://golang.org/) 1.7
Make sure your `GOPATH` is set, then: installed. [Download go](https://golang.org/dl/) if necessary. The
latest release is recommended. Then
git clone https://github.com/ncw/rclone.git
cd rclone
go build
./rclone version
You can also build and install rclone in the
[GOPATH](https://github.com/golang/go/wiki/GOPATH) (which defaults to
`~/go`) with:
go get -u -v github.com/ncw/rclone go get -u -v github.com/ncw/rclone
and this will build the binary in `$GOPATH/bin`. If you have built and this will build the binary in `$GOPATH/bin` (`~/go/bin/rclone` by
rclone before then you will want to update its dependencies first with default) after downloading the source to
this `$GOPATH/src/github.com/ncw/rclone` (`~/go/src/github.com/ncw/rclone`
by default).
go get -u -v github.com/ncw/rclone/...
## Installation with Ansible ## ## Installation with Ansible ##