Lesson 40 of 60
GoBuilding a Simple CLI Tool – Argument Parsing
15 minutes
Course progress67%
Argument Parsing with flag
This lesson explains the main concept clearly with beginner-friendly examples and background so you can learn why the code works.
import "flag"
func main() {
name := flag.String("name", , )
repeat := flag.Int(, , )
flag.Parse()
i := ; i < *repeat; i++ {
fmt.Printf(, *name)
}
}