duanjurong1347 2014-12-09 21:28
浏览 15
已采纳

外部包装来自get

I want use code.google.com/p/google-api-go-client/drive/v2 and other.

My app is structured like:

+-- MyApp
+---- app.yaml
+---- main.go
+---- src/
+------ ...external package...

My GOPATH is equal to "MyApp/src"

In my main.go I have `// +build !appengine"

I can't launch goapp serve, I get

2014/12/09 22:20:32 Can't find package "code.google.com/p/google-api-go-client/googleapi" in $GOPATH: cannot find package "code.google.com/p/google-api-go-client/googleapi" in any of:

and many other who said the same.

How I can use package download from a go get?

Thank you.

  • 写回答

1条回答 默认 最新

  • doushansu9012 2014-12-10 01:22
    关注

    Typically a gopath looks like this: (I have added random projects to it to demonstrate what it could look like)

    • gopath
      • src
        • code.google.com
          • p
            • google-api-go-client
              • etc
        • github.com
          • fluffle
            • goirc
        • rohan.com <- This is where your own projects go(or in code.google.com or github.com)
          • my_random_project
            • main.go
            • helper.go
          • my_app_engine_project
            • app
              • app.yaml
              • my_app_engine_project.go
            • routes
              • random_rest_route.go
            • process
              • random_route_logic.go
      • pkg
      • bin

    Your $GOPATH$ enviroment variable should point to that root folder which contains src, pkg and bin.

    So when you go get a package from github for example it'l be put in the github.com src folder, and that's when you'll be able to use that library in your own projects.

    Usage Example

    So for example, if I need the fluffle/goirc library from github, I'l type:

    go get github.com/fluffle/goirc
    

    The library will then be placed in:

    gopath/src/github.com
    

    And I can use the library by importing it with:

    import (
         "github.com/fluffle/goirc/client"
    )
    

    And then use it

    client.NewConfig("My User Name")
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥100 支付宝网页转账系统不识别账号
  • ¥15 基于单片机的靶位控制系统
  • ¥15 AT89C51控制8位八段数码管显示时钟。
  • ¥15 真我手机蓝牙传输进度消息被关闭了,怎么打开?(关键词-消息通知)
  • ¥15 下图接收小电路,谁知道原理
  • ¥15 装 pytorch 的时候出了好多问题,遇到这种情况怎么处理?
  • ¥20 IOS游览器某宝手机网页版自动立即购买JavaScript脚本
  • ¥15 手机接入宽带网线,如何释放宽带全部速度
  • ¥30 关于#r语言#的问题:如何对R语言中mfgarch包中构建的garch-midas模型进行样本内长期波动率预测和样本外长期波动率预测
  • ¥15 ETLCloud 处理json多层级问题