For quick hacking, I prefer to use go run prog.go ...
instead of building the executable first. However, the program I am working on should take another go-file as an argument. As a consequence, go run
and the compiled binary behave differently:
go run prog.go foo.go
will try to execute both go-files, whereas
go build prog.go && ./prog foo.go
will correctly take my file as input (the intended behaviour). Now I can pass additional args like this go run ... -- foo.go
, but then because of the --
the position of the file differs in os.Args
between the go run prog.go -- foo.go
and the ./prog foo.go
. Any easy solution? I'd like to avoid having full flag-processing. Should I just give up and stick to the compiled version?