2016-04-22 80 views
2

我试图对gofmt重写所有以某个前缀开头的包。喜欢的东西:golang gofmt包重写通配符

gofmt -r 'github.com/some/path/<wildcard> -> someotherrepo.com/some/path/<wildcard>'

显然wildcard是无效的语法,只是表示其原理。我尝试过使用一个小写字母,但这在这里不起作用。

是否有可能通过gofmt来完成我正在尝试的操作?

+0

'gofmt'不能做到这一点,因为通配符只能匹配表达式,而不是任意的文本。你可以使用https://github.com/rogpeppe/govers,这正是你想要的。 – JimB

+0

谢谢。请作为回答发布,我会接受 –

回答

-2

这就是gofmt命令页说

Given a file, it operates on that file; given a directory, it operates on all .go files 
in that directory, recursively 

https://golang.org/cmd/gofmt/