"Cannot find package" error when running "goapp tool cover"

663 views
Skip to first unread message

Ingo Jaeckel

unread,
Oct 15, 2014, 10:03:00 PM10/15/14
to golan...@googlegroups.com
Hi,

I am trying to convert my code coverage results into HTML by running the following.

$ goapp test -cover -test.v=true -test.coverprofile=c.out
$ goapp tool cover -html=c.out

I am using the Go GAE SDK (extracted to /Users/ingo/Downloads/go_appengine). I am running this from the root directory of my GAE app which is located in /Users/ingo/git/loyalty. This folder contains all my *.go files. All files belong to a package called "app".

The coverage information is collected just fine. But trying to convert them into HTML fails with this error:

goapp tool cover -html=c.out
cover: can't find "app.go": cannot find package "_/Users/ingo/git/loyalty/" in any of:
/Users/ingo/Downloads/go_appengine/goroot/src/pkg/_/Users/ingo/git/loyalty (from $GOROOT)
/Users/ingo/Downloads/go_appengine/gopath/src/_/Users/ingo/git/loyalty (from $GOPATH)

What does this mean and how can I fix it?

Thanks,
Ingo

Ingo Jaeckel

unread,
Oct 16, 2014, 7:34:38 PM10/16/14
to golan...@googlegroups.com
Is the structure of my app preventing me from running this correctly? Can I not use the "app" package that I am currently using? Or do I have to adjust my directory structure?

Is there another way to visualize the coverage results stored in the c.out file? I am not sure if the format is Go specific or if this can be parsed by existing tools.

Thanks,
Ingo

Tamás Gulácsi

unread,
Oct 17, 2014, 12:28:13 AM10/17/14
to golan...@googlegroups.com
Just a shot into the dark: try "go" instead of "goapp".

Ingo Jaeckel

unread,
Oct 17, 2014, 11:12:12 PM10/17/14
to golan...@googlegroups.com
After asking this question I was under the impression I can do this with the Go GAE SDK. Are you implying that I the coverage results can only be converted to HTML with go instead of Go's GAE SDK? If that's true, are there other things that work with go but not with goapp?

Thanks,
Ingo

$ goapp
Go is a tool for managing Go source code.

Usage:

goapp command [arguments]

The commands are:

    serve       starts a local development App Engine server
    deploy      deploys your application to App Engine
    build       compile packages and dependencies
    clean       remove object files
    env         print Go environment information
    fix         run go tool fix on packages
    fmt         run gofmt on package sources
    get         download and install packages and dependencies
    install     compile and install packages and dependencies
    list        list packages
    run         compile and run Go program
    test        test packages
    tool        run specified go tool
    version     print Go version
    vet         run go tool vet on packages

Ingo Jaeckel

unread,
Oct 25, 2014, 2:12:15 PM10/25/14
to golan...@googlegroups.com
Is it possible to collect code coverage information on Go GAE apps?

Thanks,
Ingo

Andreas Hulstkamp

unread,
Nov 2, 2014, 5:51:31 AM11/2/14
to golan...@googlegroups.com
Hi Ingo

Had trouble figuring this out too. 

It's a 2-step process.

  1. Generate coverfile, SLT: 
    goapp test -coverprofile c.out

  2. Use the go tool to launch a HTML representation of c.out: SLT: 
    go tool cover -html c.out

hth
Andy

Andreas Hulstkamp

unread,
Nov 2, 2014, 5:58:18 AM11/2/14
to golan...@googlegroups.com
Also, seems that the paths in your coverfile are invalid. Make them relative to the working directory and see if this helps.

David Cruz

unread,
May 14, 2015, 12:23:18 AM5/14/15
to golan...@googlegroups.com
Any luck with this yet? I'm facing the same problem... thanks!

Ingo Jaeckel

unread,
May 14, 2015, 9:29:39 PM5/14/15
to David Cruz, golan...@googlegroups.com
Hey David,

I posted an update about this on stackoverflow. There is an open issue related to it. As a temporary workaround I am doing the following 

goapp test -cover -test.v=true -test.coverprofile=c.out

sed -i -e "s#.*/\(.*\.go\)#\./\\1#" c.out
goapp tool cover -html c.out -o coverage.html
Hope that helps.

Thanks,
Ingo

On Thu, May 14, 2015 at 12:23 AM, David Cruz <davi...@gmail.com> wrote:
Any luck with this yet? I'm facing the same problem... thanks!

--
You received this message because you are subscribed to a topic in the Google Groups "golang-nuts" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/golang-nuts/9UswOWUvktw/unsubscribe.
To unsubscribe from this group and all its topics, send an email to golang-nuts...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

David Cruz

unread,
May 14, 2015, 10:41:30 PM5/14/15
to Ingo Jaeckel, golan...@googlegroups.com
That is perfect! Thanks a lot Ingo... you rock!
Reply all
Reply to author
Forward
0 new messages