func (g *GoFile) getPackage(name string) (*packages.Package, error) {
	pkgs, err := packages.Load(g.pkgConf, name)
	if err != nil {
		return nil, err
	}
	if len(pkgs) == 0 {
		return nil, nil
	}
	return pkgs[0], nil
}
getPackage loads module by name
package dir
import (
	"fmt"
	"go/ast"
	"go/token"
	"go/types"
	"log"
	"path/filepath"
	"strconv"
	"golang.org/x/tools/go/packages"
	"github.com/leonelquinteros/gotext/cli/xgotext/parser"
)
type GetterDef struct {
	Id      int
	Plural  int
	Context int
	Domain  int
}
func (d *GetterDef) maxArgIndex() int {
	m := d.Id
	if d.Plural > m {
		m = d.Plural
	}
	if d.Context > m {
		m = d.Context
	}
	if d.Domain > m {
		m = d.Domain
	}
	return m
}
var gotextGetter = map[string]GetterDef{
	"Get":    {0, -1, -1, -1},
	"GetN":   {0, 1, -1, -1},
	"GetD":   {1, -1, -1, 0},
	"GetND":  {1, 2, -1, 0},
	"GetC":   {0, -1, 1, -1},
	"GetNC":  {0, 1, 3, -1},
	"GetDC":  {1, -1, 2, 0},
	"GetNDC": {1, 2, 4, 0},
}
func init() {
	AddParser(goParser)
}
func goParser(dirPath, basePath string, data *parser.DomainMap) error {
	fileSet := token.NewFileSet()
	conf := packages.Config{
		Mode: packages.NeedName |
			packages.NeedFiles |
			packages.NeedSyntax |
			packages.NeedTypes |
			packages.NeedTypesInfo,
		Fset: fileSet,
		Dir:  basePath,
	}
	pkgs, err := packages.Load(&packages.Config{
		Mode: conf.Mode,
		Fset: fileSet,
		Dir:  dirPath,
	})
	if err != nil || len(pkgs) == 0 {
		return nil
	}
	for _, node := range pkgs[0].Syntax {
		file := GoFile{
			pkgConf:  &conf,
			filePath: fileSet.Position(node.Package).Filename,
			basePath: basePath,
			data:     data,
			fileSet:  fileSet,
			importedPackages: map[string]*packages.Package{
				pkgs[0].Name: pkgs[0],
			},
		}
		ast.Inspect(node, file.inspectFile)
	}
	return nil
}
type GoFile struct {
	filePath string
	basePath string
	data     *parser.DomainMap
	fileSet *token.FileSet
	pkgConf *packages.Config
	importedPackages map[string]*packages.Package
}