Why are you using kill -9?  That doesn't allow the process any time to tidy 
up whilst exiting.

But also see https://go.dev/testing/coverage/#FAQ

"If my program panics, will coverage data be written?

Programs built with go build -cover will only write out complete profile 
data at the end of execution if the program invokes os.Exit() or returns 
normally from main.main. If a program terminates in an unrecovered panic, 
or if the program hits a fatal exception (such as a segmentation violation, 
divide by zero, etc), profile data from statements executed during the run 
will be lost."

On Tuesday, 11 July 2023 at 14:17:18 UTC+1 savita juyal wrote:

> Hello All,
>
> I am trying to collect integration test coverage but its not generating 
> covcounters file. Please looks steps I am following to generate covearge.
>
> - *Build go binary* : go build -race -*cover* -o 
> $(ROOT)/go/bin/appwithrace -ldflags "-X app/handler.proxyVersion=$(VERSION) 
> -X app/handler.gitVersion=$(GITVERSION) -X 
> app/handler.buildTime=$(BUILDTIME)" cmd/proxy/proxy.go
>
> - *Run go binary* : ENABLE_TLS=false ENABLE_TLS_TO_DB=false 
> LOAD_BALANCED=false *GOCOVERDIR=./coverage/int *./go/bin/appwithrace 2>&1 
> >/dev/null &
>
> - *Exit go program* : Kill -9 go_process_id
>
> Now we only covmetadata file generated under the given path. Please me 
> know what I am doing wrong or if I am missing something?
>
> Regards
> Savita Juyal
>
>
>
>
>
>

-- 
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/83281291-dda6-4a30-8989-1d7157e8e757n%40googlegroups.com.

Reply via email to