<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't that much otherwise the project would already be on version control. It'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'm on Windows. And yes it wasn't <em>that</em> much code.</p>
<p>I tried the 'previous versions' feature but found out Windows removed the folder from the list of backed up paths (I'm pretty sure I explicitly added it at one point).</p>
<p>You are probably right that rewriting it won't be that big of a deal but since it's annoying to write the same thing again I figured I'd try recovering it first.</p></pre>IllegalCharacter: <pre><p>Do you use an IDE that supports local history? Unlikely, since I don't know of one that has <em>good</em> golang support, but if you'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'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
- 请尽量让自己的回复能够对别人有帮助
- 支持 Markdown 格式, **粗体**、~~删除线~~、
`单行代码`
- 支持 @ 本站用户;支持表情(输入 : 提示),见 Emoji cheat sheet
- 图片支持拖拽、截图粘贴等方式上传