https://play.golang.org/p/SBc-_7237V
I need to validate the images’ format and size, but of course, if an error occurs I need to save it in a variable (in this case infoMessage struct) , but due to I am using Ajax to handle the request I have no idea how can I pass the request over all the functions and then marshal the infoMessage struct and send it to the user if something wrong happens.
I’m able to send errors from validateFormatImgs
but I also need to send errors from validateSizeImgs
because of that I need the http.ResponseWritter
variable to send the JSON, but I don’t know how I can improve this code. I am kind of new in Golang maybe there is a better (sure there is one) way to do this, any tip or change is welcome!.