Standard library / strconv
strconv.QuotedPrefix()
Returns the initial valid quoted Go literal in s (single, double or backquoted), without unquoting it. Returns an error if the input does not start with such a literal. Expected stdout: '"hi" <nil>\n'.
Formal Syntax & Structure
go syntaxgo
func QuotedPrefix(s string) (string, error)Parameters & Attributes
| Name | Type | Description |
|---|---|---|
| s | string | Input 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.QuotedPrefix(`"hi" trailing`) fmt.Println(v, e)}