6

I'm having a little difficulty transitioning from Python to Go and I've historically relied on built-in utility functions like Python's dir to list underlying methods and attributes.

Is there an equivalent in go?

Jonathan Hall
  • 75,165
  • 16
  • 143
  • 189
Onescriptkid
  • 182
  • 6
  • 3
    Have you seen [this answer](https://stackoverflow.com/a/41630530/8605514)? – Grajdeanu Alex Dec 28 '20 at 22:09
  • 6
    What is your higher level goal of getting the fields and methods? The `go doc` command, the [reflect package](https://godoc.org/reflect), or the [go/types](https://godoc.org/go/types) package may be appropriate depending on that goal. – Charlie Tumahai Dec 28 '20 at 22:16
  • 3
    Structs in Go are far more straightforward than classes in Python. They are just a data structure, and may have methods (all of which you can see plainly in the source package). There's no hidden magic to be revealed with further tools. If you want to understand more about a certain struct and the usage of it, read the documentation of the package it is in. – Hymns For Disco Dec 29 '20 at 04:34
  • 1
    I have edited your question to remove the last paragraph, which is off-topic on StackOverflow. The request for "snippets" is equivalent to an off-site resource request, and not permitted here. – Jonathan Hall Dec 29 '20 at 08:26
  • The best i found was to use Visual Studio code with the GO addon. All functions are links that jumps to libraries source code and in GO almost everything is a library. The library's are most of the time well explained and does also show all methods & attributes. – Dippo Dec 29 '20 at 16:51

0 Answers0