Golang http client with excel upload

I have following struct
type Upload_sgpa_f struct {
Finyear int binding:"required"
Boardlevel string binding:"required"
Useraadhaar int binding:"required"
Excel *multipart.FileHeader form:"excel" binding:"required"
var upload_sgpa_f Upload_sgpa_f
upload_sgpa_f.Finyear = nFinyear
upload_sgpa_f.Useraadhaar = nUseraadhaar
upload_sgpa_f.Boardlevel = sBorad

how to assign file to this property upload_sgpa_f.Excel

I have tried following code
// open file handle
fh, err := os.Open(fileInfo.Name())
if err != nil {
fmt.Println(“error opening file”)
return err
defer func(fh *os.File) {
err := fh.Close()
if err != nil {

to assign file to Excel property . It is not working

AFAIK there is no Excel-support in the standard library so you’ll have to provide a bit more context about which library you are using.

BTW: did you know you can use markdown-formatting on this forum? You can make your code look a bit nicer on here. Try it out at https://markdown-it.github.io/

I would like to upload excel file with go http client ( post method )

That means you are probably using Microsoft’s Office 365 REST or GraphQL API? If so, a pointer to the API-endpoint could tell us more.

Or maybe you want to use a go-library that already wraps around said API-endpoints? If so, a link to this library would be needed to learn more.

Anyhow, this looks like a recently updated library that can read/write Excel-files locally, without depending on an external service: https://github.com/qax-os/excelize.

I need go gin server and client application sample code.

For uploading excel or any file

Go gin for server post request.
Http post request from go client by using http package.

Here’s an example to do it with the Gin-framework:

And here’s an example with the Echo-framework (to me it looks more interesting than Gin):

But both of these assume that your client is a web-browser which makes it more complex since you have to do form-handling and stuff.

I’m pretty sure I could hack together a simple http-server and -client without any HTML-stuff in between to just send binary files if that’s ultimately what you want to do? You could even use raw UDP- or TCP-sockets if both client and server or on a local network or if all ports all open but HTTP would be safer for avoiding firewalls etc on the public Internet.

I need Golang http client request .

Through html and angular we have already implemented.

Now I need from Golang client

This is solved

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.