Go master branch gives 'flag provided but not defined: -race'

2,799 views
Skip to first unread message

Gyu-Ho Lee

unread,
Dec 3, 2015, 8:10:07 PM12/3/15
to golang-nuts, Xiang Li
Could anybody help figure out what I am doing wrong? Is this Go issue or am I using the
test flags in a wrong way?

You can reproduce with:

`./godev` is the most recent Go binary built from source.
`go` is Go 1.5.2.

[FAILS with flag provided but not defined: -race]
./godev test -timeout 3m -cover github.com/coreos/etcd/client --race -cpu 1,2,4;

[SUCCESS]
./godev test -timeout 3m -cover --race -cpu 1,2,4 github.com/coreos/etcd/client;

[SUCCESS]
go test -timeout 3m -cover github.com/coreos/etcd/client --race -cpu 1,2,4;

[SUCCESS]
go test -timeout 3m -cover --race -cpu 1,2,4 github.com/coreos/etcd/client;


I am posting this because I couldn't find any related issues in Golang github.

Thanks all!

Dave Cheney

unread,
Dec 3, 2015, 10:00:34 PM12/3/15
to golang-nuts, xiang...@gmail.com
it looks like there are two hypens before the word race, it should be one.

Gyu-Ho Lee

unread,
Dec 3, 2015, 10:07:40 PM12/3/15
to Dave Cheney, Xiang Li, golang-nuts

Thanks Dave! Weird that it only breaks with go tip and go standard flag package only supports double hyphens.

Sincerely,
Gyu-Ho Lee

--
You received this message because you are subscribed to a topic in the Google Groups "golang-nuts" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/golang-nuts/MT4_KDSHLNc/unsubscribe.
To unsubscribe from this group and all its topics, send an email to golang-nuts...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Gyu-Ho Lee

unread,
Dec 3, 2015, 10:08:36 PM12/3/15
to Dave Cheney, Xiang Li, golang-nuts

Sorry meant to say
*also supports double hypens

Sincerely,
Gyu-Ho Lee

Gyu-Ho Lee

unread,
Dec 3, 2015, 10:41:39 PM12/3/15
to golang-nuts, xiang...@gmail.com
I just tried

./godev test -timeout 3m -cover github.com/coreos/etcd/client -race -cpu 1,2,4;

It also fails:

flag provided but not defined: -race


Dave Cheney

unread,
Dec 3, 2015, 11:05:25 PM12/3/15
to golang-nuts
Flags have to come before the name of the package, otherwise they are passed to the package itself.

Gyu-Ho Lee

unread,
Dec 3, 2015, 11:40:59 PM12/3/15
to Dave Cheney, golang-nuts
Thanks Dave! Do we have any documentation on this? It's weird that we 
never noticed it until now.

On Thu, Dec 3, 2015 at 8:05 PM, Dave Cheney <da...@cheney.net> wrote:
Flags have to come before the name of the package, otherwise they are passed to the package itself.
--
You received this message because you are subscribed to a topic in the Google Groups "golang-nuts" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/golang-nuts/MT4_KDSHLNc/unsubscribe.
To unsubscribe from this group and all its topics, send an email to golang-nuts...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.



--
Sincerely,
Gyu-Ho Lee

Dave Cheney

unread,
Dec 3, 2015, 11:43:04 PM12/3/15
to Gyu-Ho Lee, golang-nuts
Yup, see the godoc for the flag package

"Flag parsing stops just before the first non-flag argument ("-" is a non-flag argument) or after the terminator "--".


Gyu-Ho Lee

unread,
Dec 3, 2015, 11:45:11 PM12/3/15
to Dave Cheney, golang-nuts
Got it. Thanks Dave!
--
Sincerely,
Gyu-Ho Lee

Reply all
Reply to author
Forward
0 new messages