- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我在使用 go 时遇到了构建问题。我想知道这是编译器中的错误还是代码的问题。
// 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
}
suspect or: contentType != "image/jpeg" || contentType != "image/png"
最佳答案
您看到的是编译器警告,但应用程序将运行。
您的情况总是true
:
contentType != "image/jpeg" || contentType != "image/png"
你比较一个
string
可变为 2 个不同的
string
值(使用不相等),所以其中之一肯定是
true
, 和
true || false
总是
true
.
if contentType != "image/jpeg" && contentType != "image/png" {
return
}
关于go - 构建时出错,得到 : "suspect or ",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/62470008/
我在使用 go 时遇到了构建问题。我想知道这是编译器中的错误还是代码的问题。 // removed the error handling for sake of clarity file, _ :=
我在 Linux 服务器上运行网站。这个服务器运行很多网站,其中大部分是CMS,主要是WordPress。 有时某些东西会将我的文件从 wp-db.php 重命名为 wp-db.php.suspect
我在 magento 中制作了我的自定义模块,我在其中动态设置了折扣。我为此使用以下代码。但是当我完成付款程序时,订单状态应该是“processing”,但订单状态不是“Susspected Frau
自过去 4 天以来,我们在生产服务器(AWS EC2 实例)上遇到了一个奇怪的问题,该问题仅针对一个站点,即 SugarCRM。 问题是 /home/site_folder/public_html/i
当我执行任务compile在我的 sbt 项目中,我收到以下错误消息: [warn] Found version conflict(s) in library dependencies; some a
我收到一 strip 有上述通知的消息“我的网站上有可疑的黑客攻击通知。我不确定这里发生了什么,但是,我注意到列出了一些页面,它们不属于我的网站?? 有没有人收到过同样的信息?如果是这样,你做了什么来
最近我的 wordpress 网站被黑了,我通过重新安装 wp-content 文件夹的备份版本并在网站中运行和修复 wordfence 插件来解决这个问题。但是我的网站显示错误 500,当我发现问题
这个问题之前在这里被问过,但我没有得到答案。所以我再问一遍,有没有哪位天才解决了这个问题,然后帮我解决。 我在我的 magneto 商店中使用 Paypal 付款方式,它非常适合下订单,状态为待处理,
请参阅下面的 EDIT#2 了解可能的根本原因 我的 Django 线程/进程(同时使用 'method=threaded' 和 'method=prefork' 时会发生同样的事情),每 10 分钟
我有一个 Pandas 数据框,其中有两列名为“crashtype”和“crashloc” 我应用了 K-means 聚类并创建了一个名为“Clusters”的新列来存储聚类值。 现在我想打印集群 1
我正在尝试确定我的 web 应用程序中是否存在内存泄漏。我正在使用 VisualVM 和 JMeter 来加载测试和观察堆。 我昨天将堆转储保存到文件并下载了 Eclipse Memory Analy
我正在对现有网络服务进行故障排除。它以前工作得很好,但现在对 postgreSQL 数据库的基于 SOAP 的请求导致“未知错误:获取 http header 时出错”错误。 在查找这个问题时,我遇到
我是一名优秀的程序员,十分优秀!