Go-Flags VSCode snippet
Snippet for generating go-flags parameters in VS Code.
- Type
CMD+SHIFT+P
, writeSnippets
, and selectConfigure User snippets
- Type
go
and selectgo.json (Go)
- Add snippet
"Go-Flag": {
"prefix": "gflag",
"description": "Generate stub for go-flags package",
"body": "$1 ${2:string} `long:\"${1/([a-z]+)(?=[A-Z])|([A-Z])(?=[A-Z])|([A-Z][a-z]+)(?=$)|([A-Z][a-z]+)|([a-z]+)(?=$)/${1:/downcase}${1:+-}${2:/downcase}${2:+-}${3:/downcase}${4:/downcase}${4:+-}${5:/downcase}/g}\" env:\"${1/([a-z]+)(?=[A-Z])|([A-Z])(?=[A-Z])|([A-Z][a-z]+)(?=$)|([A-Z][a-z]+)|([a-z]+)(?=$)/${1:/upcase}${1:+_}$2${2:+_}${3:/upcase}${4:/upcase}${4:+_}${5:/upcase}/g}\" description:\"$3\"`"
}
In the code type gflag
and hit tab
References: