simpleast

package module
v0.0.5 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 1, 2024 License: Apache-2.0 Imports: 8 Imported by: 0

README

go get cirello.io/simpleast

https://pkg.go.dev/cirello.io/simpleast

Documentation

Overview

Package simpleast provides a simple way to inspect Go files and extract structs and methods from them.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Field

type Field struct {
	Name       string     `json:"name,omitempty"`
	DocComment string     `json:"doc_comment,omitempty"`
	Type       string     `json:"type,omitempty"`
	Tags       StructTags `json:"tags,omitempty"`
}

Field represents a Go field of Struct.

type Method

type Method struct {
	Name       string   `json:"name,omitempty"`
	DocComment string   `json:"doc_comment,omitempty"`
	TypeParams []string `json:"type_params,omitempty"`
	Parameters []Field  `json:"parameters,omitempty"`
	Results    []Field  `json:"results,omitempty"`
	// contains filtered or unexported fields
}

Method represents a Go method of Struct.

type Struct

type Struct struct {
	Name       string   `json:"name,omitempty"`
	DocComment string   `json:"doc_comment,omitempty"`
	TypeParams []Field  `json:"type_params,omitempty"`
	Fields     []Field  `json:"fields,omitempty"`
	Methods    []Method `json:"methods,omitempty"`
}

Struct represents a Go struct. Fields and Methods are not ordered.

func ParseStructs

func ParseStructs(r io.Reader) ([]*Struct, error)

ParseStructs extracts structs and methods from a Go file.

type StructTag

type StructTag struct {
	Name  string `json:"name,omitempty"`
	Value string `json:"value,omitempty"`
}

StructTag represents a Go struct field tag.

type StructTags added in v0.0.4

type StructTags []StructTag

func (StructTags) Get added in v0.0.4

func (st StructTags) Get(name string) string

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL