Finding functions that return a specific type

前端 未结 2 950
走了就别回头了
走了就别回头了 2020-12-20 02:52

Perhaps this is a silly question, but is there a way to find all functions (in the standard library or GOPATH) that return a specific type?

For example there are man

2条回答
  •  我在风中等你
    2020-12-20 03:40

    In my days coding I'm personally rare in need to find functions returning Int16 and error(func can return few values in Go, you know)

    For second part of your question there exists wonderful cmd implements written by Dominik Honnef go get honnef.co/go/implements After discover type that satisfy your conditions you can assume constructor for type (something like func NewTheType() TheType) would be just after TheType declaration in source code and docs. It's a proven Go practice.

提交回复
热议问题