NewDCollatedString is a helper routine to create a *DCollatedString. Panics if locale is invalid. Not safe for concurrent use.
( contents string, locale string, env *CollationEnvironment, )
| 1266 | // NewDCollatedString is a helper routine to create a *DCollatedString. Panics |
| 1267 | // if locale is invalid. Not safe for concurrent use. |
| 1268 | func NewDCollatedString( |
| 1269 | contents string, locale string, env *CollationEnvironment, |
| 1270 | ) (*DCollatedString, error) { |
| 1271 | entry, err := env.getCacheEntry(locale) |
| 1272 | if err != nil { |
| 1273 | return nil, err |
| 1274 | } |
| 1275 | if env.buffer == nil { |
| 1276 | env.buffer = &collate.Buffer{} |
| 1277 | } |
| 1278 | key := entry.collator.KeyFromString(env.buffer, contents) |
| 1279 | d := DCollatedString{contents, entry.locale, make([]byte, len(key))} |
| 1280 | copy(d.Key, key) |
| 1281 | env.buffer.Reset() |
| 1282 | return &d, nil |
| 1283 | } |
| 1284 | |
| 1285 | // AmbiguousFormat implements the Datum interface. |
| 1286 | func (*DCollatedString) AmbiguousFormat() bool { return false } |
no test coverage detected
searching dependent graphs…