Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add slice and array annotation to struct fields #91

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

artemklevtsov
Copy link

This commit adds slice type when used in the struct field.

Should fix #36 and #45.

To reproduce:

package main

import (
	"github.com/kr/pretty"
)

type MyObj struct {
	Name   string
	Fields []MyField
}

type MyField struct {
	Name string
}

func main() {
	o := MyObj{
		Name: "xxx",
		Fields: []MyField{
			{
				Name: "fff",
			},
		},
	}

	pretty.Println(o)
}

Before:

main.MyObj{
    Name:   "xxx",
    Fields: {
        {Name:"fff"},
    },
}

after:

main.MyObj{
    Name:   "xxx",
    Fields: []main.MyField{
        {Name:"fff"},
    },
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Arrays don't round-trip
1 participant