func (p *Importer) ImportFrom(path, srcDir string, mode types.ImportMode) (*types.Package, error) {
	if mode != 0 {
		panic("non-zero import mode")
	}
	var bp *build.Package
	var err error
	if srcDir != "" && srcDir != "." {
		bp, err = p.ctxt.ImportDir(srcDir, 0)
		bp.ImportPath = path
	} else {
		bp, err = p.ctxt.Import(path, srcDir, 0)
	}
	if err != nil {
		return nil, err  
	}
	if bp.ImportPath == "unsafe" {
		return types.Unsafe, nil
	}
	pkg := p.packages[bp.ImportPath]
	if pkg != nil {
		if pkg == &importing {
			return nil, fmt.Errorf("import cycle through package %q", bp.ImportPath)
		}
		if !pkg.Complete() {
			return pkg, fmt.Errorf("reimported partially imported package %q", bp.ImportPath)
		}
		return pkg, nil
	}
	p.packages[bp.ImportPath] = &importing
	defer func() {
		if p.packages[bp.ImportPath] == &importing {
			p.packages[bp.ImportPath] = nil
		}
	}()
	var filenames []string
	filenames = append(filenames, bp.GoFiles...)
	filenames = append(filenames, bp.CgoFiles...)
	files, err := p.parseFiles(bp.Dir, filenames)
	if err != nil {
		return nil, err
	}
	var firstHardErr error
	conf := types.Config{
		IgnoreFuncBodies: true,
		FakeImportC:      true,
		Error: func(err error) {
			if firstHardErr == nil && !err.(types.Error).Soft {
				firstHardErr = err
			}
		},
		Importer: importer.Default(),
		Sizes:    p.sizes,
	}
	pkg, err = conf.Check(bp.ImportPath, p.fset, files, nil)
	if pkg == nil {
		if firstHardErr != nil {
			err = firstHardErr  
		}
		return pkg, fmt.Errorf("type-checking package %q failed (%v)", bp.ImportPath, err)
	}
	p.packages[bp.ImportPath] = pkg
	return pkg, nil
}
ImportFrom imports the package with the given import path resolved from the given srcDir,
adds the new package to the set of packages maintained by the importer, and returns the
package. Package path resolution and file system operations are controlled by the context
maintained with the importer. The import mode must be zero but is otherwise ignored.
Packages that are not comprised entirely of pure Go files may fail to import because the
type checker may not be able to determine all exported entities (e.g. due to cgo dependencies).
package srcimporter
import (
	"fmt"
	"go/ast"
	"go/build"
	"go/importer"
	"go/parser"
	"go/token"
	"go/types"
	"io"
	"os"
	"path/filepath"
	"sync"
)
type Importer struct {
	ctxt     *build.Context
	fset     *token.FileSet
	sizes    types.Sizes
	packages map[string]*types.Package
}
func New(ctxt *build.Context, fset *token.FileSet, packages map[string]*types.Package) *Importer {
	return &Importer{
		ctxt:     ctxt,
		fset:     fset,
		sizes:    types.SizesFor(ctxt.Compiler, ctxt.GOARCH),  
		packages: packages,
	}
}
var importing types.Package
func (p *Importer) Import(path string) (*types.Package, error) {
	return p.ImportFrom(path, ".", 0)  
}