Functions

지니🧸·2023년 8월 29일
0

Go

목록 보기
5/8

본 게시글은 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
    • (ex) for, if-else

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
profile
우당탕탕

0개의 댓글