Help us shape the future of Go! Take the 2026 Go Developer Survey

vscode

package
v0.2.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 25, 2026 License: MIT Imports: 12 Imported by: 0

Documentation

Overview

Package vscode resolves and downloads the VS Code Server tarball that matches a given platform. The result is staged on disk so it can be COPY'd into the build context and unpacked at the canonical location VS Code expects (~/.vscode-server/bin/<commit>/).

Background: when VS Code's "Remote - Containers" extension attaches to a container, it tries to download and extract its server bin into ~/.vscode-server/bin/<commit>/. Pre-injecting that directory at build time makes the first-attach experience instant and works in offline environments.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CanonicalInstallDir

func CanonicalInstallDir(user, commit string) string

CanonicalInstallDir returns the path inside a container where VS Code expects its server binary to live for a given user.

Example: CanonicalInstallDir("vscode", "abc123") =>

"/home/vscode/.vscode-server/bin/abc123"

For root, the path is /root/.vscode-server/...

func DownloadURL

func DownloadURL(quality Quality, arch, commit string, alpine bool) string

DownloadURL builds the official VS Code update URL for a given commit.

Pattern: https://update.code.visualstudio.com/commit:<commit>/server-linux-<arch>[-alpine]/<quality>

Types

type Downloader

type Downloader struct {
	HTTP   *http.Client
	Logger func(format string, args ...any)
}

Downloader resolves and fetches VS Code server tarballs.

func NewDownloader

func NewDownloader() *Downloader

NewDownloader constructs a Downloader with sane defaults.

func (*Downloader) Fetch

func (d *Downloader) Fetch(ctx context.Context, spec Spec, stagingDir string) (*Result, error)

Fetch downloads the server tarball for the given Spec into stagingDir. The returned Result contains the on-disk path plus metadata.

type Quality

type Quality string

Quality is "stable" or "insider".

const (
	QualityStable  Quality = "stable"
	QualityInsider Quality = "insider"
)

type Result

type Result struct {
	// TarballPath is the path to the downloaded tarball on disk.
	TarballPath string
	// Commit is the resolved commit hash used in the canonical install
	// path (~/.vscode-server/bin/<Commit>/).
	Commit string
	// Quality is the resolved quality channel.
	Quality Quality
	// SHA256 is the hex digest of the tarball contents.
	SHA256 string
	// Bytes is the size of the tarball.
	Bytes int64
	// URL is the source URL that was used.
	URL string
}

Result describes a staged VS Code server download.

type ServerKind

type ServerKind string

ServerKind selects between vanilla VS Code Server and the open-source VSCodium-style "code-server" build. We default to VS Code Server since the devcontainer experience is most commonly used with VS Code.

const (
	KindVSCodeServer ServerKind = "vscode-server"
)

type Spec

type Spec struct {
	Quality  Quality
	Kind     ServerKind
	Platform platform.Platform
	// Commit, when non-empty, pins the download. When empty, the latest
	// is queried from the update API.
	Commit string
	// AlpineLibc selects musl-libc-compatible binaries.
	AlpineLibc bool
}

Spec describes the server variant to download.

func DefaultSpec

func DefaultSpec() Spec

DefaultSpec returns a sane default spec for the current platform.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL