[dev.go2go] cmd/go2go: add -brackets option

Change-Id: I5c3d36df3d84ad85d2fb70152f5692223cf6cfb6
Reviewed-on: https://go-review.googlesource.com/c/go/+/243161
Reviewed-by: Ian Lance Taylor <iant@golang.org>
This commit is contained in:
Ian Lance Taylor 2020-07-16 14:27:49 -07:00
parent 78c55f923e
commit 486b592393
2 changed files with 16 additions and 1 deletions

View File

@ -7,7 +7,13 @@
//
// Usage:
//
// go2go <command> [arguments]
// go2go [options] <command> [arguments]
//
// The only option is -brackets, which requires square brackets rather
// than parentheses for generic code. This is temporarily useful when
// translating code that uses square brackets to pass type arguments
// to generic function and types while not defining any generic
// functions or types itself.
//
// The commands are:
//

View File

@ -26,6 +26,12 @@ var cmds = map[string]bool{
"translate": true,
}
var useBrackets bool
func init() {
flag.BoolVar(&useBrackets, "brackets", false, "expect square brackets for generics")
}
func main() {
flag.Usage = usage
flag.Parse()
@ -46,6 +52,9 @@ func main() {
defer os.RemoveAll(importerTmpdir)
importer := go2go.NewImporter(importerTmpdir)
if useBrackets {
importer.UseBrackets = true
}
var rundir string
if args[0] == "run" {