Help: Recovering code from pkg?

blov · · 510 次点击    
这是一个分享于 的资源,其中的信息可能已经有所发展或是发生改变。
<p>Today I accidentially deleted my go project (ironically when trying to connect it to my git repo).</p> <p>Since my backup failed and this was my only copy, i was wondering if there is a way to get (parts of) the code back from the .a files in GOPATH/pkg.</p> <p>I already tried file recovery tools without any luck so this appears to be my last hope.</p> <p>The only thing I could recover was one .go file from a temp folder.</p> <p>Thanks for any help and advice.</p> <p>PS: I looked into the .a files and there seems to be enough human readable data for me to at least recreate most of the structure but I would obviously prefer to get function implementations along with it.</p> <hr/>**评论:**<br/><br/>shovelpost: <pre><p>I am assuming that the amount of code you wrote wasn&#39;t that much otherwise the project would already be on version control. It&#39;s quite likely that the amount of time you need to rewrite it will take much less than finding how to recover the code.</p> <p>That said, losing work always sucks big or small.</p> <p>Also, which operating system are you using? Maybe there is a way to recover the contents of the folder that way.</p></pre>TheShyro: <pre><p>I&#39;m on Windows. And yes it wasn&#39;t <em>that</em> much code.</p> <p>I tried the &#39;previous versions&#39; feature but found out Windows removed the folder from the list of backed up paths (I&#39;m pretty sure I explicitly added it at one point).</p> <p>You are probably right that rewriting it won&#39;t be that big of a deal but since it&#39;s annoying to write the same thing again I figured I&#39;d try recovering it first.</p></pre>IllegalCharacter: <pre><p>Do you use an IDE that supports local history? Unlikely, since I don&#39;t know of one that has <em>good</em> golang support, but if you&#39;re using IntelliJ or something, you can recover deleted code that way.</p></pre>TheShyro: <pre><p>Eclipse.</p> <p>While it does have local history, you can&#39;t restore deleted projects.</p></pre>sethammons: <pre><p>Ouch. As soon as my project gets more than a few lines, I <code>git init</code>. I learned the hard way to also push that up every time something gets stable(ish). I was working in sublime and every now and then the auto-complete would stop working and the best fix was <code>rm -rf $GOPATH/pkg</code>. I accidentally did <code>rm -rf $GOPATH/src</code>. Oh, that sinking feeling. I changed that command to an alias, started pushing up branches more frequently, and now am on vscode. All three are solid improvements.</p></pre>

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

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