Questions about Go initialization code for LXD client

I use the Go LXD Api, and so I’ve looked into how the “lxc” command creates an lxc.InstanceServer, in order to do the same.

In, client/connection.go uses /var/lib/lxd/unix.socket as the default location for the unix socket, but when LXD is installed via the recommended snap, there is no such socket. The snap LXD socket is /var/snap/lxd/common/lxd/unix.socket.

Similarly with the user lxd config directory:
lxc/main.go uses path.Join(os.Getenv(“HOME”), “.config”, “lxc”)
But I find that the snap lxc command uses $HOME/snap/lxd/common/config/

I understand that the non-snap paths were used by the “lxc” command before LXD was a snap.

But why does the Go code still use the pre-snap paths?

pylxd uses both paths. I would expect the Go code to do the same.

Does the snap runtime environment map /var/lib/lxd/ to /var/snap/lxd/common/lxd/
and $HOME/.config/lxc/ to $HOME/snap/lxd/common/config/?

We use this function:

To make the path relative to the snap if it detects its running inside a snap.