问题:
viper读入配置的app.start_time为:start_time=“2020-07-01”(string)
unmarshal到conf结构体中的StartTime(String)字段为空?

且Unmarshal后输出Conf结构体都为类型零值:

结果:

解决方案:
!!!!结构体定义错误!!!!
原来的定义:

type AppConfig struct {//无论config是什么类型(后缀名称),统一用mapstructure来表示tagName         string `mapstructure:"name"`Mode         string `mapstructure:"mode"`Port         int    `mapdtructure:"port"`*LogConfig   `mapstructure:"log"`*MysqlConfig `mapstructure:"mysql"`*RedisConfig `mapstructure:"redis"`
}

解决方案:把AppConfig拆出来,以后访问用:
Conf=new(multipleConfig)
Config.AppConfig.Start_time

var Conf = new(multipleConfig)type multipleConfig struct {*AppConfig   `mapstructure:"app"`*LogConfig   `mapstructure:"log"`*MysqlConfig `mapstructure:"mysql"`*RedisConfig `mapstructure:"redis"`
}type AppConfig struct {//无论config是什么类型(后缀名称),统一用mapstructure来表示tagName      string `mapstructure:"name"`Mode      string `mapstructure:"mode"`Port      int    `mapdtructure:"port"`Version   string `mapstructure:"version"`StartTime string `mapstructure:"start_time"`MachineId uint16 `mapstructure:"machine_id"`
}

go viper:init sonyflake failed,err:parsing time ““ as “2006-01-02“: cannot parse ““ as “2006“相关推荐

  1. Invocation of init method failed; nested exception is org.hibernate.InvalidMappingException: Could n

    今天在写ssh的时候遇到了一个这样的问题,连登陆页面都进不去了 报错信息如下: 严重: Exception sending context initialized event to listener ...

  2. Open /sys/bus/pci/devices/0000:01:00.0/driver/unbind failed. err 13 (Permission denied)

    问题描述 同事反馈在系统初始化时,写入设备驱动目录下的 unbind 文件将网卡从内核驱动解绑时会失败,报错信息如下: 200317 10:33:54.948 ERROR - Open /sys/bu ...

  3. initMNN: init numpy failed mnn笔记

    import MNN时报错: initMNN: init numpy failed 解决方法: pip uninstall numpy pip install numpy 报警: D:\Anacond ...

  4. Invocation of init method failed; nested exception is java.lang.NoClassDefFoundError: com/po/IdCard

    报错内容: Unsatisfied dependency expressed through field 'personDao'; nested exception is org.springfram ...

  5. Invocation of init method failed; nested exception is java.lang.IllegalStateException: Ambiguous map

    Invocation of init method failed; nested exception is java.lang.IllegalStateException: Ambiguous map ...

  6. ‘$connector-0‘: Invocation of init method failed; nested exception is java.net.BindException: Addres

    '$connector-0': Invocation of init method failed; nested exception is java.net.BindException: Addres ...

  7. nvocation of init method failed; nested exception is java.lang.AbstractMethodError: oracle.jdbc.driv

    .springframework.beans.factory.BeanCreationException: Error creating bean with name 'sqlSessionFacto ...

  8. redis集群中slot迁移的BUG:clusterManagerMoveSlot failed: ERR I don‘t know about node xx,解决办法如下文

    这个BUG很奇怪,先放BUG出现的图片吧 报错:clusterManagerMoveSlot failed: ERR I don't know about node xxx redis找不到他自己创建 ...

  9. Invocation of init method failed; nested exception is java.lang.IllegalArgumentException: Property

    来来来,记录一下阿里云Maven中央仓库的坑,当然最主要还是自身pom.xml设置问题. 昨天项目启动还好好的,为什么今天项目一启动就报错了呢?(线上项目服务器没重启的话也是正常可以访问的,只要一重启 ...

最新文章

  1. 【动画1】UIView动画
  2. dubbo被阿里放弃原因_中间件小姐姐直播“带货”——阿里程序员必知的插件
  3. vim尾部空格标红显示插件
  4. 组播理论知识的补充笔记
  5. python urlopen_Python爬虫教程-02-使用urlopen
  6. 光学定位与追踪技术_贺岁片《疯狂外星人》中徐峥出演外星人?幕后动捕技术了解一下...
  7. 阶段3 1.Mybatis_03.自定义Mybatis框架_6.自定义Mybatis的编码-实现基于XML的查询所有操作...
  8. python安装Jpype
  9. 贾玲,这次你是不是可以真的快乐了?
  10. google账号如何正确登陆
  11. 磁盘管理之动态磁盘和静态磁盘的区别
  12. 解决百度地图加载大量点卡顿
  13. 高速公路上边有没有人脸识别摄像头_支小蜜初高中智慧校园人脸识别消费系统...
  14. 1.27 Cubemx_STM32H7 软\硬件I2C
  15. QCon 北京|Apache Pulsar:云原生时代的消息服务
  16. 详细讲解Java整数类型
  17. jquery ajax json文件,jQuery ajax读取本地json文件
  18. el-checkbox点击没反应
  19. 元旦给计算机老师的贺卡,元旦贺卡给老师的祝福语(精选50句)
  20. Linux中的echo命令

热门文章

  1. Cocos 资料大全 下载链接地址
  2. 领域驱动实践总结(基本理论总结与分析+架构分析与代码设计+具体应用设计分析V)
  3. 下一代5G计算终端,正在你我的案头苏醒
  4. 华为云CDN节点扩增力度加大,构建全球智能边缘网络
  5. 当代化工研究杂志当代化工研究杂志社当代化工研究编辑部2022年第22期目录
  6. 服务器部署Nginx和Vue项目
  7. python画黑白线条_女朋友要你给她画个素描?不要慌,教你用Python分分钟弄出来!...
  8. windows api WSAStartup 使用
  9. 【专访间】数据堂共同创始人肖永红:大数据促进云落地
  10. 虚拟机服务器开启也显示内部错误,虚拟机内部错误怎么解决?-解决虚拟机提示“内部错误”的方法 - 河东软件园...