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

"go run" should be able to run a directory #20432

Closed
ahmetb opened this issue May 19, 2017 · 1 comment
Closed

"go run" should be able to run a directory #20432

ahmetb opened this issue May 19, 2017 · 1 comment

Comments

@ahmetb
Copy link

ahmetb commented May 19, 2017

What version of Go are you using (go version)?

1.8.1

Problem

When I want to run a Go program that is in ./app/ directory in my dev/test cycle, I have the following options:

  1. go build -o a.out ./program && ./a.out: I don't want to have binary files laying around
  2. go install ./program && $GOPATH/program: it takes two steps and too long to type.
  3. cd program; go run *.go: this doesn't work when I have _test.go files. (cmd/go: allow "go run" to run command in current directory #5164)

I think we should be able to point go run to a directory, as an alternative to a list of gofiles..., and run the whole directory.

It would be great if go run ./program or just go run . to execute the program in current working directory. go tool can easily detect if an argument is a go file or directory specification, then it can discover the go source files (excl. _test.go files) on the directory and then pass it as the gofiles... arg to the actual go run.

This has been previously reported at various forums:

I am opening a new issue to see if there is interest, or if the feasibility of making this change has changed in the meanwhile.

@ahmetb ahmetb changed the title "go run" should be able to run a directory. "go run" should be able to run a directory May 19, 2017
@bradfitz
Copy link
Contributor

Sorry, it has been repeatedly decided in the past not to extend the functionality of go run beyond basic "Hello, World" sorts of uses.

You can create aliases or wrapper scripts around go install (or Up+Enter) to ease the typing burden.

@golang golang locked and limited conversation to collaborators May 19, 2018
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

3 participants