drtzb06222 2014-05-18 15:37
浏览 93

在Google Go上进行项目,导入图书馆

everyone.

I am new to Go language and currently I am trying to understand the basics of building Go applications. I met the following problem.

For example, I am using other libraries in my project. I have them locally, on my computer, so my project works fine.

I am loading my code on github and another programmer download it. As I understand, my code won't work, because this programmer doesn't have the libraries I used.

So the question is: What is the best way to share my project with all libraries it has? Should I upload these libraries in the separate repositories? Then to use my project, people need to look inside the code to detect which libraries I am using to download them one by one?

For example, in Java there is such thing like Maven or Ant, which downloads all required dependencies. Is there any tools like this for Go?

Let's call the main file of my project main.go And I am using my own library: mathutil.go

what is the best way to make this project run on other computers?

  • 写回答

1条回答 默认 最新

  • douyao3895 2014-05-18 15:51
    关注

    Go's dependencies work very much like using Maven or IVY transitive dependencies. When someone does "go get" of your package, anything you depend on will automatically download.

    For example, in your source:

    import "github.com/foo/bar"
    

    go will automatically download that to your $GOPATH/src/github.com/foo/bar along with your code.

    Assuming the third party libs you use are hosted in a public repo (ie: github) then people don't need to do anything.

    If the libraries you used are not available on a public repo, you will need to post them somewhere assuming their licensing allows.

    Take a look at golang.org/doc/code.html for more details

    评论

报告相同问题?

悬赏问题

  • ¥15 matlab 用yalmip搭建模型,cplex求解,线性化处理的方法
  • ¥15 qt6.6.3 基于百度云的语音识别 不会改
  • ¥15 关于#目标检测#的问题:大概就是类似后台自动检测某下架商品的库存,在他监测到该商品上架并且可以购买的瞬间点击立即购买下单
  • ¥15 神经网络怎么把隐含层变量融合到损失函数中?
  • ¥15 lingo18勾选global solver求解使用的算法
  • ¥15 全部备份安卓app数据包括密码,可以复制到另一手机上运行
  • ¥20 测距传感器数据手册i2c
  • ¥15 RPA正常跑,cmd输入cookies跑不出来
  • ¥15 求帮我调试一下freefem代码
  • ¥15 matlab代码解决,怎么运行