# Go configuration

> Configuration options for the Fern Go SDK.

You can customize the behavior of the Go SDK generator in `generators.yml`:

```yaml {6-7} title="generators.yml"
groups:
  go-sdk:
    generators:
      - name: fernapi/fern-go-sdk
        version: 1.23.4
        config:
          packageName: acme
        output:
          location: local-file-system
          path: ../generated/go
```

<ParamField path="alwaysSendRequiredProperties" type="boolean" required={false} toc={true}>
  When enabled, ensures that all required properties are always included in API requests, even if they have default values or are otherwise optional in the implementation.
</ParamField>

<ParamField path="clientConstructorName" type="string" required={false} toc={true}>
  Customizes the name of the client constructor function. This allows you to specify a custom name for the function that users will call to create a new instance of the client.
</ParamField>

<ParamField path="clientName" type="string" required={false} toc={true}>
  Specifies the name of the generated client struct. This determines the primary client type name that users will interact with in the generated Go SDK.
</ParamField>

<ParamField path="exportedClientName" type="string" required={false} toc={true}>
  Sets the name of the exported client that will be used in code snippets and documentation examples. This is useful for customizing how the client appears in generated documentation.
</ParamField>

<ParamField path="enableWireTests" type="string" default="true" required={false} toc={true}>
  Generates [mock server (wire) tests](/sdks/deep-dives/testing#mock-server-tests) to verify that the SDK sends the correct HTTP requests and correctly handles responses per the API spec. When enabled, Docker is required as a runtime dependency to run the generated tests.
</ParamField>

<ParamField path="importPath" type="string" required={false} toc={true}>
  Use this option if you plan to depend on the generated Go SDK from within your project, and **not** depend on it as a separate, published Go module.

  <Note>
    If you plan to to distribute the generated Go SDK as a separate, published Go module, use the 

    `module`

     configuration option instead.
  </Note>

  You can generate the Go SDK code into a `gen/go/api` package with the following `generators.yml`
  configuration:

  ```yaml {7-8}
  default-group: local
  groups:
    local:
      generators:
        - name: fernapi/fern-go-sdk
          version: 0.13.0
          config:
            importPath: github.com/<YOUR_ORGANIZATION>/<YOUR_REPOSITORY>/generated/go
          output:
            location: local-file-system
            path: ../generated/go
  ```

  <Info>
    You must update the 

    `<YOUR_ORGANIZATION>`

     and 

    `<YOUR_REPOSITORY>`

     placeholders
    with the relevant elements in your 

    `go.mod`

     path. In this case, the generated Go SDK uses the same 

    `go.mod`

     path used by the rest of your Go module.
  </Info>
</ParamField>

<ParamField path="includeLegacyClientOptions" type="boolean" required={false} toc={true}>
  When enabled, includes legacy client options for backward compatibility with older versions of the SDK. This is useful for maintaining compatibility when upgrading SDK versions.
</ParamField>

<ParamField path="inlineFileProperties" type="boolean" required={false} toc={true}>
  Controls whether file upload properties are generated as inline request properties instead of separate parameters. When enabled, file upload fields become part of the request struct rather than being passed as individual function parameters.
</ParamField>

<ParamField path="inlinePathParameters" type="boolean" required={false} toc={true}>
  When enabled, path parameters are inlined into request types rather than being passed as separate function parameters. This creates a more unified request structure where path parameters are included in the request object.
</ParamField>

<ParamField path="module" type="object" required={false} toc={true}>
  Use this option if you plan to distribute the generated Go SDK as a separate, published Go module.

  <Note>
    If you only plan to use the generated SDK within your own Go module, use the 

    `importPath`

     configuration option instead.
  </Note>

  You can generate the Go SDK code into a separate module (defined with its own `go.mod`)
  with the following `generators.yml` configuration:

  ```yaml {7-9}
  default-group: local
  groups:
    local:
      generators:
        - name: fernapi/fern-go-sdk
          version: 0.13.0
          config:
            module:
              path: github.com/<YOUR_ORGANIZATION>/<YOUR_REPOSITORY>
          output:
            location: local-file-system
            path: ../generated/go
  ```

  This configuration will generate a `go.mod` alongside the rest of the Go SDK code at the target output
  location. With this, `import` statements within the generated Go SDK are all resolved from the configured
  module path.

  By default, the generated `go.mod` will be set to `1.13`. You can override this behavior by specifying
  the `version` key:

  ```yaml {10}
  default-group: local
  groups:
    local:
      generators:
        - name: fernapi/fern-go-sdk
          version: 0.13.0
          config:
            module:
              path: github.com/<YOUR_ORGANIZATION>/<YOUR_REPOSITORY>
              version: "1.19"
          output:
            location: local-file-system
            path: ../generated/go
  ```

  If you want to depend on the generated Go SDK locally (without distributing it as a separate Go module),
  and you use the `module` configuration option, you will need to modify your project's top-level `go.mod` to include a [`replace`](https://go.dev/doc/modules/gomod-ref#replace) statement:

  ```go
  module github.com/your/module

  require "github.com/your/sdk" v0.0.0
  replace "github.com/your/sdk" v0.0.0 => "path/to/generated/sdk"
  ```
</ParamField>

<ParamField path="packageLayout" type="'flat' | 'nested'" required={false} toc={true}>
  Controls the organization of the generated package structure. Choose 'flat' for a flatter package structure with fewer nested directories, or 'nested' for a more hierarchical organization that mirrors your API structure.
</ParamField>

<ParamField path="packageName" type="string" required={false} toc={true}>
  Specifies the package name for the generated Go code. This determines the package declaration that will appear at the top of generated Go files and affects how users import the SDK.
</ParamField>

<ParamField path="union" type="'v0' | 'v1'" required={false} toc={true}>
  Controls the union type generation strategy. Use 'v0' for the legacy union implementation or 'v1' for the newer, more robust union handling approach that provides better type safety and discriminated union support.
</ParamField>

<ParamField path="useReaderForBytesRequest" type="boolean" required={false} toc={true}>
  When enabled, uses `io.Reader` interface for handling byte request bodies instead of byte slices. This is more memory-efficient for large payloads and follows Go best practices for streaming data.
</ParamField>