<pre name="code" class="plain">package main import ( "fmt" ) func main() { a := []int{2,1,2,5,6,3,4,9} z := Rm_duplicate(&a) } func Rm_duplicate(list *[]int) []int { var x []int = []int{} for _,i := range *list { if len(x) == 0 { x = append(x,i) } else { for k,v := range x { if i == v { break } if k == len(x)-1 { x = append(x,i) } } } } return x }原文链接:https://www.f2er.com/go/190366.html