StringMinusOne returns the first string that's before String.
()
| 84 | |
| 85 | // StringMinusOne returns the first string that's before String. |
| 86 | func (r Ref) StringMinusOne() string { |
| 87 | if r.digest == nil { |
| 88 | return "<invalid-blob.Ref>" |
| 89 | } |
| 90 | dname := r.digest.digestName() |
| 91 | bs := r.digest.bytes() |
| 92 | buf := getBuf(len(dname) + 1 + len(bs)*2)[:0] |
| 93 | defer putBuf(buf) |
| 94 | buf = r.appendString(buf) |
| 95 | buf[len(buf)-1]-- // no need to deal with carrying underflow (no 0 bytes ever) |
| 96 | return string(buf) |
| 97 | } |
| 98 | |
| 99 | // EqualString reports whether r.String() is equal to s. |
| 100 | // It does not allocate. |