From 47b2965bc226d6a5cdcc079791eed9f848f03e08 Mon Sep 17 00:00:00 2001 From: Julien Bisconti Date: Sat, 16 May 2026 21:53:20 +0200 Subject: [PATCH 1/2] Fix v2 main.go import to use v2 library path main.go imported "github.com/campoy/embedmd/embedmd" (v1 path) while go.mod declared the module as github.com/campoy/embedmd/v2. As a result, the v2.0.0 binary executes the v1 library code, and any consumer that adds embedmd v2 as a Go tool pulls in both module versions transitively. Switch the import to "github.com/campoy/embedmd/v2/embedmd" so the v2 binary uses its own library copy. main.go's three Process call sites are updated to pass context.Background() to match the v2 Process signature added in this branch. Fixes #90. --- main.go | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/main.go b/main.go index bdbe8d4..a8a8810 100644 --- a/main.go +++ b/main.go @@ -34,6 +34,7 @@ package main import ( "bytes" + "context" "flag" "fmt" "io" @@ -41,7 +42,7 @@ import ( "os" "path/filepath" - "github.com/campoy/embedmd/embedmd" + "github.com/campoy/embedmd/v2/embedmd" "github.com/pmezard/go-difflib/difflib" ) @@ -90,11 +91,11 @@ func embed(paths []string, rewrite, doDiff bool) (foundDiff bool, err error) { return false, fmt.Errorf("error: cannot use -w with standard input") } if !doDiff { - return false, embedmd.Process(stdout, stdin) + return false, embedmd.Process(context.Background(), stdout, stdin) } var out, in bytes.Buffer - if err := embedmd.Process(&out, io.TeeReader(stdin, &in)); err != nil { + if err := embedmd.Process(context.Background(), &out, io.TeeReader(stdin, &in)); err != nil { return false, err } d, err := diff(in.String(), out.String()) @@ -147,7 +148,7 @@ func processFile(path string, rewrite, doDiff bool) (foundDiff bool, err error) defer f.Close() buf := new(bytes.Buffer) - if err := embedmd.Process(buf, f, embedmd.WithBaseDir(filepath.Dir(path))); err != nil { + if err := embedmd.Process(context.Background(), buf, f, embedmd.WithBaseDir(filepath.Dir(path))); err != nil { return false, err } From e4bd81dcff352c6ef5fb7b197010a26b6f624aa7 Mon Sep 17 00:00:00 2001 From: Julien Bisconti Date: Sat, 16 May 2026 21:53:20 +0200 Subject: [PATCH 2/2] Fix Process call in embedmd_test.go to pass context The v2 branch added a context.Context parameter to Process but the in-package test never updated its call site, so the embedmd test package failed to compile. Add context.Background() to match the v2 Process signature. --- embedmd/embedmd_test.go | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/embedmd/embedmd_test.go b/embedmd/embedmd_test.go index 47efa66..a4ad8e8 100644 --- a/embedmd/embedmd_test.go +++ b/embedmd/embedmd_test.go @@ -15,6 +15,7 @@ package embedmd import ( "bytes" + "context" "fmt" "net/url" "os" @@ -266,7 +267,7 @@ func TestProcess(t *testing.T) { if tt.dir != "" { opts = append(opts, WithBaseDir(tt.dir)) } - err := Process(&out, strings.NewReader(tt.in), opts...) + err := Process(context.Background(), &out, strings.NewReader(tt.in), opts...) if !eqErr(t, tt.name, err, tt.err) { return }