copy

使用copy 函数必须申请内存

  newRes := make([]int, len(res)) // 必须要申请内容
    copy(newRes, res)
    newRes = append(newRes,i)

Last updated

Was this helpful?