1

How can I assign the string value returned by flag into my struct? I have the following code.

destDbCfg = &dbhelper.DbConfig {}

destDbCfg.Database = flag.String( "destDBName", "", "Destination DB Database Name")
flag.Parse()

Database is a string

4

1 回答 1

1

使用这些*Var方法将设置值设置为标志中的现有变量,在这种情况下,您需要flag.StringVar

destDbCfg = &dbhelper.DbConfig{}

flag.StringVar(&destDbCfg.Database, "destDBName", "", "Destination DB Database Name")
flag.Parse()
于 2018-07-18T01:36:28.243 回答