Creates a new Set from an array of strings. Returns an error if any names are invalid.
(names []string, mode StarMode)
| 63 | |
| 64 | // Creates a new Set from an array of strings. Returns an error if any names are invalid. |
| 65 | func SetFromArray(names []string, mode StarMode) (base.Set, error) { |
| 66 | for _, name := range names { |
| 67 | if !IsValidChannel(name) { |
| 68 | return nil, illegalChannelError(name) |
| 69 | } |
| 70 | } |
| 71 | result := base.SetFromArray(names) |
| 72 | switch mode { |
| 73 | case RemoveStar: |
| 74 | result = result.Removing(UserStarChannel) |
| 75 | case ExpandStar: |
| 76 | if result.Contains(UserStarChannel) { |
| 77 | result = base.SetOf(UserStarChannel) |
| 78 | } |
| 79 | } |
| 80 | return result, nil |
| 81 | } |
| 82 | |
| 83 | // SetOf creates a new Set. Returns an error if any names are invalid. |
| 84 | func SetOf(chans ...ID) (Set, error) { |