Go - Basic Syntax
We have already discussed the basic structure of a Go program in the previous chapter.
Tokens in GoGo application includes numerous tokens.Token is likewise a keyword, an identifier, a constant, a string literal, or a symbol. For example, the subsequent Go assertion includes six tokens:-
fmt.Println("Hello, World Welookups!")The individual tokens are:
fmt . Println ( "Hello, World Welookups!" )
Line SeparatorGo application, the line separator key's a statement terminator. individual statements don't want a special separator like ";$ in C. The Go compiler internally places “;” as the statement terminator to indicate the end of one logical entity.
fmt.Println("Hello, World Welookups!") fmt.Println("I am in Go Programming!")
CommentsComments are like helping texts in your Go program and they're left out by way of the compiler. Go start with /* and terminates with the characters */ as shown below here :-
/* my first program in Go */
IdentifiersGo identifier is a name used to identify a variable, function, or any other user-defined item. identifier starts with a letter a to z or an underscore _ followed by zero or more letters, underscores, and digits (0 to 9).
KeywordsThere are following list the reserved words in Go. These reserved words may not be used as constant variable or constant or any other identifier names.
Whitespace in GoWhitespace is used in Go to describe blanks, tabs, newline characters, and comments.A line containing only whitespace, possibly with a comment, is known as a blank line.Whitespaces separate compiler to identify where one element in a statement, such as int, ends and the next element begins.
Therefore, in the following statement −
var age int;