On Thu, Apr 11, 2019 at 10:57 AM hui zhang wrote:
> How to resolve this ?
If you're not using any options in your program, just the arguments,
you may do this:
$ cat main.go
package main
import (
"flag"
"fmt"
)
func main() {
flag.Parse()
fmt.Println(flag.NArg()
my program take 4 args like
./myprogram 1 2 3 4
*args_len=: 5*
I want to test this program coverage so
go test -coverprofile coverage.out -args 1 2 3 4
myprogram_test.go
func Test_main(m *testing.T) {
main()
}
DEBUG args=
[/var/folders/cp/561_gl9j1wzd8dgv_fn5mk7cgn/T/go