Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
542 views
in Technique[技术] by (71.8m points)

google-app-engine - 外部包装来自get(external package from go get)

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

(我想使用code.google.com/p/google-api-go-client/drive/v2等。)

My app is structured like:

(我的应用程序的结构如下:)

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

My GOPATH is equal to "MyApp/src"

(我的GOPATH等于“ MyApp / src”)

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

(在我的main.go中,我有`// + build!appengine“)

I can't launch goapp serve , I get

(我无法启动goapp serve ,我得到了)

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 ?

(如何使用包下载从go get ?)

Thank you.

(谢谢。)

  ask by Druxtan translate from so

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

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

(通常,gopath看起来像这样:(我在其中添加了随机项目以演示它的外观))

  • gopath

    (gopath)

    • src

      (src)

      • code.google.com

        (code.google.com)

        • p

          (p)

          • google-api-go-client

            (google-api-go-client)

            • etc

              (等等)

      • github.com

        (github.com)

        • fluffle

          (松软)

          • goirc

            (古尔克)

      • rohan.com <- This is where your own projects go(or in code.google.com or github.com)

        (rohan.com <- 这是您自己的项目所在的地方(或在code.google.com或github.com中))

        • my_random_project

          (my_random_project)

          • main.go

            (main.go)

          • helper.go

            (helper.go)

        • my_app_engine_project

          (my_app_engine_project)

          • app

            (应用程式)

            • app.yaml

              (app.yaml)

            • my_app_engine_project.go

              (my_app_engine_project.go)

          • routes

            (路线)

            • random_rest_route.go

              (random_rest_route.go)

          • process

            (处理)

            • random_route_logic.go

              (random_route_logic.go)

    • pkg

      (包)

    • bin

      (箱子)

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

(您的$ GOPATH $环境变量应指向包含src,pkg和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.

(因此,例如,当您从github 获取软件包时,它将被放在github.com src文件夹中,这样您就可以在自己的项目中使用该库了。)

Usage Example

(使用范例)

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

(因此,例如,如果我需要来自github的fluffle / goirc库,请输入:)

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")

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...