How to Import Packages in Go

Import Go packages using the import statement with the package path or module URL.

Import packages in Go by adding an import block with the package path inside your source file.

package main

import "fmt"

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

For multiple packages, group them in parentheses:

import (
    "fmt"
    "os"
)

For external modules, use the full module path like "github.com/user/repo".