everyday

Hello World - Golang

History

First, little bit of history. Go was developed by Google as Open Source Language to combine the best part of C/C++, Python to provide Garbage collection, types and concurrency.

More details

Hello World

As it is tradition with each language to write a program that prints out Hello World.

package main

import "fmt"

func main() {
    fmt.Print("Hello")
    fmt.Println("Hello Heloo")
    fmt.Println("Hell")
}
HelloHello Heloo
Hell

Each file in go is a package and that's what we have as the first line. Main is a special type package that get executed first when the file is ran. We also have the ability to import packages and one such package is fmt which prints out formatted string.

Print - prints out the string without newline at the end.

Println - prints out the string with newline at the end.

#go-intro

- 2 toasts