2016-04-09 12 views
2

Googleのアプリエンジンでgoアプリを実行しようとしています。私はgoapp serverを実行すると、私はこのエラーを取得する:私はすべてのエラーを取得しないとアプリが正常に動作アプリエンジンなしでそれを実行した場合Googleアプリケーションエンジンのファイル競合ゴラン

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

:これは私のプロジェクトのレイアウトが

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

です。

+0

あなたはgoapp' 'で実行で説明したように、デバッグの経験を向上させ、ツールは、' GOPATH' ENV変数だけではなく、パッケージで定義されたあなたの囲碁ワークスペースで利用可能なパッケージを使用しています/アプリケーションのフォルダ内のファイルを移動します。したがって、 '$ GOPATH/src'フォルダに' model/model.go'ファイルがあります。これはそうですか? – icza

+0

@iczaはい '$ GOPATH/src/github.com/myService'の下に構築されたすべてのサービスは' model/model.go' – Rodrigo

+0

@iczaですが、 'github.com/myService/service1/model'の異なるパスを持っています 'github.com/myService/service2/model'はこれがまだ問題ですか?ようやく正解 – Rodrigo

答えて

3

私の経験によると、あなたのプロジェクトフォルダはあなたのGOPATHの下にもあるので、このエラーが出ます。 GOPATHとGOROOT ...これを実行すると、プロジェクトの下で宣言されたすべてのパッケージの重複したシンボルが見つかります。ここで

は、あなたが(あなたのプロジェクトは、そのガイドラインを破る)、いくつかのプロジェクトの構造のためにGoogleが助言し、そのうちの一つがわかります同じリンクの下でgo appengine documentation

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

で説明です:

Do not include any subdirectories in a module's directory.

アプリケーション定義とパッケージを含むリポジトリが必要な場合は、以下の構造を採用することをお勧めします。

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 

この構造はとても便利で、記事debugging Go appengine module with visual studio code

+0

。ありがとうございました – gleroyDroid

関連する問題