Completion of Xstrings:go language string library

Source: Internet
Author: User
This is a creation in Article, where the information may have evolved or changed.

Project Address: Https://github.com/huandu/xstrings

xstringsis a very simple Go language library, simply said to provide some of the standard library is strings not provided but still useful string algorithm. Each string algorithm optimizes efficiency, and all functions do not exceed O(n) the complexity, and try to save memory usage only when allocating memory.

The algorithms that are now implemented are almost always algorithms that are available in other languages (mostly Python/ruby/php/perl), and are re-implemented with Go. Perhaps I will continue to add more methods in the future, but I do not want this library to be a hodgepodge of algorithms, so it only takes into account particularly well-known and language-independent functions.

The Go strings operation string is rune done in units, but the string type can only be byte used for the unit to access the subscript, you want to use rune []rune(str) the conversion (there is additional memory allocation) or utf8. DecodeRuneInString(str) decoding. In order to maintain a high degree of unity with the standard library, xstrings but also completely in order to rune operate the string, which makes the implementation of the algorithm more difficult than other languages slightly higher, but in short, this is a bit challenging feeling very good. ٩ (' ω ') و

There are two reasons for doing this project.

On the one hand, because Go's strings own algorithm is too few, other languages inside some of the special interesting string algorithm, such as Ruby String#succ / String#tr in Go inside none, the Internet even can not search to realize, so simply own to achieve one.

On the other hand, because the go language naming style is more alternative, or there is no historical burden, in other languages are deeply troubled by the C language legacy, Go adopted a small fresh style named function, read very comfortable, just from other language people want to find a specific function by feeling a little bit tangled , such as who can think of stricmp in Go is actually called EqualFold . So I'm just going to write a table of functions that corresponds to the functions of Go strings and other language-like functions, perhaps one day to help some new go developers.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.