Anyone actually dev Golang on Windows?

polaris · · 518 次点击    
这是一个分享于 的资源,其中的信息可能已经有所发展或是发生改变。
<p>I got basic Golang running, but anything beyond very basic packages like TOML, anything that requires additional compilation fails on pkg-config. Tried installing Cygwin, Mingw, etc and dealing with the sketchiness along with them, still can&#39;t go get some packages. Should I just roll with WSL? I pretty much wasted the evening and dirtied my system trying to even get Go to see pkg-config and failed. Anyone manage to have luck developing Go? Am I just trying to do too much on Windows? I was hoping to get the libvirt-go package running which should be technically possible but none of the bastardized Linux wrappers seem to cooperate.</p> <p>Edit: msys2 works great like <a href="/u/animalmachine" rel="nofollow">/u/animalmachine</a> mentioned. A lot more polished way of deailng with mingw.</p> <hr/>**评论:**<br/><br/>dlsniper: <pre><p>No, you should assume that nobody develops on Windows. Nor should you think that by having a vague thread with nothing in it would get you more that useless replies like this.</p></pre>permalink_save: <pre><p>&#34;Nobody develops on Windows&#34; that&#39;s a naive assumption. Not everyone can chose their dev box, plus all the .net shops. I don&#39;t see how my post is vague. The tool chain is confusing despite Go docs promoting using mingw, it doesn&#39;t seem to work. I don&#39;t see how asking if anyone has gotten it to work is vague or meaningless. Bitchy maybe, but would you be happy if your OS got polluted from bad instructions?</p></pre>dlsniper: <pre><p>That was sarcasm. </p> <p>I develop on Windows, not cywin, mingw, WsL or other gimmicks. And it works fine. Post some error messages, steps you took to get to the said error message and so on. You just complain about it not working bit you expect magically we know why.</p> <p>It works for me and it works quite well. See how that is equally useless for your problem? </p></pre>AnimalMachine: <pre><blockquote> <p>I don&#39;t see how my post is vague.</p> </blockquote> <p>The way you word the title and the paragraph is vague. It makes it seem as if the question is &#34;does anyone actualy dev golang on windows&#34; which the obvious answer is yes. You seem to have a secondary question of getting libvirt to work on windows. You should have gotten to that point a lot quicker.</p> <p>And yes, I&#39;ve written a number of libraries compatible with windows. I use msys2 to give me a 64 bit mingw chain. Make sure to install the &#39;mingw-w64-x86_64-*&#39; versions of gcc or pkg-config or whatever else you need. And make sure to install the amd64 version of Go as well.</p></pre>permalink_save: <pre><p>That is true, my thought train was how are people to code Golang when anything needing GCC doesn&#39;t seem to work. Didn&#39;t try msys2, but it looks really promising. I&#39;m going to give that a try tomorrow. Looks a lot more polished than what it aims to replace. Thanks.</p> <p>Edit: yep, finds pkg-config. Not sure if libvirt is going to work but it is at least finding GCC and pkg-config, and sees <em>a</em> libvirt.pc but it&#39;s the wrong arch, either way if I can get this far at least compilation works. Thanks again, really wish msys2 was better known. Pacman makes everything a lot less painful to deal with than random msis on the internet.</p></pre>AnimalMachine: <pre><p>Yup, it&#39;s pretty rad stuff. A re-sizable terminal to boot!</p></pre>Sythe2o0: <pre><p>I develop on windows in cmd/powershell and do fine, but I specifically avoid packages that require gcc. What I&#39;ve found is a lot of specific projects have windows bugs because the people developing the project didn&#39;t sufficiently test their windows code.</p></pre>: <pre><p>[deleted]</p></pre>aboukirev: <pre><p>Concur. I use MSYS2 on Windows and with rare exceptions (a couple of instances in the past) packages with cgo compile and work.</p></pre>Tacticus: <pre><p>i think Brian Ketelsen does but in the wsl setup.</p></pre>permalink_save: <pre><p>Man, and that&#39;s what I&#39;m starting to lean towards. Of course I lose linting in my editor, which is what I&#39;m more curious about. I&#39;m not 100% on how Windows interprets paths for WSL, or if it even does (could be Git GNU tools). Wondering if I just install what I can for Go in Windows for lint and ignore missing packages.</p></pre>ligustah: <pre><p>I develop on Windows (both 7 and 10) and have done so for years without any problems. I use chocolatey to install all cli dependencies (like git, hg), write code in Atom and use mingw 64 for anything that requires tools outside of the go toolchain. I have never come across any errors related to pkg-config. Then again, I don&#39;t really use CGO a lot (either in my code or in third party libraries), except for maybe sqlite3, but that one compiles just fine on my systems.</p> <p>EDIT: I also think the git package from chocolatey comes with a bash shell that I use for most of my shell needs (especially on Windows 7 the native command prompt just sucks).</p></pre>permalink_save: <pre><p>For sqlite, have you tried <a href="https://github.com/mattn/go-sqlite3" rel="nofollow">https://github.com/mattn/go-sqlite3</a> yet? From Matz and says it doesn&#39;t require GCC at all.</p> <p>Yeah mingw was the main problem, but it didn&#39;t seem to install right from their sourceforge link. Msys2 works great though.</p></pre>ligustah: <pre><p>That is the library I use for sqlite3.</p></pre>tsdtsdtsd: <pre><p>I develop most of my private stuff on windows and use linux at work</p></pre>gopher1717: <pre><p>Go works very well on windows. (I develop in both windows and Linux). It&#39;s a different story than Ruby that is a mess on Windows. </p> <p>Don&#39;t use cygwin or similar. Just use cmd or Git Bash. </p> <p>Also, if you are trying to compile something that needs C, pay attention for which version of MinGW you have. You need MinGW 32 for Go 32 or MinGW 64 for Go 64. This is a common mistake.</p></pre>cube2222: <pre><p>I&#39;m developing on windows.</p> <p>For most things everything should work out of the box.</p> <p>Regarding cgo, don&#39;t waste your time and just use Bash on Ubuntu on Windows (aka WSL), it works flawlessly.</p></pre>Sythe2o0: <pre><p>It&#39;s worth noting you can&#39;t test gui or audio applications in Windows 10&#39;s Ubuntu.</p></pre>cube2222: <pre><p>Well, not saying you can test gui or audio applications, but I was able to get an X Client running to connect from windows. It was working flawlessly and fluently.</p></pre>eggsampler: <pre><p>If you want to develop on windows and need CGO, a really easy drop in gcc to use is this: <a href="http://tdm-gcc.tdragon.net/" rel="nofollow">http://tdm-gcc.tdragon.net/</a> - just throw the installed location in your path and should be good to go. Have used this to good effect with quite a few beginners to get them into go smoothly.</p> <p>That said, I&#39;ve used msys2, cygwin and wsl and probably the easiest of these to use is msys2. If you want to cross compile for linux or osx use wsl though, don&#39;t bother setting up a cross compiler.</p></pre>CountyMcCounterson: <pre><p>Everything works perfectly native you&#39;re just a scrub</p></pre>nasciiboy: <pre><p>mv to gnu/linux and be happy</p></pre>shovelpost: <pre><p>You don&#39;t need anything extra to make Go work on windows. </p> <ul> <li>Download the <a href="https://golang.org/dl/" rel="nofollow">latest version</a></li> <li>Run the installer</li> <li>(Latest versions automatically set your <code>GOPATH</code> to <code>C:\go</code> so you don&#39;t need to do that)</li> <li>Add <code>%GOPATH%\bin</code> to your <code>PATH</code></li> <li>Open <code>cmd</code>, enter <code>go</code>, verify that it is installed.</li> <li>enter <code>go get github.com/rjeczalik/pkgconfig/cmd/pkg-config</code></li> <li>enjoy</li> </ul></pre>

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

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