version: show build tags and type of executable

This patch modifies the output of `rclone version`.
The `os/arch` line is split into `os/type` and `os/arch`.
The `go version` line is now tagged as `go/version` for consistency.

Additionally the `go/linking` line tells whether the rclone
was linked as a static or dynamic executable.
The new `go/tags` line shows a space separated list of build tags.

The info about linking and build tags is also added to the output
of the `core/version` RC endpoint.
This commit is contained in:
Ivan Andreev
2021-03-21 15:13:09 +03:00
parent 268a7ff7b8
commit ef5c212f9b
6 changed files with 71 additions and 13 deletions

View File

@@ -29,14 +29,21 @@ var commandDefinition = &cobra.Command{
Use: "version",
Short: `Show the version number.`,
Long: `
Show the version number, the go version and the architecture.
Show the rclone version number, the go version, the build target OS and
architecture, build tags and the type of executable (static or dynamic).
Eg
For example:
$ rclone version
rclone v1.41
- os/arch: linux/amd64
- go version: go1.10
rclone v1.54
- os/type: linux
- os/arch: amd64
- go/version: go1.16
- go/linking: static
- go/tags: none
Note: before rclone version 1.55 the os/type and os/arch lines were merged,
and the "go/version" line was tagged as "go version".
If you supply the --check flag, then it will do an online check to
compare your version with the latest release and the latest beta.
@@ -89,9 +96,7 @@ func GetVersion(url string) (v *semver.Version, vs string, date time.Time, err e
return v, vs, date, err
}
vs = strings.TrimSpace(string(bodyBytes))
if strings.HasPrefix(vs, "rclone ") {
vs = vs[7:]
}
vs = strings.TrimPrefix(vs, "rclone ")
vs = strings.TrimRight(vs, "β")
date, err = http.ParseTime(resp.Header.Get("Last-Modified"))
if err != nil {