Tutorial by Examples

Constants are declared like variables, but using the const keyword: const Greeting string = "Hello World" const Years int = 10 const Truth bool = true Like for variables, names starting with an upper case letter are exported (public), names starting with lower case are not. // not e...
You can declare multiple constants within the same const block: const ( Alpha = "alpha" Beta = "beta" Gamma = "gamma" ) And automatically increment constants with the iota keyword: const ( Zero = iota // Zero == 0 One // One == 1...
Constants in Go may be typed or untyped. For instance, given the following string literal: "bar" one might say that the type of the literal is string, however, this is not semantically correct. Instead, literals are Untyped string constants. It is a string (more correctly, its default ...

Page 1 of 1