Is there an alternative to gomvpkg that actually works?

polaris · · 482 次点击    
这是一个分享于 的资源,其中的信息可能已经有所发展或是发生改变。
<p>gomvpkg panics when it actually accepts to try moving a package. Is there any alternative tool that allows one to move a go package to another folder and rewrite all imports from dependent packages automatically? </p> <pre><code>panic: runtime error: invalid memory address or nil pointer dereference [signal 0xc0000005 code=0x0 addr=0x28 pc=0x497db6] goroutine 1 [running]: panic(0x674040, 0xc04200e0c0) C:/bin/Go/src/runtime/panic.go:500 +0x1af golang.org/x/tools/refactor/rename.loadProgram(0x7e2ee0, 0xc043271500, 0xc0437d9c50, 0xc0437d9c40, 0xc042006520) c:/Users/xxx/development/src/golang.org/x/tools/refactor/rename/rename.go:397 +0x2c6 golang.org/x/tools/refactor/rename.Move(0x7e2ee0, 0xc0420423e0, 0x19, 0xc042042400, 0x19, 0x0, 0x0, 0x0, 0x4) c:/Users/xxx/development/src/golang.org/x/tools/refactor/rename/mvpkg.go:91 +0x735 main.main() c:/Users/xxx/development/src/golang.org/x/tools/cmd/gomvpkg/main.go:90 +0x186 </code></pre> <hr/>**评论:**<br/><br/>sh41: <pre><p><code>gomvpkg</code> is open source. Why would there be another tool that does the same thing, except with fewer bugs?</p> <p>I&#39;ve never had issues or panics when using <code>gomvpkg</code>, it has been very a solid tool in my experience. But I used it a while ago. Maybe there&#39;s a regression, or maybe you&#39;re using an old or broken version. Did you try doing <code>go get -u golang.org/x/tools/cmd/gomvpkg</code>? What version of Go are you using?</p> <p>Your best bet is to report an issue at <a href="https://github.com/golang/go/issues" rel="nofollow">https://github.com/golang/go/issues</a>.</p></pre>adamryman: <pre><p>I have not found one that works constantly.</p> <p>I use a little script I wrote to do it via textual search and replace with <code>ag</code> and <code>sed</code>.</p> <p>Search for the current import with <code>ag</code> and then do <code>ag-replace old/import new/import</code>.</p> <p><a href="https://github.com/adamryman/dotfiles/blob/master/scripts/ag-replace.sh" rel="nofollow">https://github.com/adamryman/dotfiles/blob/master/scripts/ag-replace.sh</a></p> <p>I know it is not ideal, though it does the job for me.</p> <p>Pretty sure you can use <code>gofmt</code> to do the text replace as well, though I have messed with it.</p></pre>

入群交流(和以上内容无关):加入Go大咖交流群,或添加微信:liuxiaoyan-s 备注:入群;或加QQ群:692541889

482 次点击  
加入收藏 微博
暂无回复
添加一条新回复 (您需要 登录 后才能回复 没有账号 ?)
  • 请尽量让自己的回复能够对别人有帮助
  • 支持 Markdown 格式, **粗体**、~~删除线~~、`单行代码`
  • 支持 @ 本站用户;支持表情(输入 : 提示),见 Emoji cheat sheet
  • 图片支持拖拽、截图粘贴等方式上传