# Go: go: updates to go.mod needed; to update it: go mod tidy

**Code:** `go: updates to go.mod needed` · **Category:** Go · **Seen on:** Go

`go.mod` is out of sync with the imports in your code, and Go is running with `-mod=readonly` (the default).

## Meaning

Run `go mod tidy` to add missing requirements and drop unused ones, then commit `go.mod` and `go.sum`. In CI use `go mod tidy && git diff --exit-code` to enforce it. The same message appears when a required Go version in go.mod is newer than your toolchain.

## Common causes

- Imports added without `go get`
- go.mod edited by hand
- Dependency upgraded in another branch
- go.mod `go` directive newer than installed Go
- Vendor mode mismatch

## Quick fix

1. `go mod tidy` and commit both files
2. Upgrade the Go toolchain when `go.mod` requires a newer version
3. Use `go mod vendor` only if you use `-mod=vendor`

## Detailed fix by platform

### Go

1. `go mod tidy && go mod verify`

## How to diagnose

1. **Imports** — New since go.mod last tidied?
2. **Version** — go directive vs toolchain?
3. **Files** — go.sum committed?

---
Source: [WhatIsMyError](https://whatismyerror.com/errors/go/go-updates-to-go-mod-needed)
