Golang does not have a generic <>, but can receive various types of values through interface{}.
Use slices and generic instances as follows:
Type Slice []interface{}func newslice () Slice { return make (Slice, 0)}func (this* Slice) Add (elem interface{}) error { for _, V: = Range *this { if v = = elem { fmt. Printf ("Slice:add elem:%v already exist\n", Elem) return err_elem_exist } } *this = Append (*this, Elem ) FMT. Printf ("Slice:add elem:%v succ\n", Elem) return Nil}func (this* Slice) Remove (elem interface{}) error { Found: = False for I, V: = Range *this { if v = = Elem { if i = = Len (*this)-1 { *this = (*this) [: i] } el Se { *this = append ((*this) [: i], (*this) [i+1:] ...) } Found = True break } } if!found { fmt. Printf ("Slice:remove elem:%v not exist\n", Elem) return err_elem_nt_exist } fmt. Printf ("Slice:remove elem:%v succ\n", Elem) return nil}