diff options
Diffstat (limited to 'pkg/btrfs/btrfstyp/uuid.go')
-rw-r--r-- | pkg/btrfs/btrfstyp/uuid.go | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/pkg/btrfs/btrfstyp/uuid.go b/pkg/btrfs/btrfstyp/uuid.go new file mode 100644 index 0000000..8b0c92e --- /dev/null +++ b/pkg/btrfs/btrfstyp/uuid.go @@ -0,0 +1,24 @@ +package btrfstyp + +import ( + "bytes" + "encoding/hex" + "strings" +) + +type UUID [16]byte + +func (uuid UUID) String() string { + str := hex.EncodeToString(uuid[:]) + return strings.Join([]string{ + str[:8], + str[8:12], + str[12:16], + str[16:20], + str[20:32], + }, "-") +} + +func (a UUID) Equal(b UUID) bool { + return bytes.Equal(a[:], b[:]) +} |