我爱占星网 我爱占星网
首页
编程
java
php
前端
首页 编程 java php 前端

如何批量更改GO软件包的别名?

I want rename many packages across many files. At the same time, I also want to change package aliases. Is there any tool to do that? The ones I find in go/x/tools only change package imports.

I want to go from import "github.com/a/b"

to

import b "github.com/c/d"

There is a cool trick with std tools.

gofmt has an option -r rule which works like this:

gofmt -w -l -r "github.com/a/b -> github.com/c/d" .

where rule have format pattern -> replacement

See gofmt docs

Also there is a gofix tool, but I haven't tried it, see docs and blog

近期文章

  • Goapp服务-警告:文件过多
  • 使用codegangsta / cli捕获命令标志变量
  • 无法从Stripe获得卡牌
  • 如何在Golang中使用成员函数正确模拟结构?
  • 如何使用Golang将变量放入电子邮件正文中?
  • 编译到Android:pthread_key_create的无效签名
  • 如何使用反射制作多维数组或切片
  • 我可以使用s3manager重命名s3上的大文件还是小文件?
  • 如何在C ++中使用GOlang方法?
  • 在API Rest golang中发送cookie
  • 哈希表:不进行转换的转换?
  • ListenAndServe返回net.DNSError“提供了节点名或服务名”
  • 同时插入到Redis
  • 不在终端上运行
  • 获取未编组的json struct中的键的值
  • 使用Go语言在AWS S3中创建对象
  • 当我启用module.jobs时Revel无法启动
  • 在Websocket(golang)上将一个客户的消息反映给另一个客户
  • 根据失败的POST请求呈现模板[golang]
  • 在Gorilla Mux处理之后运行中间件

Copyright ©2022 我爱占星 All Rights Reserved.

浙ICP备2022030071号-1

部分图文来自网络,如有侵犯您的版权,请告诉我们删除

友情链接:代码精华