Skip to content

Instantly share code, notes, and snippets.

@verdverm
Created May 20, 2020 21:21
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save verdverm/3455a4bdc1e8232f55ab8522f523f60f to your computer and use it in GitHub Desktop.
Save verdverm/3455a4bdc1e8232f55ab8522f523f60f to your computer and use it in GitHub Desktop.
Attributes function patch for Cue
func (v Value) Attributes() map[string]Attribute {
attrs := map[string]Attribute{}
// return empty
if v.path == nil || v.path.attrs == nil {
return attrs
}
// collect attribues
for _, a := range v.path.attrs.attr {
A := Attribute{internal.ParseAttrBody(token.NoPos, a.body())}
attrs[a.key()] = A
}
return attrs
}
@verdverm
Copy link
Author

This should go into the cue/test.go file, I put it next to the singular version of the function.

@verdverm
Copy link
Author

This should actually be returning a cue.Value, and when it does, it will be added into Cue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment