Hello World in Golang Last Updated : 12 Jul, 2025 Comments Improve Suggest changes 33 Likes Like Report Hello, World! is the first basic program in any programming language. Let’s write the first program in the Go Language using the following steps:First of all open Go compiler. In Go language, the program is saved with .go extension and it is a UTF-8 text file.Now, first add the package main in your program:package mainEvery program must start with the package declaration. In Go language, packages are used to organize and reuse the code. In Go, there are two types of program available one is executable and another one is the library. The executable programs are those programs that we can run directly from the terminal and Libraries are the package of programs that we can reuse them in our program. Here, the package main tells the compiler that the package must compile in the executable program rather than a shared library. It is the starting point of the program and also contains the main function in it.After adding main package import "fmt" package in your program:import("fmt")Here, import keyword is used to import packages in your program and fmt package is used to implement formatted Input/Output with functions.Now write the code in the main function to print hello world in Go language:func main() { fmt.Println("!... Hello World ...!")}In the above lines of code we have:func: It is used to create a function in Go language.main: It is the main function in Go language, which doesn't contain the parameter, doesn't return anything, and call when you execute your program.Println(): This method is present in fmt package and it is used to display "!... Hello World ...!" string. Here, Println means Print line.Example: Go // First Go program package main import "fmt"; // Main function func main() { fmt.Println("!... Hello World ...!") } Output:!... Hello World ...!How to run Golang Program?To run a Go program you need a Go compiler.. Once you have a Go compiler, first you create a program and save your program with extension .go, for example, first.go. Now we run this first.go file in the go compiler using the following command, i.e:$ go run first.goIf you're not sure how to start, check out Boot.dev's Full Go Course. It is designed for beginners, providing a clear, structured path to help you learn Go at your own pace. From basic syntax to advanced concepts, this course will ensure you develop a strong foundation in Go programming. Take your first step towards mastery, sign up now and start coding today! Comment A ankita_saini Follow 33 Improve A ankita_saini Follow 33 Improve Article Tags : Go Language Go-Basics Golang Spotlight Explore Go Tutorial 3 min read OverviewGo Programming Language (Introduction) 7 min read How to Install Go on Windows? 3 min read How to Install Golang on MacOS? 4 min read Hello World in Golang 3 min read FundamentalsIdentifiers in Go Language 3 min read Go Keywords 2 min read Data Types in Go 7 min read Go Variables 9 min read Constants- Go Language 6 min read Go Operators 9 min read Control StatementsGo Decision Making (if, if-else, Nested-if, if-else-if) 5 min read Loops in Go Language 5 min read Switch Statement in Go 2 min read Functions & MethodsFunctions in Go Language 3 min read Variadic Functions in Go 3 min read Anonymous function in Go Language 2 min read main and init function in Golang 2 min read What is Blank Identifier(underscore) in Golang? 3 min read Defer Keyword in Golang 3 min read Methods in Golang 3 min read StructureStructures in Golang 7 min read Nested Structure in Golang 3 min read Anonymous Structure and Field in Golang 3 min read ArraysArrays in Go 7 min read How to Copy an Array into Another Array in Golang? 3 min read How to pass an Array to a Function in Golang? 2 min read SlicesSlices in Golang 14 min read Slice Composite Literal in Go 3 min read How to sort a slice of ints in Golang? 2 min read How to trim a slice of bytes in Golang? 3 min read How to split a slice of bytes in Golang? 3 min read StringsStrings in Golang 7 min read How to Trim a String in Golang? 2 min read How to Split a String in Golang? 3 min read Different ways to compare Strings in Golang 2 min read PointersPointers in Golang 8 min read Passing Pointers to a Function in Go 3 min read Pointer to a Struct in Golang 3 min read Go Pointer to Pointer (Double Pointer) 4 min read Comparing Pointers in Golang 3 min read Like