uniqpkg

package
v0.2.2 Latest Latest
Warning

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

Go to latest
Published: May 1, 2022 License: MIT Imports: 4 Imported by: 0

Documentation

Overview

Package uniqpkg supports generating unique package names by creating aliases as necessary.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ImportDetails

type ImportDetails struct {
	Name    string
	Path    string
	IsAlias bool // Indicates that the name is not the default name, and thus should be specified as an alias.
}

ImportDetails stores the details of a single import within a package.

type Package

type Package struct {
	Path string
	// contains filtered or unexported fields
}

Package stores the imports for a single package.

func (*Package) AddImport

func (pkg *Package) AddImport(packagePath, packageName string) *ImportDetails

AddImport adds the package path and name as an import, generating an alias if necessary.

func (*Package) Imports

func (pkg *Package) Imports() []*ImportDetails

Imports returns the list of imports for the Package in sorted order.

type UniquePackagePaths

type UniquePackagePaths struct {
	// contains filtered or unexported fields
}

UniquePackagePaths supports generating unique package names by creating aliases as necessary.

func New

func New() *UniquePackagePaths

func (*UniquePackagePaths) ForPackage

func (p *UniquePackagePaths) ForPackage(path string) *Package

ForPackage finds or adds the package identified by the path.

func (*UniquePackagePaths) GeneratePackageName

func (p *UniquePackagePaths) GeneratePackageName(scopePackage *packages.Package, importedPackage *types.Package) string

GeneratePackageName supports generating unique package names by creating aliases as necessary. This method is expected to be called from within ifacereader, as it satisfies the PackageNameGenerator interface.

Jump to

Keyboard shortcuts

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