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/aa819a76-2c8e-4b9a-b37d-92abd3ff2877n%40googlegroups.com.

Reply via email to