<p>Hi,</p>
<p>I'm trying to do something very simple. I want to get text from some page. So I tried using net/http and io/ioutil but right away I started getting a weird error. <a href="https://gist.github.com/cjfshaw/85c4872b342d7473d5fb7d83584bb8f4" rel="nofollow">Here is a gist</a> that contains the code as well as the error I'm seeing and how I'm trying to run the program.</p>
<p>I have no idea what's happening here. I know that my GOPATH and general dev environment is in working order, as every other program I've run has worked without issue.</p>
<p>OS information:</p>
<p>No LSB modules are available.</p>
<p>Distributor ID: Ubuntu</p>
<p>Description: Ubuntu 15.10</p>
<p>Release: 15.10</p>
<p>Codename: wily</p>
<p>ETA: Solved thanks to <a href="/u/mwholt" rel="nofollow">/u/mwholt</a> </p>
<p>But now I'm seeing a new issue. http.Get is giving me a "corrupt input"
I've been looking online but haven't seen anything that would help me out with this.</p>
<hr/>**评论:**<br/><br/>nicerobot: <pre><p>What is your <code>go env</code>? You probably have defined a wrong <code>GOROOT</code>. What's it's telling you is that it's trying to recompile the standard library which is an indication that your <code>go env</code> isn't correct.</p></pre>CodeScrub: <pre><p>Hey, I've updated the gist to include the output from go env</p></pre>mwholt: <pre><p>That error is caused during linking. Make sure your user has permission to read the /usr/local/go folder.</p></pre>CodeScrub: <pre><p>I gave my user perms to the repo and the error has disappeared, thanks!</p>
<p>Although now I'm seeing something now; I'm seeing corrupt input when trying to use http.Get</p></pre>mwholt: <pre><p>That's weird. <a href="https://golang.org/src/cmd/link/internal/ld/objfile.go?h=corrupt+input" rel="nofollow">Some obscure error with the linker.</a> Try clearing your $GOPATH/pkg folder and compile again?</p></pre>CodeScrub: <pre><p>few questions for you about this</p>
<p>1.) How'd you even find that?</p>
<p>2.) How did you get clearing the gopath/pkg from that?</p>
<p>3.) When you said clear what did you mean? I just moved everything in that directory out into another one and then tried running the program again (with go run, vs go build).</p></pre>mwholt: <pre><blockquote>
<p>I just moved everything in that directory out into another one and then tried running the program again (with go run, vs go build).</p>
</blockquote>
<p>Did it work?</p>
<blockquote>
<p>1.) How'd you even find that?</p>
</blockquote>
<p>I <a href="https://golang.org/search?q=corrupt+input" rel="nofollow">searched golang.org for corrupt input</a>.</p>
<blockquote>
<p>2.) How did you get clearing the gopath/pkg from that?</p>
<p>3.) When you said clear what did you mean?</p>
</blockquote>
<p>The compiler makes object files and these are typically stored in $GOPATH/pkg. The linker then reads the object files to produce the final exe. The pkg folder is just a cache so it can be "cleared" (deleted or emptied, either one) without harm; just means the next build might take a little bit longer.</p>
<p>Since you were having strange issues during linking I figured clearing that folder wouldn't be a bad idea...</p></pre>CodeScrub: <pre><p>naw it didn't work</p>
<p>ah I was just searching google, I'll search golang.org in the future, thanks!</p>
<p>How does the pkg folder get repopulated?</p></pre>mwholt: <pre><p>I believe go build and go install will cache object files in pkg.</p></pre>CodeScrub: <pre><p>bah, I rm -rf the directory within $GOPATH/pkg, ran go build on one of my other projects, and then checked the pkg directory and it's still blank O_O</p></pre>RandNho: <pre><p>Go build doesn't cache, only go install (and go get, as it includes install step in default application) does.</p></pre>gohacker: <pre><p><code>which go</code></p></pre>
这是一个分享于 的资源,其中的信息可能已经有所发展或是发生改变。
入群交流(和以上内容无关):加入Go大咖交流群,或添加微信:liuxiaoyan-s 备注:入群;或加QQ群:692541889
- 请尽量让自己的回复能够对别人有帮助
- 支持 Markdown 格式, **粗体**、~~删除线~~、
`单行代码`
- 支持 @ 本站用户;支持表情(输入 : 提示),见 Emoji cheat sheet
- 图片支持拖拽、截图粘贴等方式上传