I've got a program I maintain that uses a 3rd party module. That module has 
a bug in it, and I've raised a pull request to fix it.

But... I need to release a new version of my program as soon as possible.

My understanding was that I can use a replace directive in the go.mod file 
to replace the implementation. So I forked the repo, made my single commit 
change and put a one-liner in the go.mod file:

replace go.lsp.dev/protocol => github.com/a-h/protocol 
v0.0.0-20230222141054-e5a15864b7f1

Locally, building the project with `go build` worked perfectly well, so I 
tagged a release, and called it a day.

However, users started reporting that they can't install the package with 
`go install` because it's broken with an error message of:

go install github.com/a-h/templ/cmd/templ@latest
go: github.com/a-h/templ/cmd/templ@latest (in 
github.com/a-h/templ@v0.2.198):
        The go.mod file for the module providing named packages contains 
one or
        more replace directives. It must not contain directives that would 
cause
        it to be interpreted differently than if it were the main module.

It was a surprise, because it works perfectly well for me. Reading through 
various issues (linked below), I see lots of discussion, but no clear 
guidance on what to do as an author.

   - https://github.com/golang/go/issues/40276
   - https://groups.google.com/g/golang-nuts/c/10AJZaH9OFU/m/WobvkcB5BwAJ


I assume it's fairly common to need to patch a 3rd party dependency, so I 
must be missing something. What's the strategy to employ here?

-- 
You received this message because you are subscribed to the Google Groups 
"golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to golang-nuts+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/golang-nuts/ad57ea0e-9ef5-4c81-bbdf-8df6643ac6ebn%40googlegroups.com.

Reply via email to