Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

Note that it was already possible before with a command like:

    go test -coverpkg=./... -c . -o main.test
This command builds a test binary with a coverage config. So if you run it, launch your tests, and stop it gracefully, it will spit out a coverage report.

I’m not exactly sure what the change in Go 1.20 is about, maybe it’s easier somehow, I’ll have to try it.



That's not the same. `go test -c` builds a binary that runs your tests, whereas (if I understand correctly) the new thing builds a binary that runs your main(). If it works as I understand, that would be fantastic because then I could get rid of this monstrosity: https://github.com/holocm/holo/blob/master/main_test.go




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: