Shell one-liner: Difference between revisions

→‎{{header|Go}}: update for current go tooling, remove solution using gorun, which didn't add anything relevant to the task
(omit SAS & Stata)
(→‎{{header|Go}}: update for current go tooling, remove solution using gorun, which didn't add anything relevant to the task)
Line 294:
 
=={{header|Go}}==
<lang bash>echo 'package main;func main(){println("hllowrldhlowrld")}'>/tmp/8h.go;gorungo run /tmp/8h.go</lang>
Go is first of all a compiled language and currently comes with no support for running as a script language. The compiler and linker can of course be run from a command line shell, as in,
{{out}}
<lang bash>echo 'package main;func main(){println("hllowrld")}'>8.go;8g 8.go;8l 8.8;8.out</lang>
This will overwrite existing files in the current directory 8.go, 8.8, and 8.out, assuming of course, that the the current directory is even writable, and will leave these files behind after executing.
 
Running Go as a script language is a popular request however, and one of the better solutions currently is [https://wiki.ubuntu.com/gorun gorun]. Gorun has solutions for the temporary file problem, writing to best-guess temporary directories by default and having an option to specify the location when this is needed or desired. Gorun still expects to read the source code from a file however, so you are on your own to deal with this before passing the file to gorun. Example,
<lang bash>echo 'package main;func main(){println("hllowrld")}'>/tmp/8.go;gorun /tmp/8.go</lang>
Output from either example:
<pre>
hlowrld
hllowrld
</pre>
 
1,707

edits