Matthew Setter on LinkedIn: Using Pointers In Go (2024)

Matthew Setter

Software Engineer, Teacher, and Author focused on PHP and Go

  • Report this post

"The standard library is fairly consistent in how it shares values based on the type of value it is working with. Don’t use pointers with built-in data types unless you have a special need to do so. Struct types have a duality. If the struct type is implemented as a primitive data type, then don’t use a pointer. If not, then share those values with a pointer. Finally, reference types should not be shared with a pointer with very few exceptions."While it didn't fully help me understand when and when not to use pointers in Go, this post still does an excellent job of discussing the topic: https://lnkd.in/g7htzckw

Using Pointers In Go ardanlabs.com

6

1 Comment

Like Comment

Stephen Popoola

Senior Engineering Manager at The Accountancy Cloud

1d

  • Report this comment

Thanks for sharing Matthew. I am still wrapping my head around when to use pointers or not but I have been reading the book, Learning Go by Jon Bodner and this post aligns with the advice given in the book.

Like Reply

1Reaction

To view or add a comment, sign in

More Relevant Posts

  • Matthew Setter

    Software Engineer, Teacher, and Author focused on PHP and Go

    • Report this post

    There's something about continuing to learn a language by building something with it. In this case, I'm trying to figure out how to store content retrieved from a SQLite BLOB column. According to https://lnkd.in/gDRNkMmb, the standard way is to use a byte array. Interesting! I've yet to try it out, but will do shortly.Any suggestions on a better approach?

    How to json marshal Blob type? forum.golangbridge.org

    1

    Like Comment

    To view or add a comment, sign in

  • Matthew Setter

    Software Engineer, Teacher, and Author focused on PHP and Go

    • Report this post

    Go 1.22 has greatly simplified how to restrict HTTP request methods when building web apps with net/http. It's a change I'm surprised wasn't implemented sooner.Here's how, in less time than it'll take to drink a coffee: https://lnkd.in/ggPZEbMY

    • Matthew Setter on LinkedIn: Using Pointers In Go (9)

    10

    1 Comment

    Like Comment

    To view or add a comment, sign in

  • Matthew Setter

    Software Engineer, Teacher, and Author focused on PHP and Go

    • Report this post

    If you want to improve the quality of your code, consider Object Calisthenics. Here's a gentle introduction: https://lnkd.in/g8bbJrbD

    Object Calisthenics bolcom.github.io

    2

    Like Comment

    To view or add a comment, sign in

  • Matthew Setter

    Software Engineer, Teacher, and Author focused on PHP and Go

    • Report this post

    I've finally implemented dark mode in my main website and couldn't be happier with the result! 🔥 This is yet another one of those times when I wonder why I didn't do it sooner. What's more, I learned so much in the process, that I feel that that site is so much better for it.Time-permitting, I'd love your input about whether I've implemented dark mode correctly or not: https://matthewsetter.com.

    • Matthew Setter on LinkedIn: Using Pointers In Go (15)
    • Matthew Setter on LinkedIn: Using Pointers In Go (16)

    2

    2 Comments

    Like Comment

    To view or add a comment, sign in

  • Matthew Setter

    Software Engineer, Teacher, and Author focused on PHP and Go

    • Report this post

    Ryan has given so much to the PHP community, and Symfony specifically, over the years. So, I'm sharing this in the hope of it reaching as far and wide as possible. Please consider supporting him and his family.

    9

    Like Comment

    To view or add a comment, sign in

  • Matthew Setter

    Software Engineer, Teacher, and Author focused on PHP and Go

    • Report this post

    While I’ve been writing more Go code over the last several months, I’ve not spent a lot of time with the command line tooling.Yes, I run "go run" a lot to run an app locally, and "go get insert/some/package" to install one or more dependencies. I don’t use the go linter or formatter directly, as they’re integrated into Vim and Visual Studio Code.But, that’s about it for me and go’s command line tooling. I’m guessing I’m not alone in this, and that there are likely a lot of Go developers who use only a minimum of command line tooling as well. However, I feel that this is a significant drawback in my productivity using the language, and something that I have to change. So, just like getting better at DevOps has greatly simplified my life building and deploying applications, I’d like to think that familiarising myself more with Go’s command-line tooling will improve my ability as a Go developer as well.So, I’m starting an ad-hoc series talking about Go’s command-line tooling, just in case you’re in a similar position and you’d like to know more about them as well.Each post won’t be an in-depth guide to a given command.However, it will cover enough about the command to get you started, and have links to further information so that you can expand your knowledge as and when you have a moment.Here's the first post, covering go mod tidy: https://lnkd.in/gqsAvws6

    • Matthew Setter on LinkedIn: Using Pointers In Go (22)

    10

    5 Comments

    Like Comment

    To view or add a comment, sign in

Matthew Setter on LinkedIn: Using Pointers In Go (25)

Matthew Setter on LinkedIn: Using Pointers In Go (26)

1,964 followers

  • 995 Posts
  • 4 Articles

View Profile

Follow

More from this author

  • 4 Reasons Why "Those Who Can't, Teach" is a Complete Myth Matthew Setter 8y
  • Do Development Frameworks Really Matter? Matthew Setter 9y
  • The Secret Weapon to Engaging with Your Audience Matthew Setter 9y

Explore topics

  • Sales
  • Marketing
  • Business Administration
  • HR Management
  • Content Management
  • Engineering
  • Soft Skills
  • See All
Matthew Setter on LinkedIn: Using Pointers In Go (2024)
Top Articles
Latest Posts
Article information

Author: Jerrold Considine

Last Updated:

Views: 5731

Rating: 4.8 / 5 (78 voted)

Reviews: 85% of readers found this page helpful

Author information

Name: Jerrold Considine

Birthday: 1993-11-03

Address: Suite 447 3463 Marybelle Circles, New Marlin, AL 20765

Phone: +5816749283868

Job: Sales Executive

Hobby: Air sports, Sand art, Electronics, LARPing, Baseball, Book restoration, Puzzles

Introduction: My name is Jerrold Considine, I am a combative, cheerful, encouraging, happy, enthusiastic, funny, kind person who loves writing and wants to share my knowledge and understanding with you.