8000 formatting of maps is invalid go code · Issue #45 · kr/pretty · GitHub
[go: up one dir, main page]

Skip to content

formatting of maps is invalid go code #45

Open

Description

@awalterschulze
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: {},
		},
	}
}

Activity

  1. awalterschulze commented on Jan 31, 2017

    @awalterschulze
    Author

    This line M: {} gives the err 75FD or: missing type in composite literal

  2. awalterschulze commented on Jan 31, 2017

    @awalterschulze
    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.

  3. added a commit that references this issue on Feb 11, 2017
  4. bana-io commented on Apr 15, 2018

    @bana-io

    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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions

      0