---
title: "Discussion on \"When Should You Use Pointers in Go\" | Hashnode"
description: "Discussion on \"When Should You Use Pointers in Go\". And why you should use them less than you think."
url: "https://hashnode.com/posts/when-should-you-use-pointers-in-go/618d2f3ff991b025366e2c8c"
---

[Feed](https://hashnode.com/feed) /

Discussion

# [When Should You Use Pointers in Go](https://golongwithgolang.com/when-should-you-use-pointers-in-go?utm_source=hashnode&utm_medium=feed)

And why you should use them less than you think.

Nov 11, 2021 · 6 min read · golongwithgolang.com  
Read the article

-   [#go](https://hashnode.com/tag/go)
-   [#computer-science](https://hashnode.com/tag/computer-science)
-   [#programming-languages](https://hashnode.com/tag/programming-languages)
-   [#data-structures](https://hashnode.com/tag/data-structures)

## Written by

[Pavle Djuric](https://hashnode.com/@pavledjuric)

@pavledjuric · Belgrade, Serbia

  
[View profile](https://hashnode.com/@pavledjuric)

Software developer/Technical writer

I am a Python/Go developer mostly working on developing REST, GRPC APIs and various different backend services. Along with developing them , I usually put them in a container and deploy them to the cloud.

## Responses 2

Markdown supported · ⌘↵ to post

[Aaron Cohen](https://hashnode.com/@cohenaa)

[Mar 30, 2023](https://hashnode.com/posts/when-should-you-use-pointers-in-go/618d2f3ff991b025366e2c8c/comment/6425b1a2975e3bb9a50f55bd)

Another reason to use pointers is if one method of the API uses a pointer. Best practice is then to have all methods take pointers even if not necessary. That decreases cognitive load on your API consumers.

[Rodolfo Albuquerque](https://hashnode.com/@rdalbuquerque)

[Jul 24, 2022](https://hashnode.com/posts/when-should-you-use-pointers-in-go/618d2f3ff991b025366e2c8c/comment/62dd5de3b12ca5754f6a6f0e)

Hey Pavle, great article!

A question I have about the first reason on why to use pointers - `Changing the state of an object` - would be, couldn't you, for example, pass the value, change it in a function and return the changed value so the calling function would reassign the original variable with the new returned value? Wouldn't it change the state of the object as well?

I get the overall point tho, thanks!

[Pavle Djuric](https://hashnode.com/@pavledjuric)

[Jul 24, 2022](https://hashnode.com/posts/when-should-you-use-pointers-in-go/618d2f3ff991b025366e2c8c/comment/62dd5de3b12ca5754f6a6f0e#reply-62ddbb64b12ca5754f6a7a43)

Hi Rodolfo. Thanks for the kind words. To answer your question - in order to update the value of an already defined variable, you need to use pointers. You can however, pass this variable into an argument of a function, update it and then return the new value. This is how the append function works in Go, for example. This will not update the original variable however. It is more of a functional approach, which favors immutability. Both options work, it just depends on what you prefer and what makes more sense in that particular situation.
