How to test the passing of arguments in Golang?
问题 package main import ( "flag" "fmt" ) func main() { passArguments() } func passArguments() string { username := flag.String("user", "root", "Username for this server") flag.Parse() fmt.Printf("Your username is %q.", *username) usernameToString := *username return usernameToString } Passing an argument to the compiled code: ./args -user=bla results in: Your username is "bla" the username that has been passed is displayed. Aim: in order to prevent that the code needs to be build and run manually