go - How do I refactor module name in Go?
问题描述
I have a Go module named mymodule
, and I'd like to rename it into github.com/hylowaker/awesome-module
Using command go mod edit -module github.com/hylowaker/awesome-module
only changes module name in go.mod
file, leaving go sources unchanged. I tried Refactor feature in GoLand IDE, but GoLand does not allow renaming with slash(/
) characters.
So I had to find and replace every import "mymodule/..."
into import "github.com/hylowaker/awesome-module/...
from my source files.
Is there a better way to refactor them?
解决方案
此功能在 GoLand 版本 2021.1 中引入。
Shift+F6
您可以通过按下文件中的模块名称来调用重命名重构go.mod
。
推荐阅读
- sql - SQL Group By + Count 与多个表
- java - Hibernate查询真的比SQL更省时间吗?
- sql - 不明确的列名“ProductNumber”
- php - 在 PHP 循环中为每个 SHELL_EXEC 设置超时
- python - 如何从 python 覆盖单元测试中省略(删除)虚拟环境(venv)?
- javascript - Reactjs无法打印ID
- reactjs - 如何让 reactJS 呈现状态变量
- eclipse - Eclipse 在运行或调试期间未使用 gradle 依赖项 jar
- while-loop - 在while循环之外定义的变量没有在里面定义?
- python - 熊猫时间序列,过滤倒数第二个工作日