Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: enable select current element for struct slice unmarshal #748

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

xzvwang
Copy link

@xzvwang xzvwang commented Jan 12, 2023

Once I met a html like this:

<div>
    <a href="url1">Name 1</a>
    <a href="url2">Name 2</a>
</div>

and I want extract the data as an array of name and url pair, so i write a selector:

[]*struct {
    Name string `selector:""`
    URL  string `selector:"" attr:"href"`
} `selector:"a"`

but the Unmarshal can not do it well, so i expand this function, add unmarshalString to handle if selector is empty string.

@xzvwang xzvwang changed the title fix: enable select current element for string selector fix: enable select current element for struct slice unmarshal Jan 12, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant