You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository has been archived by the owner on Dec 23, 2022. It is now read-only.
I saw your comment that you don't know why the result is an array. I think it's because the GO method has a dual return type: (output *js.Object, err error)
I'm very new to GO and gopherjs (in fact I found your repo after spending loo long spinning my wheels on trying to do this exact thing: build a HCL2 parser for node.js), but from what I have seen the convention in GO is that errors are not thrown but signaled using this dual-return type pattern. I suspect that if you changed the signature to:
then the result via JS would not be enclosed in an array. I would hope that there is a way to make the JS version throw the error using the gopherjs lib. If I get some more time, I may try some things out and make a PR, but for now I just wanted to mention this.
But, thanks for making this repo. I was about to give up hope.
The text was updated successfully, but these errors were encountered:
I'm having the same issue. I'm writing a loader to allow you to require() HCL files. My initial implementation used the parseToString method, but due to the returned array I had to use JSON.stringify(parseToObject(hcl)[0]) instead.
I saw your comment that you don't know why the result is an array. I think it's because the GO method has a dual return type:
(output *js.Object, err error)
I'm very new to GO and gopherjs (in fact I found your repo after spending loo long spinning my wheels on trying to do this exact thing: build a HCL2 parser for node.js), but from what I have seen the convention in GO is that errors are not thrown but signaled using this dual-return type pattern. I suspect that if you changed the signature to:
then the result via JS would not be enclosed in an array. I would hope that there is a way to make the JS version throw the error using the gopherjs lib. If I get some more time, I may try some things out and make a PR, but for now I just wanted to mention this.
But, thanks for making this repo. I was about to give up hope.
The text was updated successfully, but these errors were encountered: