tg.setenv("GOPATH", "")
tg.setenv("GOCACHE", "off")
- tg.run("build", "-v", "-gcflags=-e", "fmt")
+ tg.run("build", "-v", "-gcflags= \t\r\n -e", "fmt")
tg.grepStderr("fmt", "did not rebuild fmt")
tg.grepStderrNot("reflect", "incorrectly rebuilt reflect")
tg.grepStderr("reflect", "did not rebuild reflect")
tg.grepStderrNot("runtime", "incorrectly rebuilt runtime")
- tg.run("build", "-x", "-v", "-gcflags=reflect=-N", "fmt")
+ tg.run("build", "-x", "-v", "-gcflags= \t\r\n reflect \t\r\n = \t\r\n -N", "fmt")
tg.grepStderr("fmt", "did not rebuild fmt")
tg.grepStderr("reflect", "did not rebuild reflect")
tg.grepStderr("compile.* -N .*-p reflect", "did not build reflect with -N flag")
func (f *PerPackageFlag) set(v, cwd string) error {
f.present = true
match := func(p *Package) bool { return p.Internal.CmdlinePkg || p.Internal.CmdlineFiles } // default predicate with no pattern
+ // For backwards compatibility with earlier flag splitting, ignore spaces around flags.
+ v = strings.TrimSpace(v)
if v == "" {
// Special case: -gcflags="" means no flags for command-line arguments
// (overrides previous -gcflags="-whatever").
if i == 0 {
return fmt.Errorf("missing <pattern> in <pattern>=<value>")
}
- pattern := v[:i]
+ pattern := strings.TrimSpace(v[:i])
match = MatchPackage(pattern, cwd)
v = v[i+1:]
}