`Connection refused` when downloading go packages

A common issue I encounter after setting up Arch Linux hosts occurs when installing go packages:

clean.go:8:2: github.com/Jguer/aur@v1.2.3: Get "https://proxy.golang.org/github.com/%21jguer/aur/@v/v1.2.3.zip": dial tcp: lookup proxy.golang.org on [::1]:53: read udp [::1]:41284->[::1]:53: read: connection refused

The error messages say connection refused which may be misleading. In my case, this issue is always related to using systemd-resolved for DNS resolution without setting up the stub-resolv.conf. DNS resolution in other tools like curl works, which makes this issue even harder to detect. But go seems to rely on /etc/resolv.conf, so if that is not set up as a link to /run/systemd/resolve/stub-resolv.conf, the errors above will appear.

In any case, as hard as it was to find this issue, as easy is it to fix it: Just execute

sudo ln -sf /run/systemd/resolve/stub-resolv.conf /etc/resolv.conf

and go package installation will work.