---
title: "Comment by George on \"Top 5 Lessons I learned while working with Go for two years\" | Hashnode"
description: "Singletons are horrible advice, don&#39;t follow that pattern. Anything that creates a static, package level variable is bad."
url: "https://hashnode.com/posts/top-5-lessons-i-learned-while-working-with-go-for-two-years/60a8fb2e5379f65d10b5f642/comment/60b6406cf4a8435c0ecc4629"
---

[Discussion](https://hashnode.com/posts/top-5-lessons-i-learned-while-working-with-go-for-two-years/60a8fb2e5379f65d10b5f642)

Comment [Top 5 Lessons I learned while working with Go for two years](https://hashnode.com/posts/top-5-lessons-i-learned-while-working-with-go-for-two-years/60a8fb2e5379f65d10b5f642)

[George](https://hashnode.com/@george3000)

[Jun 1, 2021](https://hashnode.com/posts/top-5-lessons-i-learned-while-working-with-go-for-two-years/60a8fb2e5379f65d10b5f642/comment/60b6406cf4a8435c0ecc4629)

Singletons are horrible advice, don't follow that pattern. Anything that creates a static, package level variable is bad.

[Andrey Panin](https://hashnode.com/@fenhoya)

[Jun 2, 2021](https://hashnode.com/posts/top-5-lessons-i-learned-while-working-with-go-for-two-years/60a8fb2e5379f65d10b5f642/comment/60b6406cf4a8435c0ecc4629#reply-60b75b0f2102c86fd6d1801d)

Care to elaborate on that?

[George](https://hashnode.com/@george3000)

[Jun 2, 2021](https://hashnode.com/posts/top-5-lessons-i-learned-while-working-with-go-for-two-years/60a8fb2e5379f65d10b5f642/comment/60b6406cf4a8435c0ecc4629#reply-60b783862102c86fd6d18748)

[Andrey Panin](https://hashnode.com/@fenhoya) [misko.hevery.com/code-reviewers-guide/flaw-brittl…](http://misko.hevery.com/code-reviewers-guide/flaw-brittle-global-state-singletons/)

[Sayed Alesawy](https://hashnode.com/@sayedalesawy)

[Jun 2, 2021](https://hashnode.com/posts/top-5-lessons-i-learned-while-working-with-go-for-two-years/60a8fb2e5379f65d10b5f642/comment/60b6406cf4a8435c0ecc4629#reply-60b7bd872102c86fd6d18e07)

I know there is a somewhat compelling argument against singleton in general. I am not sure how could I replace it tho and get the same effect? I will check the article you mentioned. Thanks for the comment!

[George](https://hashnode.com/@george3000)

[Jun 2, 2021](https://hashnode.com/posts/top-5-lessons-i-learned-while-working-with-go-for-two-years/60a8fb2e5379f65d10b5f642/comment/60b6406cf4a8435c0ecc4629#reply-60b7cd5125dc276ffb940d3a)

[Sayed Alesawy](https://hashnode.com/@sayedalesawy) Replace it with a regular struct which accepts the dependency on it.

If it gets complex you can write a factory method on the struct.
