Home > Software design >  How do I get all the functions that are available in a Golang package?
How do I get all the functions that are available in a Golang package?

Time:07-20

How can I get all list of functions that are available in the package, For example in time package, When I click the link to list the package functions it is listing only a few functions.

There are functions which are documented under types which are not listed under the package functions.

For example:

func ParseDuration(s string) (Duration, error)

Which appears under type Duration is not listed. I believe this is the case for all the packages in Golang, if this is the case, how can I find out all package functions quickly?

Do you have some tips? Thanks in advance, Naga

CodePudding user response:

Use the go doc command to list functions in a package:

go doc -short time | grep "func "
  •  Tags:  
  • go
  • Related