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!

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

报告相同问题?

悬赏问题

  • ¥60 用visual studio编写程序,利用间接平差求解水准网
  • ¥15 Llama如何调用shell或者Python
  • ¥20 谁能帮我挨个解读这个php语言编的代码什么意思?
  • ¥15 win10权限管理,限制普通用户使用删除功能
  • ¥15 minnio内存占用过大,内存没被回收(Windows环境)
  • ¥65 抖音咸鱼付款链接转码支付宝
  • ¥15 ubuntu22.04上安装ursim-3.15.8.106339遇到的问题
  • ¥15 blast算法(相关搜索:数据库)
  • ¥15 请问有人会紧聚焦相关的matlab知识嘛?
  • ¥15 网络通信安全解决方案