TE
TechEcho
Home24h TopNewestBestAskShowJobs
GitHubTwitter
Home

TechEcho

A tech news platform built with Next.js, providing global tech news and discussions.

GitHubTwitter

Home

HomeNewestBestAskShowJobs

Resources

HackerNews APIOriginal HackerNewsNext.js

© 2025 TechEcho. All rights reserved.

When in Go, do as Gophers do

80 pointsby jvermillardover 10 years ago

10 comments

dyadicover 10 years ago
I&#x27;ve only been using Go for less than a week and my impressions are less than good. I&#x27;m still waiting and hoping to understand what it is that people like about Go, but I&#x27;m starting to suspect that won&#x27;t happen.<p>The biggest problem I have had most so far is when reading other code, finding the meaning amongst all of the error nil checks and the sprawling if conditions that they bring.<p>Another thing that makes it difficult is the preference for scattering returns everywhere and avoiding `else if`s, I read code structurally so code like this from slide 29 (<a href="http://talks.golang.org/2014/readability.slide#29" rel="nofollow">http:&#x2F;&#x2F;talks.golang.org&#x2F;2014&#x2F;readability.slide#29</a>) is really difficult to parse.<p><pre><code> func finishStatus(r Result, complete bool) int { if !complete { return http.StatusAccepted } if stat, ok := r.Object.(*api.Status); ok &amp;&amp; stat.Code != 0 { return stat.Code } if r.Created { return http.StatusCreated } return http.StatusOK }</code></pre>
评论 #8712401 未加载
评论 #8712746 未加载
sansworkover 10 years ago
I&#x27;ve never known a language with so much discussion on why what you are doing isn&#x27;t idiomatic as Go.<p>I&#x27;m enjoying using Go for the few small services I&#x27;m using it for but it seems that a language which has to constantly fight it&#x27;s users to reinforce what it considers idiomatic has some core issues.
评论 #8712028 未加载
评论 #8711939 未加载
评论 #8712469 未加载
评论 #8713409 未加载
评论 #8712032 未加载
评论 #8712171 未加载
评论 #8712826 未加载
jdkananiover 10 years ago
As I go from normal Go style to idiomatic Go style, I find more error checks. That is annoying when your code grows.<p><a href="http://talks.golang.org/2014/readability.slide#11" rel="nofollow">http:&#x2F;&#x2F;talks.golang.org&#x2F;2014&#x2F;readability.slide#11</a><p>In this example, have to check error 3 times to write 4 lines of code.
评论 #8712214 未加载
评论 #8712924 未加载
pjmlpover 10 years ago
Sad that this is still the way to test for interface implementations.<p><a href="http://talks.golang.org/2014/readability.slide#17" rel="nofollow">http:&#x2F;&#x2F;talks.golang.org&#x2F;2014&#x2F;readability.slide#17</a>
评论 #8712122 未加载
kremlinover 10 years ago
I&#x27;m on Chrome on Mac and it&#x27;s not entirely obvious how to navigate these slides. Going to the link only shows me the first 3 slides by scrolling right.<p>Playing around a bit, I discovered that the arrow keys bring you to the next slides. Perhaps there could be a way to make that more obvious, or provide buttons onscreen.
mratzloffover 10 years ago
I found that I already do all of these as a result of reading through a lot of the Go standard library when I was learning it. One of the best ways to really learn a language is to read the standard library (the parts implemented in that language, anyway). That way you get a sense of the idioms used, but also understand the sometimes subtle trade-offs of common functions.
评论 #8712059 未加载
lukasmover 10 years ago
I don&#x27;t get where is the bug in this code:<p><a href="http://talks.golang.org/2014/readability.slide#10" rel="nofollow">http:&#x2F;&#x2F;talks.golang.org&#x2F;2014&#x2F;readability.slide#10</a>
评论 #8712570 未加载
minhajuddinover 10 years ago
Unrelated to the core presentation. I wrote <a href="http://readcode.in/" rel="nofollow">http:&#x2F;&#x2F;readcode.in&#x2F;</a> to help with reading source code in a simple single page format. It really fits go code repositories as they are usually small. e.g. <a href="http://readcode.in/github.com/gorilla/mux" rel="nofollow">http:&#x2F;&#x2F;readcode.in&#x2F;github.com&#x2F;gorilla&#x2F;mux</a>
zerrover 10 years ago
Am I the only one who associates &quot;Gopher&quot; with Gopher (protocol)? Or is Golang so much prevalent nowadays? :)
vegabookover 10 years ago
Where&#x27;s the gopher?! Idiomatic Golang presentations should include a non-broken link to the gopher.