structjson

package module
v0.0.0-...-0fdd9f6 Latest Latest
Warning

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

Go to latest
Published: Dec 10, 2016 License: MIT Imports: 10 Imported by: 0

README

go-struct-json

extracting json data from go's struct code(WIP)

installl

$ go get -v github.com/podhmo/go-structjson/cmd/go-structjson

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CollectImports

func CollectImports(imports []*ast.ImportSpec) map[string]*ImportDefinition

func CollectPackageMap

func CollectPackageMap(fpath string) (map[string]*ast.Package, error)

Types

type AliasDefinition

type AliasDefinition struct {
	Name       string        `json:"name"`
	Original   Type          `json:"original"`
	Candidates []*AliasValue `json:"candidates"`
	// contains filtered or unexported fields
}

type AliasValue

type AliasValue struct {
	TypeName string `json:"-"`

	Name  string      `json:"name"`
	Value interface{} `json:"value"`
	// contains filtered or unexported fields
}

type Field

type Field struct {
	Name  string              `json:"name"`
	Tags  map[string][]string `json:"tags"`
	Type  Type                `json:"type"`
	Embed bool                `json:"embed"`
}

type ImportDefinition

type ImportDefinition struct {
	Name      string `json:"name"`
	FullName  string `json:"fullname"`
	NeedParse bool   `json:"needparse"`
}

type InterfaceDefinition

type InterfaceDefinition struct {
	Name string `json:"name"`
	// contains filtered or unexported fields
}

type Module

type Module struct {
	Name     string             `json:"name"`
	FullName string             `json:"fullname"`
	Files    map[string]*Result `json:"file"`
}

func NewModule

func NewModule(name string) *Module

type Result

type Result struct {
	Name          string                          `json:"name"`
	AliasMap      map[string]*AliasDefinition     `json:"alias,omitempty"`
	StructMap     map[string]*StructDefinition    `json:"struct,omitempty"`
	InterfaceMap  map[string]*InterfaceDefinition `json:"interface,omitempty"`
	MaybeAliasses []*AliasValue                   `json:"-"`
	ImportsMap    map[string]*ImportDefinition    `json:"import,omitempty"`
	// contains filtered or unexported fields
}

func CollectResult

func CollectResult(name string, scope *ast.Scope, imports []*ast.ImportSpec) (*Result, error)

func NewResult

func NewResult(name string) *Result

func (*Result) AddAlias

func (r *Result) AddAlias(ob *ast.Object) (*AliasDefinition, error)

func (*Result) AddAliasValue

func (r *Result) AddAliasValue(ob *ast.Object) (*AliasDefinition, error)

func (*Result) AddInterface

func (r *Result) AddInterface(ob *ast.Object) (*InterfaceDefinition, error)

func (*Result) AddStruct

func (r *Result) AddStruct(ob *ast.Object) (*StructDefinition, error)

type StructDefinition

type StructDefinition struct {
	Name string `json:"name"`

	Fields map[string]*Field `json:"fields"`
	// contains filtered or unexported fields
}

type Type

type Type interface{}

func FindType

func FindType(r *Result, node ast.Node) Type

type World

type World struct {
	Modules map[string]*Module `json:"module"`
}

func NewWorld

func NewWorld() *World

Directories

Path Synopsis
cmd
go-funcjson command
go-structjson command
examples

Jump to

Keyboard shortcuts

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