与修改后的供应商一起使用模块和依赖项

I am trying to convert one Go project to the new modules standard, but I am having trouble with one dependency.

That repository has vendored a library (in this case golang.org/x/net/html) to add some functionality to the library; meaning that it has modified the vendored dependency (added a method to a struct).

So the problem is that after doing go mod init, when i execute go get ./... the system complains about a call to that added functionality, because it ignores the modified vendor and tries to import the upstream library instead.

Is there any way to let go mod know that it should use the vendored dependency?

You can try replace directive. Something along the lines of

First

cd ./vendor/golang.org/x/net/html
go mod init

Then in your root go.mod

module your/super/module

replace golang.org/x/net/html => ./vendor/golang.org/x/net/html

require golang.org/x/net/html v0.0.0

Note that both require and replace are required.