// A Config specifies the configuration for type checking.
// The zero value for Config is a ready-to-use default configuration.
type Config struct {
- // goVersion describes the accepted Go language version. The string
+ // GoVersion describes the accepted Go language version. The string
// must follow the format "go%d.%d" (e.g. "go1.12") or it must be
// empty; an empty string indicates the latest language version.
// If the format is invalid, invoking the type checker will cause a
// panic.
- goVersion string
+ GoVersion string
// If IgnoreFuncBodies is set, function bodies are not
// type-checked.
info = new(Info)
}
- version, err := parseGoVersion(conf.goVersion)
+ version, err := parseGoVersion(conf.GoVersion)
if err != nil {
- panic(fmt.Sprintf("invalid Go version %q (%v)", conf.goVersion, err))
+ panic(fmt.Sprintf("invalid Go version %q (%v)", conf.GoVersion, err))
}
return &Checker{
// typecheck and collect typechecker errors
var conf Config
conf.Sizes = sizes
- SetGoVersion(&conf, goVersion)
+ conf.GoVersion = goVersion
// special case for importC.src
if len(filenames) == 1 {
// parse and type-check file
file, err := parser.ParseFile(fset, filename, nil, 0)
if err == nil {
- conf := Config{Importer: stdLibImporter}
- SetGoVersion(&conf, goVersion)
+ conf := Config{GoVersion: goVersion, Importer: stdLibImporter}
_, err = conf.Check(filename, fset, []*ast.File{file}, nil)
}
package types
-// SetGoVersion sets the unexported goVersion field on config, so that tests
-// which assert on behavior for older Go versions can set it.
-func SetGoVersion(config *Config, goVersion string) {
- config.goVersion = goVersion
-}
-
// Debug is set if go/types is built with debug mode enabled.
const Debug = debug