func defaultDriver(cfg *Config, patterns ...string) (*driverResponse, error) {
	driver := findExternalDriver(cfg)
	if driver == nil {
		driver = goListDriver
	}
	return driver(cfg, patterns...)
}
defaultDriver is a driver that looks for an external driver binary, and if
it does not find it falls back to the built in go list driver.
package packages
import (
	"context"
	"encoding/json"
	"fmt"
	"go/ast"
	"go/parser"
	"go/scanner"
	"go/token"
	"go/types"
	"io/ioutil"
	"log"
	"os"
	"path/filepath"
	"strings"
	"sync"
	"golang.org/x/tools/go/gcexportdata"
	"golang.org/x/tools/internal/packagesinternal"
)
type LoadMode int
const (
	NeedName LoadMode = 1 << iota
	NeedFiles
	NeedCompiledGoFiles
	NeedImports
	NeedDeps
	NeedExportsFile
	NeedTypes
	NeedSyntax
	NeedTypesInfo
	NeedTypesSizes
)
const (
	LoadFiles = NeedName | NeedFiles | NeedCompiledGoFiles
	LoadImports = LoadFiles | NeedImports
	LoadTypes = LoadImports | NeedTypes | NeedTypesSizes
	LoadSyntax = LoadTypes | NeedSyntax | NeedTypesInfo
	LoadAllSyntax = LoadSyntax | NeedDeps
)
type Config struct {
	Mode LoadMode
	Context context.Context
	Logf func(format string, args ...interface{})
	Dir string
	Env []string
	BuildFlags []string
	Fset *token.FileSet
	ParseFile func(fset *token.FileSet, filename string, src []byte) (*ast.File, error)
	Tests bool
	Overlay map[string][]byte
}
type driver func(cfg *Config, patterns ...string) (*driverResponse, error)
type driverResponse struct {
	Sizes *types.StdSizes
	Roots []string `json:",omitempty"`
	Packages []*Package
}
func Load(cfg *Config, patterns ...string) ([]*Package, error) {
	l := newLoader(cfg)
	response, err := defaultDriver(&l.Config, patterns...)
	if err != nil {
		return nil, err
	}
	l.sizes = response.Sizes
	return l.refine(response.Roots, response.Packages...)
}