Standard library / flag

flag.UnquoteUsage()

Extracts a backquoted parameter label and removes its backquotes from help text. Expected stdout: 'path write to path\n'.

Formal Syntax & Structure

go syntaxgo
func UnquoteUsage(flag *Flag) (name string, usage string)

Parameters & Attributes

NameTypeDescription
flag*FlagFlag whose help text is inspected.

Return Value

(name string, usage string)

Extracts a backquoted parameter label and removes its backquotes from help text.

Working Example

Example Snippetgo
package main
import (  "flag"  "fmt")
func main() {  f := flag.NewFlagSet("demo", flag.ContinueOnError)  f.String("out", "", "write to `path`")  n, u := flag.UnquoteUsage(f.Lookup("out"))  fmt.Println(n, u)}
Go Reference