Use `go run .` instead - it's shorter and it works with multiple files
Use `go run .` instead - it's shorter and it works with multiple files
I feel like there are two relatively distinct populations of go developer: those who love how easy it is to start (true!) and those who are frustrated by the compromises the language has made to allow for more complex cases (required!). There's also a hidden third population of people who no longer sing the praises of golang as a simple, straightforward language but accept its compromises and write productive code with it. Those people, I think, write fewer viral blog posts.
The problem is many Go tutorials start out by teaching the complex case first and leave the simple case to later (if they cover it at all).
Introducing the concept of "packages", and the fact that the directory is a package, can be deferred until later.
Either could be desirable or undesirable depending on your goals. It's good to be aware of the dynamics so that you can make an informed choice about how to present your code.
The main benefit is that you can easily figure out what is where!
Navigating unfamiliar Go codebases yields very few surprises: things are almost always where I expect to find them, and it's great! This is hardly the case with other languages, where I have to rely on grep or trace function-calls
> Potential design based on discussion with proposal review:
> go run [go flags] [single-package-or-*.go-list] [subprocess flags]
before that it was just
> go run [go flags] [*.go-list] [subprocess flags]
go help run
"usage: go run [build flags] [-exec xprog] package [arguments...]Run compiles and runs the named main Go package. Typically the package is specified as a list of .go source files from a single directory, but it may also be an import path, file system path, or pattern matching a single known package, as in 'go run .' or 'go run my/cmd'."
Nothing is said about go run main.go.
$ go run ./cmd/pathto/cli(long time I didn't use Go, back then at least, using `.` instead of `./...` could cause subtle issues)