Consider using `runtime/debug.BuildInfo` if build info not build with make.sh
With go now embedding build versions into the binary, this could be used if built from:
go install github.com/rfjakob/gocryptfs/v2@latest
Here is an example dump of what is present in each build:
/home/d/bin/gocryptfs: go1.19
path github.com/rfjakob/gocryptfs/v2
mod github.com/rfjakob/gocryptfs/v2 v2.2.1 h1:TzjjmN4tnRWffddDpG846lhMo63d4JQcWL8uZqnX1T0=
dep github.com/hanwen/go-fuse/v2 v2.1.1-0.20210825171523-3ab5d95a30ae h1:4CB6T4YTUVvnro5ba8ju1QCbOuyGAeF3vvKlo50EJ4k=
dep github.com/jacobsa/crypto v0.0.0-20190317225127-9f44e2d11115 h1:YuDUUFNM21CAbyPOpOP8BicaTD/0klJEKt5p8yuw+uY=
dep github.com/rfjakob/eme v1.1.2 h1:SxziR8msSOElPayZNFfQw4Tjx/Sbaeeh3eRvrHVMUs4=
dep github.com/sabhiram/go-gitignore v0.0.0-20201211210132-54b8a0bf510f h1:8P2MkG70G76gnZBOPGwmMIgwBb/rESQuwsJ7K8ds4NE=
dep github.com/spf13/pflag v1.0.5 h1:iy+VFUOCP1a+8yFto/drg2CJ5u0yRoB7fZw3DKv/JXA=
dep golang.org/x/crypto v0.0.0-20210817164053-32db794688a5 h1:HWj/xjIHfjYU5nVXpTM0s39J9CbLn7Cc5a7IC5rwsMQ=
dep golang.org/x/sys v0.0.0-20210817190340-bfb29a6856f2 h1:c8PlLMqBbOHoqtjteWm5/kbe6rNY2pbRfbIMVnepueo=
dep golang.org/x/term v0.0.0-20210615171337-6886f2dfbf5b h1:9zKuko04nR4gjZ4+DNjHqRlAJqbJETHwiNKDqTfOjfE=
build -compiler=gc
build CGO_ENABLED=1
build CGO_CFLAGS=
build CGO_CPPFLAGS=
build CGO_CXXFLAGS=
build CGO_LDFLAGS=
build GOARCH=amd64
build GOOS=linux
build GOAMD64=v1
This could be used where it currently print out:
gocryptfs [GitVersion not set - please compile using ./build.bash]; go-fuse [GitVersionFuse not set - please compile using ./build.bash]; 0000-00-00 go1.19 linux/amd64
The build date would not be present, but that isn't possible to have and have reproducible builds.
Good idea, looks like this added in Go 18: https://go.dev/doc/go1.18 . I currently support Go 1.13 and later, so this will likely have to wait a while
Sure, if you want I could send a PR that conditional compiles for 1.18+ that will use the data if none otherwise available.
Yes, nice!
@rfjakob PR #701 pushed. I discovered that the build information struct and function appears to be present from Go1.12. Your go.mod lists go1.16 and the CI goes back to Go1.13, so I didn't bother with a conditional build. It would still be easy to add if the CI finds a problem.