Beispiel #1
0
// Returns an array of strings containing only the filenames that should build
// according to the Context given.
func filterFilenames(bctx build.Context, inputs []string) ([]string, error) {
	outputs := []string{}

	for _, filename := range inputs {
		fullPath, err := filepath.Abs(filename)
		if err != nil {
			return nil, err
		}
		dir, base := filepath.Split(fullPath)

		matches, err := bctx.MatchFile(dir, base)
		if err != nil {
			return nil, err
		}

		if matches {
			outputs = append(outputs, filename)
		}
	}
	return outputs, nil
}
Beispiel #2
0
func matchFile(c *build.Context, dir, name string, test bool) (match bool) {
	if isGoSource(name, test) {
		match, _ = c.MatchFile(dir, name)
	}
	return match
}