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

formatting of maps is invalid go code #45

Open
awalterschulze opened this issue Jan 31, 2017 · 3 comments
Open

formatting of maps is invalid go code #45

awalterschulze opened this issue Jan 31, 2017 · 3 comments

Comments

@awalterschulze
Copy link

package main

import (
	"fmt"

	"github.com/kr/pretty"
)

type A struct {
	B *B
}

type B struct {
	M map[string]string
}

func main() {
	a := &A{B: &B{M: map[string]string{}}}
	fmt.Printf("%# v\n", pretty.Formatter(a))
        //prints out
	/*
		&main.A{
		    B:  &main.B{
		        M:  {},
		    },
		}
	*/
        //This contains a syntax error
	c := &A{
		B: &B{
			M: {},
		},
	}
}
@awalterschulze
Copy link
Author

This line M: {} gives the error: missing type in composite literal

@awalterschulze
Copy link
Author

I would really love to be able to print valid go source.

This problem is also present for slices of structs and non empty maps.

awalterschulze referenced this issue in awalterschulze/goderive Feb 11, 2017
@mbana
Copy link

mbana commented Apr 15, 2018

This tool is really quite useful. Good work.

I was also wondering, like above, if you plan to fix this soon?

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

No branches or pull requests

2 participants