du5591 2018-02-13 11:54
浏览 55

如何在Google App Engine开发服务器上使用第三方Go库?

In one of my .go files I have:

import (
  ...
  "github.com/stripe/stripe-go"
  "appengine"
  "appengine/datastore"
)

But when i run dev_appserver.py app.yaml I get the following error:

Can't find package "github.com/stripe/stripe-go" in $GOPATH

I've tried running go get github.com/stripe/stripe-go which I can see successfully installs to ~/go/src/github.com/stripe/stripe-go but the GAE dev server doesn't seem to look at that path for some reason.

gcloud app deploy works just fine, for what it's worth.

  • 写回答

1条回答 默认 最新

  • duanlun4411 2018-02-21 11:18
    关注

    Got the same error while testing the import "github.com/stripe/stripe-go" and fixed it by following the steps here "EDIT":

    export GOPATH=/home/user/go_project
    

    And a sample.go file in the example app's directory contains the following import statement:

    import (
      ...
      "github.com/stripe/stripe-go"
      "appengine"
      "appengine/datastore"
    )
    

    Then the gcloud tool will look for the "stripe/stripe-go" package in the following location when you run or deploy the app:

    /home/user/go_project/src/stripe/stripe-go
    

    Once the above is done, the devserver should look at the proper path after you've run "go get github.com/my_repo/packagename". hope it helps

    评论

报告相同问题?

悬赏问题

  • ¥15 netty整合springboot之后自动重连失效
  • ¥20 wireshark抓不到vlan
  • ¥20 关于#stm32#的问题:需要指导自动酸碱滴定仪的原理图程序代码及仿真
  • ¥20 设计一款异域新娘的视频相亲软件需要哪些技术支持
  • ¥15 stata安慰剂检验作图但是真实值不出现在图上
  • ¥15 c程序不知道为什么得不到结果
  • ¥40 复杂的限制性的商函数处理
  • ¥15 程序不包含适用于入口点的静态Main方法
  • ¥15 素材场景中光线烘焙后灯光失效
  • ¥15 请教一下各位,为什么我这个没有实现模拟点击