Go’s standard library supplies reusable packages for common application work, including networking, cryptography, serialization, and math. Its packages are imported through the same package system used for application code and external dependencies. The full library is documented with examples at pkg.go.dev/std. section 1.2.2 section 1.2.4
Start with the package that matches the task. For a direct TCP connection, net.Dial accepts a connection type and endpoint; net.Listen accepts incoming connections. For an ordinary web request, net/http offers the simpler http.Get. Check the returned error, close the response body, and read it with io.ReadAll. section 1.2.2
Listing 1.4 HTTP GET
package main
import (
"io"
"log"
"net/http"
)
func main() {
resp, err := http.Get("http://example.com/") #1
if err != nil {
log.Fatal("could not retrieve example.com", err) #2
}
defer resp.Body.Close() #3
body, err := io.ReadAll(resp.Body) #4
if err != nil {
log.Fatal("could not read body", err) #5
}
log.Println(string(body))
}
This HTTP GET example combines net/http, io, and log to retrieve a page, handle failures, close the body, and print its contents. section 1.2.2
Import a package by name and prefix its exported functions with that name: fmt.Println uses fmt, while http.Get uses net/http under the http prefix. Imports can be grouped; external packages use the same import mechanism and can be retrieved with go get. Standard-library packages also support practical command-line programs: built-in functionality handles arguments and flags, while packages such as bufio, os, and strings support input processing. section 1.2.4 section 2.1
The library has boundaries. It does not include native GUI application support; that calls for other libraries or frameworks. A standard-library import is also distinct from a toolchain command: testing supplies test facilities, while go test runs tests and can report coverage. section 2.1 section 1.2.4






