func newAnalyzers() []*analysis.Analyzer {
	return []*analysis.Analyzer{
		{
			Name: "PACKAGE_FILENAME",
			Doc:  "Verifies that every package has a file with the same name as the package.",
			Run: func(pass *analysis.Pass) (interface{}, error) {
				if len(pass.Files) == 0 {
					// Nothing to do. We can't report the error anywhere because
					// this package doesn't have any files.
					return nil, nil
				}
				packageName := pass.Pkg.Name()
				if strings.HasSuffix(packageName, "_test") {
					// Ignore test packages.
					return nil, nil
				}
				var found bool
				pass.Fset.Iterate(
					func(file *token.File) bool {
						filename := filepath.Base(file.Name())
						if strings.TrimSuffix(filename, ".go") == packageName {
							found = true
							return false
						}
						return true
					},
				)
				if !found {
					// The package is guaranteed to have at least one
					// file with a package declaration, so we report the failure there.
					// We checked that len(pass.Files) > 0 above.
					pass.Reportf(pass.Files[0].Package, "Package %q does not have a %s.go", packageName, packageName)
				}
				return nil, nil
			},
		},
		{
			Name: "NO_SYNC_POOL",
			Doc:  "Verifies that sync.Pool is not used.",
			Run: func(pass *analysis.Pass) (interface{}, error) {
				if typesInfo := pass.TypesInfo; typesInfo != nil {
					for expr, typeAndValue := range pass.TypesInfo.Types {
						if t := typeAndValue.Type; t != nil {
							if t.String() == "sync.Pool" {
								pass.Reportf(expr.Pos(), "sync.Pool cannot be used")
							}
						}
					}
				}
				return nil, nil
			},
		},
	}
}
// we don't store this as a global because we modify these in the analyzerProvider.
we don't store this as a global because we modify these in the analyzerProvider.
// we don ' t store this as a global because we modify these in the analyzerProvider .
func newAnalyzers() []*analysis.Analyzer {
	return []*analysis.Analyzer{
		{
			Name: "PACKAGE_FILENAME",
			Doc:  "Verifies that every package has a file with the same name as the package.",
			Run: func(pass *analysis.Pass) (interface{}, error) {
				if len(pass.Files) == 0 {
					return nil, nil
				}
				packageName := pass.Pkg.Name()
				if strings.HasSuffix(packageName, "_test") {
					return nil, nil
				}
				var found bool
				pass.Fset.Iterate(
					func(file *token.File) bool {
						filename := filepath.Base(file.Name())
						if strings.TrimSuffix(filename, ".go") == packageName {
							found = true
							return false
						}
						return true
					},
				)
				if !found {
					pass.Reportf(pass.Files[0].Package, "Package %q does not have a %s.go", packageName, packageName)
				}
				return nil, nil
			},
		},
		{
			Name: "NO_SYNC_POOL",
			Doc:  "Verifies that sync.Pool is not used.",
			Run: func(pass *analysis.Pass) (interface{}, error) {
				if typesInfo := pass.TypesInfo; typesInfo != nil {
					for expr, typeAndValue := range pass.TypesInfo.Types {
						if t := typeAndValue.Type; t != nil {
							if t.String() == "sync.Pool" {
								pass.Reportf(expr.Pos(), "sync.Pool cannot be used")
							}
						}
					}
				}
				return nil, nil
			},
		},
	}
}
func newAnalyzers ( ) [ ] * analysis . Analyzer { return [ ] * analysis . Analyzer { { Name : " " , Doc : " " , Run : func ( pass * analysis . Pass ) ( interface { } , error ) { if len ( pass . Files ) == 0 { return nil , nil } packageName := pass . Pkg . Name ( ) if strings . HasSuffix ( packageName , " " ) { return nil , nil } var found bool pass . Fset . Iterate ( func ( file * token . File ) bool { filename := filepath . Base ( file . Name ( ) ) if strings . TrimSuffix ( filename , " " ) == packageName { found = true return false } return true } , ) if ! found { pass . Reportf ( pass . Files [ 0 ] . Package , " " , packageName , packageName ) } return nil , nil } , } , { Name : " " , Doc : " " , Run : func ( pass * analysis . Pass ) ( interface { } , error ) { if typesInfo := pass . TypesInfo ; typesInfo != nil { for expr , typeAndValue := range pass . TypesInfo . Types { if t := typeAndValue . Type ; t != nil { if t . String ( ) == " " { pass . Reportf ( expr . Pos ( ) , " " ) } } } } return nil , nil } , } , } }
we don't store this as a global because we modify these in the analyzerProvider.
we don ' t store this as a global because we modify these in the analyzerProvider .
// Nothing to do. We can't report the error anywhere because // this package doesn't have any files. // Ignore test packages. // The package is guaranteed to have at least one // file with a package declaration, so we report the failure there. // We checked that len(pass.Files) > 0 above.