bykof / go-plantuml

Generate plantuml diagrams from go source files or directories
MIT License
388 stars 27 forks source link

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

Closed jeandeaual closed 1 year ago

jeandeaual commented 2 years ago

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).

bykof commented 2 years ago

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

mahmednabil109 commented 1 year ago

@bykof can i help with this issue?

bykof commented 1 year ago

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