github.com/niubaoshu/goutils@v0.0.0-20180828035119-e8e576f66c2b/utils.go (about) 1 package goutils 2 3 func CheckRepeat(a []int) bool { 4 set := NewSet() 5 for _, i := range a { 6 if set.Has(int64(i)) { 7 return true 8 } else { 9 set.Add(int64(i)) 10 } 11 } 12 return false 13 } 14 15 func EnlargeInt(data []int, l int) (buf []int, n int) { 16 if cap(data)-len(data) < l { 17 buf = make([]int, l+len(data)) 18 n = copy(buf, data) 19 } else { 20 buf = data[:len(data)+l] 21 } 22 return buf, len(data) 23 } 24 func EnlargeByte(data []byte, l int) (buf []byte, n int) { 25 if cap(data)-len(data) < l { 26 buf = make([]byte, l+len(data)) 27 n = copy(buf, data) 28 } else { 29 buf = data[:len(data)+l] 30 } 31 return buf, len(data) 32 }