What's the appropriate Go shebang line?

后端 未结 6 763
情书的邮戳
情书的邮戳 2021-02-01 01:55

I like using shebangs to run my Perl scripts directly:

#!/usr/bin/env perl

What\'s the shebang for Go programs?

6条回答
  •  梦谈多话
    2021-02-01 02:04

    //usr/bin/go run $0 $@ ; exit

    example:

    //usr/bin/go run $0 $@ ; exit
    package main
    
    import "fmt"
    
    func main() {
        fmt.Println("Hello World!")
    }
    

    go treat // as a single line comment and shell ignore extra /

提交回复
热议问题