Code Monkey home page Code Monkey logo

Comments (4)

mark-kubacki avatar mark-kubacki commented on August 18, 2024

That's a subtle one! Indeed, the README is not up-to-date on this. We have to go through an assignment for this to work (your non-commented code):

form := new(LoginForm)
if errs := binding.Bind(req, form); errs.Handle(resp) {
    return
}

see http://golang.org/ref/spec#Address_operators


  1. func (e *Errors) Handle(response http.ResponseWriter) bool {
  2. func Bind(req *http.Request, userStruct FieldMapper) Errors {

from binding.

mholt avatar mholt commented on August 18, 2024

Nice find. And @wmark thanks for pointing out the discrepancy.

I could change the Handle method to have a value receiver, which would enable that convenient, chained one-liner, rather than having to separate the assignment into a different statement. I tried this locally and confirmed that the example in the README still works, including that one line that is currently broken.

Making the change is simple. But I'm not sure if there are other implications of changing the receiver on that method from pointer to value. Can you think of any? If there aren't any obvious implications that I'm overlooking, I'll just make the change and resolve this issue.

from binding.

mark-kubacki avatar mark-kubacki commented on August 18, 2024

I don't see anything relevant here. Let's do it.

from binding.

mark-kubacki avatar mark-kubacki commented on August 18, 2024

Here's Rob Pike's comment on a related matter:

https://groups.google.com/d/msg/golang-nuts/INedfATw74A/XrIPT6gkB7kJ

from binding.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.