doushang2023 2015-01-15 03:25
浏览 40
已采纳

在主软件包中无法识别的导入更新

I'm working on a project and have a couple of packages that I've created which I'm importing in my main project.

Now when I take code and move it into an external package I can call it's functions fine from my main project. But once I add new functions to my external package, I always get an undefined func... error during the build process.

I've tried rebuilding my external package.. but no luck. The only way I've been able to update the reference to my custom package, has been to rename the external package & folder.

For instance, If I have the following in /project/blah/blah.go:

package blah

func DoSomethingCool(s string) {
    fmt.Print(s)
}

I can call this func in my main application (project/web/main.go) as blah.DoSomethingCool("Hello World"). Now this works as expected. But now if I update package blah to:

package blah

func DoSomethingCool(s string) {
    fmt.Print(s)
}

func DoSomethingElseEvenCooler(p string, q string) {
    fmt.Print(
        fmt.Sprint(p, q),
    )
}

I cannot call blah.DoSomethingElseEvenCooler("p", "q") even with a rebuild of blah. I end up with a func undefined error.

However if I rename blah to foo and rename the path to /project/foo/foo.go, I can call foo.DoSomethingElseEvenCooler("p", "q") perfectly fine. Seems like the reference to package blah is not being updated even though it has changed. Is there a way to force this while I'm building my main project?

Or am I just missing something?

  • 写回答

1条回答 默认 最新

  • dongli7870 2015-01-15 03:54
    关注

    Phew... Running

    go install
    

    on the external package fixed my issues. Thanks!

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 echarts动画效果失效的问题。官网下载的例子。
  • ¥60 许可证msc licensing软件报错显示已有相同版本软件,但是下一步显示无法读取日志目录。
  • ¥15 Attention is all you need 的代码运行
  • ¥15 一个服务器已经有一个系统了如果用usb再装一个系统,原来的系统会被覆盖掉吗
  • ¥15 使用esm_msa1_t12_100M_UR50S蛋白质语言模型进行零样本预测时,终端显示出了sequence handled的进度条,但是并不出结果就自动终止回到命令提示行了是怎么回事:
  • ¥15 前置放大电路与功率放大电路相连放大倍数出现问题
  • ¥30 关于<main>标签页面跳转的问题
  • ¥80 部署运行web自动化项目
  • ¥15 腾讯云如何建立同一个项目中物模型之间的联系
  • ¥30 VMware 云桌面水印如何添加