
Learning Golang – From Zero to Hero - milap
https://milapneupane.com.np/2019/07/06/learning-golang-from-zero-to-hero/
======
olah_1
This[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/)

~~~
masayune
I 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.

------
irq-1
> 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
The statement was misleading. Thanks!, it has been corrected.

------
tschellenbach
I 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.

------
Strum355
Info about workspace is outdated. Go modules allows you to to work outside
GOPATH

~~~
hliyan
I 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/ma...](https://github.com/hliyan/learn-
golang/blob/master/day-08/main.go)

Feedback welcome.

~~~
itwy
Thanks so much for sharing. Very helpful to me.

------
qwerty456127
Such a great language. If only it had a good GUI library...

~~~
_ph_
I 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
I mostly have too, but GTK itself is a bummer. Doing most any interesting
thing is a ton of work.

------
dlhavema
I 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.

------
mac_was
I 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?

~~~
freyr
Go 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.

------
nivertech
skip 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
Your opinion is fine, but you need to tell us why. A single sentence adds
nothing to the discussion.

~~~
olah_1
I 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.

~~~
hu3
Clearly there's more to it otherwise Go and other languages would be a thing
of the past.

This is really not a topic for language flamewars and it's even against HN
guidelines. I don't understand why people need to scream rust in every other
language post like if it was a religion.

~~~
bsaul
Devil’s advocate here : i think it’s due to the promise rust makes that borrow
checkers prevent you from writing unsafe code or race conditions, as well as
high level abstractions with zero performance cost.

That set of promises really would make any programmer go crazy i think, and
become a zealot.

Rust is definitely on my todo list, i’m just waiting for the language to
mature a little bit more, because some edges still seem a git rough. But i am
extremely enthusiastic about it.

~~~
hu3
It's not free though. There's a hefty price to be paid in complexity. I am as
"crazy" for Rust as I am for Ada.

I suspect that is one of the reasons why behemoths like Uber, Twitch.tv,
Stripe and Walmart chose Go over Rust.

------
jnordwick
Go'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.

~~~
BlackFly
I (and seemingly other people) consider
[https://www.techempower.com/benchmarks](https://www.techempower.com/benchmarks)
to be a good set of performance benchmarks for use cases many people around
here would be facing. I guess they haven't been updated in nearing a year
though. Go does reasonably well but apparently gets beat by Java.

More generally. I like the idea of community driven benchmarks where each
community tries to make representative, performant samples to realistic
problems. All too often you get an expert in one language making a benchmark
against a language they are not experienced with and getting really improper
results.

~~~
jnordwick
I don't do any a lot web stuff but most of my go code is quick hacks for data
analysis or display but this is still really interesting.

I had a feeling go was slow, but I didn't expect such poor performance
numbers. Some of that is probably the heavy reliance in reflection. For
example they json parsing you need to go to the bottom of the list to find a
go program, and go's json library makes extensive use of reflection and tags
to guide the parsing.

It is somewhat ironic that go's big feature was AOT compilation static type
checking, but it seems to immediately devolving into reflection and parsing
tag key value strings to do anything. I had a typo on one of those they other
day and could find the bug for an hour.

~~~
fwip
You can use alternative packages for when you need to do things more quickly.
For JSON, check out fastjson, easyjson, gojay, and more.

In real code that I write, most projects never import reflect. Sometimes I
import it in tests.

