dounei5721 2013-02-19 16:21
浏览 45
已采纳

Go中的特殊软件包名称

When importing a custom sub-package named qp with

"pkgname/qp"

the compiler complains with

... imported and not used: "pkgname/qp"
... undefined: qp

so obviously it seems to have a problem with the package name qp, because when I change it to

qp "pkgname/qp"

the errors are gone.

Are there any "reserved" or invalid package names? Why is this happening?

  • 写回答

3条回答 默认 最新

  • dt3358 2013-02-19 17:58
    关注

    I'm going to guess that the files in package qp don't start with a line that says

    package qp
    

    They probably specify a different package name. When a package is imported, the name in the package declaration is the one that is available under; if that doesn't match the import path, you can get errors like this.

    In other words, you imported "pkgname/qp", but the compiler is calling it something else, because you called it something else in the package statement. You don't refer to somethingElse in your code, so the import is unused. Then you refer to qp, which isn't defined anywhere (even though it looks like it was), because "pkgname/qp" doesn't define qp.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(2条)

报告相同问题?

悬赏问题

  • ¥15 stm32开发clion时遇到的编译问题
  • ¥15 如何用Labview在myRIO上做LCD显示?(语言-开发语言)
  • ¥15 Vue3地图和异步函数使用
  • ¥15 C++ yoloV5改写遇到的问题
  • ¥20 win11修改中文用户名路径
  • ¥15 win2012磁盘空间不足,c盘正常,d盘无法写入
  • ¥15 用土力学知识进行土坡稳定性分析与挡土墙设计
  • ¥70 PlayWright在Java上连接CDP关联本地Chrome启动失败,貌似是Windows端口转发问题
  • ¥15 帮我写一个c++工程
  • ¥30 Eclipse官网打不开,官网首页进不去,显示无法访问此页面,求解决方法