Using Cloud SQL with Go

So I recently signed up for App engine using the standard environment for Go and everything has been running smooth. I created a Cloud SQL instance, a database and downloaded the SDK to deploy code to the servers. However I’m running into what seems to be a firewall issue when trying to get the queries to run and insert code into the database once deployed. The code works fine locally so my real question I guess is am I missing something in the app.yaml configuration file, do I need to allow an extra API or is there some technical issue I’m not aware of that needs to be resolved before Go can work with Cloud SQL in production.

Here are the steps I took

1.) Downloaded the SDK go for Go

2.) Created a Cloud SQL Instance

3.) Created a Databse

Then I deployed my code through the terminal window with this command “gcloud app deploy”

Code works fine and there is no server error, I appear to be connected but when I go through these links in that order (/create /insert /read) I get no data but I should. It works find using localhost:8080 on my mac but running on the cloud at my web address the queries don’t fire but I get no connection error. Please Help.

[github link to my code](https://github.com/eddiedonhill/golang-web/blob/master/cloudsql

Have you tried this guide?
https://cloud.google.com/appengine/docs/standard/go/cloud-sql/

It could be a IAM Permission issue (the Appengine account needs access to CloudSQL)

greetings Daniel

2 Likes

I haven’t used Cloud SQL but check if the API is enabled

1 Like

Thanks for the help guys, I figured out what was wrong. I wasn’t calling appengine.main() in my func init. That needs to be handled when running on the cloud.

2 Likes

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.