...

Source file src/github.com/bazelbuild/rules_go/go/tools/gopackagesdriver/build_context.go

Documentation: github.com/bazelbuild/rules_go/go/tools/gopackagesdriver

     1  package main
     2  
     3  import (
     4  	"go/build"
     5  	"path/filepath"
     6  	"strings"
     7  )
     8  
     9  var buildContext = makeBuildContext()
    10  
    11  func makeBuildContext() *build.Context {
    12  	bctx := build.Default
    13  	bctx.BuildTags = strings.Split(getenvDefault("GOTAGS", ""), ",")
    14  
    15  	return &bctx
    16  }
    17  
    18  func filterSourceFilesForTags(files []string) []string {
    19  	ret := make([]string, 0, len(files))
    20  
    21  	for _, f := range files {
    22  		dir, filename := filepath.Split(f)
    23  		ext := filepath.Ext(f)
    24  
    25  		match, _ := buildContext.MatchFile(dir, filename)
    26  		// MatchFile filters out anything without a file extension. In the
    27  		// case of CompiledGoFiles (in particular gco processed files from
    28  		// the cache), we want them.
    29  		if match || ext == "" {
    30  			ret = append(ret, f)
    31  		}
    32  	}
    33  	return ret
    34  }
    35  

View as plain text