Go is an strong and statically typed. It has an excellent community. golangbridge.org is a good example
Key features
- Simplicity
- Fast compile times
- Garbage collection
- Concurrency
- Stand alone binaries
Go is focus on server side and not on clients
Variable Topics
- Variable declaration
- Redeclaration and shadowing
- Visibility
- Naming conventions
- Type conversions
Three different ways to declare a variable:
var foo int // Use when the value is not known at the moment
var foo int = 42 // Use when the compiler might get it wrong
foo := 42 // Most use. Works inside a block not at the package level
Three level of visibility for a variable
Package level with lower case
Global with capitalize
Variable at block lowercase
Single letter for short lived variables
Lower names for long lived variables using camelCase
To convert to string using strconv function
Summary
- var foo int
- var foo int = 423
- foo := 42
Normally the third version is used. The second version is used when the compiler is going to guess it wrong. The first version is used when the value is not known right away
Can’t redeclare variables, but can shadow them. All variables must be used
Visibility
- lower case first letter for package scope.
- upper case first letter to export.
- no private scope
Naming conventions
- Pascal or camelCase
- – Capitalize Acronyns(HTTP, URL).
- As short as reasonable
- – longer names for longer lives
Type conversions
- destination Type(variable).
- use
strconvpackage for strings