Go is a language developed by Google.It is a simple and robust language.
Go has the following features
- Fully compiled
- Go is object oriented
- Clean syntax It has simple syntax like Python
- Concurrency Concurrent system can be implemented in Go easily
- Strongly and statically typed
Code file or module in Go is contained in a package.Main package contains main function which is the entry point of the program
Following is the simplest go program
package main func main() { println("First Go Program") }
Please note that the function is called main and it is not part of any class unlike other languages such as C# or Java..We can modify the program by declaring the variable for displaying the message
package main var( msg string="First Go Program" ) func main() { println(msg) }
We can modify the above program to include init function as:
package main var( msg string="First Go Program" ) func main() { println(msg) } func init(){ println("Hello World") }
this prints
Hello World
First Go Program