# How to Install the go-modern-guidelines CLI and Where It Is Cached Locally

> Learn how to install the go-modern-guidelines CLI using go install or IDE plugins and find its local cache location at XDG_CACHE_HOME go-modern-guidelines.

- Repository: [JetBrains/go-modern-guidelines](https://github.com/jetbrains/go-modern-guidelines)
- Tags: how-to-guide
- Published: 2026-08-30

---

**The go-modern-guidelines CLI is installed via standard `go install` commands or automatically by IDE plugin wrappers, with compiled binaries stored in a version-specific subdirectory under `$XDG_CACHE_HOME/go-modern-guidelines` (or `~/.cache/go-modern-guidelines` on most systems).**

The JetBrains/go-modern-guidelines repository provides a command-line tool for analyzing Go code against modern best practices. Understanding how the go-modern-guidelines CLI is installed and where it caches binaries locally ensures reliable usage across different environments, whether invoked manually by developers or automatically by marketplace plugins like Junie or Cursor.

## Installation Methods for the go-modern-guidelines CLI

The repository supports three distinct installation paths depending on whether you are an end user, a plugin consumer, or a contributor.

### Automatic Installation via Marketplace Plugins

When using the CLI through supported marketplace plugins (such as Junie, Claude Code, Codex, or Cursor), the [`plugin/skills/use-modern-go/scripts/run-tool.sh`](https://github.com/JetBrains/go-modern-guidelines/blob/main/plugin/skills/use-modern-go/scripts/run-tool.sh) wrapper script handles installation transparently. On first execution, the wrapper runs:

```bash
go install github.com/JetBrains/go-modern-guidelines@latest

```

This command fetches the source, compiles the binary, and places it in the local cache. Subsequent invocations reuse the cached binary without rebuilding, ensuring zero-configuration setup for IDE users.

### Manual Installation with go install

For developers who prefer direct control, install the CLI manually using the standard Go toolchain:

```bash
go install github.com/JetBrains/go-modern-guidelines@latest

```

This places the binary in your `$GOPATH/bin` or `$GOBIN` directory by default. However, when invoked through the official wrapper or plugin integrations, the tool specifically looks for the binary in the dedicated cache directory rather than the standard Go binary path.

### Developer Installation from Source

Contributors working on the repository can compile the current checkout and install it directly into the cache directory using the provided Make target:

```bash
make dev-install

```

This executes the [`scripts/dev-install.sh`](https://github.com/JetBrains/go-modern-guidelines/blob/main/scripts/dev-install.sh) helper script, which builds the binary from the current working tree and copies it into the version-specific cache subdirectory. This approach bypasses the remote fetch step and allows immediate testing of local changes to [`main.go`](https://github.com/JetBrains/go-modern-guidelines/blob/main/main.go) or [`internal/cli/cli.go`](https://github.com/JetBrains/go-modern-guidelines/blob/main/internal/cli/cli.go).

## Where the go-modern-guidelines CLI Is Cached Locally

The CLI employs a deterministic caching strategy to avoid redundant compilation and network requests.

### Cache Directory Resolution

The binary is stored under the user-specific cache root defined by the environment variable `$XDG_CACHE_HOME`. If this variable is unset, the fallback location is:

```text
~/.cache/go-modern-guidelines

```

This path is documented in both the repository README and the developer installation scripts.

### Version-Specific Binary Storage

Inside the cache root, the binary resides in a version-specific subdirectory following the pattern:

```text
$XDG_CACHE_HOME/go-modern-guidelines/v1.0.0/go-modern-guidelines

```

The wrapper script creates this directory structure automatically and records the installed version. When you invoke `go-modern-guidelines list` or `go-modern-guidelines explain 123`, the wrapper checks this location first. If the expected version is present, it executes the cached binary immediately; otherwise, it triggers a fresh `go install` to populate the cache.

## Core Source Files Governing Installation Behavior

Several key files in the JetBrains/go-modern-guidelines repository define the installation and caching logic:

- **[`main.go`](https://github.com/JetBrains/go-modern-guidelines/blob/main/main.go)** — The entry point that forwards `os.Args` to the CLI library.
- **[`internal/cli/cli.go`](https://github.com/JetBrains/go-modern-guidelines/blob/main/internal/cli/cli.go)** — Implements command parsing for subcommands like `list`, `explain`, and `--version`.
- **[`scripts/dev-install.sh`](https://github.com/JetBrains/go-modern-guidelines/blob/main/scripts/dev-install.sh)** — Automates local builds and cache population for developers.
- **[`plugin/skills/use-modern-go/scripts/run-tool.sh`](https://github.com/JetBrains/go-modern-guidelines/blob/main/plugin/skills/use-modern-go/scripts/run-tool.sh)** — The production wrapper that manages automatic installation and cache validation for marketplace plugins.

## Summary

- The **go-modern-guidelines CLI** supports automatic installation via IDE plugin wrappers, manual installation via `go install`, and local development builds via `make dev-install`.
- Binaries are cached in `$XDG_CACHE_HOME/go-modern-guidelines` or `~/.cache/go-modern-guidelines` if the XDG variable is unset.
- The cache uses **version-specific subdirectories** (e.g., `v1.0.0/`) to support multiple installed versions simultaneously.
- The **[`run-tool.sh`](https://github.com/JetBrains/go-modern-guidelines/blob/main/run-tool.sh)** wrapper ensures the correct binary is available before executing commands like `list` or `explain`.

## Frequently Asked Questions

### How do I manually install the go-modern-guidelines CLI?

Run `go install github.com/JetBrains/go-modern-guidelines@latest` to fetch and compile the latest release. This places the binary in your Go bin directory, though plugin integrations typically relocate or reference the binary from the dedicated cache directory instead.

### What environment variable controls the cache location?

The CLI respects `$XDG_CACHE_HOME`. When this variable is not defined, it defaults to `~/.cache/go-modern-guidelines` on Unix-like systems. This follows the XDG Base Directory Specification for user-specific cached data.

### How does the CLI handle updates when a new version is released?

The wrapper script checks the version tag in the cache directory against the requested version (typically `@latest`). If the cached binary is missing or outdated, the script automatically re-runs `go install` to fetch the new version and stores it in a fresh subdirectory (e.g., `v1.0.1/`), leaving previous versions intact.

### Can I run the CLI without installing it via go install?

Yes. You can clone the repository and execute `go run .` from the root directory, or use `make dev-install` to build the binary into the cache without using the remote `go install` command. This is useful when testing modifications to [`internal/cli/cli.go`](https://github.com/JetBrains/go-modern-guidelines/blob/main/internal/cli/cli.go) or the argument parsing logic.