TE
科技回声
首页24小时热榜最新最佳问答展示工作
GitHubTwitter
首页

科技回声

基于 Next.js 构建的科技新闻平台,提供全球科技新闻和讨论内容。

GitHubTwitter

首页

首页最新最佳问答展示工作

资源链接

HackerNews API原版 HackerNewsNext.js

© 2025 科技回声. 版权所有。

Go 1.11 got me to stop ignoring Go

119 点作者 waits超过 6 年前

14 条评论

brandur超过 6 年前
A few years into using Go, I have mixed feelings about `GOPATH`. On one hand, I can see the author&#x27;s frustration in that it was always incredibly presumptuous of the language&#x27;s authors to dictate how its users should organize their hard drives, and more so it feels like exactly the type of arrogance that people tend to attribute to the Go&#x27;s core and community.<p>Also, having helped a number of people now through their early days of the language it&#x27;s also the one biggest thing by far that reliably confuses every single person. And I mean <i></i>everyone<i></i> — from first time programmers all the way up to people who&#x27;ve been in the industry for decades and are learning Go as their tenth language. Being forced to put files in certain places is incredibly non-intuitive because there&#x27;s nothing else out there that requires it. I must have sent the Go documentation on workspaces [1] to two dozen different people at this point.<p>But on the other hand, once you&#x27;ve grasped the system and are using it, `GOPATH` is surprisingly not bad. It&#x27;s always obvious where your dependencies are located and which versions are going to be used to build your project. Even better, it lets you very easily drop into those dependencies and add minor changes or debugging lines if you need to. This can be <i>incredibly</i> useful if you&#x27;re trying to understand how one of them works or think that that you might have found a bug and trying to verify or patch it. A very powerful feature once you know about it.<p>The new Go modules seem good, and will be a huge improvement in lowering the barrier to entry for Go, but I&#x27;ll miss the old `GOPATH` style of work at this point.<p>[1] <a href="https:&#x2F;&#x2F;golang.org&#x2F;doc&#x2F;code.html#Workspaces" rel="nofollow">https:&#x2F;&#x2F;golang.org&#x2F;doc&#x2F;code.html#Workspaces</a>
评论 #18179510 未加载
评论 #18179511 未加载
评论 #18180319 未加载
评论 #18179452 未加载
sebcat超过 6 年前
Having introduced Golang in a business environment in 2014 and having seen the language solve real problems at that time, at scale, I feel that if your own reason to not use Go is GOPATH... Either Go does not solve any real problems for your use case, or your reasons to use Go is misaligned.<p>GOPATH is really not a problem, but efficient concurrency is. Go made the company I worked for go from 20 deployments for a service to 1 (I&#x2F;O bound), reducing the costs for that service a lot. If you are willing to let the environment get in between that...<p>Of course, you could have implemented that system using assembler for all I care, but Go really made it possible within that organization, something Java, C and other languages failed at before Go was introduced.<p>N=1, ymmv, &amp;c
评论 #18179695 未加载
评论 #18179878 未加载
sonaltr超过 6 年前
I whole heartedly agree with the author.<p>While I disagree with GO&#x27;s style guide and a ton of other choices - I don&#x27;t mind following them since that&#x27;s what the language requires. But it goes past that and wants me to organize everything my working directory just for it - it&#x27;s absolutely crossing a line.<p>While I didn&#x27;t stop using Go because of GOPATH, it&#x27;s one of those things that absolutely annoyed the crap out of me.<p>to the point that all my go projects are now organized as `project_name&#x2F;go&#x2F;src&#x2F;github.com&#x2F;username&#x2F;project_name` as an example.<p>This was really really annoying to say the least.
评论 #18179277 未加载
评论 #18179208 未加载
jerf超过 6 年前
If you read over the rest of this thread, you can find opinions ranging from &quot;GOPATH is horrible&quot; to &quot;It&#x27;s wonderful&quot;. And I just want to point out this is pretty good example of how important the marginal improvements can be. Abstractly, you might have a hard time sitting there imagining how for a thousand of your users, improving $ONE_SMALL_FEATURE might flip them from not paying you to paying you, but at scale, yes, such margin-based thinking really is important. Just like you may find it hard to really intuit that going from .75s page rendering to .5s page rendering can have a significant impact on the bottom line for an e-retailer, but, yeah, it does.<p>Just wanted to point this out as a clear example of such an issue, since it doesn&#x27;t come up very often so cleanly.
tingletech超过 6 年前
I guess go 1.11 introduced a modules experimental feature as an alternative to `GOPATH`<p>&gt; Go 1.11 adds preliminary support for a new concept called “modules,” an alternative to GOPATH with integrated support for versioning and package distribution. Using modules, developers are no longer confined to working inside GOPATH, version dependency information is explicit yet lightweight, and builds are more reliable and reproducible. <a href="https:&#x2F;&#x2F;golang.org&#x2F;doc&#x2F;go1.11#modules" rel="nofollow">https:&#x2F;&#x2F;golang.org&#x2F;doc&#x2F;go1.11#modules</a>
symmitchry超过 6 年前
&gt; I have major gripes with PEP-8, and if you ever see me using it I want you to shoot me in the face.<p>That sounds extreme. I&#x27;ve never heard this before. Why?
评论 #18179077 未加载
评论 #18179203 未加载
评论 #18179124 未加载
docker_up超过 6 年前
My biggest problem with Go is the lack of a constructor. I don&#x27;t feel that a struct type is good enough to enforce data integrity and as you have a more complex program, you need to know that the object you are being passed has data integrity.<p>With a constructor, I can force data to conform to what I need it to. I can ensure that certain fields are not nil, that they conform to a specific list of values, etc.<p>Because of a lack of a constructor in Go, I can&#x27;t do that and I need to continuously validate the data, which is annoying and a source of bugs. It can be said that this can be accomplished with interfaces but that&#x27;s adding a lot of complexity to something that should be a lot easier to handle, in my opinion.
评论 #18179305 未加载
评论 #18179534 未加载
评论 #18184501 未加载
评论 #18179326 未加载
评论 #18179359 未加载
paxy超过 6 年前
I have used goinstall, go get (in GOPATH), godep, dep, multiple GOPATHs, symlinks, git submodules and lots more to figure out dependencies in Go, and modules is FINALLY something that actually makes sense.
neduma超过 6 年前
GOPATH issues - Elaborate more?
评论 #18179064 未加载
评论 #18179017 未加载
评论 #18178987 未加载
评论 #18178996 未加载
throw7超过 6 年前
But how did Go solve the GOPATH problem? He didn&#x27;t say.
评论 #18179307 未加载
floatboth超过 6 年前
I actually adopted GOPATH for <i>everything</i>. I use <a href="https:&#x2F;&#x2F;github.com&#x2F;motemen&#x2F;ghq" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;motemen&#x2F;ghq</a> to quickly clone non-Go projects into the ~&#x2F;src&#x2F;github.com&#x2F;user&#x2F;project style paths.<p>But… I don&#x27;t like Go itself (anymore).<p>It&#x27;s not just the &#x27;if err != nil&#x27;, it&#x27;s more the general attitude&#x2F;philosophy from which it comes. Go is anti-intellectual, the designers basically don&#x27;t respect the user. &quot;You&#x27;re too stupid to use generics&#x2F;Result&lt;A,B&gt;&#x2F;monads&#x2F;whatever&quot; is what it feels like they think of you.<p>Go internals are more infuriating than Go language though…<p>Especially the Plan9-based custom assembler. It truly is a horrific atrocity. I&#x27;ve had to deal with it two times:<p>1. That assembler does not support all instructions and even addressing modes (!) of amd64, so people have had to create hacks like <a href="https:&#x2F;&#x2F;github.com&#x2F;minio&#x2F;c2goasm" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;minio&#x2F;c2goasm</a> to run asm functions without the overhead of cgo. Please actually read that project&#x27;s README, but tl;dr it assembles your code using a normal assembler and STICKS THE BINARY CODE INTO A GO ASSEMBLY FILE AS HEX CONSTANTS. This hack actually didn&#x27;t work for me when I tried to use some SIMD code, so I had to resort to cgo with its call overhead.<p>2. I also tried (and failed) to port the Go runtime to FreeBSD&#x2F;aarch64. This was the last straw, this is what made me actually <i>hate</i> Go.
haolez超过 6 年前
Side note: I really liked the design of his blog.
xet7超过 6 年前
Yes, but how to do error handling correctly with Go? My Go code crashes.
sdinsn超过 6 年前
Server is down?