Wednesday 1 May 2019

Go: Hello World Application


Open any text editor and create HelloWorld.go file with below content.

HelloWorld.go
package main

func main() {
 println("Hello, World")
}


Execute the command ‘go run HelloWorld.go’.
$ go run HelloWorld.go 
Hello, World

package main
It is used by the Go compiler to determine application entry point.

func main()
Program execution starts from here. ‘func’ keyword is used to define a function. ‘main’ function do not take any arguments.

println("Hello, World")
‘println’ is a built in function in Go, that is used to print given message to console.

Note
a.   Unlike C, C++ and Java, you no need to end a statement by a semi colon.
b.   String in Go, are placed in between double quotes
c.    Strings in Go are Unicode.


Previous                                                 Next                                                 Home

No comments:

Post a Comment