I'm serving some files dynamically using golang and the following code handles the actual serving of files:

        data, err := ioutil.ReadFile(file.Path)
        logo.RuntimeError(err)
        http.ServeContent(w, r, file.Name, time.Now(), bytes.NewReader(data))

Within the previous code "file" is simply a custom struct holding various information about the file.

The only problem with this code is that it results in me downloading a file called "download" whenever I call the specific handler. I'd like to give the file the user is downloading a custom name, or, rather, signify in a way that is as browser neutral as possible that I want the file to have a certain name.

I assume this might be doable using w.WriteHeader ? But I've been unable to find any examples or clear guidelines on how to do this.