dongwuzun4630 2018-06-09 06:08
浏览 91
已采纳

指定reflect.ValueOf应该返回什么值

I have a struct such as this:

type Time struct {
    Time time.Time
    Valid bool
}

Now if I call reflect.ValueOf() on a Time struct initialized with, say time.Now() and false, I'll get the following results:

{2018-06-09 15:03:17.4320396 false}

Is there a way to alter the struct (add a method? rename the fields?) so that reflect would only return the time.Time value, but not the bool one ? Kind of like what the Valuer/Scanner interface does for SQL queries, but with reflect.

  • 写回答

1条回答 默认 最新

  • douxiyi2418 2018-06-09 07:25
    关注

    No this is not possible. Sorry.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 程序不包含适用于入口点的静态Main方法
  • ¥15 素材场景中光线烘焙后灯光失效
  • ¥15 请教一下各位,为什么我这个没有实现模拟点击
  • ¥15 执行 virtuoso 命令后,界面没有,cadence 启动不起来
  • ¥50 comfyui下连接animatediff节点生成视频质量非常差的原因
  • ¥20 有关区间dp的问题求解
  • ¥15 多电路系统共用电源的串扰问题
  • ¥15 slam rangenet++配置
  • ¥15 有没有研究水声通信方面的帮我改俩matlab代码
  • ¥15 ubuntu子系统密码忘记