MCPcopy Create free account
hub / github.com/github/gh-aw / ToValue

Method ToValue

pkg/workflow/templatables.go:122–130  ·  view source on GitHub ↗

ToValue returns the native Go value for use in map literals and JSON output: - an int for numeric literals (e.g. 30) - a string for GitHub Actions expressions (e.g. "${{ inputs.timeout }}") This is the canonical helper for producing a map[string]any entry; callers should prefer it over calling IsEx

()

Source from the content-addressed store, hash-verified

120// This is the canonical helper for producing a map[string]any entry;
121// callers should prefer it over calling IsExpression + IntValue/String manually.
122func (t *TemplatableInt32) ToValue() any {
123 if t.IsExpression() {
124 return string(*t)
125 }
126 if n, err := strconv.Atoi(string(*t)); err == nil {
127 return n
128 }
129 return string(*t)
130}
131
132// Ptr returns a pointer to a copy of t, convenient for constructing
133// *TemplatableInt32 values inline.

Callers 2

ToMapMethod · 0.80
ToMapMethod · 0.80

Calls 1

IsExpressionMethod · 0.95

Tested by

no test coverage detected