This is an old revision of the document!
Overview
Notes on Golangbot Golang tutorial series.
The primary focus of Golang is to make the development of highly available and scalable web apps simple and easy.
Misc
- Concurrency
- Compiled
- Static linking
- Linux based IDEs?
- Debuggers?
- Code analyzers?
Introduction
Introduction and Installation
Variables, Types and Constants
Variables
- “zero value” for different variable types
- inferred variable type:
var age [int] = 29
- multiple variable declaration:
var width, height [int] = 100, 50
Types
Go does not allow automatic type promotion or conversion – “type conversion.”
bool (&&, ||) string int8 int16 int32 int64 int (32 or 64 depending) uint8 uint16 uint32 uint64 uint (32 or 64 depending) uintptr float32 float64 complex64 complex128 byte // alias for uint8 rune // alias for int32
%T printf format specifier prints the type of something.
Constants
const i = 42
- Value assigned to
constmust be known at compile time; cannot require any function execution. - Untyped constants have a default type associated with them and they supply it if and only if a line of code demands it. You can always created a typed constant if you want:
const typedhello string = "Hello World"
Functions and Packages
Functions
- return type follows parameter list