I recently started working with Go and ran into a small problem. Below is my code for saving a file into the "./images" directory. While the code works and the files are being saved into "./images", the file is also being saved into the root directory of the project simultaneously. TL;DR: File is being saved twice (into root, as well as target) when it should only be saved once in the target directory
// Save
imageSave, err := os.Open(imageOutput.Name())
if err != nil {
log.Fatal(err)
}
defer imageSave.Close()
dir := "./images"
dst, err := os.Create(filepath.Join(dir, filepath.Base(imageOutput.Name())))
if err != nil {
log.Fatal(err)
}
defer dst.Close()
defer imageOutput.Close()
_, err = io.Copy(dst, imageSave)
if err != nil {
log.Fatal(err)
}
Any help is appreciated!