我爱占星网 我爱占星网
首页
编程
java
php
前端
首页 编程 java php 前端

高朗的布尔型

How do I return a true or false from a function and then check it. This code returns an error: mismatched types func() bool and bool

func d() bool {
    var e bool
    return e
}

if d == true {
    fmt.Printf("true")
}

You're comparing the actual function to true, not the function result, you need to call the function, e.g.

func d() bool {
    var e bool
    return e
}

if d() {
    fmt.Printf("true")
}

近期文章

  • Golang解组JSON列表
  • 具有自己实现的处理程序的服务器未连续侦听
  • Golang异步和CPU使用率
  • 是否有任何便捷的方法来获取没有类型断言的JSON元素?
  • Golang HTML中继器
  • 为什么我不能键入assert空接口?
  • go中的结构的内存分配
  • Golang在将“ {}”主体解码为struct时不产生错误
  • 连接拒绝后,Go程序退出
  • 如何使用golang打印到浏览器控制台中[重复]
  • 错误:redisstor函数主体外部的非声明语句
  • 附加到[] byte,写入文件并读取后,Go出现问题
  • 没有看到结构Golang的公共功能
  • 如何连接用不同语言编写的客户端-服务器
  • 执行.go文件时出错。 即使安装了go也无法识别
  • Base64编码不会因无效字符而失败[关闭]
  • 如何解决“缺少表的FROM子句条目”错误
  • 自己的结构体数组的JSON编码
  • 转到:无法运行非主程序包?
  • 如何在golang中打印json值[关闭]

Copyright ©2022 我爱占星 All Rights Reserved.

浙ICP备2022030071号-1

部分图文来自网络,如有侵犯您的版权,请告诉我们删除

友情链接:代码精华