Documentation
¶
Index ¶
- func Charindex(s Mystr, rune_section_start int, findstr Mystr, findstr_rune_count_hint int, ...) (pos_start int, pos_endx int, found_rune_index int)
- func Compare(a Mystr, b Mystr, collator *collate.Collator) int
- func Equal(a Mystr, b Mystr, collator *collate.Collator) bool
- func Equal_strict(a Mystr, b Mystr) bool
- func Starts_with(s Mystr, prefix Mystr, prefix_rune_count_hint int, collator *collate.Collator) bool
- type Mystr
- func Left(dest Mystr, s Mystr, rune_count int) (res Mystr)
- func Map(dest Mystr, s Mystr, mapping func(r rune) rune) (res Mystr)
- func Replace(dest Mystr, s Mystr, findstr Mystr, replacement Mystr, ...) (res Mystr)
- func Right(dest Mystr, s Mystr, rune_count int) (res Mystr)
- func Stuff(dest Mystr, s Mystr, rune_section_start int, rune_section_length int, ...) (res_NULL_flag bool, res Mystr)
- func Substring(dest Mystr, s Mystr, rune_section_start int, rune_section_length int) (res Mystr)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Charindex ¶
func Charindex(s Mystr, rune_section_start int, findstr Mystr, findstr_rune_count_hint int, collator *collate.Collator) (pos_start int, pos_endx int, found_rune_index int)
Charindex return the rune index (returned found_rune_index is 1-based) of findstr. Returned values pos_start and pos_endx are 0-based. If findstr is not found, returns found_rune_index == 0, and pos_start == -1.
If you know the length in runes of findstr, pass it in findstr_rune_count_hint. Else, pass -1.
rune_section_start is 1-based. To start the search from the first character, pass 1 for this argument.
We could use package golang.org/x/text/search. TODO I must think about it.
func Compare ¶
Compare compares string a and b. The trailing blanks of a and b are skipped. The result will be 0 if a==b, -1 if a < b, and +1 if a > b.
func Equal ¶
Equal compares string a and b for equality.
It is the same code as Compare(), but with a quick path (byte comparison). THIS FUNCTION IS NOT USED BECAUSE IN A SQL QUERY, MOST RESULT OF '=' RETURN FALSE, AND IN THIS CASE, THE SHORTCUT PATH IS JUST USELESS WORK.
The trailing blanks of a and b are skipped. The result will be 0 if a==b, -1 if a < b, and +1 if a > b.
func Equal_strict ¶
Equal_strict compares two strings for equality, byte per byte. It is a strict comparison, because trailing blanks are not discarded.
Types ¶
type Mystr ¶
type Mystr []byte
func Left ¶
Left writes rune_count runes from s, starting from left, into dest slice. If capacity of dest is not enough, a new storage array is allocated. The slice containing result is returned.
If not enough characters are available, a copy of s is returned.
func Map ¶
Map writes all runes of s, mapped with function 'mapping', into dest slice. If capacity of dest is not enough, a new storage array is allocated. The slice containing result is returned.
func Right ¶
Right writes rune_count runes from s, starting from right, into dest slice. If capacity of dest is not enough, a new storage array is allocated. The slice containing result is returned.
If not enough characters are available, a copy of s is returned.
func Stuff ¶
func Stuff(dest Mystr, s Mystr, rune_section_start int, rune_section_length int, replacement Mystr) (res_NULL_flag bool, res Mystr)
Stuff deletes section of string s which starts at rune_section_start (1-based) of length rune_section_length (in runes), and replaces it by replacement. If argument invalid, returned res_NULL_flag is true, meaning that the SQL result of the function must be NULL.
func (*Mystr) Fit_to_precision_no_truncate ¶
Fit_to_precision_no_truncate removes trailing spaces in excess, if rune count in mystr is larger than precision. If trailing characters in excess are not all spaces, an error is returned. Else, the function just returns.