In Go, a rune is an alias for the int32
type and represents a Unicode code point. To create a pointer to a rune in Go, you can define a variable of type rune
and use the &
operator to get its memory address. Here's an example:
main.go124 chars10 lines
In this example, we first define a variable r
of type rune
and assign it the Unicode character 'あ' (which has the code point U+3042). We then use the &
operator to get the memory address of r
and assign it to the variable pR
, which has type *rune
(i.e., a pointer to a rune
). Finally, we print the value and memory address of r
using the fmt.Printf
function and the %c
and %v
format specifiers, respectively.
Output:
main.go26 chars2 lines
gistlibby LogSnag