Skip to content

Add string matching helper functions to Go templates #6370

@iilyak

Description

@iilyak

In a gh extension (written in bash) I needed to implement a fuzzy matching on the content of a label. Specifically I needed to exclude issues which has a label with project: prefix. However, I couldn't find any functions in https://github.com/cli/go-gh/blob/trunk/pkg/template/template.go or standard go templates to support startsWith.

There are quite a few string related function in https://github.com/Masterminds/sprig including the function which would help in my case:

  • contains
  • hasPrefix
  • hasSuffix
  • regexMatch

If inclusion of sprig into go-gh is not an option, would it be possible to implement at least contains in the pkg/template/template.go?

Metadata

Metadata

Labels

enhancementa request to improve CLIgh-helprelating to the gh help commandhelp wantedContributions welcome

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions