
본 게시글은 Golang Tutorial for Beginners | Full Go Course을 학습하며 작성한 개인 노트입니다.
Functions
// code
}
Return values
func funcName(parameterName datatype) output-data-type {
// code
}
- functions can return data as a result
- You have to specify input & output parameters (including type)
- functions can return multiple values
Scopes
Local level variables
- Declared within functions: can be used only within the function
- Declared within block: can be used only within that block
Package level variables
- defined at top outside all functions
- can be accessed inside any functions of the same package
- can only be defined through syntax:
var varname = value
Global level variables
- shared across packages
- first letter capitalized