mtsatellite/common/coords.go

20 lines
463 B
Go
Raw Normal View History

// 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.
2014-08-16 16:06:42 +02:00
package common
import (
"strconv"
)
// Constructs a database key out of byte slice.
2014-08-16 16:06:42 +02:00
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(strconv.FormatInt(key, 10))
}