github.com/corona10/go@v0.0.0-20180224231303-7a218942be57/src/cmd/go/internal/base/flag.go (about) 1 // Copyright 2017 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 base 6 7 import ( 8 "flag" 9 10 "cmd/go/internal/cfg" 11 "cmd/go/internal/str" 12 ) 13 14 // A StringsFlag is a command-line flag that interprets its argument 15 // as a space-separated list of possibly-quoted strings. 16 type StringsFlag []string 17 18 func (v *StringsFlag) Set(s string) error { 19 var err error 20 *v, err = str.SplitQuotedFields(s) 21 if *v == nil { 22 *v = []string{} 23 } 24 return err 25 } 26 27 func (v *StringsFlag) String() string { 28 return "<StringsFlag>" 29 } 30 31 // AddBuildFlagsNX adds the -n and -x build flags to the flag set. 32 func AddBuildFlagsNX(flags *flag.FlagSet) { 33 flags.BoolVar(&cfg.BuildN, "n", false, "") 34 flags.BoolVar(&cfg.BuildX, "x", false, "") 35 }