YTSFlix_Go/vendor/github.com/asticode/go-astitools/byte/length.go
2018-11-04 15:58:15 +01:00

18 lines
334 B
Go

package astibyte
// ToLength forces the length of a []byte
func ToLength(i []byte, rpl byte, length int) []byte {
if len(i) == length {
return i
} else if len(i) > length {
return i[:length]
} else {
var o = make([]byte, length)
o = i
for idx := 0; idx < length-len(i); idx++ {
o = append(o, rpl)
}
return o
}
}