Tutorial Gateway

  • C
  • C#
  • Java
  • Python
  • SQL
  • MySQL
  • Js
  • BI Tools
    • Informatica
    • Talend
    • Tableau
    • Power BI
    • SSIS
    • SSRS
    • SSAS
    • MDX
    • R Tutorial
    • Alteryx
    • QlikView
  • More
    • C Programs
    • C++ Programs
    • Go Programs
    • Python Programs
    • Java Programs

Golang Hello World Program

by suresh

In any Programming language, we write the traditional or common Hello World program. In this golang tutorial also, we start writing the hello world program in our Visual Studio Code Editor. You can use any of your favorite Go editors to write your programs.

The following golang code will print the Hello World message as an output of the terminal. Let me save this program as helloworld.go. Here, go is the extension of the program that we write in golang.

package main

import "fmt"

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

To run this hello world program, go to the terminal and navigate to the folder that you saved the program using the cd command. Next, type go run program_Name.go. Here, it is

go run helloworld.go
Go Hello World Program 1

golang Hello World Program Analysis

The Go compiler executes the code from top to bottom. Every Go program must start with the package declaration.

package main

In the next line, we are importing the fmt (format) package into the program. It is the standard library that contains the common input and output functions.

Every function starts with the keyword func. Within this main function, we used the Println function to print the output. If you don’t use the import “fmt”, you can’t use this Println function.

Golang Hello World Program 2

In this simple Go program, we used for loop to print hello world message five times.

package main

import "fmt"

func main() {
    for i := 1; i <= 5; i++ {
        fmt.Println("Hello World")
    }
}
Golang Hello World Program 2

Placed Under: Go Examples

  • Golang Hello World Program
  • Go Add Two Number
  • Go Compound Interest
  • Go Count Digits in a Number
  • Go Cube of a Number
  • Go Even or Odd
  • Go Largest of Three Numbers
  • Go Reverse Natural Numbers
  • Go Multiplication Table
  • Go Number divisible by 5 and 11
  • Go Positive or Negative
  • Go Power of a Number
  • Go Print Natural Numbers
  • Go Profit or Loss
  • Go Print 1 to 100 without loop
  • Go Program to Print 1 to 100
  • Go Product of Digits in a Number
  • Go Palindrome Number Program
  • Go Print Even Numbers
  • Go Print Odd Numbers
  • Go Factors of a Number
  • Go Perfect Number
  • Go Prime Number
  • Go Reverse a Number
  • Go Simple Interest
  • Go Square of a Number
  • Go Square root of a Number
  • Go Sum of Digits in a Number
  • Go Sum & Avg of Natural Nums
  • Go Sum of Even Numbers
  • Go Sum of Odd Numbers
  • Go Sum of Even and Odd
  • Go Sphere Vol & Surface Area
  • Go Cylinder Vol & Surface Area
  • Go Cuboid Vol & Surface Area
  • Go Cube Volume & Surface Area
  • Go Cone Volume & Surface Area

Copyright © 2021 · All Rights Reserved by Suresh

About Us | Contact Us | Privacy Policy