我爱占星网 我爱占星网
首页
编程
java
php
前端
首页 编程 java php 前端

标志返回到我的结构的值

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

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()

近期文章

  • 一对多关联无效
  • 在读取json数据时动态识别对象的类型
  • 样品无需更换在golang中
  • go_lang中的“制作” TLS客户端Hello
  • 通过操作员框架对K8s Pod进行负载平衡
  • 将整个golang包推送到github
  • AWS单个会话还是多个会话?
  • RabbitMQ Go教程日志。Printf无法写入磁盘文件?
  • 为什么建议使用ctx作为第一个参数?
  • Go中具有动态类型(空接口)的XML Unmarshal
  • GORM中的一对多递归关系
  • 如何找到函数类型的实现?
  • 在GoTour并发教程中为何需要Goroutines的解释
  • Go Dep无法解析“ golang.org/x/crypto”
  • 如何解决此程序中打印出的JSON数据?
  • 我如何将动态Viper或JSON键解组为Go中的struct字段的一部分
  • 从Google存储设备加载文件时在bigquery中使用.Run(ctx)复制记录
  • 无法在Gobuffalo中验证并创建模型
  • 包含其他目录中的模板
  • golang创建多级字符串映射

Copyright ©2022 我爱占星 All Rights Reserved.

浙ICP备2022030071号-1

部分图文来自网络,如有侵犯您的版权,请告诉我们删除

友情链接:代码精华