can not build an example program in golang workspace

Issue

I’m trying to use golang workspace to manage my golang project, but there’s a very strange problem that I can not get one module with specific name (example/apps/albireo) built with error: package example/apps/albireo is not in GOROOT.

I have my test code submitted in https://github.com/archsh/go-workspace-example, and here’s the project structure:

.:
apps  go.work  Makefile

./apps:
albi  albireo  albireo1  gliese

./apps/albi:
go.mod  main.go

./apps/albireo:
go.mod  main.go

./apps/albireo1:
go.mod  main.go

./apps/gliese:
go.mod  main.go

Each module has only one simple main func inside, but when I try to build the modules, only the example/apps/albireo was failed:

> make
Building gliese ...
Building albi ...
Building albireo1 ...
Building albireo ...
package example/apps/albireo is not in GOROOT (/opt/go/src/example/apps/albireo)
make: *** [Makefile:7: albireo] Error 1

And I’m using go1.8.3 under linux.

Regards.

Solution

It’s a typo in your go.mod file inside of albireo folder. It should be:

module example/apps/albireo

instead of

module example/apps/albiero

Answered By – Endre Simo

Answer Checked By – David Marino (GoLangFix Volunteer)

Leave a Reply

Your email address will not be published.