There is possibly a way to do this by parsing strings in the binary. Because when -cover is enabled, go will insert instrumentation statements into the source code, thus the resulting binary would contain these info.
On May 14, 2024, at 17:19, Akash Kumar <meakash7...@gmail.com> wrote:
I unable to find a flag from corresponds to -cover in the result returned from debug.buildInfo On Monday, May 13, 2024 at 10:51:33 PM UTC+5:30 Tamás Gulácsi wrote:
runtime/debug.ReadBuildInfo is a good source of truth:
$ strings bin/godeb|grep '^build\s'
build -buildmode=exe build -compiler=gc build DefaultGODEBUG=httplaxcontentlength=1,httpmuxgo121=1,panicnil=1,tls10server=1,tlsrsakex=1,tlsunsafeekm=1 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 build -buildmode=exe build -compiler=gc build DefaultGODEBUG=httplaxcontentlength=1,httpmuxgo121=1,panicnil=1,tls10server=1,tlsrsakex=1,tlsunsafeekm=1 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
Akash Kumar a következőt írta (2024. május 13., hétfő, 18:42:30 UTC+2):
I am writing an external go program that will take the path to another go binary as argument, and checks if the binary was built with cover flag.
`debug.ReadBuildInfo()` is meant for getting build info embedded in the running binary as > ReadBuildInfo returns the build information embedded in the running binary
On Monday, May 13, 2024 at 6:37:46 PM UTC+5:30 Zxilly Chou wrote:
try debug.ReadBuildInfo(), then iterate the pair in the buildinfo.Settings
在2024年5月13日星期一 UTC+8 20:56:51<Akash Kumar> 写道:
Is there a way in go to find whether a go binary is built with -cover flag ?
--
You received this message because you are subscribed to the Google Groups "golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscr...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/golang-nuts/9fda396a-b79e-4b9e-9bc0-13a9cef2c921n%40googlegroups.com.
--
You received this message because you are subscribed to the Google Groups "golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscr...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/golang-nuts/50BA2D36-E4D4-4BE1-9117-A7BA15E17446%40gmail.com.
|