Structure

Program Structure

  • Documentation block

  • Preprocessor Statements

  • The main ( ) function

  • Local Variable Declarations

  • Program statements

  • User defined functions

/* This is my first Go program. */
package main
import "fmt"
func main() {
    fmt.Println("Hello, World!")
}

Documentation Block

/*
Program Name: First Go Program
Version: 1.0
Description: Go program basic program structure.
Author: @Oliver
Date Created 04/01/2021
*/

Package Declaration

package main

Preprocessor Statements

import "fmt"

The main() function

Mandatory to have in Go.

Local Variable Declarations

Variables in main

Statements and Expressions

This is the section where we place our main logic of the program which included the executable statements, that tell the computer to perform a specification action. Program statement can be an input-output statements, arithmetic statements, control statements, simple assignment statements and any other statements and it also includes comments that are enclosed within /* and */.

User Defined Functions

Functions in main

Last updated