Standard library / strconv

strconv.Unquote()

Decodes a complete single-, double- or backquoted Go literal into its string value. Returns an error on malformed syntax or trailing material. Expected stdout: '"a\\tb" <nil>\n'.

Formal Syntax & Structure

go syntaxgo
func Unquote(s string) (string, error)

Parameters & Attributes

NameTypeDescription
sstringInput text to parse, inspect or quote.

Return Value

(string, error)

Decoded or parsed value and error; inspect the error before using the result.

Working Example

Example Snippetgo
package main
import (  "fmt"  "strconv")
func main() {  v, e := strconv.Unquote(`"a\tb"`)  fmt.Printf("%q %v\n", v, e)}
Go Reference