[SOLVED] How to locally build statically linked hugo binary?

Hello,

I can build hugo successfully using the go get command in the README.md.

That gives me hugo binary. But that is a dynamically linked binary.

ldd gives me:

> ldd hugo
        linux-vdso.so.1 =>  (0x00007fffd9f34000)
        libpthread.so.0 => /lib64/libpthread.so.0 (0x00000033e3800000)
        libc.so.6 => /lib64/libc.so.6 (0x00000033e3000000)
        /lib64/ld-linux-x86-64.so.2 (0x00000033e2800000)

I would like to build a statically linked binary like the hugo dev provides with each release, so that I can use that with Gitlab runner.

How do I do that?

Thanks.

I think I can now answer this myself :slightly_smiling:

This seems to work:

#!/usr/bin/env bash   

export CGO_ENABLED=0
export GO_EXTLINK_ENABLED=0

go get -u -v --ldflags '-extldflags "-static"' github.com/spf13/hugo