paint-brush
Today I Learned: Beware with pointer in Golang!!!by@imantumorang
8,756 reads
8,756 reads

Today I Learned: Beware with pointer in Golang!!!

by Iman Tumorang3mAugust 9th, 2018
Read on Terminal Reader
Read this story w/o Javascript
tldt arrow

Too Long; Didn't Read

Today’s bug and a lesson to be learned is about non/pointer receiver function. It happens when I’m doing custom marshal JSON for my struct. In my custom MarshalJSON I make the receiver is a pointer. So my custom marshall won’t called if I try to marshal a non-pointer object. But, if I marshal. a non.pointer object, it will. succeed to. marshal the. Object. It also vise versa for non. pointer (value) receiver in function.

People Mentioned

Mention Thumbnail
featured image - Today I Learned: Beware with pointer in Golang!!!
Iman Tumorang HackerNoon profile picture
Iman Tumorang

Iman Tumorang

@imantumorang

Software Engineer

Learn More
LEARN MORE ABOUT @IMANTUMORANG'S
EXPERTISE AND PLACE ON THE INTERNET.
L O A D I N G
. . . comments & more!

About Author

Iman Tumorang HackerNoon profile picture
Iman Tumorang@imantumorang
Software Engineer

TOPICS

THIS ARTICLE WAS FEATURED IN...

Permanent on Arweave
Read on Terminal Reader
Read this story in a terminal
 Terminal
Read this story w/o Javascript
Read this story w/o Javascript
 Lite
Stackoverflow
Azurefd
Helpex
Coffee-web
Dzone
Clojure