A tour of Go
main
return
statement without arguments returns the named return values. This is known as naked return.var
statement declares a list of variables. A var
statement can be at package or function level.var
declaration with implicit type. Outside a function, every statement begins with a keyword(var
, func
and so on) and so := construct is not available.int
, uint
and uintptr
types are usually 32-bits wide on 32-bit systems and 64 bits wide on 64-bit systems.T(v)
converts the value v
to the type T
. In Go assignment between items or different type requires an explicit conversion.const
keyword. They can be of any type int, bool, string etc. But const can not be declared using := syntax.for
loop. The basic loop has 3 components similar to C language without parentheses surrounding three components and the braces are always required.While
equivalent in Go isif
statements need not be surrounded by ()
but the braces {}
are required.fmt.print
statements.