this post was submitted on 16 Jul 2026
4 points (70.0% liked)

Golang

2711 readers
4 users here now

This is a community dedicated to the go programming language.

Useful Links:

Rules:

founded 3 years ago
MODERATORS
top 2 comments
sorted by: hot top controversial new old
[–] uuj8za@piefed.social 2 points 3 days ago* (last edited 3 days ago)

tl;dr arr[len(arr)] is wrong; arr[len(arr)-1] is right because Go uses zero-based indexes like a bunch of other languages.

[–] who@feddit.org 3 points 4 days ago* (last edited 4 days ago)

This is a thinly veiled advertisement.

tl;dr: The length of a slice is not a valid index into that slice.

Of course. Because Go uses zero-based indexing, just like many other languages.