I'm encountering a build issue with go. I'm wondering if it's a bug in the compiler or a problem with the code.
// removed the error handling for sake of clarity
file, _ := c.FormFile("file")
openedFile, _ := file.Open()
buffer := make([]byte, 512)
n, _ := openedFile.Read(buffer)
contentType := http.DetectContentType(buffer[:n])
// doesn't work
if contentType != "image/jpeg" || contentType != "image/png" {
return
}
// works
if contentType != "image/jpeg" {
return
}
else if contentType != "image/png" {
return
}
error suspect or: contentType != "image/jpeg" || contentType != "image/png"
fyi " c.FormFile("file") " is form Gin gonic. but it shouldnt really matter.