GOLANG: A SIMPLE PROGRAM

How to write a simple Go Program

In this tutorial, we are going to look at the basic structure of a Go program and run a simple Hello World program.

Uday Hiwarale
RunGo
Published in
6 min readJun 30, 2018

--

(source: pexels.com)

What is a Go program?

A Go program file is a simple UTF-8 text file with .go extension. Hence you can edit a Go program in simple text editors like notepad, sublime text or IDEs like VSCode or WebStorm. You can use terminal editors like vim or nano too.

💡 If you are using VSCode, then install vscode-go extension. This will help you write better code and make formatting/debugging easier.

Go program structure

Every Go program must be included in a package. A standalone executable Go program must have a main function and must be included in the main package. The main function is the entry point of the execution.

💡 A standalone executable program is a Go program that can be built to an executable using go build command or ran using go run command.

package mainimport "fmt"func main() {
fmt.Println("Hello World!")
}

--

--