MCPcopy Index your code
hub / github.com/go-task/task / ToCacheMap

Method ToCacheMap

taskfile/ast/vars.go:100–120  ·  view source on GitHub ↗

ToCacheMap converts Vars to an unordered map containing only the static variables

()

Source from the content-addressed store, hash-verified

98// ToCacheMap converts Vars to an unordered map containing only the static
99// variables
100func (vars *Vars) ToCacheMap() (m map[string]any) {
101 if vars == nil || vars.om == nil {
102 return nil
103 }
104 defer vars.mutex.RUnlock()
105 vars.mutex.RLock()
106 m = make(map[string]any, vars.Len())
107 for k, v := range vars.All() {
108 if v.Sh != nil && *v.Sh != "" {
109 // Dynamic variable is not yet resolved; trigger
110 // <no value> to be used in templates.
111 continue
112 }
113 if v.Live != nil {
114 m[k] = v.Live
115 } else {
116 m[k] = v.Value
117 }
118 }
119 return m
120}
121
122// Merge loops over other and merges it values with the variables in vars. If
123// the include parameter is not nil and its it is an advanced import, the

Callers 5

TestVars_ToCacheMapFunction · 0.95
ResetCacheMethod · 0.80
ResolveRefFunction · 0.80
ReplaceWithExtraFunction · 0.80
GetFromVarsFunction · 0.80

Calls 2

LenMethod · 0.95
AllMethod · 0.95

Tested by 1

TestVars_ToCacheMapFunction · 0.76