Our training paths
Grow your skills
You’ll get our FREE Video Series & special offers on upcoming training events along with notifications on our latest blog posts.
Valid email required.
Submit failed. Try again or message us directly at email@example.com.
Check your email for confirmation.
In the documentation provided by the Go language team you will find great information on pointers and memory allocation. Here is a link to that documentation:http://golang.org/doc/faq#PointersWe need to start with the understanding that all variables contain a value. Based on the type that variable represents will determine how we can use it to manipulate the memory it contains. Read this post to learn more: Understanding Type In Go
In Go we can create variables that contain the "value of" the value itself or an address to the value. When the "value of" the variable is an address, the variable is considered a pointer.In the diagram below we have a variable called myVariable. The "value of" myVariable is the address to a value that was allocated of the same type. myVariable is considered a pointer variable.
In the next diagram the "value of" myVariable is the value itself, not a reference to the value.To access properties of a value we use a selector operator. The selector operator allows us to access a specific field in the value. The syntax is always Value.FieldName, where the period (.) is the selector operator.In the C programming language we need to use different selector operators depending on the type of variable we are using. If the "value of" the variable is the value, we use a period (.). If the "value of" the variable is an address, we use an arrow (->).One really nice thing about Go is that you don’t need to worry about what type of selector operator to use. In Go we only use the period (.) regardless if the variable is the value or a pointer. The compiler takes care of the underlying details to access the value.So why is all of this important? It becomes important when we start using functions to abstract and break up logic. Eventually you need to pass variables to these functions and you need to know what you are passing.In Go, variables are passed to a function by value. That means the "value of" each variable that is specified is copied onto the stack for access by that function. In this example we call a function that is supposed to change the state of a value that is allocated in main.
We have taught Go to thousands of developers all around the world since 2014. There is no other company that has been doing it longer and our material has proven to help jump start developers 6 to 12 months ahead of their knowledge of Go. We know what knowledge developers need in order to be productive and efficient when writing software in Go.
Our classes are perfect for both experienced and beginning engineers. We start every class from the beginning and get very detailed about the internals, mechanics, specification, guidelines, best practices and design philosophies. We cover a lot about "if performance matters" with a focus on mechanical sympathy, data oriented design, decoupling and writing production software.
Interested in Ultimate Go Corporate Training and special pricing?
Our courses have been designed from training over 4,000 engineers since 2013 and they go beyond just being a language course. Our goal is to challenge every student to think about what they are doing and why.
Please fill out the form below and we'll get back to you soon.
Check your email for confirmation of your sent message. We'll get back to you shortly.
Ardan Labs Copyrights © 2022