ArrayRemoveDuplicates removes any duplicated elements in a string array.
(s *[]string)
| 127 | |
| 128 | // ArrayRemoveDuplicates removes any duplicated elements in a string array. |
| 129 | func ArrayRemoveDuplicates(s *[]string) { |
| 130 | found := make(map[string]bool) |
| 131 | j := 0 |
| 132 | for i, x := range *s { |
| 133 | if !found[x] { |
| 134 | found[x] = true |
| 135 | (*s)[j] = (*s)[i] |
| 136 | j++ |
| 137 | } |
| 138 | } |
| 139 | *s = (*s)[:j] |
| 140 | } |
| 141 | |
| 142 | // ArrayToString gets a printable string for a string array. |
| 143 | func ArrayToString(s []string) string { |
no outgoing calls
no test coverage detected
searching dependent graphs…