Skip to content

UnmarshalParam doesn't work #784

@sluchznak

Description

@sluchznak

Description

I want to unmarshal string param to array of strings

Checklist

  • Dependencies installed
  • No typos
  • Searched existing issues and docs

Expected behaviour

&{[city city.country]}

Actual behaviour

&{[city,city.country]}

Steps to reproduce

Working code to debug

type Expand []string

func (t *Expand) UnmarshalParam(param string) error {
	*t = Expand(strings.Split(param, ","))
	return nil
}

type HotelRequest struct {
	Expand Expand `json:"ex" form:"ex" query:"ex"`
}

then i try bind param:

requestModel := new(request.HotelRequest)
if err := c.Bind(requestModel); err != nil {
	log.Fatal(err)
}
fmt.Println(requestModel)

Version/commit

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions