Reputation: 34081
I am working on my webapplication and using the revel framework. To execute an revel application, I run the following code
revel run myapp
Now, I am really wonder how revel approximately works. My question is, how do revel framework execute myapp with many go files, that I wrote for the application? Is revel a virtual machine?
How can I write an application in Go and read Go files and execute it?
Upvotes: 0
Views: 78
Reputation: 91
Revel is not a virtual machine. Infact it's a framework in Go.
As the home page of Revel says:
Hot Code Reload
Edit, save, and refresh. Revel compiles your code and templates for you, so you don't miss a beat. Code doesn't compile? It gives you a helpful description. Run-time code panic? Revel has you covered.
Upvotes: 0
Reputation: 24818
Revel is a pre-processor rather than a framework. It abstracts Go's workings away and introduces it's own code structure and concepts. This is generally frowned upon in the Go community but that's not the topic of your question and so neither will I make it that of this answer.
The way it does that is by combining your code with boilerplate of its own and compiling everything together.
How can I write an application in Go and read Go files and execute it?
Either you write a REPL or you do like Revel and just make an application which will compile other Go applications through the use of the Go compiler suite.
Edit to answer question in the comments: Revel itself is a pretty good example. here on line 73 it executes go build
with some flags and sets the output to binName
which is a path to a temporary file.
Upvotes: 2
Reputation: 5676
No, revel is not a virtual machine. Revel recompile your source code when you modify it.
That is described in features on http://revel.github.io/
Hot Code Reload Edit, save, and refresh. Revel compiles your code and templates for you, so you don't miss a beat. Code doesn't compile? It gives you a helpful description. Run-time code panic? Revel has you covered.
Go sources compiles very fast, so it becomes possible
Upvotes: 3