Golang Syntax, Variables, Types, Constants, and Operators
Build the core language foundation with variables, explicit types, constants, and the operator behavior used in everyday Go programming.
Inside this chapter
- Variable Declarations
- Basic Types
- Constants
- Operators
- Why Static Typing Helps
Series navigation
Study the chapters in order for the clearest path from Golang basics to advanced concurrency, service design, and production engineering. Use the navigation at the bottom to move smoothly through the full tutorial series.
Variable Declarations
var name string = "Asha"
age := 24
Go supports both explicit and short variable declaration styles. The short declaration syntax is especially common inside functions, but understanding both forms is important.
Basic Types
stringint,int64, and other numeric typesfloat32andfloat64boolbyteandrune
Constants
const appName = "LearnGo"
const maxRetries = 3
Constants are useful for fixed configuration values, enumerated states, and domain values that should not change at runtime.
Operators
total := 10 + 5
isReady := total > 10
isAllowed := isReady && total < 20
Arithmetic, comparison, logical, and assignment operators are straightforward in Go. One reason many learners enjoy Go is that the language usually avoids surprising behavior.
Why Static Typing Helps
Go's static typing catches many problems during compilation instead of at runtime. In production systems, this improves confidence during refactoring and makes contracts clearer between parts of the codebase.