如何检查具有相同字符的单词,其中一个变量中的单词

I'm thinking up about how I find the same characters in one variable looks like this:

var words string = "abab"

and then I want's to eliminate the same characters in that one variable and here's the output to be

Output:

ab

have any solution about this?

One solution can be the use of go map[] to track the taken characters.

sample code:

func main() {
    s := "abcdaabcefgahccij"
    newS := ""
    taken := make(map[rune]int)
    for _, value := range s {
        if _, ok := taken[value]; !ok {
            taken[value] = 1
            newS += string(value)
        }
    }
    fmt.Println(newS)
}

Output:

abcdefghij