Skip to main content

go CLI reference

ModularPipelines.Go provides strongly typed access to the go CLI.

Executable prerequisite​

This package does not install the go executable. Install it separately and ensure go is available on PATH.

Follow the executable's official documentation for installation instructions.

Package installation​

dotnet add package ModularPipelines.Go

Resolve the service with context.Tools.Go. Projects using C# 13 or another .NET language can use context.Tools.Get<ModularPipelines.Go.Services.IGo>() instead.

Module example​

using ModularPipelines;
using ModularPipelines.Go.Options;

public class RunCommandModule : Module<CommandResult>
{
protected override async Task<CommandResult> ExecuteAsync(
IModuleContext context,
CancellationToken cancellationToken)
{
return await context.Tools.Go.VetAsync(
new GoVetOptions(),
cancellationToken: cancellationToken);
}
}

Global options​

Global options are rendered before the selected subcommand.

CLI optionPropertyAvailabilityDescription
-CWorkingDirectoryAll editionsChange to dir before running the command. Any files named on the command line are interpreted after changing directories. If used, this flag must be the first one in the command line.

Commands​

CLI commandOptions record
go bugGoBugOptions
go buildGoBuildOptions
go cleanGoCleanOptions
go docGoDocOptions
go envGoEnvOptions
go fixGoFixOptions
go fmtGoFmtOptions
go generateGoGenerateOptions
go getGoGetOptions
go installGoInstallOptions
go listGoListOptions
go modGoModOptions
go mod downloadGoModDownloadOptions
go mod editGoModEditOptions
go mod graphGoModGraphOptions
go mod initGoModInitOptions
go mod tidyGoModTidyOptions
go mod vendorGoModVendorOptions
go mod verifyGoModVerifyOptions
go mod whyGoModWhyOptions
go runGoRunOptions
go telemetryGoTelemetryOptions
go testGoTestOptions
go toolGoToolOptions
go versionGoVersionOptions
go vetGoVetOptions
go workGoWorkOptions
go work editGoWorkEditOptions
go work initGoWorkInitOptions
go work syncGoWorkSyncOptions
go work useGoWorkUseOptions
go work vendorGoWorkVendorOptions