# GolangAppHostingExtension Methods

- Package: [CommunityToolkit.Aspire.Hosting.Golang](/reference/api/csharp/communitytoolkit.aspire.hosting.golang.md)
- Type: [GolangAppHostingExtension](/reference/api/csharp/communitytoolkit.aspire.hosting.golang/golangapphostingextension.md)
- Kind: `Methods`
- Members: `3`

Provides extension methods for adding Golang applications to an `Hosting.IDistributedApplicationBuilder`.

## AddGolangApp(IDistributedApplicationBuilder, string, string, string[])

> **Obsolete:** Use AddGolangApp with buildTags parameter instead. This method will be removed in a future version.

- Name: `AddGolangApp(IDistributedApplicationBuilder, string, string, string[])`
- Modifiers: `extension`
- Returns: `IResourceBuilder<GolangAppExecutableResource>`
- Source: [GitHub](https://github.com/CommunityToolkit/Aspire/blob/67afcca30f02c18687f9c5219313710af9706630/src/CommunityToolkit.Aspire.Hosting.Golang/GolangAppHostingExtension.cs#L26)

Adds a Golang application to the application model. Executes the executable Golang app.

```csharp
public static class GolangAppHostingExtension
{
    public static IResourceBuilder<GolangAppExecutableResource> AddGolangApp(
        this IDistributedApplicationBuilder builder,
        string name,
        string workingDirectory,
        string[] args)
    {
        // ...
    }
}
```

## Parameters

- `builder` (`IDistributedApplicationBuilder`)
  The `Hosting.IDistributedApplicationBuilder` to add the resource to.
- `name` (`string`)
  The name of the resource.
- `workingDirectory` (`string`)
  The working directory to use for the command. If null, the working directory of the current process is used.
- `args` (`string[]`)
  The optional arguments to be passed to the executable when it is started.

## Returns

`IResourceBuilder<GolangAppExecutableResource>` -- A reference to the `ApplicationModel.IResourceBuilder`1`.

## AddGolangApp(IDistributedApplicationBuilder, string, string, string[]?, string[]?)

- Name: `AddGolangApp(IDistributedApplicationBuilder, string, string, string[]?, string[]?)`
- Modifiers: `extension`
- Returns: `IResourceBuilder<GolangAppExecutableResource>`
- Source: [GitHub](https://github.com/CommunityToolkit/Aspire/blob/67afcca30f02c18687f9c5219313710af9706630/src/CommunityToolkit.Aspire.Hosting.Golang/GolangAppHostingExtension.cs#L38)

Adds a Golang application to the application model. Executes the executable Golang app.

```csharp
public static class GolangAppHostingExtension
{
    public static IResourceBuilder<GolangAppExecutableResource> AddGolangApp(
        this IDistributedApplicationBuilder builder,
        string name,
        string workingDirectory,
        string[]? args = null,
        string[]? buildTags = null)
    {
        // ...
    }
}
```

## Parameters

- `builder` (`IDistributedApplicationBuilder`)
  The `Hosting.IDistributedApplicationBuilder` to add the resource to.
- `name` (`string`)
  The name of the resource.
- `workingDirectory` (`string`)
  The working directory to use for the command. If null, the working directory of the current process is used.
- `args` (`string[]?`) `optional`
  The optional arguments to be passed to the executable when it is started.
- `buildTags` (`string[]?`) `optional`
  The optional build tags to be used when building the Golang application.

## Returns

`IResourceBuilder<GolangAppExecutableResource>` -- A reference to the `ApplicationModel.IResourceBuilder`1`.

## AddGolangApp(IDistributedApplicationBuilder, string, string, string, string[]?, string[]?)

- Name: `AddGolangApp(IDistributedApplicationBuilder, string, string, string, string[]?, string[]?)`
- Modifiers: `extension`
- Returns: `IResourceBuilder<GolangAppExecutableResource>`
- Source: [GitHub](https://github.com/CommunityToolkit/Aspire/blob/67afcca30f02c18687f9c5219313710af9706630/src/CommunityToolkit.Aspire.Hosting.Golang/GolangAppHostingExtension.cs#L52-L77)

Adds a Golang application to the application model. Executes the executable Golang app.

```csharp
public static class GolangAppHostingExtension
{
    public static IResourceBuilder<GolangAppExecutableResource> AddGolangApp(
        this IDistributedApplicationBuilder builder,
        string name,
        string workingDirectory,
        string executable,
        string[]? args = null,
        string[]? buildTags = null)
    {
        // ...
    }
}
```

## Parameters

- `builder` (`IDistributedApplicationBuilder`)
  The `Hosting.IDistributedApplicationBuilder` to add the resource to.
- `name` (`string`)
  The name of the resource.
- `workingDirectory` (`string`)
  The working directory to use for the command. If null, the working directory of the current process is used.
- `executable` (`string`)
  The path to the Golang package directory or source file to be executed. Use "." to execute the program in the current directory. For example, "./cmd/server".
- `args` (`string[]?`) `optional`
  The optional arguments to be passed to the executable when it is started.
- `buildTags` (`string[]?`) `optional`
  The optional build tags to be used when building the Golang application.

## Returns

`IResourceBuilder<GolangAppExecutableResource>` -- A reference to the `ApplicationModel.IResourceBuilder`1`.
