Google app engine file conflict golang

So, I'm trying to run the go go application with the google engine. When I start goapp server , I get this error:

 go-app-builder: Failed parsing input: app file model.go conflicts with same file imported from GOPATH 

This is my project layout:

 . ├── model │ └── model.go ├── reqres │ └── reqres.go ├── app.yaml ├── service.go ├── main.go └── transport.go 

If I run it without an application, I get no errors and the application is working fine.

+2
source share
1 answer

In my experience, you are getting this error because your project folder is also under your GOPATH. "goapp" seems to clone your project folder and build it against the GOPATH and GOROOT environments ... By doing this, it finds duplicate characters for the entire package that was declared in your project.

Here is the explanation in go appengine documentation

If you include package sources in GOPATH, you must be careful not to place the source code in directories or in any directories of your App Engine project containing app.yaml files. If this happens, the package can be downloaded twice, once for a path relative to the module directory and once for a fully qualified path. This can cause minor problems, so the Go SDK scans your project and your GOPATH, detects this case and reports it as an error.

Follow the same link to find some Google tips for your project structure, and one of them (your project violates this guide):

Do not include subdirectories in the module directory.

If you need a repository defining your application and sending packages, I recommend that you accept the folliwing structure:

 projectRoot |- modules | |- myModule1 | | |- init.go // router pattern to handler | | |- myModule1.yaml // configuration for the module | |- myModule2 | |- init.go // router pattern to handler | |- myModule2.yaml // configuration for the module | |- pkg | |- myModule1 | | |- *.go // sources, subfolders(packages) | | // with handlers and business code | |- myModule2 | | |- *.go // sources, subfolders(packages) // with handlers and business code 

This structure is convenient and improves debugging work, as described in the article debugging. Go to appengine module with visual studio code.

+3
source

Source: https://habr.com/ru/post/1438893/


All Articles