Skip to content
This repository was archived by the owner on Dec 23, 2022. It is now read-only.
This repository was archived by the owner on Dec 23, 2022. It is now read-only.

parse methods are returning an array #1

Description

@markmelville

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:

func parseToObject(input string) (output *js.Object)

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions