3 ms·
If you're juggling a bunch of different types of strings and want to keep them straight, Go does support defining separate types for them. An example is the HTM
by skybrian 11y ago
If you're juggling a bunch of different types of strings and want to keep them straight, Go does support defining separate types for them. An example is the HTML type from the template library [1].
The question is which sanitized string types are worth defining in the standard library. Presumably UTF-8 sanitized strings didn't make the cut.
Not sure about UTF-8B. Suppose the input is already UTF-8B? Do you double-escape it somehow?
It looks like DecodeRuneInString returns RuneError if it can't decode something and RuneError is defined as U+FFFD. The example uses a hard-coded string where it can't happen, so technically it's not a bug that it doesn't check for the error. But a linter might want to flag it.
[1] http://golang.org/pkg/html/template/#HTML http://golang.org/pkg/html/template/#HTML