Last active
April 27, 2019 20:05
-
-
Save nkhine/b758a68062a2b682eac562a975d05c18 to your computer and use it in GitHub Desktop.
if we want to use go like python and executed without gorun
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
``` | |
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