---
title: Go easy instrumentation
source: https://docs.newrelic.com/docs/apm/agents/go-agent/installation/install-automation-new-relic-go
---

Go is a compiled language with an opaque runtime, making it unable to support automatic instrumentation like other languages. For this reason, the New Relic Go agent is designed as an SDK. Since the Go agent is an SDK, it requires more manual work to set up than agents for languages that support automatic instrumentation.

In an effort to make instrumentation easier, the Go agent team created the Go easy instrumentation tool. This tool does most of the work for you by suggesting changes to your source code that instrument your application with the New Relic Go agent.

## How it works [#how-it-works]

This tool doesn't interfere with your application's operation, and it doesn't make any changes to your code directly. Here's what happens:

-   It analyzes your code and suggests changes that allow the Go agent to capture telemetry data.
-   You review the changes in the `.diff` file and decide which changes to add to your source code.

As part of the analysis, this tool may invoke `go get` or other Go language toolchain commands which may modify your `go.mod` file, but not your actual source code.

## What is instrumented? [#what-is-instrumented]

The scope of what this tool can instrument in your application is limited to these actions:

-   Capturing errors in any function wrapped or traced by a transaction
-   Detect any existing New Relic Instrumentation and suggest changes to your source code based on already existing New Relic code
-   Tracing locally defined functions that are invoked in the application's `main()` method with a transaction
-   Tracing async functions and function literals with an async segment
-   Adding middleware to supported libraries for tracing
-   Injecting distributed tracing into external traffic

### Supported Libraries [#supported-libraries]

-   standard library
-   net/http
-   gin
-   gRPC
-   gochi
-   mysql
-   slog

## Installation [#go-easy-install]

Before you start the installation steps below, make sure you have a version of Go installed that is within the support window for the current [Go programming language lifecycle](https://endoflife.date/go).

Install Go easy instrumentation:

```sh
go install github.com/newrelic/go-easy-instrumentation@latest
```

**Setting up your GOPATH**

To install `go-easy-instrumentation` make sure `GOPATH` bin is in your `PATH`.

**Mac or Linux**

In your terminal, bashrc, or zshrc, the following line adds the path to your `GOPATH` bin to your `PATH`:

````sh
export PATH=$PATH:$(go env GOPATH)/bin
```

````

**Windows**

In a windows terminal or powershell window, the following line will add the path to your `GOPATH` bin to your `PATH`:

````sh
go env -w GOPATH=c:\go-work
```

````

> #### 💡 SUGGESTION GENERATION
>
> The Go easy instrumentation tool provides suggestions for instrumenting your Go application. Review the outputted diff file carefully to verify correctness of instrumentation.

## Generate instrumentation suggestions [#generate-suggestions]

This tool works best with Git. We recommend you verify your application is on a branch without any unstaged changes before applying any of the suggested changes to it. After checking that, follow these steps to generate, review, and apply the changes that install the New Relic Go agent in an application:

1.  Run the following CLI command to create a file named `new-relic-instrumentation.diff` in your working directory:
    ```sh
    go-easy-instrumentation instrument ../my-application/
    ```
2.  Open the `.diff` file and verify or correct the contents.
3.  When you are satisfied with the instrumentation suggestions, save the file, and then apply the changes:
    ```sh
    mv new-relic-instrumentation.diff ../my-application/
    cd ../my-application
    git apply new-relic-instrumentation.diff
    ```

Once the changes are applied, the application should run with the New Relic Go agent installed. If the agent installation is not working the way you want it to, you can easily recover by using common Git commands. For example, you could try one of the following:

-   Stash the changes with `git stash`
-   Revert the code to a previous commit

## What's next? [#what-is-next]

If you have any suggestions or find issues, please create a [Github issue](https://github.com/newrelic/go-easy-instrumentation).
