]> git.r.bdr.sh - rbdr/mobius/blame - concat/slices.go
Troubleshoot build pipeline
[rbdr/mobius] / concat / slices.go
CommitLineData
6988a057
JH
1package concat
2
3// Slices is a utility function to make appending multiple slices less painful and more efficient
4// Source: https://stackoverflow.com/questions/37884361/concat-multiple-slices-in-golang
5func Slices(slices ...[]byte) []byte {
6 var totalLen int
7 for _, s := range slices {
8 totalLen += len(s)
9 }
10 tmp := make([]byte, totalLen)
11 var i int
12 for _, s := range slices {
13 i += copy(tmp[i:], s)
14 }
15
16 return tmp
17}