I have two slice A := []string{"a","b","c","d"}
and B := []string{"a","b"}
.
How to get ["c","d"]
from slice A?
I've tried various ways but still not getting the result I want. Thank you
package main
import (
"fmt"
)
func main() {
A := []string{"a","b","c","d"}
B := []string{"a","b"}
temp := []string{}
for _, a := range A {
for _, b := range B {
if a == b {
fmt.Printf("%s == %s\n", a,b)
temp = append(temp, a)
break
}
}
}
}