Category: Data

Constants can be confusing and easy to misuse in Go if you are coming from an untyped language. Let’s take a look at some of the nuanced details of how they work in Go.

Go and JavaScript both declare new constants in the same way: The takeaway if you are coming from JavaScript is that Go’s constants are just different.

In Go, constants provide complete safety in regards to the value they hold.

However, I have written another article on the elegant ways to get “effectively constant” slices and maps in Go.

Related Articles