...
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
27
28
29 if match || ext == "" {
30 ret = append(ret, f)
31 }
32 }
33 return ret
34 }
35
View as plain text