Hacker Newsnew | past | comments | ask | show | jobs | submit | rustandmore's commentslogin

Ownership is perfectly consistent.

`append` always returns a new slice value

`func append(slice []Type, elems ...Type) []Type`

The only correct way to use append is something like `sl = append(sl, 1, 2, 3)`

`sl` is now a new slice value, as `append` always returns a new slice value. You must now pass the new slice value back to the user, and the user must use the new slice value. The user must not use the old slice value.

It's trivial to fix the "bug" in the article, once you actually understand what a slice value is: https://go.dev/play/p/JRMV_IuXcZ6

A slice is not the underlying array, and the underlying array is not the slice. A slice is just a box with 3 numbers.


Most of non-opinion parts of this article are "Go sucks because <insert newbie mistake>" or otherwise factually incorrect points.

At that point, all languages suck because there's newbie mistakes and I don't understand them.

Maybe it is time to dump credentials rather than being obscure. I don't believe it for a moment that you have decade+ experience in Go.


Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: