Golang Unsafe Type Conversions and Memory Accessby@avk-ai
5,943 reads
5,943 reads

Golang Unsafe Type Conversions and Memory Access

by Aleksandr Kochetkov4mMarch 15th, 2020
Read on Terminal Reader
Read this story w/o Javascript
tldt arrow

Too Long; Didn't Read

Go is strongly typed, you have to convert variable from one type to another to use in different parts of application. But sometimes you need to step around this type safety. Unsafe operation potentially could safe a lot of allocations. It also allows to hack into any struct field, including slices, strings, maps etc. It's called unsafe for a reason. It could be needed to optimization of bottle necks in high load systems, where every tick counts. Go compiler understands that string is constant and put it in memory along with other constants.

Company Mentioned

Mention Thumbnail
featured image - Golang Unsafe Type Conversions and Memory Access
Aleksandr Kochetkov HackerNoon profile picture
Aleksandr Kochetkov

Aleksandr Kochetkov

@avk-ai

Go developer. Blockchain expert.

About @avk-ai
LEARN MORE ABOUT @AVK-AI'S
EXPERTISE AND PLACE ON THE INTERNET.
L O A D I N G
. . . comments & more!

About Author

Aleksandr Kochetkov HackerNoon profile picture
Aleksandr Kochetkov@avk-ai
Go developer. Blockchain expert.

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