Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add String() methods to DN and its subtypes #386

Merged
merged 2 commits into from Jul 22, 2022

Conversation

rhafer
Copy link
Contributor

@rhafer rhafer commented Jul 19, 2022

This is bascially a try to revive #104. AFAICS the only missing piece (apart from rebasing) was to duplicate the code to the v3 folder.

@cpuschma cpuschma self-assigned this Jul 19, 2022
Copy link
Member

@cpuschma cpuschma left a comment

Choose a reason for hiding this comment

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

Thank you for your PR! 👍 I'll leave this PR open for a few days for others to comment ^^

Josh Hawn and others added 2 commits July 22, 2022 08:47
This patch adds `String() string` methods to each of the following types:

- DN
- RelativeDN
- AttributeTypeAndValue

So that a `*DN` implements the `fmt.Stringer` interface. These methods also
produce normalized strings: Attribute Type and Value are lowercased and joined
with a "=" character while multiple attributes of a Relative DN are sorted
lexicographically before being joined witha "+" character.

This allows one to use the string representation of a DN as a map key and
ensure that two DNs which `Equal()` eachother would have the same `String()`
value.

Docker-DCO-1.1-Signed-off-by: Josh Hawn <josh.hawn@docker.com> (github: jlhawn)
@cpuschma cpuschma merged commit c4ad4d4 into go-ldap:master Jul 22, 2022
inv2004 pushed a commit to inv2004/ldap that referenced this pull request Jan 17, 2023
* Add String() methods to DN and its subtypes

This patch adds `String() string` methods to each of the following types:

- DN
- RelativeDN
- AttributeTypeAndValue

So that a `*DN` implements the `fmt.Stringer` interface. These methods also
produce normalized strings: Attribute Type and Value are lowercased and joined
with a "=" character while multiple attributes of a Relative DN are sorted
lexicographically before being joined witha "+" character.

This allows one to use the string representation of a DN as a map key and
ensure that two DNs which `Equal()` eachother would have the same `String()`
value.

Docker-DCO-1.1-Signed-off-by: Josh Hawn <josh.hawn@docker.com> (github: jlhawn)

* Mirror DN String() methods to v3 folder

Co-authored-by: Josh Hawn <josh.hawn@docker.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants