This article explains how different types of function parameters behave in Go, addressing common questions about why certain data types are mutated in functions while others are not. It also covers the behavior of pointer parameters and provides examples of how to correctly modify variables outside of a function. The article highlights the importance of understanding the distinction between parameters and arguments and provides insights into how maps, slices, and channels are implemented in Go.
Table of contents
Parameters and argumentsFunctions operate on copies of the argumentsPointer parametersWrite-though vs reassignmentAutomatic dereferencing"Reference types"Maps and ChannelsSlicesSummarySort: