Giter Site home page Giter Site logo

go-stringutils's Introduction

stringutils

Some string utils

UnsafeString([]byte) string return unsafe string from bytes slice indirectly (without allocation)

UnsafeStringFromPtr(*byte, length) string return unsafe string from bytes slice pointer indirectly (without allocation)

UnsafeStringBytes(*string) []bytes return unsafe string bytes indirectly (without allocation)

Split2(s string, sep string) (string, string, int) Split2 return the split string results (without memory allocations). Use Index for find separator.

Split(s string, sep string, buf []string) []string // Split return splitted slice (use pre-allocated buffer, reallocated if needed). Use Index for find separator. SplitByte(s string, sep byte, buf []string) []string // SplitByte return splitted slice (use pre-allocated buffer, reallocated if needed). Use Index for find separator. SplitRune(s string, sep rune, buf []string) []string // SplitByte return splitted slice (use pre-allocated buffer, reallocated if needed). Use Index for find separator. For Unicode long-width rune it's slower than Split

SplitN(s string, sep string, buf []string) []string // SplitN deprecated and removed, use Split

Reverse(string) string return reversed string (rune-wise left to right) ReverseSegments(string, delim) string return reversed string by segments around string delimiter (ReverseSegments("hello, world", ", ") return world, hello).

Replace(s, old, new string, n int) (string, changed) // Replace returns a copy of the string s with the first n non-overlapping instances of old replaced by new. Also return change flag.

ReplaceAll(s, old, new string) (string, changed) // Replace returns a copy of the string s with all non-overlapping instances of old replaced by new. Also return change flag.

WriteString(w io.Writer, s string) (int, error) writes the contents of the string s to w, which accepts a slice of bytes. No bytes alloation instead of io.WriteString.

Builder very simular to strings.Builder, but has better perfomance in some cases (reallocate with scale 2, if needed, also append numbers in-place) (at golang 1.14).

Template is a simple templating system

go-stringutils's People

Contributors

msaf1980 avatar

Watchers

James Cloos avatar  avatar

go-stringutils's Issues

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.