literal

package
v0.0.13 Latest Latest
Warning

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

Go to latest
Published: Oct 19, 2019 License: Apache-2.0 Imports: 4 Imported by: 12

Documentation

Overview

Package literal implements conversions to and from string representations of basic data types.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Unquote

func Unquote(s string) (string, error)

Unquote interprets s as a single- or double-quoted, single- or multi-line string, possibly with custom escape delimiters, returning the string value that s quotes.

Types

type QuoteInfo

type QuoteInfo struct {
	// contains filtered or unexported fields
}

QuoteInfo describes the type of quotes used for a string.

func ParseQuotes

func ParseQuotes(start, end string) (q QuoteInfo, nStart, nEnd int, err error)

ParseQuotes checks if the opening quotes in start matches the ending quotes in end and reports its type as q or an error if they do not matching or are invalid. nStart indicates the number of bytes used for the opening quote.

func (QuoteInfo) IsDouble

func (q QuoteInfo) IsDouble() bool

IsDouble reports whether the literal uses double quotes.

func (QuoteInfo) Unquote

func (q QuoteInfo) Unquote(s string) (string, error)

Unquote unquotes the given string. It must be terminated with a quote or an interpolation start. Escape sequences are expanded and surrogates are replaced with the corresponding non-surrogate code points.

Jump to

Keyboard shortcuts

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