I'm using the Echo web framework. One of the requests I need it to handle is to query an pgsql and return the data in CSV format. https://echo.labstack.com/guide/response I believe it would be something like:
func(c echo.Context) (err error) {
data := []byte(//the CSV formated data??)
return c.Blob(http.StatusOK, "text/csv", data)
}
The thing is I couldn't find a great way to query the db and get the data in CSV format 64byte encoded. The closest I could find is the package sqltocsv https://github.com/joho/sqltocsv but I couldn't make it work.
Is there a nice and clean way to do it?