如何在Golang的sql.open函数中调用变量

How do I achieve replacing of the practice of calling actual password in above code with a variable.

pwd := "password"
    db, err := sql.Open("mysql", "root:pwd@/events")
if err != nil {
    fmt.Printf("Error: Failed to connect events schema. 
")
    return
}
defer db.Close()

Instead of using the hardcoded string, use fmt.Sprintf:

pwd := "password"
db, err := sql.Open("mysql", fmt.Sprintf("root:%s@/events", pwd))

Docs: https://golang.org/pkg/fmt/#Sprintf

Simple GoPlay: https://play.golang.org/p/TKSvTuD8BY