7 common mistakes in Go and when to avoid them by Steve Francia (Docker)

preview_player
Показать описание
Steve Francia talks about most common mistakes in Go #golang and how to avoid them.

ABOUT DATA COUNCIL:

FOLLOW DATA COUNCIL:
Рекомендации по теме
Комментарии
Автор

These kinds of talks where the presenter is a true expert in his field.

hz
Автор

I'm on a Go youtube lectures spree and every time a finish one of them, I wanna refactor all the code I've done so far :)

marioskrlec
Автор

Still easily one of the best Go "best practices" video on youtube

bryanenglish
Автор

Pointer vs. Value discussion:
Based on the Method vs. Function discussion, ADT should be strictly adhered to. Operations that modify the ADT are modeled as functions that take the old state as an argument and return the new state as part of the result. In other words, a function should enforce immutability.

The ADT approach helps with concurrency, making the code cleaner and easier to read. As an API user, I shouldn't worry about the state changing when I pass a structure.

Of course, the pure ADT model's problem is memory consumption. That's why ADT models are generally implemented in VMs that can routinely find old structures without references and remove them from memory.

malcolmgdavis
Автор

Good talk. It's cool to watch this in 2022, as it can be considered ancient relative to Go's lifetime

guitaripod
Автор

Good talk. Hugo powers my blog, and I love it!

chmod
Автор

There needs to be a book on these. He's racing through concepts that could use a lot more detail.

naikrovek
Автор

Thank you very much! Great presentation to us!

castmetal
Автор

Fantastic talk! I am new to go and had no idea on the proper way to handle errors. I am off to fix my code :D

jengo
Автор

Excellent talk I really appreciated the code examples :) Nicely done sir.

xmlviking
Автор

My video tags and descriptions:
1) Don't user interfaces 3:19
2) Don't use io.Reader & io.Writer 6:24
3) Requiring brod interface 8:44
4) Method vs function 10:41
5) Pointer Vs Value 14:58
6) Error is does not a string 16:56
7) To be safe or not to be 22:14


P.S. Top secret skill: 24:56

saimonshaplygin
Автор

Methods not necessary imply mutation, therefore generating shortcodes (13:00) can be a method as well, maybe even a lazy var which is instantiated only once.
Languages like C++/Swift have const/mutating keywords for indicating a method mutating or not mutating its fields

DenisG
Автор

I sincerely believe that io.Reader and io.Writer are the two most powerful interfaces in the language. They're so underrated that it kind of makes me sad.

nano_sweet
Автор

great sensei .... got me up to speed on docker.

malinyamato
Автор

Pointers vs values - it's not just about usage. "If you want to share it, use a pointer" is a pretty contextless way to describe an issue that can easily become sensitive. Don't share unless you absolutely need to is a better way because otherwise a good starter is: I'll share because it's more flexible and I'll see about it later. But memory allocation is an important point as overusing pointers is a sure way to shoot yourself in the foot sooner rather than later.

AndreiDinTheHouse
Автор

you, some one should collect all these pull request reviews and upload it in one website with git diff + comments :D

yotubecreators
Автор

If a method is supposed to modify the state (vs functions), how come you wouldn't use a pointer in a receiver...?

MaximeFRYSOU
Автор

Really good talk! I learnt a lot. Am coming from Python!

sanketg
Автор

In the example for using functions over methods when no side effects are intended I'd argue that *Page should be Page instead - its a clearer argument for expressing no side-effects when you have a value receiver where side effects are not possible.

romand
Автор

Just to be clear, maps are the only issue with concurrent access. A quick fix is to use sync.Map, but in a lot of cases using a drop-in replacement using a slice of struct{k, v string m Mutex} is slightly faster as you only need to lock on write with a high load of concurrent access.

danaadalaide