在灵活环境中将 Google App Engine 与 Google Cloud Storage 连接

Connect Google App Engine with Google Cloud Storage in flexible environment

我想从我的 GAE 应用程序连接到我的 Google Cloud MySQL 实例。我正在使用 github.com/go-sql-driver/mysql 驱动程序,并且我按照 tutorial. Apparently I can connect to the database without an error but when I want to make a request I get driver: bad connection and packets.go:33: unexpected EOF. I authorised both my local IP address and the GAE app to access my database and I can connect to it from my local machine and the mysql client without a problem. I have already tried setting up my app in the standard environment and followed the advice here 中指定的步骤进行操作,但它也不起作用。

这是我用来连接数据库的 Go 代码:

host := os.Getenv("DB_HOST")
user := os.Getenv("DB_USER")
pwd := os.Getenv("DB_PWD")
connectionInfo := fmt.Sprintf("%v:%v@tcp(%v:3306)/mobile_data?parseTime=true", user, pwd, host)
db, err := sql.Open("mysql", connectionInfo)

这是我的 app.yaml 文件:

runtime: go
vm: true
env_variables:
    "DB_HOST": "[Google Cloud MySQL Instance IPv4]"
    "DB_USER": "[User]"
    "DB_PWD": "[Password]"

非常感谢任何提示或建议!

This link 声明尚不支持 App Engine 柔性环境与第一代云 SQL 实例之间的实例级访问。如果您想连接到第二代云 SQL,则必须使用云 SQL 代理。
感谢@天舟给我指点link.