Keywords or Reserved words are the words in a language that are used for some internal process or represent some predefined actions. These words are therefore not allowed to use as an identifier. Doing this will result in a compile-time error.
Example:
package main
import "fmt"
func main() {
var a = "GeeksforGeeks"
fmt.Println(a)
}
|
Output:
GeeksforGeeks
There are total 25 keywords present in the Go language as follows:
break |
case |
chan |
const |
continue |
default |
defer |
else |
fallthrough |
for |
interface |
map |
package |
range |
return |
select |
struct |
switch |
type |
var |
Example:
package main
import "fmt"
func main() {
var Pname = "GeeksforGeeks"
var Lname = "Go Language"
var Cname = "Keywords"
fmt.Printf( "Portal name: %s" , Pname)
fmt.Printf( "\nLanguage name: %s" , Lname)
fmt.Printf( "\nChapter name: %s" , Cname)
}
|
Output:
Portal name: GeeksforGeeks
Language name: Go Language
Chapter name: Keywords