You won't be able to avoid editing the go.mod - it's the starting point for all module resolution.
How about taking a copy of the original go.{mod,sum} and restoring them, or using git checkout . to trash unstaged changes? On Tue, 6 Aug 2019, 07:26 Peter Feichtinger, <shi...@gmx.at> wrote: > Thanks for that, this will come in handy for editing the go.mod file. > But I'd like to avoid editing the file at all. > > > On Monday, August 5, 2019 at 7:16:08 PM UTC+2, Paul Jolly wrote: >> >> Take a look at go mod edit >> >> https://golang.org/cmd/go/#hdr-Module_maintenance >> >> >> >> On Mon, 5 Aug 2019, 18:45 Peter Feichtinger, <shi...@gmx.at> wrote: >> >>> Hi Go Nuts, >>> >>> I have a rather unusual use case and I'm hoping for some input. >>> >>> For testing purposes, I want to build a Go binary with different >>> versions of one of its dependencies. The only way I could think of was to >>> modify the go.mod file to add a replace directive with the version I >>> want to test. >>> Instead I'd like to avoid having to modify the go.mod file during the >>> build and specify the replacement on the command line instead, but I don't >>> think that's possible. >>> >>> Do you guys have any ideas on how else I might accomplish overriding a >>> module version during build? >>> >>> -- Peter >>> >>> -- >>> 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 golan...@googlegroups.com. >>> To view this discussion on the web visit >>> https://groups.google.com/d/msgid/golang-nuts/efc91729-47a6-4dcb-a08d-6c907b24bd56%40googlegroups.com >>> <https://groups.google.com/d/msgid/golang-nuts/efc91729-47a6-4dcb-a08d-6c907b24bd56%40googlegroups.com?utm_medium=email&utm_source=footer> >>> . >>> >> -- > 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/6ced2780-eca5-4692-a7f6-c0c73ad5b966%40googlegroups.com > <https://groups.google.com/d/msgid/golang-nuts/6ced2780-eca5-4692-a7f6-c0c73ad5b966%40googlegroups.com?utm_medium=email&utm_source=footer> > . > -- 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/CACoUkn7ELJawV7SVzba%3DZNrwSC7QXfekB-VDC6yPf-3TOyubLA%40mail.gmail.com.