github.com/knieriem/gointernal@v0.2.0-pre2/cmd/go/work/build.go (about) 1 // Copyright 2011 The Go Authors. All rights reserved. 2 // Use of this source code is governed by a BSD-style 3 // license that can be found in the LICENSE file. 4 5 package work 6 7 import ( 8 "strings" 9 10 "github.com/knieriem/gointernal/cmd/go/base" 11 ) 12 13 // TagsFlag is the implementation of the -tags flag. 14 type TagsFlag []string 15 16 func (v *TagsFlag) Set(s string) error { 17 // For compatibility with Go 1.12 and earlier, allow "-tags='a b c'" or even just "-tags='a'". 18 if strings.Contains(s, " ") || strings.Contains(s, "'") { 19 return (*base.StringsFlag)(v).Set(s) 20 } 21 22 // Split on commas, ignore empty strings. 23 *v = []string{} 24 for _, s := range strings.Split(s, ",") { 25 if s != "" { 26 *v = append(*v, s) 27 } 28 } 29 return nil 30 } 31 32 func (v *TagsFlag) String() string { 33 return "<TagsFlag>" 34 }