casting pointers in golang
- You have a type eg.
type Poop string
, Say variableyeet
is of typePoop
- Now there’s a struct
Yolo
that has fielddoop
which accepts*string
- To assign
yeet
todoop
, we do{ ... doop: (*string)(&yeet) }
type Poop string
, Say variable yeet
is of type Poop
Yolo
that has field doop
which accepts *string
yeet
to doop
, we do
{
...
doop: (*string)(&yeet)
}