go.mod replace: fallthrough

github logo ・1 min read

How do you use replace in go.mod when you want to replace a pkg that an imported pkg uses?

The Problem

Project uses Lib
Lib uses SubLib

Project
  Lib
    SubLib

You want to replace SubLib with a local version that you're working on to see the result in Project.

The Answer

Open go.mod in Project to use the replace directive.

// go.mod

require(
  github.com/example/lib
  // `lib` imports github.com/sublib/sublib
)

replace github.com/sublib/sublib => /local/dir/sublib

Profit!

May my hours of suffering help another.

twitter logo DISCUSS
Classic DEV Post from Feb 22

What are some Browser plugins that you can't live without ?

What are some of your essential browser extension/plugin that make your life easier ?

William Antonelli profile image