How to find out if the *main* function is started by executing the compiled 
binary or by *go run*?

By examining *os.Args* it can be seen at the first case (running the app) 
we will have the *binary name* as the first argument without any path and 
when it is started using go run, we will have something like 
*/tmp/go-build899137799/command-line-arguments/_obj/exe/appname* as the 
first argument.

Is this a reliable way for performing this task? To assume if the path is 
similar to this - for example using regex - it is running using go run?

*Motivation:*
The *go run* mode is used for some code generation - I've not tested if it 
works with *//go:generate go run main.go* or not; yet.

-- 
You received this message because you are subscribed to the Google Groups 
"golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to golang-nuts+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to