Skip to content

Instantly share code, notes, and snippets.

@nkhine
Last active April 27, 2019 20:05
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save nkhine/b758a68062a2b682eac562a975d05c18 to your computer and use it in GitHub Desktop.
Save nkhine/b758a68062a2b682eac562a975d05c18 to your computer and use it in GitHub Desktop.
if we want to use go like python and executed without gorun
```
echo ':golang:E::go::/usr/local/bin/gorun:OC' | sudo tee /proc/sys/fs/binfmt_misc/register
:golang:E::go::/usr/local/bin/gorun:OC
```
```
package main
import (
"fmt"
"os"
)
func main() {
s := "world"
if len(os.Args) > 1 {
s = os.Args[1]
}
fmt.Printf("Hello, %v!", s)
fmt.Println("")
if s == "fail" {
os.Exit(30)
}
}
```
```
chmod u+x hello.go
```
https://www.kernel.org/doc/html/v4.14/admin-guide/binfmt-misc.html
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment