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.
When SQL server suspects the primary filegroup of the database to be damaged or if the database file is missing, the database status is set to ‘Suspect’. Also, there are a wide range of errors that could result in SQL database in suspect mode .
When connecting to the SQL Server database for instance, if you find a message indicating that the database is in the suspect mode, it means the server suspects the primary filegroup of the database to be damaged.
It describes step-wise instructions to fix the ‘SQL server suspect database’ issue by running Transact-SQL (T-SQL) commands in SQL Server Management Studio (SSMS). Also, it provides an alternative solution to restore the database using a SQL Recovery tool. When SQL database goes into suspect mode, it becomes inaccessible.
Many common build errors may occur as a result of rebuilding your app while using ng serve or running ng build or ng build --prod directly. Module Not Found One of the most common Angular errors is the infamous "Module not found" error.
What you see is a compiler warning, but the app will run.
Your condition is always true
:
contentType != "image/jpeg" || contentType != "image/png"
You compare a string
variable to 2 different string
values (using not equal), so one of them will surely be true
, and true || false
is always true
.
Most likely you need logical AND: I assume you want to test if the content type is neither JPEG nor PNG:
if contentType != "image/jpeg" && contentType != "image/png" {
return
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With