Documentation ¶
Overview ¶
Extracted from: gopkg.in/src-d/proteus.v1/scanner
Index ¶
- Constants
- Variables
- func GetTempGoModFilepath(rawPath string) string
- func RemoveGoPath(pkg *types.Package) string
- func RemoveGoSrcClonePath(pkgPath string) string
- func SplitPathVersion(rawPath string) (path string, version string)
- func StringRemoveGoPath(pkgPath string) string
- type Alias
- type BaseType
- func (t *BaseType) GetType() types.Type
- func (t *BaseType) GetTypesVar() *types.Var
- func (t *BaseType) IsBasic() bool
- func (t *BaseType) IsNullable() bool
- func (t *BaseType) IsPtr() bool
- func (t *BaseType) IsStruct() bool
- func (t *BaseType) IsVariadic() bool
- func (t *BaseType) SetIsBasic(v bool)
- func (t *BaseType) SetIsPtr(v bool)
- func (t *BaseType) SetIsStruct(v bool)
- func (t *BaseType) SetIsVariadic(v bool)
- func (t *BaseType) SetNullable(v bool)
- func (t *BaseType) SetRepeated(v bool)
- func (t *BaseType) SetType(v types.Type)
- func (t *BaseType) SetTypesVar(v *types.Var)
- func (t *BaseType) String() string
- func (t *BaseType) TypeString() string
- func (t *BaseType) UnqualifiedName() string
- type Basic
- type Chan
- type Docs
- type Documentable
- type Enum
- type EnumValue
- type Field
- type Func
- type Interface
- type MMap
- type Named
- type Package
- type Scanner
- type ScannerFunc
- type Struct
- type Type
Constants ¶
const (
// Use default Golang proxy (???)
GoProxy = "https://proxy.golang.org/"
)
Variables ¶
var ErrNoGoPathSet = errors.New("GOPATH environment variable is not set")
ErrNoGoPathSet is the error returned when the GOPATH variable is not set.
Functions ¶
func GetTempGoModFilepath ¶
GetTempGoModFilepath gets the go.mod file with which the package was loaded.
func RemoveGoPath ¶
func RemoveGoSrcClonePath ¶
func SplitPathVersion ¶
SplitPathVersion splits a path string (e.g. example.com/hello/world@1.0.1) into its path and version components. If no version notation is present, rawPath is returned.
func StringRemoveGoPath ¶
Types ¶
type Alias ¶
type Alias struct { *BaseType // Type represents the type being declared Type Type // Underlying represent the aliased type. Underlying Type }
Alias represents a type declaration from a type to another type
func (Alias) IsNullable ¶
func (Alias) TypeString ¶
TypeString returns a string representation for the type casting
func (Alias) UnqualifiedName ¶
UnqualifiedName returns the bare name, without the package.
type BaseType ¶
type BaseType struct { Repeated bool Nullable bool Ptr bool Struct bool ID string TypesVar *types.Var Variadic bool Basic bool Type types.Type }
BaseType contains the common fields for all the types.
func (*BaseType) GetTypesVar ¶
func (*BaseType) IsNullable ¶
IsNullable reports wether the type is a pointer or not.
func (*BaseType) IsVariadic ¶
func (*BaseType) SetIsBasic ¶
func (*BaseType) SetIsStruct ¶
func (*BaseType) SetIsVariadic ¶
func (*BaseType) SetNullable ¶
SetNullable sets the type as pointer.
func (*BaseType) SetRepeated ¶
SetRepeated sets the type as repeated or not repeated.
func (*BaseType) SetTypesVar ¶
func (*BaseType) TypeString ¶
TypeString returns a string representation for the type casting
func (*BaseType) UnqualifiedName ¶
String returns a string representation for the type
type Basic ¶
Basic is a basic type, which only is identified by its name.
func (Basic) IsNullable ¶
IsNullable returns true ONLY if it's also a pointer. Otherwise, Basic types are not nullable, and have just the zero values.
Basic types: int, int8, int16, int32, int64 uint, uint8, uint16, uint32, uint64 uintptr float32, float64 byte rune string complex64, complex128
func (Basic) TypeString ¶
TypeString returns a string representation for the type casting
func (Basic) UnqualifiedName ¶
UnqualifiedName returns the bare name, without the package.
type Chan ¶
Chan is a map type with a key and a value type.
func (Chan) TypeString ¶
TypeString returns a string representation for the type casting
func (Chan) UnqualifiedName ¶
UnqualifiedName returns the bare name, without the package.
type Docs ¶
Docs holds the documentation of a struct, enum, value, field, etc.
func (*Docs) SetComments ¶
func (d *Docs) SetComments(comments *ast.CommentGroup)
SetComments sets the documentation from an AST comment group.
func (*Docs) SetDocs ¶
func (d *Docs) SetDocs(comments *ast.CommentGroup)
SetDocs sets the documentation from an AST comment group.
type Documentable ¶
type Documentable interface { // SetDocs sets the documentation from an AST comment group. SetDocs(*ast.CommentGroup) SetComments(*ast.CommentGroup) }
Documentable is something whose documentation can be set.
type Func ¶
type Func struct { *BaseType Docs Name string // Receiver will not be nil if it's a method. Receiver Type Input []Type Output []Type // Variadic will be true if the last input parameter is variadic. Variadic bool Signature string PkgPath string PkgName string }
Func is either a function or a method. Receiver will be nil in functions, otherwise it is a method.
func (Func) TypeString ¶
TypeString returns a string representation for the type casting
func (Func) UnqualifiedName ¶
UnqualifiedName returns the bare name, without the package.
type Interface ¶
Interface is an interface.
func (Interface) TypeString ¶
TypeString returns a string representation for the type casting
func (Interface) UnqualifiedName ¶
UnqualifiedName returns the bare name, without the package.
type MMap ¶
MMap is a map type with a key and a value type.
func (MMap) TypeString ¶
TypeString returns a string representation for the type casting
func (MMap) UnqualifiedName ¶
UnqualifiedName returns the bare name, without the package.
type Named ¶
Named is non-basic type identified by a name on some package.
func (Named) TypeString ¶
TypeString returns a string representation for the type casting
func (Named) UnqualifiedName ¶
UnqualifiedName returns the bare name, without the package.
type Package ¶
type Package struct { Path string Name string Module *packages.Module Structs []*Struct Funcs []*Func Interfaces []*Interface Methods []*Func Types []*Named // Types contains types found in the package. }
Package holds information about a single Go package and a reference of all defined structs and type aliases. A Package is only safe to use once it is resolved.
type Scanner ¶
type Scanner struct {
// contains filtered or unexported fields
}
Scanner scans packages looking for Go source files to parse and extract types and structs from.
func New ¶
New creates a new Scanner that will look for types and structs only in the given packages. A provided package path can be in the form `path@version`, or just `path` and the latest version will be used. For Go standard library packages, the local version is used (must have Go installed).
func NewDEPRECATED ¶
New creates a new Scanner that will look for types and structs only in the given packages.
func (*Scanner) Scan ¶
Scan retrieves the scanned packages containing the extracted go types and structs.
func (*Scanner) ScanWithCustomScanner ¶
func (s *Scanner) ScanWithCustomScanner(sc ScannerFunc) ([]*Package, error)
ScanWithCustomScanner retrieves the scanned packages containing the extracted go types and structs; it uses the provided ScannerFunc.
type Struct ¶
type Struct struct { *BaseType Docs Name string Fields []*Field Type *types.Named AnonymousType *types.Struct Embedded []Type }
Struct represents a Go struct with its name and fields. All structs
func (Struct) TypeString ¶
TypeString returns a string representation for the type casting
func (Struct) UnqualifiedName ¶
UnqualifiedName returns the bare name, without the package.
type Type ¶
type Type interface { fmt.Stringer SetNullable(bool) IsNullable() bool SetIsPtr(bool) IsPtr() bool SetIsStruct(bool) IsStruct() bool // TypeString returns a string representing the final type. // Though this might seem that this should be just String, for Alias types // both representations are different: a string representation of the final // type, this is just the alias, while string contains also the underlying type. TypeString() string // Name returns the unqualified name. UnqualifiedName() string GetTypesVar() *types.Var SetTypesVar(*types.Var) GetType() types.Type SetType(types.Type) SetIsVariadic(bool) IsVariadic() bool SetIsBasic(v bool) IsBasic() bool }
Type is the common interface for all possible types supported in protogo. Type is neither a representation of a Go type nor a representation of a protobuf type. Is an intermediate representation to ease future steps in the conversion from Go to protobuf. All types can be repeated (or not).