To create a struct with a field of type rune
in Go, you simply need to define the field with the rune
keyword. Here's an example:
main.go71 chars6 lines
In this example, we have defined a struct called Person
with three fields: Name
of type string
, Age
of type int
, and Initial
of type rune
. You can now create variables of this struct type and access their individual fields like this:
main.go170 chars5 lines
Note that the rune
type in Go is an alias for int32
and represents a Unicode code point. You can assign a rune
value to a variable using single quotes, like 'A'
.
gistlibby LogSnag