• who@feddit.org
    link
    fedilink
    English
    arrow-up
    3
    ·
    edit-2
    13 天前

    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.

  • uuj8za@piefed.social
    link
    fedilink
    English
    arrow-up
    2
    ·
    edit-2
    12 天前

    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.