Skip to content

"rsync for cloud storage" - Google Drive, S3, Dropbox, Backblaze B2, One Drive, Swift, Hubic, Wasabi, Google Cloud Storage, Azure Blob, Azure Files, Yandex Files

version: show build tags and type of executable

Ivan Andreevef5c212f9bf8
diff --git a/cmd/cmd.go b/cmd/cmd.go
index fee58d61b..e2a03db5d 100644
--- a/cmd/cmd.go
+++ b/cmd/cmd.go
@@ -36,6 +36,7 @@ import (
"github.com/rclone/rclone/fs/rc/rcflags"
"github.com/rclone/rclone/fs/rc/rcserver"
"github.com/rclone/rclone/lib/atexit"
+ "github.com/rclone/rclone/lib/buildinfo"
"github.com/rclone/rclone/lib/random"
"github.com/rclone/rclone/lib/terminal"
"github.com/spf13/cobra"
@@ -74,9 +75,13 @@ const (
// ShowVersion prints the version to stdout
func ShowVersion() {
+ linking, tagString := buildinfo.GetLinkingAndTags()
fmt.Printf("rclone %s\n", fs.Version)
- fmt.Printf("- os/arch: %s/%s\n", runtime.GOOS, runtime.GOARCH)
- fmt.Printf("- go version: %s\n", runtime.Version())
+ fmt.Printf("- os/type: %s\n", runtime.GOOS)
+ fmt.Printf("- os/arch: %s\n", runtime.GOARCH)
+ fmt.Printf("- go/version: %s\n", runtime.Version())
+ fmt.Printf("- go/linking: %s\n", linking)
+ fmt.Printf("- go/tags: %s\n", tagString)
}
// NewFsFile creates an Fs from a name but may point to a file.
diff --git a/cmd/version/version.go b/cmd/version/version.go
index 85a049b37..0ccfe8e3f 100644
--- a/cmd/version/version.go
+++ b/cmd/version/version.go
@@ -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 {
diff --git a/fs/rc/internal.go b/fs/rc/internal.go
index a3018bc4a..4c8d8617f 100644
--- a/fs/rc/internal.go
+++ b/fs/rc/internal.go
@@ -17,6 +17,7 @@ import (
"github.com/rclone/rclone/fs"
"github.com/rclone/rclone/fs/config/obscure"
"github.com/rclone/rclone/lib/atexit"
+ "github.com/rclone/rclone/lib/buildinfo"
)
func init() {
@@ -179,6 +180,8 @@ This shows the current version of go and the go runtime
- os - OS in use as according to Go
- arch - cpu architecture in use according to Go
- goVersion - version of Go runtime in use
+- linking - type of rclone executable (static or dynamic)
+- goTags - space separated build tags or "none"
`,
})
@@ -190,6 +193,7 @@ func rcVersion(ctx context.Context, in Params) (out Params, err error) {
if err != nil {
return nil, err
}
+ linking, tagString := buildinfo.GetLinkingAndTags()
out = Params{
"version": fs.Version,
"decomposed": version.Slice(),
@@ -198,6 +202,8 @@ func rcVersion(ctx context.Context, in Params) (out Params, err error) {
"os": runtime.GOOS,
"arch": runtime.GOARCH,
"goVersion": runtime.Version(),
+ "linking": linking,
+ "goTags": tagString,
}
return out, nil
}
@@ -425,9 +431,7 @@ func rcRunCommand(ctx context.Context, in Params) (out Params, err error) {
allArgs = append(allArgs, command)
}
// Add all from arg
- for _, cur := range arg {
- allArgs = append(allArgs, cur)
- }
+ allArgs = append(allArgs, arg...)
// Add flags to args for e.g. --max-depth 1 comes in as { max-depth 1 }.
// Convert it to [ max-depth, 1 ] and append to args list
diff --git a/lib/buildinfo/cgo.go b/lib/buildinfo/cgo.go
new file mode 100644
index 000000000..8009d3bea
--- /dev/null
+++ b/lib/buildinfo/cgo.go
@@ -0,0 +1,7 @@
+// +build cgo
+
+package buildinfo
+
+func init() {
+ Tags = append(Tags, "cgo")
+}
diff --git a/lib/buildinfo/cmount.go b/lib/buildinfo/cmount.go
new file mode 100644
index 000000000..67ffbbea5
--- /dev/null
+++ b/lib/buildinfo/cmount.go
@@ -0,0 +1,7 @@
+// +build cmount
+
+package buildinfo
+
+func init() {
+ Tags = append(Tags, "cmount")
+}
diff --git a/lib/buildinfo/tags.go b/lib/buildinfo/tags.go
new file mode 100644
index 000000000..84b79bd19
--- /dev/null
+++ b/lib/buildinfo/tags.go
@@ -0,0 +1,30 @@
+package buildinfo
+
+import (
+ "sort"
+ "strings"
+)
+
+// Tags contains slice of build tags
+var Tags []string
+
+// GetLinkingAndTags tells how the rclone executable was linked
+// and returns space separated build tags or the string "none".
+func GetLinkingAndTags() (linking, tagString string) {
+ linking = "static"
+ tagList := []string{}
+ for _, tag := range Tags {
+ if tag == "cgo" {
+ linking = "dynamic"
+ } else {
+ tagList = append(tagList, tag)
+ }
+ }
+ if len(tagList) > 0 {
+ sort.Strings(tagList)
+ tagString = strings.Join(tagList, " ")
+ } else {
+ tagString = "none"
+ }
+ return
+}