10000 feat(struct): add struct name function by ch3nnn · Pull Request #328 · duke-git/lancet · GitHub
[go: up one dir, main page]

Skip to content

Conversation

ch3nnn
Copy link
Contributor
@ch3nnn ch3nnn commented Sep 10, 2025
  • Add Name() method to Struct type to return the struct name
  • Implement unit tests for the new Name() method

- Add Name() method to Struct type to return the struct name
- Implement unit tests for the new Name() method
}

// Name return struct name
func (s *Struct) Name() string {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi ch3nnn,

Thank you!

Is Name a good name for this function? Intuitively, I don not think that the type name of a struct is its name.

Some could argue that the name of the struct is the name of the variable assigned (in the tests below it would be s1), for example.
Others could argue that a struct has no name, or its name is Struct.

You see, this function would return the same response for two instances of the same type... that can be confusing.

My suggestion would be to consider the TypeName instead of Name. What do you think?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

agree

Copy link
Collaborator
@idichekop idichekop left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Name of the suggested function should be reviewed.

- Rename method Name to TypeName for clarity and accuracy
- Update corresponding test cases
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

Successfully merging this pull request may close these issues.

2 participants

0