Where does GO look for google-cloud-sdk ? What should GOPATH be?

前端 未结 1 1465
眼角桃花
眼角桃花 2020-12-15 23:24

I\'m having trouble setting up Go App engine on osX. Should the google-cloud-sdk path be in GOROOT or GOPATH?

I put the google-cloud-sdk in /usr/local

It loo

相关标签:
1条回答
  • 2020-12-16 00:08

    It goes in neither $GOROOT or $GOPATH. Just unpack it to your $HOME directory and run the installer. If necessary, add it to your $PATH by adding this line to your .bash_profile.

    export PATH=$HOME/google-cloud-sdk:$PATH
    

    Make sure you grab the golang SDK as well with gcloud components install app-engine-go https://cloud.google.com/appengine/docs/standard/go/download

    DO NOT change your path to include the src dir in google-cloud-sdk/platform/google_appengine/goroot/src. That will break things. You leave your $GOPATH to be your normal installation. Using the App Engine SDK for Go automatically uses the sources in that dir without any manipulation.

    Also, you should NEVER MANUALLY change $GOROOT unless you plan on compiling a new Go version from source (as in a new version of the language). It will automatically set the proper $GOROOT for you. https://dave.cheney.net/2013/06/14/you-dont-need-to-set-goroot-really

    If your install is messed up beyond reason (happened to me once), just remove the cloud SDK and any references to it in your $PATH. Also completely uninstall the regular Go installation. Then start from scratch. Install Go, unpack google-cloud-sdk, run installer (add to $PATH if needed), gcloud components install app-engine-go. Voila.

    When developing for App Engine, your go sources go into your REGULAR $GOPATH. They DO NOT go in google-cloud-sdk/... anywhere. To run the dev_appserver locally, run dev_appserver.py [path-to-source] where the given path contains your code and the app.yaml. I usually cd in to my project path (e.g. cd $HOME/go/src/myproject) and run with dev_appserver.py ./. https://cloud.google.com/appengine/docs/standard/go/tools/using-local-server

    Deployment is covered here. https://cloud.google.com/appengine/docs/standard/go/tools/uploadinganapp

    EDIT: Folder structure.

    $GOPATH = $HOME/go

    Location for google-cloud-sdk folder

    0 讨论(0)
提交回复
热议问题