【问题标题】:golang gofmt package rewrite wildcardgolang gofmt 包重写通配符
【发布时间】:2016-08-15 10:36:27
【问题描述】:

我正在尝试对所有以某个前缀开头的包进行gofmt 重写。比如:

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

显然wildcard 不是有效的语法,只是展示了这个概念。我尝试过使用单个小写字符,但这在这里不起作用。

我可以用gofmt 做我正在尝试的事情吗?

【问题讨论】:

  • gofmt 不能这样做,因为通配符只能匹配表达式,不能匹配任意文本。您可以使用 github.com/rogpeppe/govers 来满足您的需求。
  • 谢谢。请张贴作为答案,我会接受

标签: go import url-rewriting gofmt


【解决方案1】:

这是 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/

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2023-03-13
    • 1970-01-01
    • 2018-03-22
    • 2014-06-11
    • 2021-02-07
    • 1970-01-01
    • 2011-08-25
    • 2022-11-24
    相关资源
    最近更新 更多