8 ms·
Go by Example
- lukasm 11y agoReally nice. I'd be better to have them in a single place, similar to http://coffeescript.org/ http://coffeescript.org/ Better grepablity.
- melling 11y agoI started keeping personal one page notes on Github for languages I want to learn so that it's easier to be effective when I start a small project. Here are my Go notes: https://github.com/melling/ComputerLanguages/blob/master/go.org https://github.com/melling/ComputerLanguages/blob/master/go.... My OCaml notes are a better example of what I'm trying to do: https://github.com/melling/ComputerLanguages/blob/master/ocaml.org https://github.com/melling/ComputerLanguages/blob/master/oca...
- gab_metzger 11y agoIf you want quick introduction about some languages, there is also https://learnxinyminutes.com/ https://learnxinyminutes.com/.
- mattiemass 11y agoLooks great - well done!
- dpflan 11y agoGo does have some nice, clean resources, provided by the core language group and users. I find golang.org to be quite helpful. If you're interested in learning Go, I suggest Go's A Tour of Go to start: http://tour.golang.org/welcome/1 http://tour.golang.org/welcome/1 There is a previous discussion of Go by Example if you want to mine the comments: https://news.ycombinator.com/item?id=7075515 https://news.ycombinator.com/item?id=7075515 There is also Effective Go for learning about, well, idiomatic Go: https://golang.org/doc/effective_go.html https://golang.org/doc/effective_go.html And there is a previous discussion of Effective Go if you want to mine the comments: https://news.ycombinator.com/item?id=4285461 https://news.ycombinator.com/item?id=4285461
- wiremine 11y agoI second the recommendation Effective Go. It's a fairly quick read and routed me around a lot of poor design decisions: https://golang.org/doc/effective_go.html https://golang.org/doc/effective_go.html
- Numberwang 11y agoAre any of these for novice programmers?
- dpflan 11y agoHow novice? You could try out the Go Tour [1.]; it's gradual and if you find yourself getting stuck, you can break and definitely use Google to find help. [1.] http://tour.golang.org/welcome/1 http://tour.golang.org/welcome/1
- kylequest 11y agoThe Tour is a great place to start. It's a good idea to complement the basics you learn there with the common gotchas. "50 Shades of Go" covers most of the major gotchas.
- paradite 11y agoEdit: This site is great, really good for people who haven't seen it. (Please stop downvoting me:)) Am I missing something here? This site is well known and I have been using it as reference for a long time.
- guessmyname 11y agoOP must be new to Go if he does not knows this website already. And the argument that people use in other submissions to justify a re-post or apparently irrelevant submissions does not works here because if you search "Go Examples" [1] in most web crawlers will return this website among the first results. [1] https://www.google.com/search?q=go+examples https://www.google.com/search?q=go+examples
- Kurtz79 11y agoI didn't know about it and I'm glad someone posted the link. It's common for old stories get reposted, and it's fine since it's impossible for everyone to be aware of everything all the time.
- myst 11y agoEveryone who at least couple of times googled for anything Go related knows this site. Should I post golang.org now, because there may be someone living under a rock?
- laumars 11y agoI've been programming in Go for a few years now and I've never seen this site before. It's quite possible that the specific search terms you use (eg I never include "example" when Googling about Go[1]) and Google's personalisation (eg favouring resources you've used previously) would result in different search results to what other people might receive. [1] Since any resource offering help in programming will include example source code, I always considered the search term "example" to be redundant.
- chuhnk 11y agoBy far one of the better ways to learn the syntax of Go.
- wooptoo 11y agoThank you so much! Was looking for exactly something like this.
- workusername 11y agogoogle.com Edit: no, seriously, as the other commenter mentions: "This site is well known and I have been using it as reference for a long time." If looking for something like this, it would've been hard to avoid this. This post seems sponsored, or friends doing favours. Weird.
- brndn 11y agoYou're not going to win this fight. Content makes it the the front page of HN (and Reddit and other user-generated content sites) by getting upvotes. You just have to accept that you may see content that isn't new to you. If it is on the front page, that means enough people haven't seen it yet. Edit: I have already seen the website as well, but I was glad to see it again because I could come to the comments section for some good discussion.
- brianberns 11y agoDang, I was really hoping this was going to teach me how to play the game of Go, not how to program in the Go language.
- bassislife 11y agoWell maybe an example of something related to the game of Go written in Go should be planned in the future then. :)
- DocSavage 11y agoNote that clicking the tiny gopher icon in the upper right of the code box will launch play.golang.org with that code. That's a good way to play with code and see results in your browser.
- pif 11y ago> Go is an open source programming language designed for building simple, fast, and reliable software. By the way, what would you use for complex, fast, and reliable software?
- omginternets 11y agoI would say "Go" (among others). I think the author meant that Go is a simple means to design fast & reliable software. That would certainly be my point of view, in any case.
- lmm 11y agoA language with generics, e.g. OCaml, Haskell, Scala or F#. Once complexity reaches a certain level that's one of the tools you need to manage it.
- tptacek 11y agoSometimes. Other times, generics are a tool that development teams use to amplify complexity.
- lmm 11y agoGiving your team more powerful tools should always be a positive. If you don't trust them not to do harmful things with them then you have bigger problems.
- tptacek 11y agoIt doesn't feel like that's a strategy that worked especially well for Scala or C++. Go isn't the only language that removes powerful tools: all the strict functional languages do too!
- pcwalton 11y agoThe issues that Scala and C++ have are far beyond just "having generics". Classical (ML-style) generics are an incredibly simple feature, much more so than, say, built-in channels.
- andrewstuart2 11y agoAs an aside: Holy heck, CloudFront. 14ms! That's like half the best RTT I get to my office right down the street.
- VeejayRampay 11y agoGreat resource for beginners. Though I've noticed a trend when trying to familiarize myself with languages and Golang in particular: examples tend to be too simple and I've found myself struggling once I tried to create more "real-life" things with it (similar to hello world or server examples on Node.js). Though this is most likely personal/anecdotal and the website is an invaluable resource for a beginner. Well done.
- dpflan 11y agoPerhaps one of these resources can show more advanced use cases: https://github.com/golang/go/wiki/Books https://github.com/golang/go/wiki/Books Have you read The Go Programming Language by Donovan and Kernighan? - Book Site: http://www.gopl.io/ http://www.gopl.io/ - Book Example Source Code: https://github.com/adonovan/gopl.io/ https://github.com/adonovan/gopl.io/
- moonlighter 11y agoI highly recommend this book. I find it the best Go book out there right now. Manning's "Go in Action" isn't nearly as good as Donovan & Kernighan's work.
- Zikes 11y agoOne of the things I absolutely love about Go is that the standard library is so readable and accessible. It's been a great resource for learning by example, especially for some fairly complex design patterns.
- evm9 11y agoAgreed. I feel like the struggling when actually implementing the language for a real project/product is normal. I think this is because programming languages are built with performance, readability, and writability in mind. I've yet to come across a programming language that was specifically built to make it easy to use to build a software product (plenty of frameworks though, ex Rails).
- moonlighter 11y agoI can highly recommend "The Go Programming Language". I find it extremely well written, and worth every penny. http://www.amazon.com/gp/product/0134190440 http://www.amazon.com/gp/product/0134190440
- dpflan 11y agoFor sure, it's like the "C and R" for Go. Plus the source code for the examples is on Github. - Book Site: http://www.gopl.io/ http://www.gopl.io/ - Book Example Source Code: https://github.com/adonovan/gopl.io/ https://github.com/adonovan/gopl.io/
- tptacek 11y agoI didn't love it. I found it a little inconsistent, and I didn't learn that much from it; most of the Go blog posts have more insight than the book does. It's a fine introduction to the language! It's great that Go has a credible book. But if you're already familiar with Go, I think you can skip this. Happy to hear if other readers had different experiences.
- percept 11y agoI looked forward to a complete chapter on IO (not unlike http://www.amazon.com/Programming-Language-Brian-W-Kernighan/dp/0131103628/ http://www.amazon.com/Programming-Language-Brian-W-Kernighan...), but didn't see one. Perhaps a future edition...
- ChemicalWarfare 11y ago
- LanguageGamer 11y agoI clicked expecting a go-the-board-game learning site. I think I need to learn the rudiments of go-the-programming-language, just so I stop forgetting there's still something to disambiguate when I see the word 'Go' as a noun.
- josep2 11y agoSweet list. Thanks for posting.
- mcintyre1994 11y agoThis is a really nice resource and I've been wanting to look at Go for a while! Could anybody point at the sort of projects that the goroutine/channel infrastructure excels at in particular?
- aws_ls 11y agoYou can use goroutine ( call function prefixed with 'go' e.g. go foo() ) or channels, any where where you would use threads in languages like C/C++/Java. Their terminology is concurrent programming. So you never actually spawn threads. But just declare your code to be able to run concurrently. So it will parallel process on multi cpu machine. Or just get scheduled in/out of cpu, when waiting for I/O. So very much like threads, but the mental/programming model is different. Channels are particularly very useful, where you would use a thing like Barrier in Java, for threads to converge. In channels you get concurrency by message passing on channels. So example application can be, crawl multiple sites concurrently and converge using channels. In my experience its very robust, and once coded and tested, rarely(if at all) you face any weird bugs, e.g. Deadlocks/etc which you would, in explicit threaded programming. Not to imply that its not shoot-in-the-foot proof. But for a programmer having experience of multi-threaded programming, when one moves to this model, it seems more intuitive and robust. Edit: I see other programmers have endorsed http://tour.golang.org/welcome/1 http://tour.golang.org/welcome/1 . I second/third them. IMHO that's the best resource to learn Go (and from your browser). After I did the 70 or thereabouts exercises, over there, I attained Nirvana :-) , and didn't need anything else. Of course apart from golang pkg docs. And one piece which confused me in the beginning was slice/array. Its very easy, once you get a hang of it. Another thumb rule I follow is always have pointers to struct in slices or maps. To avoid, the costly copy. May be its obvious in hindsight, but wasn't to me, in the beginning, as sometimes passed pointer to slice, having struct as values, to a function argument. On realizing what a foolish thing it was, as slice/maps are passed by reference, I started doing the reverse (i.e. slice as is, but having pointers to structs) :-).
- throwaway6497 11y agoThis is awesome! Thank you. This is especially helpful for programmers who are good at other languages and want to get a feel of go quickly over a weekend. Much easier to map the existing mental models built over-time to the new go programming semantics. Humans learn best by example and comparing the new stuff with what we already know.
- mediocrejoker 11y agoI agree 100%. I had a similar desire, that is to get a feel for go without making a big time commitment. I went to the wikipedia page and read that it has something called channels that sounded kind of like FIFOs or perhaps something out of SystemC. This page gives a much faster understanding of what the language is like.
- muhammadusman 11y agoare there websites like this for other languages too? I really like the format of this.
- thewhitetulip 11y agoI had recently started to write a short guide about writing webapps in Go, https://github.com/thewhitetulip/web-dev-golang-anti-textbook https://github.com/thewhitetulip/web-dev-golang-anti-textboo...