github.com/weedge/lib@v0.0.0-20230424045628-a36dcc1d90e4/copy/copy.go (about) 1 package copy 2 3 func CopyTwoDimensionInt(src [][]int) [][]int { 4 n := len(src) 5 res := make([][]int, n) 6 for i := 0; i < n; i++ { 7 res[i] = make([]int, len(src[0])) 8 copy(res[i], src[i]) 9 } 10 11 return res 12 } 13 14 func CopyTwoDimensionInt64(src [][]int64) [][]int64 { 15 n := len(src) 16 res := make([][]int64, n) 17 for i := 0; i < n; i++ { 18 res[i] = make([]int64, len(src[0])) 19 copy(res[i], src[i]) 20 } 21 22 return res 23 }