goscript allows to use Go like if were a script language.
Internally, it compiles and links the script file whose executable is saved in the subdirectory ".go", then it is run. If that executable does not exist or its modified time is different than script's, then it's compiled again.
There is not obligation to use an extension, but if it's used then you could use ".go" if you want syntax highlighting in your editor. Another extension to use could be ".gos" (Go Script); see directory misc for ".gos" syntax in editor gedit.
The use of Go scripts is especially useful:
- During learning
- For administration issues
- Boot init of operating systems
- Web developing; by example for the routing
- Interfaces of database models
$ git clone git://github.com/kless/goscript.git
$ cd goscript && ./Install.sh && cd -
Since the command env doesn't allow to pass any option to the interpreter, then the solution has been to create a link in /usr/bin/goscript. That link is created when installing with Install.sh.
Insert in the head of the Go Script:
#!/usr/bin/goscript
And set its executable bit:
$ chmod +x file.go
An example of Go script:
#!/usr/bin/goscript
package main
import (
"fmt"
)
func main() {
fmt.Println("Take it on the other side")
}
A special case is when there is any Go script into a shared filesystem with access from a heterogeneous network. Then, there is to call the Go script from your system so it can takes values about the system where is going to run:
$ /usr/bin/goscript -shared /path/to/shared-fs/file.go
Copyright 2010 The "goscript" Authors
See file AUTHORS and CONTRIBUTORS (if any).
Licensed under Simplified BSD License.
See file LICENSE.
To contact, send e-mail through github.
To reporting bugs, please login and create a new issue here.
For credits, see file AUTHORS and CONTRIBUTORS (if any).
For changes between the commits, see the commit history.
Generated by gowizard