This is a simple Go program that prints "Hello, World!" to the console.
To run this program on your local machine, follow these steps:
-
Make sure you have Go installed. If not, you can download it here.
-
Clone this repository:
git clone https://github.com/ouzdev/go-learn-the-basics
-
Navigate to the project directory:
cd go-learn-the-basics
-
Run the program:
go run syntax.go
The code is organized into the following sections:
-
Package Declaration: Every Go program is part of a package. In this example, the program belongs to the main package.
-
Import Statement: The
import "fmt"
statement imports thefmt
package, which provides functions for formatting and printing. -
Main Function: The
main
function is the entry point of the program. Code inside its curly braces will be executed. Here, it prints "Hello, World!" to the console.
There's also a compact version provided in the comments, but it's not recommended for readability.
package main; import "fmt"; func main() {fmt.Println("Hello, World!")}