Use var for package-level or typed declarations and := for short, inferred declarations inside functions.
Use var to declare variables at the package level or when you need to specify a type explicitly, and use := for short variable declarations inside functions when the type can be inferred.
// Package-level or explicit type
var count int = 0
// Inside a function, type inferred
func main() {
name := "Go"
age := 25
}
Use var when you are setting up variables for the whole program or need to be very specific about what kind of data it holds. Use := when you are inside a function and just want to quickly create a new variable without typing out the type name. Think of var as filling out a formal form and := as just grabbing a sticky note.