2018-08-30 Go Learning Notes

  • In functions, the short assignment statement := can replace var declarations where the type is clear. However, constants must be declared using const
  • Outside of functions, every statement must start with a keyword (var, func, etc.), therefore := syntax cannot be used outside of functions.
  • Why Go uses trailing type declarations: https://blog.go-zh.org/gos-declaration-syntax
  • Go has the following types:
bool

string

int  int8  int16  int32  int64
uint uint8 uint16 uint32 uint64 uintptr

byte // alias for uint8

rune // alias for int32
    // represents a Unicode code point

float32 float64

complex64 complex128
  • When you need an integer value, you should use the int type, unless you have a specific reason to use a fixed size or unsigned integer type.
  • Go does not support implicit type conversion
comments powered by Disqus
Built with Hugo
Theme Stack designed by Jimmy