<!--
  Copyright (c) 2009-2026 ASN Lab
  All rights reserved.
-->

# ASN.1 Go Compiler Guide

The ASN.1 Go Compiler (`asngc`) generates Go source code from ASN.1 modules.
Generated types are Go structs and work with the Go runtime library for
encoding and decoding.

## Compiler Options

| Field             | Type    | Default            | Description |
|-------------------|---------|--------------------|-------------|
| `output-folder`   | string  | `"go"`             | Output directory for generated Go sources. |
| `mapping.integer` | ENUM    | `automatic-int64`  | See [Integer Mapping](#integer-mapping). |
| `mapping.real`    | ENUM    | `automatic`        | `automatic`, `float32`, `float64`. |
| `generate.equals` | BOOLEAN | --                 | Generate `Equals` methods. |
| `generate.prints` | BOOLEAN | --                 | Generate `String` methods. |

## Integer Mapping

Controls how ASN.1 INTEGER is mapped to Go types:

| Option             | Go type |
|--------------------|---------|
| `automatic`        | `int64` (same as `automatic-int64`). |
| `automatic-int64`  | `int64`. |
| `automatic-bigint` | `*big.Int`. |
| `int32`            | `int32`. |
| `int64`            | `int64`. |
| `big-integer`      | `*big.Int`. |

## Real Mapping

| Option      | Go type |
|-------------|---------|
| `automatic` | `float64`. |
| `float32`   | `float32`. |
| `float64`   | `float64`. |

## Project Configuration Example

```asn1
compilers {
    {
        language "go",
        options {
            output-folder "go",
            mapping {
                integer automatic-int64,
                real automatic
            }
        }
    }
}
```

## Runtime Integration

Import the generated Go package and the Go runtime library in your module. The
generated types provide `Encode` and `Decode` methods that accept an encoding
rule constant (BER, DER, UPER, APER, OER, XER, JER).

## Generated Output

With `output "build"` and `go.output-folder "go"`, output is written under
`build/go/`. Each ASN.1 module produces a Go package.
