Reserved Words?

Viewed 169

The following keywords are reserved and may not be used as identifiers:

break        default      func         interface    select
case         defer        go           map          struct
chan         else         goto         package      switch
const        fallthrough  if           range        type
continue     for          import       return       var

Programs attempting to use these words as identifies will not compile:

package main

import "fmt"

func main() {
	var := "hello"
	fmt.Println(var)
}

Without reserved word identifiers everything is ok:

package main

import "fmt"

func main() {
	message := "hello"
	fmt.Println(message)
}
1 Answers