Do I need the entire go toolchain, or only the go binary itself?

As the title says, when using hugo mod or hugo module, go binary is needed.

I’m just wondering, if I need to install the entire toolchain or just a single go binary. The stuff under pkg and src takes a lot of space and if they are not needed I will not add them.

Thank you!

How are you installing Go?

According to GOLANG document,
curl -L -O https://go.dev/dl/go1.24.3.linux-amd64.tar.gz
tar -C /usr/local -xzf go1.24.3.linux-amd64.tar.gz
PATH="/usr/local/go/bin:${PATH}"

After removing the src and pkg directories, I tested with a site that downloads a content module, and everything seems to work fine, but I needed to do this too:

export GOROOT=/usr/local/go

Having said that, those two directories combined are only 240 MB…

I’m trying to make a docker image and reducing size of the image.

Thanks for the testing, though I still hope to get some answers from the dev…

Only the /bin files should be fine.

This is a nice way of installing dependencies in Docker, I use it for node and other stuff in a few projects.

COPY --from=golang:1 /usr/local/go/bin /usr/local/go/bin

1 Like