How can I convert *string
to string
?
Heres my error code:
cannot use m.Body (type *string) as type string in argument to strings.NewReader
Here is my code:
dec := json.NewDecoder(strings.NewReader(m.Body))
How can I convert *string
to string
?
Heres my error code:
cannot use m.Body (type *string) as type string in argument to strings.NewReader
Here is my code:
dec := json.NewDecoder(strings.NewReader(m.Body))
Dereference the pointer to get the value of string
from *string
and then use it in strings.NewReader
function. For eg:-
strValue := *m.Body
dec := json.NewDecoder(strings.NewReader(strValue))
For working example check Go playground