aboutsummaryrefslogtreecommitdiff
path: root/lib/bytes/bytes.go
diff options
context:
space:
mode:
Diffstat (limited to 'lib/bytes/bytes.go')
-rw-r--r--lib/bytes/bytes.go32
1 files changed, 29 insertions, 3 deletions
diff --git a/lib/bytes/bytes.go b/lib/bytes/bytes.go
index 6e44f0a6..b47b0a85 100644
--- a/lib/bytes/bytes.go
+++ b/lib/bytes/bytes.go
@@ -1,6 +1,6 @@
-// Copyright 2018, Shulhan <ms@kilabit.info>. All rights reserved.
-// Use of this source code is governed by a BSD-style
-// license that can be found in the LICENSE file.
+// SPDX-FileCopyrightText: 2018 M. Shulhan <ms@kilabit.info>
+//
+// SPDX-License-Identifier: BSD-3-Clause
// Package bytes provide a library for working with byte or slice of bytes.
package bytes
@@ -32,6 +32,19 @@ func AppendInt32(data []byte, v int32) []byte {
return data
}
+// AppendInt64 append an int64 value into slice of byte.
+func AppendInt64(data []byte, v int64) []byte {
+ data = append(data, byte(v>>56))
+ data = append(data, byte(v>>48))
+ data = append(data, byte(v>>40))
+ data = append(data, byte(v>>32))
+ data = append(data, byte(v>>24))
+ data = append(data, byte(v>>16))
+ data = append(data, byte(v>>8))
+ data = append(data, byte(v))
+ return data
+}
+
// AppendUint16 append an uint16 value into slice of byte.
func AppendUint16(data []byte, v uint16) []byte {
data = append(data, byte(v>>8))
@@ -48,6 +61,19 @@ func AppendUint32(data []byte, v uint32) []byte {
return data
}
+// AppendUint64 append an uint64 value into slice of byte.
+func AppendUint64(data []byte, v uint64) []byte {
+ data = append(data, byte(v>>56))
+ data = append(data, byte(v>>48))
+ data = append(data, byte(v>>40))
+ data = append(data, byte(v>>32))
+ data = append(data, byte(v>>24))
+ data = append(data, byte(v>>16))
+ data = append(data, byte(v>>8))
+ data = append(data, byte(v))
+ return data
+}
+
// Concat merge one or more []byte or string in args into slice of
// byte.
// Any type that is not []byte or string in args will be ignored.