MemoizeStr returns memoized version of stringFunc. When the result of l is not "", it will be cached and returned directly next time. MemoizeStr is not concurrency safe.
(l func() string)
| 365 | // |
| 366 | // MemoizeStr is not concurrency safe. |
| 367 | func MemoizeStr(l func() string) fmt.Stringer { |
| 368 | var result string |
| 369 | return StringerFunc(func() string { |
| 370 | if result != "" { |
| 371 | return result |
| 372 | } |
| 373 | result = l() |
| 374 | return result |
| 375 | }) |
| 376 | } |
| 377 | |
| 378 | // StringerStr defines a alias to normal string. |
| 379 | // implement fmt.Stringer |