First off, I’m a complete newbie when it comes to Go. I’ve got it installed, both on Windows and Linux, and can create a simple Hello World program, which builds and runs fine.
I can clone and download the repository, but haven’t a clue as to how to even build it as-is… The few times I’ve got go build or go install to do anything more than an immediate not found type error, it’s referencing github… I’ve tried putting them in various folder structures, “go init mod”, etc, but with no luck.
If I can’t even build the code as-is, I’m not going to get anywhere learning how to write my own stuff on top.
So… Is there a tutorial anywhere on how to actually download and use third-party code? Starting from the very basics, “create this directory structure, run these exact commands.” …
When such guidance is not available, your next priority is to seek out the main package within the repository. Example, on the leaf server, there is a main.go inside leafserver/src/server at master · name5566/leafserver · GitHub. So on the root directory, you go build against src/server package instead of the root directory.
Keep in mind that both repositories are outdated and are not using go module. So you will need to go get it with GOPATH set. Try:
$ go get -u github.com/name5566/leafserver/tree/master/src/server
OR
# Note you need to manually resolve all dependencies if you use go build
$ cd $GOPATH/github.com/name5566/leafserver
$ go build -o ./bin ./src/server
Thanks everyone. After several days of fiddling, I’ve managed to get leafserver compiling as-is using modules outside gopath… . Changes are mostly changing all the import paths from e.g. ‘server/conf’ to the full github.com path. Also added a -replace directive to the go.mod to point at local copy of leaf. Changes all up at github.com/irrelevantdotcom/leafserver (& /leaf)