Platform

Resources

Community

Platform

Resources

Community

Dagger Go SDK 0.4: Multi-platform, improved filesystem API and more

November 6, 2022

Nov 6, 2022

None

Share
Share
Share
Share

As you might have seen, we released the Dagger Go SDK 0.3.0 early last week. Thanks to your many questions and suggestions, we were able to ship several additional improvements, which we are releasing today as the Dagger Go SDK 0.4.0.

Note that this version introduces a breaking API change. However, we believe the improved API allows you to write much shorter code, which is significantly better in the long run.

Get Started

Dagger Go SDK 0.4 Highlights:

Multi-platform pipelines

  • Dagger now supports pulling container images and executing commands on platforms that differ from the underlying host.

  • For example, you can use Dagger to compile binaries that target different CPU architectures, test those binaries and push them to a registry bundled as a multi-platform container image, all on a single host.

Learn more about Dagger’s multi-platform support

Improved filesystem API

  • Import any directory from the host filesystem with Host.Directory. This replaces the more cumbersome LocalDirs, Host.Workdir and HostDirectory.Read

  • Export any directory to the host filesystem with Directory.Export. This replaces HostDirectory.Write

  • Export any file to the host filesystem with Directory.Export

  • Export any container to an OCI archive on the host filesystem with Container.Export.

  • Host.Directory, Host.Workdir, and Directory.WithDirectory now support include:/exclude: params for filtering the set of files to select.

See more examples of working with the host filesystem

Less boilerplate

You no longer need to pass IDs, which makes the code you need to write much shorter. See the example below:

Before:

modules := c.Directory()
for _, f := range []string{"go.mod", "go.sum", "sdk/go/go.mod", "sdk/go/go.sum"} {
	fileID, err := workdir.File(f).ID(ctx)
	if err != nil {
		return err
	}

	modules = modules.WithCopiedFile(f, fileID)
}

After:

modules := c.Directory()
for _, f := range []string{"go.mod", "go.sum", "sdk/go/go.mod", "sdk/go/go.sum"} {
	modules = modules.WithCopiedFile(f, workdir.File(f))
}

Read the API documentation

New Documentation

Along with the new release, we’ve added four guides to our documentation that answer the most common questions we’ve heard in the days following the initial release. We hope these guides will help you make the most of the Go SDK.

  • Work with the Host Filesystem: This guide explains how to interact with the host filesystem using the Go SDK. It includes code examples of setting the working directory on the host, mounting a host directory in a container, exporting a directory from a container to the host, and more.

  • Understand Multi-Platform Support: This guide demonstrates different techniques to build applications for multiple platforms using the Go SDK. It includes code examples of building multi-platform applications using emulation and cross-compilation.

  • Copy Embedded Directories into a Container: This guide explains how to copy an entire directory tree from a host to a container.

  • Use Dagger with Private Git Repositories: You can use ssh-add to securely authenticate your Dagger Go CI pipeline against private Git repositories.This guide shows you how.

Thank you to the Dagger Community for your continuous and quick feedback through our Discord channel and GitHub issues. We look forward to releasing more features and documentation soon!

Are you looking for updates on a different SDK? Fill out this form, and we will notify you when your SDK is ready.

Do you have feedback on our documentation? Would you like to suggest a new guide? Send us your feedback and ideas in our Discord channel or open a new issue on GitHub.



As you might have seen, we released the Dagger Go SDK 0.3.0 early last week. Thanks to your many questions and suggestions, we were able to ship several additional improvements, which we are releasing today as the Dagger Go SDK 0.4.0.

Note that this version introduces a breaking API change. However, we believe the improved API allows you to write much shorter code, which is significantly better in the long run.

Get Started

Dagger Go SDK 0.4 Highlights:

Multi-platform pipelines

  • Dagger now supports pulling container images and executing commands on platforms that differ from the underlying host.

  • For example, you can use Dagger to compile binaries that target different CPU architectures, test those binaries and push them to a registry bundled as a multi-platform container image, all on a single host.

Learn more about Dagger’s multi-platform support

Improved filesystem API

  • Import any directory from the host filesystem with Host.Directory. This replaces the more cumbersome LocalDirs, Host.Workdir and HostDirectory.Read

  • Export any directory to the host filesystem with Directory.Export. This replaces HostDirectory.Write

  • Export any file to the host filesystem with Directory.Export

  • Export any container to an OCI archive on the host filesystem with Container.Export.

  • Host.Directory, Host.Workdir, and Directory.WithDirectory now support include:/exclude: params for filtering the set of files to select.

See more examples of working with the host filesystem

Less boilerplate

You no longer need to pass IDs, which makes the code you need to write much shorter. See the example below:

Before:

modules := c.Directory()
for _, f := range []string{"go.mod", "go.sum", "sdk/go/go.mod", "sdk/go/go.sum"} {
	fileID, err := workdir.File(f).ID(ctx)
	if err != nil {
		return err
	}

	modules = modules.WithCopiedFile(f, fileID)
}

After:

modules := c.Directory()
for _, f := range []string{"go.mod", "go.sum", "sdk/go/go.mod", "sdk/go/go.sum"} {
	modules = modules.WithCopiedFile(f, workdir.File(f))
}

Read the API documentation

New Documentation

Along with the new release, we’ve added four guides to our documentation that answer the most common questions we’ve heard in the days following the initial release. We hope these guides will help you make the most of the Go SDK.

  • Work with the Host Filesystem: This guide explains how to interact with the host filesystem using the Go SDK. It includes code examples of setting the working directory on the host, mounting a host directory in a container, exporting a directory from a container to the host, and more.

  • Understand Multi-Platform Support: This guide demonstrates different techniques to build applications for multiple platforms using the Go SDK. It includes code examples of building multi-platform applications using emulation and cross-compilation.

  • Copy Embedded Directories into a Container: This guide explains how to copy an entire directory tree from a host to a container.

  • Use Dagger with Private Git Repositories: You can use ssh-add to securely authenticate your Dagger Go CI pipeline against private Git repositories.This guide shows you how.

Thank you to the Dagger Community for your continuous and quick feedback through our Discord channel and GitHub issues. We look forward to releasing more features and documentation soon!

Are you looking for updates on a different SDK? Fill out this form, and we will notify you when your SDK is ready.

Do you have feedback on our documentation? Would you like to suggest a new guide? Send us your feedback and ideas in our Discord channel or open a new issue on GitHub.



As you might have seen, we released the Dagger Go SDK 0.3.0 early last week. Thanks to your many questions and suggestions, we were able to ship several additional improvements, which we are releasing today as the Dagger Go SDK 0.4.0.

Note that this version introduces a breaking API change. However, we believe the improved API allows you to write much shorter code, which is significantly better in the long run.

Get Started

Dagger Go SDK 0.4 Highlights:

Multi-platform pipelines

  • Dagger now supports pulling container images and executing commands on platforms that differ from the underlying host.

  • For example, you can use Dagger to compile binaries that target different CPU architectures, test those binaries and push them to a registry bundled as a multi-platform container image, all on a single host.

Learn more about Dagger’s multi-platform support

Improved filesystem API

  • Import any directory from the host filesystem with Host.Directory. This replaces the more cumbersome LocalDirs, Host.Workdir and HostDirectory.Read

  • Export any directory to the host filesystem with Directory.Export. This replaces HostDirectory.Write

  • Export any file to the host filesystem with Directory.Export

  • Export any container to an OCI archive on the host filesystem with Container.Export.

  • Host.Directory, Host.Workdir, and Directory.WithDirectory now support include:/exclude: params for filtering the set of files to select.

See more examples of working with the host filesystem

Less boilerplate

You no longer need to pass IDs, which makes the code you need to write much shorter. See the example below:

Before:

modules := c.Directory()
for _, f := range []string{"go.mod", "go.sum", "sdk/go/go.mod", "sdk/go/go.sum"} {
	fileID, err := workdir.File(f).ID(ctx)
	if err != nil {
		return err
	}

	modules = modules.WithCopiedFile(f, fileID)
}

After:

modules := c.Directory()
for _, f := range []string{"go.mod", "go.sum", "sdk/go/go.mod", "sdk/go/go.sum"} {
	modules = modules.WithCopiedFile(f, workdir.File(f))
}

Read the API documentation

New Documentation

Along with the new release, we’ve added four guides to our documentation that answer the most common questions we’ve heard in the days following the initial release. We hope these guides will help you make the most of the Go SDK.

  • Work with the Host Filesystem: This guide explains how to interact with the host filesystem using the Go SDK. It includes code examples of setting the working directory on the host, mounting a host directory in a container, exporting a directory from a container to the host, and more.

  • Understand Multi-Platform Support: This guide demonstrates different techniques to build applications for multiple platforms using the Go SDK. It includes code examples of building multi-platform applications using emulation and cross-compilation.

  • Copy Embedded Directories into a Container: This guide explains how to copy an entire directory tree from a host to a container.

  • Use Dagger with Private Git Repositories: You can use ssh-add to securely authenticate your Dagger Go CI pipeline against private Git repositories.This guide shows you how.

Thank you to the Dagger Community for your continuous and quick feedback through our Discord channel and GitHub issues. We look forward to releasing more features and documentation soon!

Are you looking for updates on a different SDK? Fill out this form, and we will notify you when your SDK is ready.

Do you have feedback on our documentation? Would you like to suggest a new guide? Send us your feedback and ideas in our Discord channel or open a new issue on GitHub.



Get Involved With the community

Discover what our community is doing, and join the conversation on Discord & GitHub to help shape the evolution of Dagger.

Subscribe to our newsletter

Get Involved With the community

Discover what our community is doing, and join the conversation on Discord & GitHub to help shape the evolution of Dagger.

Subscribe to our newsletter

Get Involved With the community

Discover what our community is doing, and join the conversation on Discord & GitHub to help shape the evolution of Dagger.

Subscribe to our newsletter