Web Technologies - Go Language

Back to Course

Lesson Description

Lession - #351 GO-Basic Synatax

Go - Basic Syntax

We examined the fundamental construction of a Go program in the past section. Presently it will be straightforward the other fundamental structure squares of the Go programming language.

Tokens in Go

A Go program comprises of different tokens. A token is either a watchword, an identifier, a steady, a string strict, or an image. For instance, the accompanying Go assertion comprises of six tokens −

fmt.Println("Hello, World!">

The individual tokens are −

   "Hello, World!"

Line Separator

In a Go program, the line separator key is an assertion eliminator. That is, individual articulations needn't bother with a unique separator like ";" in C. The Go compiler inside places ";" as the explanation eliminator to show the finish of one intelligent substance. For instance, investigate the accompanying assertions −

fmt.Println("Hello, World!">
fmt.Println("I am in Go Programming World!">


Comments resemble helping texts in your Go program and they are disregarded by the compiler. They start with/* and ends with the characters */as displayed underneath −

/* my first program in Go */

You can't include remarks inside remarks and they don't happen inside a string or character literals.


A Go identifier is a name used to distinguish a variable, work, or some other client characterized thing. An identifier begins with a letter start to finish or beginning to end or a highlight _ followed by nothing or more letters, highlights, and digits (0 to 9>
. identifier = letter { letter | unicode_digit }. Go doesn't permit accentuation characters, for example, @, $, and % inside identifiers. Go is a case-delicate programming language. Subsequently, Manpower and labor are two distinct identifiers in Go. Here are a few instances of satisfactory identifiers −

mahesh      kumar   abc   move_name   a_123
myname50   _temp    j      a23b9      retVal

Whitespace in Go

Whitespace is the term utilized in Go to depict spaces, tabs, newline characters, and remarks. A line containing just whitespace, conceivably with a remark, is known as a clear line, and a Go compiler absolutely disregards it. Whitespaces separate one piece of an assertion from another and empowers the compiler to distinguish where one component in a proclamation, for example, int, closes and the following component starts. Accordingly, in the accompanying proclamation −

var age int;

There should be somewhere around one whitespace character (normally a space>
among int and age for the compiler to have the option to recognize them. Then again, in the accompanying proclamation −

fruit = apples + oranges;   // get the total fruit