003variables

command
v0.0.0-...-db3ee8d Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 27, 2021 License: MPL-2.0 Imports: 1 Imported by: 0

README

Variables

In Go, variables are explicitly declared and used by the compiler; e.g. to check type-correctness of function calls.

var declares 1 or more variables, i.e. multiple variables can be declared at once

Go will infer the type of initialized variables. Variables declared without a corresponding initialization are zero-valued. For example, the zero value for an int is 0.

The := syntax is shorthand for declaring and initializing a variable, e.g. f := "apple" for var f string = "apple"


Poor explanation from <gobyexample.com>, reason being = is assignment operator where as := declaration and assignment, meaning we can't do the following

f:=1
f:=3
// but we can do
f:=1
f=3

Documentation

The Go Gopher

There is no documentation for this package.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL