mirror of
https://bitbucket.org/s_l_teichmann/mtsatellite
synced 2024-11-08 11:10:27 +01:00
21 lines
466 B
Go
21 lines
466 B
Go
// Copyright 2014 by Sascha L. Teichmann
|
|
// Use of this source code is governed by the MIT license
|
|
// that can be found in the LICENSE file.
|
|
|
|
package common
|
|
|
|
import (
|
|
"fmt"
|
|
"strconv"
|
|
)
|
|
|
|
// Constructs a database key out of byte slice.
|
|
func DecodePosFromBytes(key []byte) (pos int64, err error) {
|
|
return strconv.ParseInt(string(key), 10, 64)
|
|
}
|
|
|
|
// Encode a block pos to byte slice.
|
|
func EncodePosToBytes(key int64) []byte {
|
|
return []byte(fmt.Sprintf("%d", key))
|
|
}
|