kazukousen/gouml

Can not convert inline struct correctly

Closed this issue · 2 comments

p1ass commented

Issue

I would like to convert the code below.

package foo

type foo struct{
	id int `json:"id"`
	bar struct{
		id int `json:"bar_id"`
	} `json:"bar"`
}

However, the output contains struct tag data.

package "foo" {
	class "foo" as foo.foo <<V,Orchid>> {
		-id: int
		-bar: struct{id int "json:\"bar_id\""}
	}
}

スクリーンショット 2019-04-15 13 48 05

I think this is because that types.Struct has not only field data, but also tag data like,

&types.Struct{
    fields:[]*types.Var{(*types.Var)(0xc0000ee3c0)},
    tags:[]string{"json:\"bar_id\""}
}

Therefore, when we use types.Struct.String(), unnecessary information is showed.

Thank you for raising the issue very much!
That's right, this issue occurred from using types.Type.String() .
It is temporary implementation. So I hope to use another way.

I think I would like to draw an unnamed type's field as follows:

image

nested inline struct

type foo struct {
	id  int `json:"id"`
	bar struct {
		id  int `json:"bar_id"`
		baz struct {
			id int `json:"bar_baz_id"`
		}
	} `json:"bar"`
}
package "main" {
	class "foo" as main.foo <<V,Orchid>> {
		-id: int
		-bar: struct{id: int; baz: struct{id: int}}
	}
}

image