Giter Club home page Giter Club logo

xstrings's Introduction

大家好 / Hi there 👋

我是一名来自中国的开发者 🎉

  • 我熟悉各种前端和后端技术架构,各种技术栈上都有很多实战经验。
  • 曾作为技术负责人设计开发过多种不同类型的大型复杂互联网业务架构。
  • 我在 Github 上开源的项目大多与 Go 相关,平时喜欢研究 Go runtime 并解决与之相关的疑难杂症。
  • 当前,我是一个创业公司的合伙人,业务主要与视频相关,开发的技术涵盖播放器、流媒体服务、音视频格式等方面。

I'm a software developer from China. 🎉

  • I have lots of work experience in both front end and back end software.
  • I led the development of multiple large scale and complex projects as chief architecture in the past.
  • Most of my open source projects are writen in Go. I'm fond of investigating and hacking Go runtime to solve complicated issues.
  • Right now, I'm a partner of a start-up company. My business involves lots of video technologies, including video player, video streaming server, video format and so forth.

My Stats

xstrings's People

Contributors

huandu avatar whilei avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

xstrings's Issues

ToCamelCase handles spaces as word connector

Shouldn't the ToCamelCase handle spaces?

When you use hello world as the input to ToCamelCase you get Hello world. I was expecting to see HelloWorld instead. Looking at ToKebab and ToSnakeCase I did get the expected results: hello-world and hello_world .

One way I can get the behaviour I want is to do ToCamelCase(toSnakeCase("hello world")).

xstrings imports testing

xstrings currently imports the testing package: https://godoc.org/github.com/huandu/xstrings?import-graph

This is kind of a bummer for consumers further downstream, because it causes the inclusion of all sorts of stuff like runtime/pprof, which will bloat the final binaries for any user of the library.

It looks like this is just because testing is imported in test.go... which look like is just providing helper functions for testing, so moving it into the testing namespaces by moving the file to e.g. util_test.go should fix this.

Feature: Hyphen case

Hyphen case is similar to snake case. All alphabets are lower case and words are connected with hyphens.

Feature: Get successor string by incrementing characters.

See String#next in ruby.

Ruby document doesn't define the algorithm in String#next clearly. Here is my version (may not be 100% same as ruby).

Alphanumeric runes are following.

  • a - z
  • A - Z
  • 0 - 9

If there is one alphanumeric rune is found in string, increase the rune by 1. If increment generates a "carry", the rune to the left of it is incremented. This process repeats until there is no carry, adding an additional rune if necessary.

If there is no alphanumeric rune, the rightmost rune will be increased by 1 regardless whether the result is a valid rune or not.

CamelCase and capital input

Hi,

func TestToCamelCase(t *testing.T) {
	runTestCases(t, ToCamelCase, _M{
		"GOLANG":             "Golang",
	})
}

The following test should succeed instead it returns "GOLANG".

--- FAIL: TestToCamelCase (0.00s)
        util_test.go:22: case fails. [case:GOLANG]
                should => "Golang"
                actual => "GOLANG"

Is it a wanted behavior?

Cheers,

ToSnakeCase should handle numbers as well

Expect both ToSnakeCase("http2xx") and ToSnakeCase("HTTP2XX") to generate http_2xx.

Currently, the former (lowercase) returns http2xx and the latter htt_p2_xx 😕

Feature: Translate string from a set of runes to another

See String#tr in ruby.

Function signature will be func Translate(str, from, to string) string. In this function, from and to are a pattern defined as following.

  • Special characters:
    • - means a range of runes, e.g. "a-z" means all characters from 'a' to 'z' inclusive.
    • ^ as first character means a set of all runes excepted listed, e.g. "^a-z" means all characters except 'a' to 'z' inclusive.
    • \ escapes special characters.
  • Normal character represents itself, e.g. "abc" is a set including 'a', 'b' and 'c'.

Translate will try to find a 1:1 mapping from from to to. If to is smaller than from, last rune in to will be used to map "out of range" characters.

There should be a set of functions to "compile" translate from and to string to a rune set for better performance.

Feature: Reverse string

Go string is immutable and encoded in utf8 internally. It's a bit more challenge than reversing an ascii string.

Feature: Camel case from/to underscore conversion

Camel case to underscore.

  • SomeWords => some_words
  • HTTPServer => http_server
  • NoHTTPS => no_https

Underscore to camel case.

  • some_words => SomeWords
  • http_server => HttpServer
  • no_https => NoHttps
  • _complex__case_ => _Complex_Case_

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.