func FormValues(reader io.Reader, id string) (FormVars, error) {
	vars := FormVars{Inputs: make(map[string]string)}

	doc, err := goquery.NewDocumentFromReader(reader)
	if err == nil {
		// only interested in meta tag?
		if meta := doc.Find("meta[name=_csrf]"); id == "meta" {
			if meta.Length() != 1 {
				return vars, errors.New("meta not found")
			}

			csrf, exists := meta.Attr("content")
			if !exists {
				return vars, errors.New("meta attribute not found")
			}
			vars.Inputs["_csrf"] = csrf
			return vars, nil
		}

		form := doc.Find(id).First()
		if form.Length() != 1 {
			return vars, errors.New("form not found")
		}

		action, exists := form.Attr("action")
		if !exists {
			return vars, errors.New("form attribute not found")
		}
		vars.Action = action

		form.Find("input").Each(func(_ int, el *goquery.Selection) {
			if name, ok := el.Attr("name"); ok {
				vars.Inputs[name], _ = el.Attr("value")
			}
		})
	}

	return vars, err
}
// FormValues extracts FormVars from given HTML document
FormValues extracts FormVars from given HTML document
// FormValues extracts FormVars from given HTML document
func FormValues(reader io.Reader, id string) (FormVars, error) {
	vars := FormVars{Inputs: make(map[string]string)}
	doc, err := goquery.NewDocumentFromReader(reader)
	if err == nil {
		if meta := doc.Find("meta[name=_csrf]"); id == "meta" {
			if meta.Length() != 1 {
				return vars, errors.New("meta not found")
			}
			csrf, exists := meta.Attr("content")
			if !exists {
				return vars, errors.New("meta attribute not found")
			}
			vars.Inputs["_csrf"] = csrf
			return vars, nil
		}
		form := doc.Find(id).First()
		if form.Length() != 1 {
			return vars, errors.New("form not found")
		}
		action, exists := form.Attr("action")
		if !exists {
			return vars, errors.New("form attribute not found")
		}
		vars.Action = action
		form.Find("input").Each(func(_ int, el *goquery.Selection) {
			if name, ok := el.Attr("name"); ok {
				vars.Inputs[name], _ = el.Attr("value")
			}
		})
	}
	return vars, err
}
func FormValues ( reader io . Reader , id string ) ( FormVars , error ) { vars := FormVars { Inputs : make ( map [ string ] string ) } doc , err := goquery . NewDocumentFromReader ( reader ) if err == nil { if meta := doc . Find ( " " ) ; id == " " { if meta . Length ( ) != 1 { return vars , errors . New ( " " ) } csrf , exists := meta . Attr ( " " ) if ! exists { return vars , errors . New ( " " ) } vars . Inputs [ " " ] = csrf return vars , nil } form := doc . Find ( id ) . First ( ) if form . Length ( ) != 1 { return vars , errors . New ( " " ) } action , exists := form . Attr ( " " ) if ! exists { return vars , errors . New ( " " ) } vars . Action = action form . Find ( " " ) . Each ( func ( _ int , el * goquery . Selection ) { if name , ok := el . Attr ( " " ) ; ok { vars . Inputs [ name ] , _ = el . Attr ( " " ) } } ) } return vars , err }
FormValues extracts FormVars from given HTML document
FormValues extracts FormVars from given HTML document
// only interested in meta tag?