### Write GPX Document
Source: https://github.com/twpayne/go-gpx/blob/master/README.md
Demonstrates how to create and write a GPX document to standard output using `gpx.GPX.WriteIndent`. It includes setting GPX version, creator, and waypoints, and handles potential write errors.
```go
g := &gpx.GPX{
Version: "1.1",
Creator: "ExpertGPS 1.1 - http://www.topografix.com",
Wpt: []*gpx.WptType{
{
Lat: 42.438878,
Lon: -71.119277,
Ele: 44.586548,
Time: time.Date(2001, 11, 28, 21, 5, 28, 0, time.UTC),
Name: "5066",
Desc: "5066",
Sym: "Crossing",
Type: "Crossing",
},
},
}
if _, err := os.Stdout.WriteString(xml.Header); err != nil {
fmt.Printf("err == %v", err)
}
if err := g.WriteIndent(os.Stdout, "", " "); err != nil {
fmt.Printf("err == %v", err)
}
// Output:
//
//
//
// 44.586548
//
// 5066
// 5066
// Crossing
// Crossing
//
//
```
--------------------------------
### Read GPX Document
Source: https://github.com/twpayne/go-gpx/blob/master/README.md
Demonstrates how to read a GPX document from a byte buffer using the `gpx.Read` function. It handles potential errors and prints the first waypoint's details.
```go
r := bytes.NewBufferString(`
44.586548
5066
5066
Crossing
Crossing
`)
t, err := gpx.Read(r)
if err != nil {
fmt.Printf("err == %v", err)
return
}
fmt.Printf("t.Wpt[0] == %+v", t.Wpt[0])
// Output:
// t.Wpt[0] == &{Lat:42.438878 Lon:-71.119277 Ele:44.586548 Speed:0 Course:0 Time:2001-11-28 21:05:28 +0000 UTC MagVar:0 GeoidHeight:0 Name:5066 Cmt: Desc:5066 Src: Link:[] Sym:Crossing Type:Crossing Fix: Sat:0 HDOP:0 VDOP:0 PDOP:0 AgeOfDGPSData:0 DGPSID:[] Extensions:}
```
=== COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.