mirror of
https://github.com/octoleo/restic.git
synced 2024-11-26 23:06:32 +00:00
backend: Add String() to IDs
This commit is contained in:
parent
a0bad1695c
commit
2cb0fbf589
@ -1,5 +1,10 @@
|
|||||||
package backend
|
package backend
|
||||||
|
|
||||||
|
import (
|
||||||
|
"encoding/hex"
|
||||||
|
"fmt"
|
||||||
|
)
|
||||||
|
|
||||||
// IDs is an ordered list of IDs that implements sort.Interface.
|
// IDs is an ordered list of IDs that implements sort.Interface.
|
||||||
type IDs []ID
|
type IDs []ID
|
||||||
|
|
||||||
@ -48,3 +53,17 @@ func (ids IDs) Uniq() (list IDs) {
|
|||||||
|
|
||||||
return list
|
return list
|
||||||
}
|
}
|
||||||
|
|
||||||
|
type shortID ID
|
||||||
|
|
||||||
|
func (id shortID) String() string {
|
||||||
|
return hex.EncodeToString(id[:shortStr])
|
||||||
|
}
|
||||||
|
|
||||||
|
func (ids IDs) String() string {
|
||||||
|
elements := make([]shortID, 0, len(ids))
|
||||||
|
for _, id := range ids {
|
||||||
|
elements = append(elements, shortID(id))
|
||||||
|
}
|
||||||
|
return fmt.Sprintf("%v", elements)
|
||||||
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user