go命令行参数例子:
package main import( "fmt" "os" "strings" ) func main(){ who := "World!" //有参数通过空格隔开 if len(os.Args) > 1 { who = strings.Join(os.Args[1:], " ") } fmt.Println("Hello", who) }
执行效果如下:
2024-02-28 14:17:10
go命令行参数例子:
package main import( "fmt" "os" "strings" ) func main(){ who := "World!" //有参数通过空格隔开 if len(os.Args) > 1 { who = strings.Join(os.Args[1:], " ") } fmt.Println("Hello", who) }
执行效果如下: