Skip to main content
Published
Jun 19, 2026
4mo ago
Total Downloads
26.5K
26,474

Install

dotnet add package Aspire.Hosting.Go --version 13.4.6-preview.1.26319.6
ProductVersions
.NET
net8.0

README

Aspire.Hosting.Go library

Provides extension methods and resource definitions for an Aspire AppHost to configure Go applications.

Getting started

Prerequisites

The Go toolchain (go) must be available on the PATH of the machine running the AppHost. For GoLand remote debugging, Delve (dlv) must also be on the PATH.

Install the package

In your AppHost project, install the Aspire Go library with NuGet:

dotnet add package Aspire.Hosting.Go

Usage example

In the AppHost.cs file of AppHost, add a Go application resource:

var builder = DistributedApplication.CreateBuilder(args);

var api = builder.AddGoApp("api", "../go-api")
    .WithHttpEndpoint(port: 8080)
    .WithExternalHttpEndpoints()
    .WithOtlpExporter();

builder.Build().Run();

The method executes the package as go run . from the directory containing go.mod. Pass runtime arguments via .WithAppArgs(...) and pre-start module commands via .WithModTidy(), .WithModVendor(), .WithModDownload(), or .WithVetTool().

Build flags

Build-time compiler options are parameters of AddGoApp itself:

builder.AddGoApp("api", "../go-api",
    buildTags: ["integration", "netgo"],
    ldFlags: "-X main.version=1.2.3 -s -w",
    gcFlags: "all=-N -l",
    raceDetector: true);

Pass runtime arguments to the program:

builder.AddGoApp("api", "../go-api")
    .WithAppArgs("--config", "prod.yaml");

Debugging

Delve is the only Go debugger — both VS Code and GoLand use it under the hood, just in different modes. Aspire.Hosting.Go supports both modes.

VS Code (automatic, default)

VS Code debugging is enabled automatically by AddGoApp. Install the Go extension and use the normal Aspire "Start Debugging" flow. The extension launches its own dlv-dap process; the application continues to run as go run . and no extra setup is required.

GoLand or VS Code attach mode (headless Delve server)

Use WithDelveServer when you need GoLand or a VS Code "attach to remote" configuration. The application is replaced by a headless Delve server:

builder.AddGoApp("api", "../go-api")
    .WithDelveServer(port: 2345)
    .WithHttpEndpoint(port: 8080);

This launches:

dlv --headless=true --listen=127.0.0.1:2345 --api-version=2 debug .

GoLand — create a Go Remote run/debug configuration (Edit | Run Configurations):

  • Host: localhost
  • Port: 2345

VS Code — add to launch.json:

{
  "name": "Attach to api",
  "type": "go",
  "request": "attach",
  "mode": "remote",
  "host": "localhost",
  "port": 2345
}

Start the debug configuration after the resource appears as running in the Aspire dashboard. See the JetBrains docs for details.

Additional documentation

Feedback & contributing

https://github.com/dotnet/aspire

Changes from Previous Version

No structural changes between v13.4.5-preview.1.26316.12 and v13.4.6-preview.1.26319.6.

Adoption Assessment

A verified publisher signal is available. Assess fit from the package's supported frameworks, license and dependency graph rather than popularity alone.

This version is marked prerelease. Validate its API and upgrade path before production use.Compatibility metadata lists 1 target framework; confirm the exact target used by your application.The published metadata declares 30 direct dependency entries across framework groups. Inspect the resolved dependency graph for your target framework.

Related Guides & Workflows

Learn how to evaluate, integrate, or audit this package in your .NET project.