# Adding custom code

> Learn how to add custom logic and methods to your Go SDK with Fern. Extend generated clients with helper functions and custom code.

This page covers how to add custom logic and methods to your Go SDK.

<Info>
  Before getting started, 

  [read about how Fern SDKs use custom code and learn about the `.fernignore` file](/sdks/overview/custom-code)

  .
</Info>

## Adding custom logic

To get started adding custom code:

<Steps>
  ### Create a new file and add your custom logic

  ```go title="helper.go"
  func MyHelper() {
    fmt.Println("Hello World!")
  }
  ```

  ### Add your file to `.fernignore`

  ```yaml {3} title=".fernignore"
  # Specify files that shouldn't be modified by Fern

  helper.go
  ```

  ### Consume the helper

  Now your users can consume the helper function by importing it from the SDK.

  ```go
  import "github.com/package/example"

  example.MyHelper();
  ```
</Steps>

## Adding custom SDK methods

Fern also allows you to add custom methods to the SDK itself (e.g.
`client.my_method()` ) by inheriting the Fern generated client and then
extending it.

<Steps>
  ### Update `generators.yml` configuration

  Name your Fern-generated client something like `BaseClient` to reflect that this client will be extended.

  ```yml {4} title="generators.yml"
  - name: fernapi/fern-go-sdk
      version: "..."
      config:
        clientName: BaseClient
  ```

  ### Import and extend the generated client

  First, import the Fern generated base client and extend it. Then, add whatever methods you want.

  ```go title="client/my_client.go"
  type MyClient struct {
    *Client // Embed the Fern generated client.
  }

  func NewMyClient(opts ...option.RequestOption) *MyClient {
    return &MyClient{
      Client: NewClient(opts...),
    }
  }

  func (m *MyClient) MyHelper() {
    fmt.Println("Hello World!")
  }
  ```

  ### Update `.fernignore`

  Add the `client/my_client.go.` to `.fernignore`.

  ```diff title=".fernignore"
  + client/my_client.go
  ```

  ### Consume the method

  Instead of constructing the generated client, your users will want to construct the extended client.

  ```go title="main.go"
  import exampleclient "github.com/package/example/client"

  client := exampleclient.NewMyClient():
  ```

  Now your users can consume the helper function by importing it from the SDK.

  ```go
  client.MyHelper()
  ```
</Steps>