Documentation ¶
Index ¶
Examples ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var (
DocTruncationSize = 10
)
Functions ¶
Types ¶
type Config ¶ added in v0.4.0
type Config struct { SkipComments bool // if true, skip extracting argNames and comments FillArgNames bool // func(context.Context, int) -> func(ctx context.Context, arg0 int) FillReturnNames bool // func() (int, error) -> func() (ret0, err) IncludeGoTestFiles bool DocTruncationSize int Fset *token.FileSet // contains filtered or unexported fields }
Example ¶
package main import ( "fmt" reflectshape "github.com/podhmo/reflect-shape" ) // User is the object for User. type User struct { // name of User. Name string Age int // age of User. } // Hello function. func Hello(user *User /* greeting target */) { fmt.Println("Hello", user.Name) } func main() { cfg := reflectshape.Config{IncludeGoTestFiles: true} shape := cfg.Extract(User{}) fmt.Printf("%s %s %s %q\n", shape.Name, shape.Kind, shape.Package.Path, shape.Struct().Doc()) for _, f := range shape.Struct().Fields() { fmt.Printf("-- %s %q\n", f.Name, f.Doc) } shape2 := cfg.Extract(Hello) fmt.Printf("%s %s %s %q\n", shape2.Name, shape2.Kind, shape2.Package.Path, shape2.Func().Doc()) for _, a := range shape2.Func().Args() { fmt.Printf("-- %s %q\n", a.Name, a.Doc) } }
Output: User struct github.com/podhmo/reflect-shape_test "User is the object for User." -- Name "name of User." -- Age "age of User." Hello func github.com/podhmo/reflect-shape_test "Hello function." -- user "greeting target"
type Extractor ¶
type Func ¶ added in v0.4.0
type Func struct { Shape *Shape // contains filtered or unexported fields }
func (*Func) IsVariadic ¶ added in v0.4.0
type Named ¶ added in v0.4.0
type Named struct { Shape *Shape // contains filtered or unexported fields }
type Scope ¶ added in v0.4.0
type Scope struct {
// contains filtered or unexported fields
}
func (*Scope) NamesWithMethod ¶ added in v0.4.0
type Shape ¶
type Shape struct { Name string Kind reflect.Kind IsMethod bool ID ID Type reflect.Type DefaultValue reflect.Value Number int // If all shapes are from the same extractor, this value can be used as ID Lv int // pointer level. v is 0, *v is 1. Package *Package // contains filtered or unexported fields }
Click to show internal directories.
Click to hide internal directories.