Go Configuration

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

1default-group: local
2groups:
3 local:
4 generators:
5 - name: fernapi/fern-go-sdk
6 version: 1.5.2
7 config:
8 packageName: acme
9 output:
10 location: local-file-system
11 path: ../generated/go

SDK Configuration Options

alwaysSendRequiredProperties
boolean
clientConstructorName
string
clientName
string
exportedClientName
string
importPath
string

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.

If you plan to to distribute the generated Go SDK as a separate, published Go module, use the module configuration option instead.

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

1default-group: local
2groups:
3 local:
4 generators:
5 - name: fernapi/fern-go-sdk
6 version: 0.13.0
7 config:
8 importPath: github.com/<YOUR_ORGANIZATION>/<YOUR_REPOSITORY>/generated/go
9 output:
10 location: local-file-system
11 path: ../generated/go
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.
includeLegacyClientOptions
boolean
inlineFileProperties
boolean
inlinePathParameters
boolean
module
ModuleConfigSchema

Use this option if you plan to distribute the generated Go SDK as a separate, published Go module.

If you only plan to use the generated SDK within your own Go module, use the importPath configuration option instead.

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

1default-group: local
2groups:
3 local:
4 generators:
5 - name: fernapi/fern-go-sdk
6 version: 0.13.0
7 config:
8 module:
9 path: github.com/<YOUR_ORGANIZATION>/<YOUR_REPOSITORY>
10 output:
11 location: local-file-system
12 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:

1default-group: local
2groups:
3 local:
4 generators:
5 - name: fernapi/fern-go-sdk
6 version: 0.13.0
7 config:
8 module:
9 path: github.com/<YOUR_ORGANIZATION>/<YOUR_REPOSITORY>
10 version: "1.19"
11 output:
12 location: local-file-system
13 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 statement:

1module github.com/your/module
2
3require "github.com/your/sdk" v0.0.0
4replace "github.com/your/sdk" v0.0.0 => "path/to/generated/sdk"
packageLayout
'flat' | 'nested'
packageName
string
union
'v0' | 'v1'
useReaderForBytesRequest
boolean