Skip to content

Commit 5e88805

Browse files
authored
Merge pull request #71 from CommunityToolkit/issue43
Golang Integration
2 parents 8c54eea + e620836 commit 5e88805

File tree

24 files changed

+895
-1
lines changed

24 files changed

+895
-1
lines changed

.devcontainer/devcontainer.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,8 @@
1313
},
1414
"ghcr.io/devcontainers/features/docker-in-docker": {},
1515
"ghcr.io/devcontainers/features/node:latest": {},
16-
"ghcr.io/devcontainers/features/python:latest": {}
16+
"ghcr.io/devcontainers/features/python:latest": {},
17+
"ghcr.io/devcontainers/features/go:latest": {}
1718
},
1819

1920
"customizations": {

.github/workflows/dotnet-ci.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,10 @@ jobs:
3030
dotnet-version: |
3131
8.0.x
3232
9.0.x
33+
- uses: actions/setup-go@v5
34+
name: Set up Go
35+
with:
36+
go-version: '^1.22.1'
3337
- uses: actions/setup-java@v4
3438
name: Set up Java
3539
with:

.github/workflows/dotnet-main.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,10 @@ jobs:
3030
dotnet-version: |
3131
8.0.x
3232
9.0.x
33+
- uses: actions/setup-go@v5
34+
name: Set up Go
35+
with:
36+
go-version: '^1.22.1'
3337
- uses: actions/setup-java@v4
3438
name: Set up Java
3539
with:

.github/workflows/dotnet-release.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,10 @@ jobs:
3434
dotnet-version: |
3535
${{ env.DEFAULT_DOTNET_VERSION }}
3636
9.0.x
37+
- uses: actions/setup-go@v5
38+
name: Set up Go
39+
with:
40+
go-version: '^1.22.1'
3741
- uses: actions/setup-java@v4
3842
name: Set up Java
3943
with:

Aspire.CommunityToolkit.sln

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,15 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Aspire.CommunityToolkit.Hos
5757
EndProject
5858
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Aspire.CommunityToolkit.Hosting.Ollama.Web", "examples\ollama\Aspire.CommunityToolkit.Hosting.Ollama.Web\Aspire.CommunityToolkit.Hosting.Ollama.Web.csproj", "{0A17021E-5F10-429B-88C8-E4073EADACB6}"
5959
EndProject
60+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Aspire.CommunityToolkit.Hosting.Golang", "src\Aspire.CommunityToolkit.Hosting.Golang\Aspire.CommunityToolkit.Hosting.Golang.csproj", "{93789F1B-0539-49B5-A585-9F6EF9E88264}"
61+
EndProject
62+
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "golang", "golang", "{03950661-2B1F-48F4-91D2-1E6395B710C2}"
63+
EndProject
64+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Aspire.CommunityToolkit.Hosting.Golang.AppHost", "examples\golang\Aspire.CommunityToolkit.Hosting.Golang.AppHost\Aspire.CommunityToolkit.Hosting.Golang.AppHost.csproj", "{3A03552A-252D-4E86-A8D7-135579AAEB85}"
65+
EndProject
66+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Aspire.CommunityToolkit.Hosting.Golang.ServiceDefaults", "examples\golang\Aspire.CommunityToolkit.Hosting.Golang.ServiceDefaults\Aspire.CommunityToolkit.Hosting.Golang.ServiceDefaults.csproj", "{C60BCC90-BAEE-4678-ACC9-11553AA64249}"
67+
EndProject
68+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Aspire.CommunityToolkit.Hosting.Golang.Tests", "tests\Aspire.CommunityToolkit.Hosting.Golang.Tests\Aspire.CommunityToolkit.Hosting.Golang.Tests.csproj", "{0294714B-A1CC-4F8E-8935-315B3499638F}"
6069
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Aspire.CommunityToolkit.OllamaSharp", "src\Aspire.CommunityToolkit.OllamaSharp\Aspire.CommunityToolkit.OllamaSharp.csproj", "{22D81BC2-2659-483A-B7AC-8FCA086A99A7}"
6170
EndProject
6271
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Aspire.CommunityToolkit.OllamaSharp.Tests", "tests\Aspire.CommunityToolkit.OllamaSharp.Tests\Aspire.CommunityToolkit.OllamaSharp.Tests.csproj", "{B170B19B-3FFA-4F71-AF12-A1E3955A0F8E}"
@@ -147,6 +156,22 @@ Global
147156
{0A17021E-5F10-429B-88C8-E4073EADACB6}.Debug|Any CPU.Build.0 = Debug|Any CPU
148157
{0A17021E-5F10-429B-88C8-E4073EADACB6}.Release|Any CPU.ActiveCfg = Release|Any CPU
149158
{0A17021E-5F10-429B-88C8-E4073EADACB6}.Release|Any CPU.Build.0 = Release|Any CPU
159+
{93789F1B-0539-49B5-A585-9F6EF9E88264}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
160+
{93789F1B-0539-49B5-A585-9F6EF9E88264}.Debug|Any CPU.Build.0 = Debug|Any CPU
161+
{93789F1B-0539-49B5-A585-9F6EF9E88264}.Release|Any CPU.ActiveCfg = Release|Any CPU
162+
{93789F1B-0539-49B5-A585-9F6EF9E88264}.Release|Any CPU.Build.0 = Release|Any CPU
163+
{3A03552A-252D-4E86-A8D7-135579AAEB85}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
164+
{3A03552A-252D-4E86-A8D7-135579AAEB85}.Debug|Any CPU.Build.0 = Debug|Any CPU
165+
{3A03552A-252D-4E86-A8D7-135579AAEB85}.Release|Any CPU.ActiveCfg = Release|Any CPU
166+
{3A03552A-252D-4E86-A8D7-135579AAEB85}.Release|Any CPU.Build.0 = Release|Any CPU
167+
{C60BCC90-BAEE-4678-ACC9-11553AA64249}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
168+
{C60BCC90-BAEE-4678-ACC9-11553AA64249}.Debug|Any CPU.Build.0 = Debug|Any CPU
169+
{C60BCC90-BAEE-4678-ACC9-11553AA64249}.Release|Any CPU.ActiveCfg = Release|Any CPU
170+
{C60BCC90-BAEE-4678-ACC9-11553AA64249}.Release|Any CPU.Build.0 = Release|Any CPU
171+
{0294714B-A1CC-4F8E-8935-315B3499638F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
172+
{0294714B-A1CC-4F8E-8935-315B3499638F}.Debug|Any CPU.Build.0 = Debug|Any CPU
173+
{0294714B-A1CC-4F8E-8935-315B3499638F}.Release|Any CPU.ActiveCfg = Release|Any CPU
174+
{0294714B-A1CC-4F8E-8935-315B3499638F}.Release|Any CPU.Build.0 = Release|Any CPU
150175
{22D81BC2-2659-483A-B7AC-8FCA086A99A7}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
151176
{22D81BC2-2659-483A-B7AC-8FCA086A99A7}.Debug|Any CPU.Build.0 = Debug|Any CPU
152177
{22D81BC2-2659-483A-B7AC-8FCA086A99A7}.Release|Any CPU.ActiveCfg = Release|Any CPU
@@ -184,6 +209,11 @@ Global
184209
{F4602DC8-3C17-4834-B640-9A3B27FE278A} = {14BD8AE7-C8DF-4C7C-8244-7F74C101569D}
185210
{2F037600-2002-4A13-9359-98FB0D2416BE} = {14BD8AE7-C8DF-4C7C-8244-7F74C101569D}
186211
{0A17021E-5F10-429B-88C8-E4073EADACB6} = {14BD8AE7-C8DF-4C7C-8244-7F74C101569D}
212+
{93789F1B-0539-49B5-A585-9F6EF9E88264} = {414151D4-7009-4E78-A5C6-D99EBD1E67D1}
213+
{03950661-2B1F-48F4-91D2-1E6395B710C2} = {8519CC01-1370-47C8-AD94-B0F326B1563F}
214+
{3A03552A-252D-4E86-A8D7-135579AAEB85} = {03950661-2B1F-48F4-91D2-1E6395B710C2}
215+
{C60BCC90-BAEE-4678-ACC9-11553AA64249} = {03950661-2B1F-48F4-91D2-1E6395B710C2}
216+
{0294714B-A1CC-4F8E-8935-315B3499638F} = {899F0713-7FC6-4750-BAFC-AC650B35B453}
187217
{22D81BC2-2659-483A-B7AC-8FCA086A99A7} = {414151D4-7009-4E78-A5C6-D99EBD1E67D1}
188218
{B170B19B-3FFA-4F71-AF12-A1E3955A0F8E} = {899F0713-7FC6-4750-BAFC-AC650B35B453}
189219
EndGlobalSection

docs/integrations/hosting-golang.md

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
# CommunityToolkit.Hosting.Golang
2+
3+
## Overview
4+
5+
This is a .NET Aspire Integration for [Go](https://go.dev/) applications.
6+
7+
## Usage
8+
9+
```csharp
10+
var builder = DistributedApplication.CreateBuilder(args);
11+
12+
var golang = builder.AddGolangApp("golang", "../gin-api");
13+
14+
builder.Build().Run();
15+
```
16+
17+
### Configuration
18+
- `name`- The name of the resource.
19+
- `workingDirectory`- The working directory to use for the command. If null, the working directory of the current process is used.
20+
- `port`- This is the port that will be given to other resource to communicate with this resource. Deafults to `8080`.
21+
- `args`- The optinal arguments to be passed to the executable when it is started.
22+
23+
### OpenTelemetry Configuration
24+
25+
In the [example](../../examples/golang/) folder, you can find an example of how to configure OpenTelemetry in the Go application to use the Aspire dashboard.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
<Project Sdk="Microsoft.NET.Sdk">
2+
3+
<PropertyGroup>
4+
<OutputType>Exe</OutputType>
5+
<TargetFramework>net8.0</TargetFramework>
6+
<ImplicitUsings>enable</ImplicitUsings>
7+
<Nullable>enable</Nullable>
8+
<IsAspireHost>true</IsAspireHost>
9+
<UserSecretsId>5a6548a5-b5dd-40f0-876a-9e3d4ac91fd1</UserSecretsId>
10+
</PropertyGroup>
11+
12+
<ItemGroup>
13+
<PackageReference Include="Aspire.Hosting.AppHost" />
14+
</ItemGroup>
15+
16+
<ItemGroup>
17+
<ProjectReference Include="..\..\..\src\Aspire.CommunityToolkit.Hosting.Golang\Aspire.CommunityToolkit.Hosting.Golang.csproj" IsAspireProjectResource="false" />
18+
</ItemGroup>
19+
20+
</Project>
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
var builder = DistributedApplication.CreateBuilder(args);
2+
3+
var golang = builder.AddGolangApp("golang", "../gin-api");
4+
5+
builder.Build().Run();
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
{
2+
"$schema": "https://json.schemastore.org/launchsettings.json",
3+
"profiles": {
4+
"https": {
5+
"commandName": "Project",
6+
"dotnetRunMessages": true,
7+
"launchBrowser": true,
8+
"applicationUrl": "https://localhost:17247;http://localhost:15071",
9+
"environmentVariables": {
10+
"ASPNETCORE_ENVIRONMENT": "Development",
11+
"DOTNET_ENVIRONMENT": "Development",
12+
"DOTNET_DASHBOARD_OTLP_ENDPOINT_URL": "https://localhost:21120",
13+
"DOTNET_RESOURCE_SERVICE_ENDPOINT_URL": "https://localhost:22298"
14+
}
15+
},
16+
"http": {
17+
"commandName": "Project",
18+
"dotnetRunMessages": true,
19+
"launchBrowser": true,
20+
"applicationUrl": "http://localhost:15071",
21+
"environmentVariables": {
22+
"ASPNETCORE_ENVIRONMENT": "Development",
23+
"DOTNET_ENVIRONMENT": "Development",
24+
"DOTNET_DASHBOARD_OTLP_ENDPOINT_URL": "http://localhost:19155",
25+
"DOTNET_RESOURCE_SERVICE_ENDPOINT_URL": "http://localhost:20207"
26+
}
27+
}
28+
}
29+
}
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
{
2+
"Logging": {
3+
"LogLevel": {
4+
"Default": "Information",
5+
"Microsoft.AspNetCore": "Warning",
6+
"Aspire.Hosting.Dcp": "Warning"
7+
}
8+
}
9+
}

0 commit comments

Comments
 (0)