How to run go test on all test files in my project except for vendor packages

前端 未结 2 2019
面向向阳花
面向向阳花 2020-12-10 01:47

My project folder contains:

Makefile  README.md  component/  driver/  service/  vendor/  worker/

I\'d like to run go test on a

2条回答
  •  我在风中等你
    2020-12-10 02:18

    The -run pattern is matched only against the test identifier (not the filename); in principle you could do:

    go test -run TestFoo
    

    but when you'd have to add Foo to all your test function names, which you probably don't want.

    The ... wildcard excludes the ./vendor directory since Go 1.9, so you can now just run go test ./... and it won't include ./vendor.

提交回复
热议问题