go-plantuml icon indicating copy to clipboard operation
go-plantuml copied to clipboard

Error when struct declaration is in a different file than its method

Open jeandeaual opened this issue 2 years ago • 1 comments

Hi,

go-plantuml cannot seem to find a type if its declaration is in a different file than one of its method.

For example, with the following files:

impl.go:

package models

func (user *User) SetFirstName(firstName string) {
	user.FirstName = firstName
}

func PackageFunction() string {
	return "Hello World"
}

user.go:

package models

type User struct {
	FirstName      string
	LastName       string
	Age            uint8
}

I'm getting the following error when running go-plantuml generate:

2022/09/08 14:45:56 Could not find class: User for function SetFirstName

This seems to depend on the name of the files and the order in which they are parsed by the tool. The same issue happens if the type is an alias (e.g. type User string).

jeandeaual avatar Sep 11 '22 01:09 jeandeaual

Thanks for the request, I'll have a look at it

bykof avatar Sep 13 '22 10:09 bykof

@bykof can i help with this issue?

mahmednabil109 avatar Feb 13 '23 18:02 mahmednabil109

@mahmednabil109 sure, feel free to work on it :)

bykof avatar Feb 13 '23 19:02 bykof