couldBeGHOwner returns true if s looks like a valid GitHub username/org.
(s string)
| 434 | |
| 435 | // couldBeGHOwner returns true if s looks like a valid GitHub username/org. |
| 436 | func couldBeGHOwner(s string) bool { |
| 437 | if len(s) == 0 || len(s) > 39 { |
| 438 | return false |
| 439 | } |
| 440 | for i, c := range s { |
| 441 | switch { |
| 442 | case c >= 'a' && c <= 'z', c >= 'A' && c <= 'Z', c >= '0' && c <= '9': |
| 443 | continue |
| 444 | case c == '-': |
| 445 | if i == 0 || i == len(s)-1 { |
| 446 | return false |
| 447 | } |
| 448 | default: |
| 449 | return false |
| 450 | } |
| 451 | } |
| 452 | return true |
| 453 | } |
| 454 | |
| 455 | type ghCodeSearchItem struct { |
| 456 | Name string `json:"name"` |
no outgoing calls