go-swagger: Generating spec cannot import dependencies

Problem statement

I’m unable to run the spec generator on my app. What am I doing wrong? https://gist.github.com/morenoh149/e44be6819bde86f52e7e

I get many errors of the form ... .go:10:2: could not import github.com/facebookgo/stackerr (cannot find package "github.com/ ...

Steps to reproduce

execute $ swagger generate spec -o ./swagger.json in project folder

About this issue

  • Original URL
  • State: closed
  • Created 8 years ago
  • Comments: 17 (9 by maintainers)

Most upvoted comments

I uninstalled go-swagger from brew, installed it from source and it worked. So strange. And no, I installed it through brew:

GOARCH="amd64"
GOBIN=""
GOEXE=""
GOHOSTARCH="amd64"
GOHOSTOS="darwin"
GOOS="darwin"
GOPATH="/Users/gsquire/gopath"
GORACE=""
GOROOT="/usr/local/Cellar/go/1.6.1/libexec"
GOTOOLDIR="/usr/local/Cellar/go/1.6.1/libexec/pkg/tool/darwin_amd64"
GO15VENDOREXPERIMENT="1"
CC="clang"
GOGCCFLAGS="-fPIC -m64 -pthread -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -fno-common"
CXX="clang++"
CGO_ENABLED="1"

I am running into this issue when trying to generate a swagger spec as well. I believe it is because I installed go with home brew on a mac so my library paths are different.

Command I am running: swagger generate spec File I am trying to generate with: https://gist.github.com/gsquire/cce277b4bd10ba283f4522e896dc91d6

Error trace:

/Users/gsquire/scratch/test-swagger.go:14:2: could not import fmt (cannot find package "fmt" in any of:
    /usr/local/go/src/fmt (from $GOROOT)
    /Users/gsquire/gopath/src/fmt (from $GOPATH))
/Users/gsquire/scratch/test-swagger.go:15:2: could not import net/http (cannot find package "net/http" in any of:
    /usr/local/go/src/net/http (from $GOROOT)
    /Users/gsquire/gopath/src/net/http (from $GOPATH))
/Users/gsquire/scratch/test-swagger.go:18:14: undeclared name: http
/Users/gsquire/scratch/test-swagger.go:18:38: undeclared name: http
/Users/gsquire/scratch/test-swagger.go:19:2: undeclared name: fmt
/Users/gsquire/scratch/test-swagger.go:23:2: undeclared name: http
/Users/gsquire/scratch/test-swagger.go:24:2: undeclared name: http