pagser icon indicating copy to clipboard operation
pagser copied to clipboard

Why there are "each" versions of functions?

Open mitar opened this issue 4 years ago • 1 comments

I think it could be simplified so that one could do:

type PageData struct {
	Link    string   `pagser:"a->attr(href)"`
	Links   []string `pagser:"a->attr(href)"`
}

The package could inspect the type associated with the tag and if it is slice, automatically assume "each" behavior. In general I think all functions should be returning slices, which then optionally are converted to an individual value (by default the first one, but you could set using ->Eq some other index).

mitar avatar Jan 05 '22 11:01 mitar

It like a good idea.

foolin avatar Oct 29 '22 02:10 foolin