简体   繁体   中英

How to run/debug a beego app using Gogland (go language)

Im using Gogland (IDE from JetBrains. Version 1.0 Preview/EAP Feb, 10 2017) to create a Beego web app. I can run it from command line with:

bee run

and everything works.

However if I run it from the IDE with the following configuration 在此输入图像描述

when I go to localhost:8080 it says it can not find the template file in path:

在此输入图像描述

I thought it was related to GOPATH, but then I realized that Gogland IDE is probably running

go run main.go

instead of

bee go

and when I checked runing

go run main.go

from the shell, I got the same issue: cant find the template.


I even tried to run the 'bee' command from the IDE. I partially succeed. With this configuration: 在此输入图像描述 I can run it from the IDE, but the debugger doesn't stop in any breakpoint. IE: I can only run (but not debug) it, from Gogland.

So my question is how to make gogland IDE debug a beego project

You cannot change the IDE to run the bee command. However, you can change the run configuration to a Go Application by going to Run | Edit Configurations | + | Go Application select the package type then type the full package name ( github.com/dlsniper/demo for example if your package main is under GOPATH/src/github.com/dlsniper/demo) and make sure the working directory is where you need it to be. Hope it helps.

Use Delve and Remote Debugging Configuration(start from gogland eap9).

Run your bee app like:

bee dlv -package="app_name" -port=2345

On gogland make configuration Go Remote with port which you set previous.

I resolve this by setting:

beego.BConfig.WebConfig.ViewsPath="/Users/xxxxx/go/src/xxxxxxx/views"  // your views directory

by the way: if you have staticpath , you should also use absolute path. eg: beego.SetStaticPath("/static", "/Users/xxx/go/src/xxxx/static")

it's only used when debug, if you publish your program, you should remove this hard code config.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM