storj/pkg/satellite/satellitedb/utils.go
Yehor Butko 5352778b3c
refactored byte to uuid converting (#610)
* refactored byte to uuid converting

* linter fixed

* error messages updated
2018-11-12 09:14:16 +00:00

22 lines
428 B
Go

// Copyright (C) 2018 Storj Labs, Inc.
// See LICENSE for copying information.
package satellitedb
import (
"github.com/skyrings/skyring-common/tools/uuid"
"github.com/zeebo/errs"
)
// bytesToUUID is used to convert []byte to UUID
func bytesToUUID(data []byte) (uuid.UUID, error) {
var id uuid.UUID
copy(id[:], data)
if len(id) != len(data) {
return uuid.UUID{}, errs.New("Invalid bytes array")
}
return id, nil
}