Skip to content

Not support String() implement function?  #48

@rsgok

Description

@rsgok

Seems like litter not accept costumed String() implement func

Example comparing go-spew

package main

import (
	"github.com/davecgh/go-spew/spew"
	"github.com/sanity-io/litter"
)

func main() {
	TT()
}

type A struct {
	Tag string
	Num int
	InA InA
}

type InA struct {
	Id   int
	Type string
}

func (t InA) String() string {
	return t.Type
}

func TT() {
	a := A{
		Tag: "tag-A",
		Num: 1,
		InA: InA{
			Id:   100,
			Type: "test",
		},
	}
	spew.Dump(a)
	litter.Dump(a)
}

Output compare

(main.A) {
 Tag: (string) (len=5) "tag-A",
 Num: (int) 1,
 InA: (main.InA) test
}
main.A{
  Tag: "tag-A",
  Num: 1,
  InA: main.InA{
    Id: 100,
    Type: "test",
  },
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions