# bugstack for Go

Go

# bugstack for Go

Auto-fix nil pointer dereference, index out of range, and concurrency panics in Gin, Echo, and Go stdlib.

## What Go Errors bugstack Fixes

-   **nil pointer dereference** — accessing fields or methods on nil pointers
-   **index out of range** — accessing slices or arrays beyond their bounds
-   **concurrent map read/write** — race conditions on unsynchronized maps
-   **send on closed channel** — writing to a channel that has already been closed

## Install the SDK

Add bugstack to your Go module:

```
go get github.com/MasonBachmann7/Bugstack-Go
```

Then initialize it in your main function:

```
import "github.com/MasonBachmann7/Bugstack-Go/bugstack"

func main() {
    bugstack.Init(bugstack.Config{
        APIKey: os.Getenv("BUGSTACK_API_KEY"),
    })
    defer bugstack.Flush()

    // your application code
}
```

## Example Fix

bugstack detects a nil pointer dereference panic and writes a surgical fix:

Before (broken)

```
func GetUserEmail(id int) string {
    user := findUserByID(id)
    return user.Email
}

// Runtime panic when user is nil:
// panic: runtime error: invalid
//   memory address or nil pointer
//   dereference
```

After (fixed by bugstack)

```
func GetUserEmail(id int) (string, error) {
    user := findUserByID(id)
    if user == nil {
        return "", fmt.Errorf(
            "user %d not found", id,
        )
    }
    return user.Email, nil
}
```

## Related Error Guides

-   [Fix index out of range in Go](/errors/index-out-of-range-go)
-   [Fix panic recovery in Go](/errors/go-panic-recovery)
-   [Fix nil pointer dereference in Gin](/errors/nil-pointer-dereference-gin)
-   [Fix channel deadlock in Go](/errors/go-channel-deadlock)

[Full installation guide with config reference →](/docs/installation/go)

## Stop fixing Go panics manually

bugstack catches runtime panics in production, writes the fix, runs your CI, and opens a tested pull request — in under 2 minutes.

[Start Free](https://dashboard.bugstack.ai/login)

14-day free trial · No credit card required