init
This commit is contained in:
17
vendor/github.com/asticode/go-astitools/byte/length.go
generated
vendored
Normal file
17
vendor/github.com/asticode/go-astitools/byte/length.go
generated
vendored
Normal file
@ -0,0 +1,17 @@
|
||||
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
|
||||
}
|
||||
}
|
29
vendor/github.com/asticode/go-astitools/byte/pad.go
generated
vendored
Normal file
29
vendor/github.com/asticode/go-astitools/byte/pad.go
generated
vendored
Normal file
@ -0,0 +1,29 @@
|
||||
package astibyte
|
||||
|
||||
// PadLeft adds n rpl to the left of i so that len is length
|
||||
func PadLeft(i []byte, rpl byte, length int) []byte {
|
||||
if len(i) >= length {
|
||||
return i
|
||||
} else {
|
||||
var o = make([]byte, length)
|
||||
o = i
|
||||
for idx := 0; idx < length-len(i); idx++ {
|
||||
o = append([]byte{rpl}, o...)
|
||||
}
|
||||
return o
|
||||
}
|
||||
}
|
||||
|
||||
// PadRight adds n rpl to the right of i so that len is length
|
||||
func PadRight(i []byte, rpl byte, length int) []byte {
|
||||
if len(i) >= length {
|
||||
return i
|
||||
} else {
|
||||
var o = make([]byte, length)
|
||||
o = i
|
||||
for idx := 0; idx < length-len(i); idx++ {
|
||||
o = append(o, rpl)
|
||||
}
|
||||
return o
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user