Hello World

Duration: 5 min•Difficulty: Easy•

The first program when learning a programming language is usually "Hello World". This ensures your compiler and environment are running correctly.

Structure of a Go Program

  1. package main: Indicates that this file should be compiled into an executable (a program that can be run), not a library.
  2. import "fmt": Includes the built-in fmt (format) package for input/output, such as printing text.
  3. func main(): The entry point for program execution. The code inside the curly braces {} will be executed first.
MAIN.GO
package main
import "fmt"
func main() {
fmt.Println("Hello, World!")
}