Skip to content

go/build: inconsistency on whether NoGoError includes test files #31921

@bradfitz

Description

@bradfitz

The code & documentation disagree about whether go/build.NoGoError includes tests.

Code says:

        if len(p.GoFiles)+len(p.CgoFiles)+len(p.TestGoFiles)+len(p.XTestGoFiles) == 0 {
                return p, &NoGoError{p.Dir}
        }

But docs say:

// NoGoError is the error used by Import to describe a directory                                                                                                                                                                        
// containing no buildable Go source files. (It may still contain                                                                                                                                                                       
// test files, files hidden by build tags, and so on.)                                                                                                                                                                                  
type NoGoError struct {
        Dir string
}

(Notably, the "it may still contain test files" part, implying that a directory with only foo_test.go should be NoGoError).

/cc @bcmills @jayconrod @rsc @ianlancetaylor

Metadata

Metadata

Assignees

No one assigned

    Labels

    NeedsInvestigationSomeone must examine and confirm this is a valid issue and not a duplicate of an existing one.

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions