From a2a4152b867b0add58af3c3fb1b8450374240224 Mon Sep 17 00:00:00 2001 From: Antoni Sawicki Date: Tue, 2 Jul 2024 01:19:19 -0700 Subject: [PATCH] fix destination bug --- txt.go | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/txt.go b/txt.go index ffc1c7a..52cbfd0 100644 --- a/txt.go +++ b/txt.go @@ -117,12 +117,13 @@ func (t *astTransformer) Transform(node *ast.Document, reader text.Reader, pc pa } if img, ok := n.(*ast.Image); ok && entering { id := fmt.Sprintf("txt%05d.gif", rand.Intn(99999)) // atomic.AddInt64 could be better here - img.Destination = []byte(imgZpfx + id) - err := grabImage(id, string(img.Destination)) // TODO: use goroutines with waitgroup + err := grabImage(id, string(img.Destination)) // TODO: use goroutines with waitgroup if err != nil { log.Print(err) n.Parent().RemoveChildren(n) + return ast.WalkContinue, nil } + img.Destination = []byte(imgZpfx + id) } return ast.WalkContinue, nil })