File tree 2 files changed +20
-0
lines changed
2 files changed +20
-0
lines changed Original file line number Diff line number Diff line change @@ -334,6 +334,20 @@ The `replace` directive can be useful in situations such as the following:
334
334
* You've identified an issue with a dependency, have cloned the dependency's
335
335
repository, and you're testing a fix with the local repository.
336
336
337
+ Note that a `replace` directive alone does not does not add a module to the
338
+ [module graph](/ref/mod#glos-module-graph). A [`require` directive](#require)
339
+ that refers to a replaced module version is also needed, either in the main
340
+ module's `go.mod` file or a dependency's `go.mod` file. If you don't have a
341
+ specific version to replace, you can use a fake version, as in the example
342
+ below. Note that this will break modules that depend on your module, since
343
+ `replace` directives are only applied in the main module.
344
+
345
+ ```
346
+ require example.com/mod v0.0.0-replace
347
+
348
+ replace example.com/mod v0.0.0-replace => ./mod
349
+ ```
350
+
337
351
For more on replacing a required module, including using Go tools to make the
338
352
change, see:
339
353
Original file line number Diff line number Diff line change @@ -675,6 +675,12 @@ must match the module path it replaces.
675
675
and are ignored in other modules. See [ Minimal version
676
676
selection] ( #minimal-version-selection ) for details.
677
677
678
+ Note that a ` replace ` directive alone does not add a module to the [ module
679
+ graph] ( #glos-module-graph ) . A [ ` require ` directive] ( #go-mod-file-require ) that
680
+ refers to a replaced module version is also needed, either in the main module's
681
+ ` go.mod ` file or a dependency's ` go.mod ` file. A ` replace ` directive has no
682
+ effect if the module version on the left side is not required.
683
+
678
684
```
679
685
ReplaceDirective = "replace" ( ReplaceSpec | "(" newline { ReplaceSpec } ")" newline ) .
680
686
ReplaceSpec = ModulePath [ Version ] "=>" FilePath newline
You can’t perform that action at this time.
0 commit comments