---
title: "Go SDK Examples"
description: "Complete examples using the TraceRTM Go SDK"
keywords: [go, sdk, examples, code samples, tutorials]
---

# Go SDK Examples

Complete examples demonstrating TraceRTM Go SDK usage.

## Complete Workflow Example

```go
package main

import (
    "fmt"
    "log"
    "os"
    "github.com/tracertm/tracertm-go"
)

func main() {
    client := tracertm.NewClient(
        tracertm.WithAPIKey(os.Getenv("TRACERTM_API_KEY")),
    )

    // Create project
    project, err := client.Projects.Create(tracertm.CreateProjectRequest{
        Name:        "Authentication System",
        Description: "OAuth 2.0 implementation",
    })
    if err != nil {
        log.Fatal(err)
    }

    // Create requirement
    req, err := client.Items.Create(tracertm.CreateItemRequest{
        Title:     "OAuth 2.0 Support",
        View:      "requirements",
        Status:    "draft",
        ProjectID: project.ID,
    })
    if err != nil {
        log.Fatal(err)
    }

    // Create test case
    test, err := client.Items.Create(tracertm.CreateItemRequest{
        Title:     "OAuth Flow Test",
        View:      "test-cases",
        Status:    "draft",
        ProjectID: project.ID,
    })
    if err != nil {
        log.Fatal(err)
    }

    // Create link
    link, err := client.Links.Create(tracertm.CreateLinkRequest{
        SourceID: req.ID,
        TargetID: test.ID,
        LinkType: "verified_by",
    })
    if err != nil {
        log.Fatal(err)
    }

    fmt.Printf("Created traceability: %s --[verified_by]--> %s\n",
        req.Title, test.Title)
}
```

## Impact Analysis Example

```go
impact, err := client.Analysis.Impact(tracertm.ImpactRequest{
    ItemID:    "item_req_001",
    ProjectID: "proj_123",
})
if err != nil {
    log.Fatal(err)
}

fmt.Printf("Affects %d items:\n", impact.TotalAffected)
for _, item := range impact.AffectedItems {
    fmt.Printf("  - %s (depth: %d)\n", item.Title, item.Depth)
}
```

## Error Handling Example

```go
item, err := client.Items.Get("item_abc123")
if err != nil {
    if tracertm.IsNotFound(err) {
        log.Println("Item not found")
        return
    }
    if tracertm.IsAuthError(err) {
        log.Fatal("Authentication failed")
    }
    log.Fatal(err)
}

fmt.Printf("Item: %s\n", item.Title)
```

## Related Documentation

- [Quickstart](./02-quickstart) - Get started
- [Authentication](./03-authentication) - Auth setup
- [Artifacts](./04-artifacts) - Item operations
