package module
v0.2.1 Latest Latest

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

Go to latest
Published: Jul 5, 2018 License: MIT Imports: 14 Imported by: 7


ainsp library

Build Status Go Report Card Release Version

Go ast library for aah framework, it does inspect and discovers the Go struct which embeds particular type struct. For e.g.: aah.Context, ws.Context.


  • v0.2.1 released and tagged on Jul 05, 2018

Visit official website to learn more about aah.



Package ainsp is a Go ast library for aah framework, it does inspect and discovers the Go `struct` which embeds particular type `struct`.

For e.g.: `{aah.Context, ws.Context}`, etc.



View Source
const Version = "0.2.1"

Version no. of ainsp library for aah framework.


This section is empty.


func FindFieldIndexes

func FindFieldIndexes(targetTyp reflect.Type, searchTyp reflect.Type) [][]int

FindFieldIndexes method does breadth-first search on struct anonymous field to find given type `struct` discover index positions.

For e.g.: `aah.Context`, `ws.Context`, etc.


type Method

type Method struct {
	Name       string
	Parameters []*Parameter

Method holds single method information of target.

type Parameter

type Parameter struct {
	Name string
	Type reflect.Type
	Kind reflect.Kind

Parameter holds parameter information of method.

type Program

type Program struct {
	Path              string
	Packages          []*packageInfo
	RegisteredActions map[string]map[string]uint8

Program holds all details loaded from the Go source code for given Import Path.

func Inspect

func Inspect(path string, excludes ess.Excludes, registeredActions map[string]map[string]uint8) (*Program, []error)

Inspect method processes the Go source code for the given directory and its sub-directories.

func (*Program) CreateImportPaths

func (prg *Program) CreateImportPaths(types []*typeInfo, importPaths map[string]string) map[string]string

CreateImportPaths method returns unique package alias with import path.

func (*Program) FindTypeByEmbeddedType

func (prg *Program) FindTypeByEmbeddedType(qualifiedTypeName string) []*typeInfo

FindTypeByEmbeddedType method returns all the typeInfo that has directly or indirectly embedded by given type name. Type name must be fully qualified type name. E.g.:

type Target

type Target struct {
	Name            string
	FqName          string
	NoSuffixName    string
	Namespace       string
	Type            reflect.Type
	Methods         map[string]*Method
	EmbeddedIndexes [][]int

Target struct holds info about targeted controller, websocket, etc.

func (*Target) Lookup

func (t *Target) Lookup(methodName string) *Method

Lookup method returns method info for given name (case insensitive) otherwise nil.

type TargetRegistry

type TargetRegistry struct {
	Registry   map[string]*Target
	SearchType reflect.Type

TargetRegistry struct holds registered information and provides lookup. Such as aah application controllers, websockets, etc.

func (*TargetRegistry) Add

func (tr *TargetRegistry) Add(t interface{}, methods []*Method)

Add method adds given target struct and its methods after processing.

func (*TargetRegistry) Lookup

func (tr *TargetRegistry) Lookup(fqName string) *Target

Lookup method returns `Target` info from registry for given `fqName` (fully qualified name) otherwise nil.

It does exact match or exact suffix match.

Jump to

Keyboard shortcuts

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