Config for GoLang返回“非名称”错误

I am having trouble compiling code Google-Cloud offers on connecting to a mysql database remotely using Golang.

The code is a direct copy-paste from here: https://cloud.google.com/sql/docs/mysql/connect-external-app#go. One may also look here: https://github.com/GoogleCloudPlatform/cloudsql-proxy/blob/master/proxy/dialers/mysql/hook_test.go.

I've tried providing a second variable to the first line below, but there is an error as only one value is returned by the mysql function.

The troublesome code is on the second line, possibly due to the first line.

cfg := mysql.Cfg("haveibeenexploited:us-west1:hibe", "username", "password")
cfg.DBName := "mythril"
db, err := mysql.DialCfg(cfg)

searchcontract/searchcontract.go:67:5: non-name cfg.DBName on left side of := is the error message I get.

Change this line of code:

cfg.DBName := "mythril"

to:

cfg.DBName = "mythril"

The := operator declares a new variable and assigns it a value. This is called "Short Variable Declarations". Since DBName is part of the structure cfg you are using the wrong operator. The correct operator to use is the assignment operator =.