Web Services : Due to the built in Concurrency feature of Go, it is mostly preferred because because Web Services deals with multiple transaction. And Go's Concurrency model helps to achieve the same.
Automation : Although automation is good for scripting languages like Go. But Go is a suitable in this case as well.
Easy to Read/Write : As said earlier, Go is quite easy to read and write, as code written in Go is quite similar to plain English and Mathematics.
package main import "fmt" func main() { fmt.Println("Hello World") }
For now, you can least bother about the first two lines, we will understand in the coming tutorials.
Just remember that the above lines are the mandatory lines that is needed to run a Go application.
func main() { ... }
func main() { fmt.Println("Hello World") }
Since, 'fmt.Println("Hello World")' is inside the main( ) method, it got printed.
We have to write all our codes inside the main method. And the main method should be inside a class.
package main import "fmt" func main() { //OUR CODE SHOULD BE WRITTEN HERE. }
The codes in Go should be written inside a file with extension '.go'.
So, we will be writing the above code to print 'Hello World' inside a file named 'FirstApplication.go'.
package main import "fmt" func main() { fmt.Println("Hello World") }
Now, to execute the above code, we have to type the following in the command prompt :