Module Not Found

cannot find module providing package github.com/foo/bar

Quick Answer

The module is not in your go.mod file. Run go get github.com/foo/bar to add the dependency.

Why This Happens

Go modules require all dependencies to be listed in go.mod. If you import a package that is not in go.mod, the compiler cannot find it. Run go get to download the module and add it to your go.mod and go.sum files.

The Problem

// go.mod does not include the dependency
import "github.com/gorilla/mux" // module not found

The Fix

// Run: go get github.com/gorilla/mux
import "github.com/gorilla/mux" // now works

Step-by-Step Fix

  1. 1

    Identify the missing module

    Read the error to find the exact module path that cannot be found.

  2. 2

    Add the dependency

    Run go get github.com/foo/bar to download and add it to go.mod.

  3. 3

    Verify with go mod tidy

    Run go mod tidy to clean up and verify all dependencies are correct.

Bugsly catches this automatically

Bugsly's AI analyzes this error pattern in real-time, explains what went wrong in plain English, and suggests the exact fix — before your users even report it.

Try Bugsly free