Not able to download or compile lxd-p2c

Reading the directions on https://blog.simos.info/how-to-compile-lxd-p2c-to-migrate-physical-servers-to-lxd-containers/

I was not able to find the binaries. Also when trying to compile it failed. I have the following errors.

~/go/pkg/mod/github.com/lxc/lxd@v0.0.0-20210417150257-249e78e8ab1b# make lxd-p2c
CGO_ENABLED=0 go install -v -tags netgo ./lxd-p2c
lxd-p2c/transfer.go:12:2: cannot find package "github.com/gorilla/websocket" in any of:
	/snap/go/7360/src/github.com/gorilla/websocket (from $GOROOT)
	/root/go/src/github.com/gorilla/websocket (from $GOPATH)
lxd-p2c/utils.go:13:2: cannot find package "github.com/lxc/lxd/client" in any of:
	/snap/go/7360/src/github.com/lxc/lxd/client (from $GOROOT)
	/root/go/src/github.com/lxc/lxd/client (from $GOPATH)
lxd-p2c/main_migrate.go:16:2: cannot find package "github.com/lxc/lxd/lxc/utils" in any of:
	/snap/go/7360/src/github.com/lxc/lxd/lxc/utils (from $GOROOT)
	/root/go/src/github.com/lxc/lxd/lxc/utils (from $GOPATH)
lxd-p2c/transfer.go:15:2: cannot find package "github.com/lxc/lxd/lxd/migration" in any of:
	/snap/go/7360/src/github.com/lxc/lxd/lxd/migration (from $GOROOT)
	/root/go/src/github.com/lxc/lxd/lxd/migration (from $GOPATH)
lxd-p2c/transfer.go:16:2: cannot find package "github.com/lxc/lxd/lxd/rsync" in any of:
	/snap/go/7360/src/github.com/lxc/lxd/lxd/rsync (from $GOROOT)
	/root/go/src/github.com/lxc/lxd/lxd/rsync (from $GOPATH)
lxd-p2c/transfer.go:17:2: cannot find package "github.com/lxc/lxd/shared" in any of:
	/snap/go/7360/src/github.com/lxc/lxd/shared (from $GOROOT)
	/root/go/src/github.com/lxc/lxd/shared (from $GOPATH)
lxd-p2c/main_migrate.go:17:2: cannot find package "github.com/lxc/lxd/shared/api" in any of:
	/snap/go/7360/src/github.com/lxc/lxd/shared/api (from $GOROOT)
	/root/go/src/github.com/lxc/lxd/shared/api (from $GOPATH)
lxd-p2c/main_netcat.go:12:2: cannot find package "github.com/lxc/lxd/shared/eagain" in any of:
	/snap/go/7360/src/github.com/lxc/lxd/shared/eagain (from $GOROOT)
	/root/go/src/github.com/lxc/lxd/shared/eagain (from $GOPATH)
lxd-p2c/main_migrate.go:18:2: cannot find package "github.com/lxc/lxd/shared/osarch" in any of:
	/snap/go/7360/src/github.com/lxc/lxd/shared/osarch (from $GOROOT)
	/root/go/src/github.com/lxc/lxd/shared/osarch (from $GOPATH)
lxd-p2c/main.go:8:2: cannot find package "github.com/lxc/lxd/shared/version" in any of:
	/snap/go/7360/src/github.com/lxc/lxd/shared/version (from $GOROOT)
	/root/go/src/github.com/lxc/lxd/shared/version (from $GOPATH)
lxd-p2c/transfer.go:13:2: cannot find package "github.com/pborman/uuid" in any of:
	/snap/go/7360/src/github.com/pborman/uuid (from $GOROOT)
	/root/go/src/github.com/pborman/uuid (from $GOPATH)
lxd-p2c/main_migrate.go:12:2: cannot find package "github.com/pkg/errors" in any of:
	/snap/go/7360/src/github.com/pkg/errors (from $GOROOT)
	/root/go/src/github.com/pkg/errors (from $GOPATH)
lxd-p2c/main.go:6:2: cannot find package "github.com/spf13/cobra" in any of:
	/snap/go/7360/src/github.com/spf13/cobra (from $GOROOT)
	/root/go/src/github.com/spf13/cobra (from $GOPATH)
lxd-p2c/utils.go:10:2: cannot find package "golang.org/x/crypto/ssh/terminal" in any of:
	/snap/go/7360/src/golang.org/x/crypto/ssh/terminal (from $GOROOT)
	/root/go/src/golang.org/x/crypto/ssh/terminal (from $GOPATH)
lxd-p2c/main_migrate.go:14:2: cannot find package "golang.org/x/sys/unix" in any of:
	/snap/go/7360/src/golang.org/x/sys/unix (from $GOROOT)
	/root/go/src/golang.org/x/sys/unix (from $GOPATH)
make: *** [Makefile:39: lxd-p2c] Error 1

One of the issues is that I do not have the directory ~/go/src/github.com/lxc/lxc
I have this directory instead: ~/go/pkg/mod/github.com/lxc/lxd@v0.0.0-20210417150257-249e78e8ab1b

You can download prebuilt binaries from https://github.com/lxc/lxd/actions

I must be missing something. When I select any of the actions in https://github.com/lxc/lxd/actions It take me back to the main lxd directory https://github.com/lxc/lxd. Is there an issue with Github directory?

Also I am curious Why When I try to build lxd (actually lxd-p2c) on a fresh lxd ubuntu 20.04 I am getting a different go directory then you have. I have installed the snap go (snap install go --classic)

The latest version of Go uses modules and is a bit different from the earlier versions (that put the source in ~/go/src/).

If you do not mind having a dynamically-linked binary, you can continue the compilation with

apt install pkg-config
go get github.com/lxc/lxd/lxd-p2c

The dynamically linked lxd-p2c can be then found in ~/go/bin/.

The Github Actions page is a bit confusing. The latest one now is at https://github.com/lxc/lxd/actions/runs/762561259 and the binary packages are at the very end of the page, under the heading Artifacts (you need to log in into your Github account first).