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

iridescent
  • 383
  • 1
  • 13
buildmaestro
  • 1,386
  • 5
  • 22
  • 37

1 Answers1

1

Use the *Var methods to set set values to existing variables from flags, in this case you want flag.StringVar

destDbCfg = &dbhelper.DbConfig{}

flag.StringVar(&destDbCfg.Database, "destDBName", "", "Destination DB Database Name")
flag.Parse()
JimB
  • 104,193
  • 13
  • 262
  • 255