It's pretty simple. First, create and open a file using os.Create
.
out, err := os.Create("filename.pdf)
if err != nil {
return err
}
defer out.Close()
Next, use io.Copy()
to download the content.
_, err = io.Copy(out, resp.Body)
You can take a look at this for reference.