diff --git a/.github/workflows/build-test.yml b/.github/workflows/build-test.yml index a1ae6ef..7dfed9b 100644 --- a/.github/workflows/build-test.yml +++ b/.github/workflows/build-test.yml @@ -9,7 +9,7 @@ jobs: steps: - uses: actions/setup-go@v2 with: - go-version: 1.13.x + go-version: 1.17 - uses: actions/checkout@v3 - name: Build run: go build . diff --git a/formatter_test.go b/formatter_test.go index 6e27b27..17e25ae 100644 --- a/formatter_test.go +++ b/formatter_test.go @@ -337,3 +337,30 @@ func TestCycle(t *testing.T) { *iv = *i t.Logf("Example long interface cycle:\n%# v", Formatter(i)) } + +type AValue struct { + ID int + Name string +} + +type ComplexValue struct { + AValues []*AValue + Values []interface{} + ByName map[string]interface{} +} + +func TestReuseVisitMap(t *testing.T) { + var a = &AValue{ID: 1, Name: "A"} + var c = ComplexValue{ + AValues: []*AValue{a}, + Values: []interface{}{a}, + ByName: map[string]interface{}{ + "A": a, + }, + } + + var s = Sprint(c) + if strings.Contains(s, "CYCLIC") { + t.Error("there should not cycle in ComplexValue ", s) + } +} diff --git a/go.mod b/go.mod index 98e6163..1cdb7d5 100644 --- a/go.mod +++ b/go.mod @@ -1,6 +1,6 @@ module github.com/kr/pretty -go 1.12 +go 1.17 require ( github.com/kr/text v0.2.0