问:出现构建错误“无效的导入路径”

I'm stuck on running the BeeGO app using "bee run" it says enter image description here

The thing is I've already have setup properly my GOPATH to D:/Web Dev/GO/BeeGO/test-project/ and also routers path does exist and I've tried to manual build the file but it doesn't generate an .exe file.

Anyone knows how to fix this?

I'm using Windows 8.1 Pro (64-bit)

Thanks

That's not how you import a package.

The import path is relative to $GOPATH/src. use:

import "quickstart/routers"

Finally fixed the bug from the framework,

What I did:

in main.go import from "D:/Web Dev/GO/BeeGO/test-project/quickstart/routers"

I changed it to _"../quickstart/routers" make sure to include _ this means to import the library even if it is not used,

Then in the routers/router.go I changed the import path "D:/Web Dev/GO/BeeGO/test-project/quickstart/controllers" to "../controllers"

It seems BeeGO doesn't generate the template properly and caused the build to fail.

GO expects the directory structure under $GOPATH in following ways as described in code organization:

$GOPATH/src  <--- where your source code goes
       /pkg
       /bin

Instead of placing your source files directly under $GOPATH (D:/Web Dev/GO/BeeGO/test-project/ for your case), you want to move your code under $GOPATH/src.

D:/Web Dev/GO/BeeGO/test-project/src/main.go
D:/Web Dev/GO/BeeGO/test-project/src/quickstart/routers/routers.go
D:/Web Dev/GO/BeeGO/test-project/src/quickstart/controllers/controllers.go

import path should be always starting from $GOPATH/src. routers.go can be always imported as import "quickstart/routers" and controllers.go can be imported as import "quickstart/controllers".

Another possiblity for this error, is when you copy-paste code from the internet, and

import "quickstart/routers"

became

import "quickstart/routers "

due to bugs in some CMS/Blog systems (notice the space at the end before the closing quote...).