Error generating automated API doc using bee tool

Tarun Vashisth
Feb 4, 2017 · 1 min read

Recently, I was setting up beego api framework for creating apis in go. I was using features of bee tool to speed up things. One such feature is generating automated api document using swagger. After following all the steps mentioned in documentation, I end up in a helpless situation with an error message below which leaves me to figure out what actually went wrong

$ bee run -downdoc=true -gendoc=true
2017/02/02 12:29:58 INFO ▶ 0001 Using 'backend' as 'appname'
2017/02/02 12:29:58 INFO ▶ 0002 Loading default configuration...
2017/02/02 12:29:58 INFO ▶ 0003 Initializing watcher...
2017/02/02 12:29:58 INFO ▶ 0004 Watching:
.
.
.
2017/02/02 12:29:58 INFO ▶ 0009 Generating the docs...
2017/02/02 12:29:58 ERROR ▶ 0010 Failed to generate the docs

Digging into bee source code, I found that a child command bee generate doc failed with an error below:

______
| ___ \
| |_/ / ___ ___
| ___ \ / _ \ / _ \
| |_/ /| __/| __/
\____/ \___| \___| v1.6.2
2017/02/02 12:37:44 FATAL ▶ 0001 GOROOT environment variable is not set or empty

Unfortunately, this error is neither propagated nor mentioned in docs that your GOROOT must be set as environment variable. To fix this:

- Ensure your GOROOT is set. Check using go env
- Export this path in your ~/.bash_profile(on MacOS)

export GOROOT="/path/to/goroot"

Load you bash profile by opening a new terminal. This should help you fix the issue.

Tarun Vashisth

Computer Programmer

Welcome to a place where words matter. On Medium, smart voices and original ideas take center stage - with no ads in sight. Watch
Follow all the topics you care about, and we’ll deliver the best stories for you to your homepage and inbox. Explore
Get unlimited access to the best stories on Medium — and support writers while you’re at it. Just $5/month. Upgrade