Source File
helper.go
Belonging Package
github.com/stoewer/go-strcase
// Copyright (c) 2017, A. Stoewer <adrian.stoewer@rz.ifi.lmu.de>// All rights reserved.package strcase// isLower checks if a character is lower case. More precisely it evaluates if it is// in the range of ASCII character 'a' to 'z'.func isLower( rune) bool {return >= 'a' && <= 'z'}// toLower converts a character in the range of ASCII characters 'A' to 'Z' to its lower// case counterpart. Other characters remain the same.func toLower( rune) rune {if >= 'A' && <= 'Z' {return + 32}return}// isLower checks if a character is upper case. More precisely it evaluates if it is// in the range of ASCII characters 'A' to 'Z'.func isUpper( rune) bool {return >= 'A' && <= 'Z'}// toLower converts a character in the range of ASCII characters 'a' to 'z' to its lower// case counterpart. Other characters remain the same.func toUpper( rune) rune {if >= 'a' && <= 'z' {return - 32}return}// isSpace checks if a character is some kind of whitespace.func isSpace( rune) bool {return == ' ' || == '\t' || == '\n' || == '\r'}// isDigit checks if a character is a digit. More precisely it evaluates if it is// in the range of ASCII characters '0' to '9'.func isDigit( rune) bool {return >= '0' && <= '9'}// isDelimiter checks if a character is some kind of whitespace or '_' or '-'.func isDelimiter( rune) bool {return == '-' || == '_' || isSpace()}// iterFunc is a callback that is called fro a specific position in a string. Its arguments are the// rune at the respective string position as well as the previous and the next rune. If curr is at the// first position of the string prev is zero. If curr is at the end of the string next is zero.type iterFunc func(prev, curr, next rune)// stringIter iterates over a string, invoking the callback for every single rune in the string.func stringIter( string, iterFunc) {var runevar runefor , := range {if == 0 {==continue}(, , )==}if len() > 0 {(, , 0)}}
![]() |
The pages are generated with Golds v0.8.2. (GOOS=linux GOARCH=amd64) Golds is a Go 101 project developed by Tapir Liu. PR and bug reports are welcome and can be submitted to the issue list. Please follow @zigo_101 (reachable from the left QR code) to get the latest news of Golds. |