whitespace

package
v1.0.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 11, 2019 License: MIT Imports: 4 Imported by: 4

Documentation

Overview

whitespace centralises information and some utility functions regarding whitespace.

Index

Constants

View Source
const (
	// Chars is a string containing all the literal whitespace characters.
	Chars = " \t\r\n"
	// EscapedChars is a string containing the whitespace characters escaped
	// with a backslash.
	EscapedChars = ` \t\r\n`
)

Variables

This section is empty.

Functions

func CleanWS

func CleanWS(doc string) string

CleanWS takes a long string and left aligns it In other words, if you have a string in the midst of code, and all of its lines have at least the same level of indent as the first line, CleanWS will strip that indent from each line. There's an exception made for otherwise blank lines so that you don't need to maintain lines with only whitespace in the code.

func Regexp

func Regexp() *regexp.Regexp

Regexp returns a compiled *regexp.Regexp representing whitespace.

func Split

func Split(s string) []string

Split splits a string into chunks by contiguous blocks of whitespace.

func SplitN

func SplitN(s string, n int) []string

SplitN is similar to Split, but lets you specify the maximum number of chunks to return.

func Trim

func Trim(s string) string

Trim trims all leading and trailing whitespace from a string.

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL