Skip to content

WnP/go-sfmt

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

19 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

sfmt

Build Status Coverage Status Go Report Card GoDoc

Description

sfmt stands for string format, this package provided simple utilities to convert any supported string format:

  • spaced
  • dashed
  • doted
  • underscored
  • camelcased

to any supported string format -spaced|dashed|doted|underscored|camelcased.

All string's characters are first convert to lower case before processing, so the result string is a lower cased formated string.

Install

Using go get:

go get -u github.com/WnP/go-sfmt

Usage

for all examples don't forget to import the package:

import "github.com/WnP/go-sfmt"

CamelCased

CamelCased return a string where the first character is lower cased, you could easily convert the first letter to upper case using strings.Title.

fmt.Println(sfmt.CamelCased("The_quick_brown_fox_jumps_over_the_lazy_dog"))
// Output: theQuickBrownFoxJumpsOverTheLazyDog

Dashed

fmt.Println(sfmt.Dashed("The quick brown fox jumps over the lazy dog"))
// Output: the-quick-brown-fox-jumps-over-the-lazy-dog

Doted

fmt.Println(sfmt.Doted("The-quick-brown-fox-jumps-over-the-lazy-dog"))
// Output: the.quick.brown.fox.jumps.over.the.lazy.dog

Spaced

fmt.Println(sfmt.Spaced("The.quick.brown.fox.jumps.over.the.lazy.dog"))
// Output: the quick brown fox jumps over the lazy dog

Underscored

fmt.Println(sfmt.Underscored("TheQuickBrownFoxJumpsOverTheLazyDog"))
// Output: the_quick_brown_fox_jumps_over_the_lazy_dog

License (MIT)

MIT License (MIT)

Copyright (c) 2015 Steeve Chailloux

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

Sources

All sources are hosted at: https://github.com/WnP/go-sfmt

Contribute

Pull requests and issues are welcome.

About

Utilities to change string format

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages