SYNOPSIS
golo shebang main_file arguments …
DESCRIPTION
This commands ease the use of golo programs as executable simple scripts.
EXAMPLES
module hello
function main = |args| {
require(args: length() > 1, "You should set at least one argument!")
println("Hello " + args: get(1) + " from '" + args: get(0) + "'!")
}
the script above can be executed with:
$ golo shebang hello.golo World
Hello World from 'hello.golo'!
$
Naturally the main goal is to use this command to make the script self-executable:
#!/path/to/golo shebang
module hello
function main = |args| {
require(args: length() > 1, "You should set at least one argument!")
println("Hello " + args: get(1) + " from '" + args: get(0) + "'!")
}
Now, we can run the script directly:
$ chmod +x hello.golo $ ./hello.golo World Hello World from 'hello.golo'! $
Golo also provides golosh(1) script that is a shortcut for the golo shebang
command, thus
a golo script can be hasbanged with env
:
#!/usr/bin/env golosh
module hello
function main = |args| {
require(args: length() > 1, "You should set at least one argument!")
println("Hello " + args: get(1) + " from '" + args: get(0) + "'!")
}
PITFALLS
Each golo
and jar
files present in the script file’s directory or the sub directories will be scanned.
This makes it easy to run scripts and have an automatic classpath for libraries, and automatically compile and load other Golo files.
However, be aware that this may lead to surprising errors if you run code from, say, a clone of the Golo source code repository since it contains duplicated type and module definitions, as well as files from the test suite that have errors on purpose.
SEE ALSO
golo-golo(1), golosh(1)
BUGS
See https://github.com/eclipse/golo-lang/issues for issues.
AUTHOR
See https://github.com/eclipse/golo-lang/graphs/contributors or the CONTRIBUTORS
file in the golo source distribution.
COPYRIGHT
This work is made available under the terms of the Eclipse Public License 2.0.
See http://www.eclipse.org/legal/epl-2.0 or the LICENCE
file in the golo source distribution.