Newbie Development Question

(David R) #1

Hi, I’m considering trying to play with adding something to syncthing. I’m completely new to both go and git. I read the development section of the docs, and I believe I have my directories set up correctly. I ran git clone and then “go run build.go”. I get many errors like the following ones:

lib/protocol/protocol.go:16:2: cannot find package “github.com/bkaradzic/go-lz4” in any of: /usr/lib64/go/1.11/src/github.com/bkaradzic/go-lz4 (from $GOROOT) /home/drosky132/go/src/github.com/bkaradzic/go-lz4 (from $GOPATH) lib/fs/basicfs.go:17:2: cannot find package “github.com/calmh/du” in any of: /usr/lib64/go/1.11/src/github.com/calmh/du (from $GOROOT) /home/drosky132/go/src/github.com/calmh/du (from $GOPATH)

I definitely don’t have any of those directories in my “github.com” directory, so I’m not surprised I’m getting these errors. It appears that there are numerous source code packages I still need that aren’t included in the syncthing repository. Do I need to “git clone” all of these one at a time, or is there a way that either the git or go command can automatically pull them in?

Thanks…

(David R) #2

Sorry for the poor code formatting in the above post. I tried to change it, but the system told me my edited post was “too similar to the original body” and wouldn’t let me save it. Here is the compiler output in (hopefully) more readable form:

lib/protocol/protocol.go:16:2: cannot find package "github.com/bkaradzic/go-lz4" in any of:
	/usr/lib64/go/1.11/src/github.com/bkaradzic/go-lz4 (from $GOROOT)
	/home/drosky132/go/src/github.com/bkaradzic/go-lz4 (from $GOPATH)
lib/fs/basicfs.go:17:2: cannot find package "github.com/calmh/du" in any of:
	/usr/lib64/go/1.11/src/github.com/calmh/du (from $GOROOT)
	/home/drosky132/go/src/github.com/calmh/du (from $GOPATH)
(Evgeny Kuznetsov) #3

Something is wrong with your Go setup.

Basically, what you’re observing is lacking the packages Syncthing depends on (whole lot of them). What’s supposed to happen is Go downloading them automagically to /home/drosky132/go/pkg/mod and use them from there, but it looks like it’s not even looking in that directory.

What version of Go are you using? Maybe your version is too old to understand the whole go mod concept, which is relatively recent in Go.

1 Like
(David R) #4

Thank you for the reply! That let me know where to look. I am using go 1.11, which, I have found out, has the module support, but you must manually enable it by setting the environment variable GO111MODULE=on. When I do that, it works as you describe. Now I have a starting point.

2 Likes
(Jakob Borg) #5

Yeah Go is in a bit of a transition at the moment, and our build instructions aren’t 100% updated. It boils down to setting the variable you found, or not having the source in $GOPATH (i.e., roughly the opposite of our old build instructions…).

(In our source tarballs we include a vendor directory, so that downstream packagers wouldn’t have to suffer through this transition by surprise.)

1 Like
(Jakob Borg) #6

I’ve updated the build instructions to take modules into account.

3 Likes