There is another way to execute your Go code that does not create any permanent executable files – it just generates some intermediate files that are automatically deleted afterward.
The way presented allows you to use Go as if it is a scripting programming language like Python, Ruby, or Perl.
So, in order to run aSourceFile.go without creating an executable file, you will need to execute the following command:
$ go run aSourceFile.go This is a sample Go program!
As you can see, the output of the preceding command is exactly the same as before.
Please note that with go run, the Go compiler still needs to create an executable file. It is because you do not see it, it is automatically executed, and it is automatically deleted after the program has finished that you might think that there is no need for an executable file.
This book mainly uses go run to execute the example code; primarily because it is simpler than running go build and then executing the executable file. Additionally, go run does not leave any files on your hard disk after the program has finished its execution.