Rclone go pull requests

@ncw I am trying to follow this but so far has been unsuccessful with some of the commands.

The first four commands work perfectly fine.

git clone https://github.com/rclone/rclone.git
cd rclone
git remote rename origin upstream
git remote add origin git@github.com:YOURUSER/rclone.git

But the fifth line however gives me errors, that I don't understand.

go build

The output from the above command is as follows :-

:~/GitHubProjects/rclone$ go build
rclone.go:7:2: cannot find package "github.com/rclone/rclone/backend/all" in any of:
        /home/USER/go/src/github.com/rclone/rclone/backend/all (from $GOROOT)
        /home/USER/GoProjects/src/github.com/rclone/rclone/backend/all (from $GOPATH)
rclone.go:8:2: cannot find package "github.com/rclone/rclone/cmd" in any of:
        /home/USER/go/src/github.com/rclone/rclone/cmd (from $GOROOT)
        /home/USER/GoProjects/src/github.com/rclone/rclone/cmd (from $GOPATH)
rclone.go:9:2: cannot find package "github.com/rclone/rclone/cmd/all" in any of:
        /home/USER/go/src/github.com/rclone/rclone/cmd/all (from $GOROOT)
        /home/USER/GoProjects/src/github.com/rclone/rclone/cmd/all (from $GOPATH)
rclone.go:10:2: cannot find package "github.com/rclone/rclone/lib/plugin" in any of:
        /home/USER/go/src/github.com/rclone/rclone/lib/plugin (from $GOROOT)
        /home/USER/GoProjects/src/github.com/rclone/rclone/lib/plugin (from $GOPATH)
package .
        imports runtime: cannot find package "runtime" in any of:
        /home/USER/go/src/runtime (from $GOROOT)
        /home/USER/GoProjects/src/runtime (from $GOPATH)

I've installed Go and also configured $GOROOT and $GOPATH. I'm confused as to why it's looking in those directories, even when I change $GOROOT and $GOPATH I still get similar errors as it can't find the packages such as time for example.

If I type the command go version I get the following output: -

go version go1.7.4 linux/amd64

So it must be installed, this is a problem as I am unable to test any code I have written for rclone.

A quick guess, your go version is too old to fetch and compile rclone. Mine is

go version go1.16.3 windows/amd64

oh really? I'd assumed it was a paths issue, I will compile from source then instead of using the repo one.

I used this - quick and simple (on Windows):
https://golang.org/doc/install

Ah I am using Linux, but it's ok I have upgraded it now, and it's all working nicely.

Great, the link also supports download of a compiled version for linux/amd64 :grinning:

Yes indeed it does, thank you, such a strange error message for an incompatible version, I'd of expected something more meaningful that said what the actual issue was. But I guess the error message is from Go and not rclone.

Go underwent a big change to do with modules and how they are handled. Rclone uses the module system and if you use a version of go which doesn't understand the module system then it will give an error on every module rclone tries to use.

Oh I see, this is the first time I have tried to do anything with Go. Not having the best of experiences so far, but I think the recursive functionality to touch is getting closer, I'm getting less errors so that's something. touch: add recurse functionality - issue #5301 by aeromaxx · Pull Request #5330 · rclone/rclone · GitHub

I did a quick look on your fist commit and noticed some errors, that my editor/IDE would have eliminated or at least helped me to avoid.

Perhaps one of the popular editors for Go will make your programming easier?

I use Visual Studio Code and really like the integrated support for syntax, cross-referencing, debugging, git and GitHub support. It does have a learning curve too, but once passed you can quickly move between different projects and programming languages. It is free and cross-platform (incl. linux/amd64).

1 Like

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.