Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cmd/go: go run x_test.go compiles nothing #4032

Closed
gopherbot opened this issue Sep 1, 2012 · 5 comments
Closed

cmd/go: go run x_test.go compiles nothing #4032

gopherbot opened this issue Sep 1, 2012 · 5 comments
Milestone

Comments

@gopherbot
Copy link

by d.wright.dev:

'go run' invokes 'go test' when source filename ends with *_test.go

What steps will reproduce the problem?

1. create a new go source file 'filename.go' with an arbitrary program
2. run 'go run filename.go'

What is the expected output?

output of go run

What do you see instead?

> can't load package: package <package>: use of cgo in test
/path/to/file/using/cgo/dlbug_fail_test.go not supported

Which compiler are you using (5g, 6g, 8g, gccgo)?

8g

Which operating system are you using?

OS X 10.8.1 (12B19)

Which version are you using?  (run 'go version')

go version go1.0.2

Please provide any additional information below.
@rsc
Copy link
Contributor

rsc commented Sep 1, 2012

Comment 1:

My guess is that your filename.go imports "path/to/file/using/cgo". The go command here
is telling you that it cannot process that package, due to issue #4030. I don't think go
run is invoking go test.

Status changed to WaitingForReply.

@gopherbot
Copy link
Author

Comment 2 by d.wright.dev:

It's definitely running go test:
go run not_a_test.go 
>runtime.main: undefined: main.init
>runtime.main: undefined: main.main
go run not_a_varmint.go
>But I'm not a test!

Attachments:

  1. not_a_test.go (83 bytes)
  2. not_a_varmint.go (83 bytes)

@rsc
Copy link
Contributor

rsc commented Sep 1, 2012

Comment 3:

It is not running 'go test'. However, it is omitting the _test.go files from the list,
like it would omit them from a directory listing, meaning that it compiles nothing at
all. 
I am not sure whether we will support 'go run x_test.go' - it breaks some of the
symmetry with other commands - but at the least we should give a better error in this
case.

Labels changed: added priority-later, go1.1, removed priority-triage.

Status changed to Accepted.

@rsc
Copy link
Contributor

rsc commented Dec 10, 2012

Comment 4:

Labels changed: added size-m.

@rsc
Copy link
Contributor

rsc commented Jan 31, 2013

Comment 5:

This issue was closed by revision 8b6534b.

Status changed to Fixed.

@rsc rsc added this to the Go1.1 milestone Apr 14, 2015
@rsc rsc removed the go1.1 label Apr 14, 2015
@golang golang locked and limited conversation to collaborators Jun 24, 2016
This issue was closed.
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

2 participants