Skip to content

Commit

Permalink
DOM: reuse container factory instance
Browse files Browse the repository at this point in the history
Signed-off-by: Richard Kosegi <richard.kosegi@gmail.com>
  • Loading branch information
rkosegi committed Nov 15, 2024
1 parent 15c871b commit 073207c
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 6 deletions.
6 changes: 4 additions & 2 deletions dom/container.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,16 +18,18 @@ package dom

import (
"fmt"
"github.com/rkosegi/yaml-toolkit/utils"
"io"
"regexp"
"strconv"
"strings"

"github.com/rkosegi/yaml-toolkit/utils"
)

var (
listPathRe = regexp.MustCompile("\\[\\d+]$")
nilLeaf = LeafNode(nil)
b = &containerFactory{}
)

type containerImpl struct {
Expand Down Expand Up @@ -319,7 +321,7 @@ func (f *containerFactory) FromReader(r io.Reader, fn DecoderFunc) (ContainerBui
}

func Builder() ContainerFactory {
return &containerFactory{}
return b
}

var _ ContainerBuilder = &containerBuilderImpl{}
5 changes: 1 addition & 4 deletions dom/container_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,15 +18,12 @@ package dom

import (
"bytes"
"github.com/stretchr/testify/assert"
"os"
"slices"
"strings"
"testing"
)

var (
b = Builder()
"github.com/stretchr/testify/assert"
)

func TestBuilderFromYamlString(t *testing.T) {
Expand Down

0 comments on commit 073207c

Please sign in to comment.