You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
29 lines
538 B
Go
29 lines
538 B
Go
package stbl
|
|
|
|
import (
|
|
"fmt"
|
|
"unicode/utf8"
|
|
)
|
|
|
|
// Entry represents a single record in a string table. It's not called "Record"
|
|
// because it's called "Entry" in the protobufs.
|
|
type Entry struct {
|
|
Key string
|
|
Value []byte
|
|
}
|
|
|
|
func (e Entry) String() string {
|
|
if e.Value == nil {
|
|
return fmt.Sprintf("{%s nil}", e.Key)
|
|
}
|
|
|
|
if utf8.Valid(e.Value) {
|
|
return fmt.Sprintf("{%s %s}", e.Key, e.Value)
|
|
}
|
|
|
|
if len(e.Value) > 32 {
|
|
return fmt.Sprintf("{%s 0x%x}", e.Key, e.Value[:32])
|
|
}
|
|
return fmt.Sprintf("{%s 0x%x}", e.Key, e.Value)
|
|
}
|