gorun
⇤ ← Revision 1 as of 2011-03-11 22:02:10
2270
Comment:
|
2272
|
Deletions are marked like this. | Additions are marked like this. |
Line 14: | Line 14: |
Contents
What is it?
The gorun project enables Go programs to be used in a way resembling so called "scripting" languages. To make use of it, simply put the gorun command location at the top of a Go source file, and make it executable.
Example
As an example, copy the following content to a file named "hello.go" (or "hello", if you prefer):
package main func main() { println("Hello world!") }
Then, simply run it:
$ chmod +x hello.go $ ./hello.go Hello world!
Is it slow?
No, it's not, thanks to the Go (gc) compiler suite, which compiles code surprisingly fast.
Here is a trivial/non-scientific comparison with Python:
$ time ./gorun hello.go Hello world! ./gorun hello.go 0.03s user 0.00s system 74% cpu 0.040 total $ time ./gorun hello.go Hello world! ./gorun hello.go 0.00s user 0.00s system 0% cpu 0.003 total $ time python -c 'print "Hello world!"' Hello world! python -c 'print "Hello world!"' 0.01s user 0.00s system 63% cpu 0.016 total $ time python -c 'print "Hello world!"' Hello world! python -c 'print "Hello world!"' 0.00s user 0.01s system 64% cpu 0.016 total
Note how the second run is significantly faster than the first one. This happens because a cached version of the file is used after the first compilation.
gorun will correctly recompile the file whenever necessary.
Where are the compiled files kept?
They are kept under the ~/.gorun directory.
You can remove these files, but there's no reason to do this. These compiled files will be garbage collected by gorun itself when they stop being used. This is done in a fast and safe way so that concurrently executing scripts will not fail to execute.
How to build and install gozk
First, obtain the code from Launchpad:
$ bzr branch lp:gorun
Then, build it:
$ cd gorun $ make
Reporting bugs
Please report bugs at:
License
gorun is licensed under the GPL.
Contact
To get in touch, send a message to gustavo.niemeyer@canonical.com
gorun (last edited 2012-06-10 22:34:14 by 200-203-57-54)