mirror of
https://github.com/securego/gosec.git
synced 2025-11-25 22:22:17 +02:00
fix: build tag parsing. (#1413)
* fix: build tag parsing. * chore: lint fixes.
This commit is contained in:
committed by
GitHub
parent
d2d734859c
commit
10cf58a4a4
21
helpers.go
21
helpers.go
@@ -553,3 +553,24 @@ func parseGoVersion(version string) (int, int, int) {
|
||||
|
||||
return major, minor, build
|
||||
}
|
||||
|
||||
// CLIBuildTags converts a list of Go build tags into the corresponding CLI
|
||||
// build flag (-tags=form) by trimming whitespace, removing empty entries,
|
||||
// and joining them into a comma-separated -tags argument for use with go build
|
||||
// commands.
|
||||
func CLIBuildTags(buildTags []string) []string {
|
||||
var buildFlags []string
|
||||
if len(buildTags) > 0 {
|
||||
for _, tag := range buildTags {
|
||||
// remove empty entries and surrounding whitespace
|
||||
if t := strings.TrimSpace(tag); t != "" {
|
||||
buildFlags = append(buildFlags, t)
|
||||
}
|
||||
}
|
||||
if len(buildFlags) > 0 {
|
||||
buildFlags = []string{"-tags=" + strings.Join(buildFlags, ",")}
|
||||
}
|
||||
}
|
||||
|
||||
return buildFlags
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user