阅读背景:

为什么我不能在GAE上部署“goapp部署”,我就无法找到导入:github.com/go-sql-driver/mysql

来源:互联网 

Main problem: can't deploy with 'goapp deploy' to GAE, keep getting this message:

主要问题:不能将“goapp部署”部署到GAE,请继续获取此消息:

src/mygoprog.go:11: can't find import: "github.com/go-sql-driver/mysql"

src / mygoprog。go:11:找不到导入:github.com/go-sql-driver/mysql

I have deployed 'hello world' program that listens on port 8080 to GAE with no problems; now trying to deploy a more sophisticated program.

我已经部署了“hello world”程序,监听端口8080到GAE,没有任何问题;现在尝试部署一个更复杂的程序。

This works just fine to test locally: C:\mysql\src>go run mygoprog.go

这在本地测试是可行的:C:\mysql\src>运行mygoprog.go。

This does not when trying to deploy to GAE: C:\mysql>goapp deploy

当试图将其部署到GAE: C:\mysql>goapp部署时,这不会发生。

I've reinstalled goappengine and go language from scratch with cleaned up registry between uninstall and install. Any help would be appreciated.

我已经重新安装了goappengine,并在卸载和安装之间清理注册表。如有任何帮助,我们将不胜感激。

github install command(s): goapp get github.com/go-sql-driver/mysql also tried go get github.com/go-sql-driver/mysql

github安装命令:goapp获得github.com/go-sql-driver/mysql,也尝试获得github.com/go-sql-driver/mysql。

Source code (I've tried moving it around, the error follows the move to line 11 or 2 or whatever):

源代码(我尝试过移动它,错误跟随到第11行或第2行):

import (
    "database/sql"
    "io/ioutil"
    "encoding/json"
    "fmt"
    "net/http"
    "log"
)
import  _ "github.com/go-sql-driver/mysql"

Environment: Python 2.7 Windows 7 - 64 bit goappengine sdk version 1.9.1 mercurial 2.9.1

环境:Python 2.7 Windows 7 - 64位goappengine sdk版本1.9.1 mercurial 2.9.1。

Environment variables: GOPATH=C:\mysql\ GOROOT=C:\Go\

环境变量:GOPATH = C:\ mysql \ GOROOT = C:\ \

app.yml contents: application: skilled-nation-521 version: 1 runtime: go api_version: go1

yml内容:应用程序:技术国家521版本:1运行时:go api_version: go1。

handlers: - url: /.* script: _go_app

处理程序:- url:/。*脚本:_go_app

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ This does not work: C:\mysql>goapp deploy

~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~这并不工作:C:\ mysql > goapp部署

Results:
05:20 PM Application: skilled-nation-521; version: 1
05:20 PM Host: appengine.google.com
05:20 PM
Starting update of app: skilled-nation-521, version: 1
05:20 PM Getting current resource limits.
05:20 PM Scanning files on local disk.
05:20 PM Cloning 23 application files.
05:20 PM Compilation starting.
05:20 PM Compilation: 16 files left.
05:20 PM Error 422: --- begin server output ---
Compile failed:
2014/03/26 15:20:24 go-app-builder: build timing: 2├ù6g (171.487931ms total), 2├gopack (61.001119ms total), 0├ù6l (0 total)
2014/03/26 15:20:24 go-app-builder: failed running 6g: exit status 1



src/mygoprog.go:11: can't find import: "github.com/go-sql-driver/mysql"
--- end server output ---
05:20 PM Rolling back the update.
Error 422: --- begin server output ---

--- end server output --- error while running appcfg.py: exit status 1

---结束服务器输出—运行appcfg时出错。py:退出状态1

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Directory structure of c:\mysql:

~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~目录结构的c:\ mysql:

C:\mysql>dir
 Volume in drive C is OS
 Volume Serial Number is D2E8-63AC

 Directory of C:\mysql

03/26/2014  05:14 PM    <DIR>          .
03/26/2014  05:14 PM    <DIR>          ..
03/25/2014  04:17 PM               119 app.yaml
03/26/2014  05:14 PM    <DIR>          pkg
03/26/2014  05:17 PM    <DIR>          src
               1 File(s)            119 bytes
               4 Dir(s)  20,781,137,920 bytes 


C:\mysql>cd src

C:\mysql\src>dir
 Volume in drive C is OS
 Volume Serial Number is D2E8-63AC

 Directory of C:\mysql\src

03/26/2014  05:17 PM    <DIR>          .
03/26/2014  05:17 PM    <DIR>          ..
03/26/2014  05:14 PM    <DIR>          github.com
03/26/2014  05:14 PM             2,666 mygoprog.go
               1 File(s)          2,666 bytes
               3 Dir(s)  20,781,387,776 bytes free

C:\mysql\src>cd github.com

C:\mysql\src\github.com>dir
 Volume in drive C is OS
 Volume Serial Number is D2E8-63AC

 Directory of C:\mysql\src\github.com

03/26/2014  05:14 PM    <DIR>          .
03/26/2014  05:14 PM    <DIR>          ..
03/26/2014  05:14 PM    <DIR>          go-sql-driver
               0 File(s)              0 bytes
               3 Dir(s)  20,781,387,776 bytes free

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~

1 个解决方案

#1


1  

The import path must work from the folder where the app.yaml resides. So you need to move the github.com folder up there. (Similar question: How to import local Golang package in GAE)

导入路径必须从app.yaml所在的文件夹中工作。你需要移动github.com文件夹。(类似的问题:如何在GAE中导入本地的Golang包)

Note: You should never test your App Engine stuff with the go executable, always use the goapp tool.

注意:你永远不应该用go可执行程序来测试你的应用程序引擎,总是使用goapp工具。


分享到: