Constants

suggest change

Go supports constants of character, string, boolean, and numeric values.

Basics of constants

const (
	i  int = 32       // int constant
	s      = "string" // string constant
	i2     = 33       // untyped number constant
)

var (
	// values that are not read-only (like slices or maps or structs) cannot be
	// constants
	// we can declare them as top-level variables
	b = []byte{3, 4} // this could not be a constant
)

Learn more about constants.

Feedback about page:

Feedback:
Optional: your email if you want me to get back to you:



Table Of Contents