Skip to content

Latest commit

 

History

History

Basics

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 

Basics

There is a bunch of ways to work with variables in Go. Like:

  • var i int
  • var i int = 1
  • var i = 1
  • i := 1 (:= syntax is shorthand for declaring and initializing a variable)
  • const i int = 1 (const is the keyword for a constant that cannot change)
  • const i = 1

Similar to these you are also able to declare multiple variables in one line like:

  • var i,j int (Multiple of same type)
  • var i, isGoAwesome, myName = 1, true, "Joshua" (Multiple different types)

You can also use the package fmt to format and/or print text.

fmt.Println("Hello World")