Go语言必须以main函数作为入口
main函数不支持传入参数,main函数不支持返回值
package main
import (
"fmt"
"os"
)
func main() {
fmt.Println(os.Args)
if len(os.Args) > 1{
fmt.Println("Hello wolrd",os.Args[1])
}
fmt.Println("Hello Wolrd")
os.Exit(1)
}
The master has failed more times than the beginner has tried.
这篇博客介绍了Go语言程序的入口函数main(),强调了main函数不接受参数和返回值的特点。示例代码展示了如何获取命令行参数并根据参数数量打印不同信息,从而揭示了Go语言处理命令行参数的基本方法。
3091

被折叠的 条评论
为什么被折叠?



