Skip to content

proposal: Go 2: integer array <-> integer type conversion #37658

Closed
@jfcg

Description

@jfcg

Integer types are convertable to each other. I propose to extend it to arrays:

a := [2]uint16{1, 2}
b := int32(a)
c := [4]byte(a)

d := uint32(65537)
e := [2]int16(d)

This will allow to see:

  • sub-bytes or sub-words of a larger integer variable
  • bytes/words in an array as a larger integer

without unsafe.Pointer tricks.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions