Skip to content

Instantly share code, notes, and snippets.

@ffloyd
Created May 10, 2016 18:26
Show Gist options
  • Save ffloyd/c4c6e347ac285bde32f03d404ef5a617 to your computer and use it in GitHub Desktop.
Save ffloyd/c4c6e347ac285bde32f03d404ef5a617 to your computer and use it in GitHub Desktop.
flatten_slice.go
func flattenSlice(input *[][]interface{}) *[]interface{} {
capSum := 0
for _, v := range *input {
capSum += cap(v)
}
result := make([]interface{}, 0, capSum)
for _, v := range *input {
result = append(result, v)
}
return &result
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment