Documentation ¶
Index ¶
- Variables
- func DefaultPkgName(gopkgPath string) (name string)
- func GetCallersDirname() string
- type Package
- func (pkg *Package) CrawlPackages(seen map[*Package]struct{}) (res []*Package)
- func (pkg *Package) FullNameForType(rt reflect.Type) string
- func (pkg *Package) GetDependency(gopkg string) (*Package, error)
- func (pkg *Package) GetType(rt reflect.Type) (t Type, ok bool)
- func (pkg *Package) HasFullName(fullname string) (exists bool)
- func (pkg *Package) HasName(name string) (exists bool)
- func (pkg *Package) ReflectTypes() []reflect.Type
- func (pkg *Package) String() string
- func (pkg *Package) TypeURLForType(rt reflect.Type) string
- func (pkg *Package) WithDependencies(deps ...*Package) *Package
- func (pkg *Package) WithGoPkgName(name string) *Package
- func (pkg *Package) WithP3GoPkgPath(p3gopkg string) *Package
- func (pkg *Package) WithP3ImportPath(path string) *Package
- func (pkg *Package) WithP3SchemaFile(file string) *Package
- func (pkg *Package) WithTypes(objs ...interface{}) *Package
- type PackageSet
- type Type
Constants ¶
This section is empty.
Variables ¶
var ( RE_DOMAIN = `[[:alnum:]-_]+[[:alnum:]-_.]+\.[a-zA-Z]{2,4}` RE_GOPKG_PART = `[[:alpha:]-_]+` RE_GOPKG = fmt.Sprintf(`(?:%v|%v)(?:/%v)*`, RE_DOMAIN, RE_GOPKG_PART, RE_GOPKG_PART) RE_P3PKG_PART = `[[:alpha:]_]+` RE_P3PKG = fmt.Sprintf(`%v(?:\.:%v)*`, RE_P3PKG_PART, RE_P3PKG_PART) )
Functions ¶
func DefaultPkgName ¶
func GetCallersDirname ¶
func GetCallersDirname() string
Utility for whoever is making a NewPackage manually.
Types ¶
type Package ¶
type Package struct { // General info GoPkgPath string GoPkgName string DirName string Dependencies []*Package Types []Type // Proto3 info P3GoPkgPath string P3PkgName string P3ImportPath string P3SchemaFile string }
func NewPackage ¶
Like amino.RegisterPackage (which is probably what you're looking for unless you are developking on go-amino dependencies), but without global amino registration.
P3GoPkgPath (the import path for go files generated from protoc) are by default set to "<GoPkgPath>/pb", but can be overridden by WithP3GoPkgPath(). You may want to override this for main package, for the subdirectory "pb" doesn't produce a "main/pb" package. See ./proto/example/pacakge.go for such usage.
(This field is needed for improving the performance of encoding and decoding by using protoc generated go code, but is slated to be replaced by native Go generation.)
GoPkgName is by default derived from gopkgPath, but can also be overridden with WithGoPkgName().
P3ImportPath is what is imported in the p3 import spec. Generally this is GoPkgPath + "/types.proto", but packages can override this behavior, and sometimes (e.g. for google.protobuf.Any) it is necessary to provide fixed values. This is not the absolute path to the actual file. That is P3SchemaFile.
Panics if invalid arguments are given, such as slashes in p3pkgName, invalid go pkg paths, or a relative dirName.
func (*Package) CrawlPackages ¶
For a given package info, crawl and discover all package infos.
func (*Package) FullNameForType ¶
panics of rt was not registered.
func (*Package) GetDependency ¶
Finds a dependency package from the gopkg. Well known packages are not known here, so some dependencies may not show up, such as for google.protobuf.Any for any interface fields. For that, use a P3Context.GetPackage().
func (*Package) HasFullName ¶
func (*Package) ReflectTypes ¶
func (*Package) TypeURLForType ¶
panics of rt (or a pointer to it) was not registered.
func (*Package) WithDependencies ¶
func (*Package) WithGoPkgName ¶
func (*Package) WithP3GoPkgPath ¶
func (*Package) WithP3ImportPath ¶
This path will get imported instead of the default "types.proto" if this package is a dependency. This is not the filesystem path, but the path imported within the proto schema file. The filesystem path is .P3SchemaFile.
func (*Package) WithP3SchemaFile ¶
This file will get imported instead of the default "types.proto" if this package is a dependency.
type PackageSet ¶
e.g. "github.com/tendermint/tendermint/abci/types" ->
&Package{...}
func NewPackageSet ¶
func NewPackageSet() PackageSet
func (PackageSet) Add ¶
func (ps PackageSet) Add(pkg *Package) bool
func (PackageSet) Get ¶
func (ps PackageSet) Get(gopkg string) *Package
func (PackageSet) Has ¶
func (ps PackageSet) Has(gopkg string) bool