Skip to content

Commit 09e36d8

Browse files
committed
internal/gophers: add missing documentation
This is a step towards improving the usability of this package. Use myself as an example of the types of queries that GetPerson accepts. Updates golang/go#27631 Change-Id: I3f4d497eb237958c652e51e03fd2459f0f9df8ef Reviewed-on: https://go-review.googlesource.com/c/build/+/195064 Reviewed-by: Brad Fitzpatrick <[email protected]>
1 parent 9c46470 commit 09e36d8

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

internal/gophers/gophers.go

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ import (
1212
"golang.org/x/build/gerrit"
1313
)
1414

15+
// Person represents a person.
1516
type Person struct {
1617
Name string // "Foo Bar"
1718
Github string // "FooBar" (orig case, no '@')
@@ -63,10 +64,27 @@ func (p *Person) mergeIDs(ids ...string) {
6364
// keys are "@lowercasegithub", "lowercase name", "[email protected]".
6465
var idToPerson = map[string]*Person{}
6566

67+
// GetPerson looks up a person by id and returns one if found,
68+
// or nil otherwise.
69+
//
70+
// The id is case insensitive, and may be one of:
71+
//
72+
// • full name (for example, "Dmitri Shuralyov")
73+
//
74+
// • GitHub username (for example, "@dmitshur"), leading '@' is mandatory
75+
//
76+
// • Gerrit <account ID>@<instance ID> (for example, "6005@62eb7196-b449-3ce5-99f1-c037f21e1705")
77+
//
78+
// • email (for example, "[email protected]")
79+
//
80+
// Only exact matches are supported.
81+
//
6682
func GetPerson(id string) *Person {
6783
return idToPerson[strings.ToLower(id)]
6884
}
6985

86+
// GetGerritPerson looks up a person from the Gerrit account ai.
87+
// It uses the name and email in the Gerrit account for the lookup.
7088
func GetGerritPerson(ai gerrit.AccountInfo) *Person {
7189
if p := GetPerson(ai.Name); p != nil {
7290
return p

0 commit comments

Comments
 (0)