2012-09-22 01:54
浏览 71

在Data :: Dumper中是否有与Perls的Dumper()方法等效的Go语言?

I've looked at the very similarly titled post (Is there a C equivalent to Perls' Dumper() method in Data::Dumper?), regarding a C equivalent to Data::Dumper::Dumper();. I have a similar question for the Go language.

I'm a Perl Zealot by trade, and am a progamming hobbyist, and make use of Data::Dumper and similar offspring literally hundreds of times a day. I've taken up learning Go, because it looks like a fun and interesting language, something that will get me out of the Perl rut I'm in, while opening my eyes to new ways of doing stuffz... One of the things I really want is something like:


to see the resulting data structure, like Data::Dumper would turn the JSON into an Array of Hashes. Seeing this in Go, will help me to understand how to construct and work with the data. Something like this would be considered a major lightbulb moment in my learning of Go.

Contrary to the statements made in the C counterpart post, I believe we can write this, and since I'll be passing Dumper to Println, after compilation what ever JSON string or XML page I pass in and decode. I should be able to see the result of the decoding, in a Dumper like state... So, does any more know of anything like this that exists? or maybe some pointers to getting something like this done?

图片转代码服务由CSDN问答提供 功能建议

我看过标题非常相似的帖子(关于Data :: Dumper中的Perls的Dumper()方法是否存在C等效项?), 一个等效于 Data :: Dumper :: Dumper(); 的C。 对于Go语言,我也有类似的问题。

我是一名Perl狂热者,是一名编程爱好者,并且使用了 Data :: Dumper 和类似的后代,每天实际上要进行数百次。 我开始学习Go,因为它看起来像是一种有趣的有趣语言,它会让我从所从事的Perl车辙中脱颖而出,同时也让我看到了新的做事方式。 我真的想要这样的东西:


to 请参见生成的数据结构,例如 Data :: Dumper 会将JSON转换为哈希数组。 在Go中看到这一点,将有助于我理解如何构造和使用数据。

与之类似的这样的事情将被视为我学习Go的主要灯泡时刻。与 C 对应文章中的陈述相反,我相信我们可以写 这样,由于我将Dumper传递给Println,所以在编译之后,无论什么JSON字符串或XML页面,我都会传递并解码。 我应该能够在类似Dumper的状态下看到解码的结果...那么,是否还知道这样的存在? 还是一些指向完成此操作的指示?

  • 写回答
  • 好问题 提建议
  • 追加酬金
  • 关注问题
  • 收藏
  • 邀请回答

3条回答 默认 最新

  • duanhuoyao7011 2014-01-31 19:33

    I found a couple packages to help visualize data in Go.

    My personal favourite - https://github.com/davecgh/go-spew

    There's also - https://github.com/tonnerre/golang-pretty

    解决 无用
    打赏 举报
  • 查看更多回答(2条)

相关推荐 更多相似问题