One way to do it would be to put the functions you don’t want tested in a separate go file, and use a build tag to keep it from being included during tests. For example, I do this sometimes with applications where I have a main.go
file with the main function, maybe a usage function, etc., that don’t get tested. Then you can add a test tag or something, like go test -v -cover -tags test
and the main might look something like:
//+build !test
package main
func main() {
// do stuff
}
func usage() {
// show some usage info
}