> For clean Markdown of any page, append .md to the page URL.
> For a complete documentation index, see https://docs.detectant.com/llms.txt.
> For AI client integration (Claude Code, Cursor, etc.), connect to the MCP server at https://docs.detectant.com/_mcp/server.

![Detectant](https://www.detectant.com/images/detectant-github-banner.png)

# Detectant Go SDK

[Detectant is a malware scanning API with support for Go](https://www.detectant.com)

Scan files for malware from Go services and applications.

## Install

```bash
go get github.com/Detectant/go-sdk
```

Set your API key in the environment:

```bash
export DETECTANT_API_KEY="your-api-key"
```

## Create a client

```go
import (
    "os"

    detectant "github.com/Detectant/go-sdk/client"
    "github.com/Detectant/go-sdk/option"
)

client := detectant.NewClient(
    option.WithAPIKey(os.Getenv("DETECTANT_API_KEY")),
)
```

## Scan one file

```go
file, err := os.Open("./invoice.pdf")
if err != nil {
    log.Fatal(err)
}
defer file.Close()

result, err := client.Scan(context.Background(), file)
if err != nil {
    log.Fatal(err)
}

fmt.Println(result.Verdict, result.Detections)
```

The SDK streams from any `io.Reader`, so large files do not need to be loaded into memory.

## Scan a batch

Upload between 1 and 20 files. Results are returned in the same order as the inputs.

```go
batch, err := client.ScanBatch(context.Background(), []io.Reader{invoice, archive})
if err != nil {
    log.Fatal(err)
}

for _, item := range batch.Results {
    fmt.Println(item.Filename)
}
```

Requests retry transient failures twice by default. Use request options to configure retry attempts, timeouts, headers, or a custom HTTP client.

## Source

The SDK is generated with Fern and maintained at [Detectant/go-sdk](https://github.com/Detectant/go-sdk). Package documentation is available on [pkg.go.dev](https://pkg.go.dev/github.com/Detectant/go-sdk).