-
Book Overview & Buying
-
Table Of Contents
Practical Systems Programming in Go
By :
Go offers a strong, yet straightforward type system designed to be efficient, predictable, and expressive. This chapter explores the fundamental data types, including numeric types, Boolean values, strings, arrays, and slices. But first, let us discuss variables and constants.
In Go, variables and constants are fundamental building blocks for managing data, but they serve different purposes. Variables are declared using the var keyword or the short declaration operator (:=) and can hold values that may change during program execution. Go is statically typed, but it also supports type inference, meaning the compiler can deduce the variable type from the assigned value when using :=. For example, x := 10 automatically infers x as an int type. On the other hand, constants are declared using the const keyword and represent immutable values known at compile time. They must be assigned a value that the compiler can determine before runtime, making...