8 ms·
Learning Golang – From Zero to Hero
- Strum355 7y agoInfo about workspace is outdated. Go modules allows you to to work outside GOPATH
- milap 7y agoAgree. With go mod we workspace can be outside of GOPATH. The post does not cover go mod.
- hliyan 7y agoI recently hastily put together a "Learn Go in 10 days" program for my team, where I only used go modules: https://github.com/hliyan/learn-golang/blob/master/day-08/main.go https://github.com/hliyan/learn-golang/blob/master/day-08/ma... Feedback welcome.
- itwy 7y agoThanks so much for sharing. Very helpful to me.
- ausjke 7y agoagree, newbie to golang, just started with go1.13beta1 which will make go-module preferred to GOPATH/workspace.
- sascha_sl 7y agoThe default mode is already `auto`, which checks if you're within GOPATH (if GOPATH is set) and defaults to mod if you're not.
- ausjke 7y agodon't know this, thanks! I also assume you no longer need set GO111MODULE=on anymore
- cyphar 7y agoThat depends -- it defaults to "auto" which means that its enabled outside of $GOPATH but disabled inside it. If you're working on a project that makes use of "go mod vendor" and is built from within your $GOPATH (which is true of quite a few free software Go projects) then you'll need it.
- geoka9 7y agoSome useful tools[0] are still to catch up with Go modules, so using GOPATH still makes sense if you use them. [0] https://github.com/golang/go/issues/24661 https://github.com/golang/go/issues/24661
- nivertech 7y agoskip Golang, go straight for Rust EDIT: as my time for learning new programming languages is limited, I would invest it in learning Rust, rather than learning Golang or learning both of them. IMO the only reason to learn Golang is if your already have a legacy Golang codebase or if you want to contribute to various open source projects written in Go, like for example Kubernetes (my first experience with Golang was trying to compile a patched Hashicorp project). It's the same as suggesting to a front-end dev, skipping Backbone, Ember and Angular and going straight for React. There are lots of overlapping technologies in our space and learning all of them is a huge time waste.
- Buttons840 7y agoYour opinion is fine, but you need to tell us why. A single sentence adds nothing to the discussion.
- olah_1 7y agoI agree. I would guess the "why" is that Rust is capable of everything that Golang is capable of, except more and better. Not to mention that Rust has a very supportive community to help each other.
- onei 7y agoAfter using Rust for about a year on the side, I get the feeling that it's not quite mature enough yet in some places. On the other hand, I also get the feeling that the development of the language itself has been measured and careful which could also be seen as a bit slow. On the other hand, I hear good things about Go across lots of people I work with although I've yet to sit down and give it a meaningful try. But I also have concerns about the maturity of a language who has jumped to V2 in what seems like a relatively small amount of time. I'm inclined to believe both languages have lots of promise and could easily be the future of software development, but I'd be hesitant to pick either for a project that needs to be maintainable for a long time in case the language changes too much and leaves you with technical debt.
- olah_1 7y agoThis[0] is the best way I've seen to learn Golang. It's exactly what I needed to make things stick and make sense. 0: https://quii.gitbook.io/learn-go-with-tests/ https://quii.gitbook.io/learn-go-with-tests/
- garren 7y agoI completely agree - I've worked through most of this as well and I feel it is a really great way to introduce someone to the language. It seems to me that a lot of languages would benefit from this style of tutorial or introduction.
- masayune 7y agoI have to second this as well. What’s even better is if you require more detail on a subject, there’s often a link to another well-written, detailed Go article.
- jnordwick 7y agoGo's not existent standard library is almost a deal breaker for me. The lack of even a dynamic array (c++ vector, Java arraylist) means you write a lot of 2-3 lines of slice notation phrases that require stopping and thinking about indices you wouldn't need to in other languages (and creating a lot of zero length slices for boundary conditions that shouldn't be needed). Also no balanced tree is a big issue (googles side implemention sucks in that the comparator cannot be passed in). I recently tried to write some small library functions using sqlx to do arbitrary sql queries and then some munging of the results before returning it. It was extremely difficult. The language feels half done at times. I find it hard to believe that Google used it much internally before releasing it. So many unfinished corners. Generics would go a long way to fixing some of these issues. While the ahead of time compilation is nice and had lead to me using it for things that need fast startup (some shell like scripts and literally old school cgi), it often seems like a worse Java. If you don't like Java's verbosity, go's from my small use is about twice as bad. 300 lines of go does surprisingly little - part of this is gofmt's fault though. Also, does anybody know of good performance tests between Java and go? I mean like well written and optimised. Most tests over I've are very poorly written and do dumb things like include hotspot startup and compilation times. Hotspot can generate some very slick code, but it just takes 10k passes to get up that point.
- leftyted 7y ago> The lack of even a dynamic array Are go slices not dynamic arrays? They grow automatically when necessary.
- qwerty456127 7y agoSuch a great language. If only it had a good GUI library...
- spease 7y agohttps://github.com/therecipe/qt https://github.com/therecipe/qt
- _ph_ 7y agoI have made very good experiences with the GTK bindings for go (https://github.com/gotk3/gotk3 https://github.com/gotk3/gotk3). As the GTK Api is C-Based, it fits conceptually very good to Go. Actually I consider the Go bindings even better than using GTK from C, as the thin object model GTK uses, translates well to Go structures, most functions become methods on those structures. And the Go garbage collector solves the memory handling of the GTK structures.
- weberc2 7y agoI mostly have too, but GTK itself is a bummer. Doing most any interesting thing is a ton of work.
- mythrwy 7y agoThis looks interesting. https://wails.app/ https://wails.app/ Also there are ways to talk back and forth with Electron for front end. Full disclosure, have not tried either but just looking around as I get into Go. I do a lot of web dev so like idea of HTML/JS for front end. I know I know, Electron is awful but maybe less awful if it's light?
- chewxy 7y agofyne.io is pretty great
- irq-1 7y ago> With a buffered channel, the receiver will not get the message until the buffer is full. This is wrong. https://golang.org/doc/effective_go.html#channels https://golang.org/doc/effective_go.html#channels > Receivers always block until there is data to receive. If the channel is unbuffered, the sender blocks until the receiver has received the value. If the channel has a buffer, the sender blocks only until the value has been copied to the buffer; if the buffer is full, this means waiting until some receiver has retrieved a value.
- milap 7y agoThe statement was misleading. Thanks!, it has been corrected.
- mac_was 7y agoI wosh I had time to learn new languages as I used to... but with 2 kids, one being 4 months it is nearly impossible. How do others devs hungry for knowledge deal with situations like this one?
- nprateem 7y agoCV-driven development. AKA find an excuse to use it (and learn it) at work. At least that's what it seems my colleagues do.
- wgj 7y agoWith two young children, try to get enough sleep. All learning is more effective when you get enough sleep. With that in mind, spaced repetition is a great technique that fits with having limited time in small blocks. Squeezing in some time here and there becomes a strength instead of a weakness. https://en.wikipedia.org/wiki/Spaced_repetition https://en.wikipedia.org/wiki/Spaced_repetition
- freyr 7y agoGo is a language you can pick up in a relatively short amount of time. The syntax is in the vein of C and Python, so it's probably familiar. The language itself is fairly small, and the focus is on simplicity over expressiveness. If you want to learn new languages but have limited time, my answer is to take a look at Go.
- dlhavema 7y agoI love reading articles like this. I really want to find a good work related reason to learn Go, just not a thing right now. My main concern with the article is the massive abundance of typos. Like more so than a normal article written by a programmer. They make me stop and double check if I read it wrong, it is a term or something I haven't seen before, or just a typo.
- tschellenbach 7y agoI wrote this post about learning Go: https://getstream.io/blog/go-1-11-rocket-tutorial/ https://getstream.io/blog/go-1-11-rocket-tutorial/ We switched from Python to Go over 2 years ago and it's been an amazing improvement in terms of performance as well as developer productivity for building high traffic endpoints.