Giter Club home page Giter Club logo

Comments (7)

axw avatar axw commented on July 19, 2024

I would suggest using the go/build package to locate the package, and read sources from there. Something like:

import "go/build"
...
pkg, err := build.Import("github.com/imosquera/uploadthis", "", build.FindOnly)
...

Then you can use pkg.Dir to construct your paths. Will this work for your tests?

from gocov.

imosquera avatar imosquera commented on July 19, 2024

Nope, I still get the same error:

Panic: can't open config fileopen /var/folders/qy/zmrxj1t14mnbxsxrz9gtknxc0000gn/T/withmock126237784/path/src/github.com/imosquera/uploadthis/fixtures/sample-config.yaml: no such file or directory (PC=0x14CA1)

I tried by using the GOPATH but I realized that had changed as well during the gocov testing.

Perhaps when gocov moves the gopath it should move ALL files in the package wether they're .go files or not since the code may depend on them.

What do you think?

from gocov.

imosquera avatar imosquera commented on July 19, 2024

Or perhaps just an environment variable or an exported variable somewhere that gives me the original GOPATH gocov changes it.

from gocov.

axw avatar axw commented on July 19, 2024

Ah, okay, I see the problem.

Gocov purposely does not copy subdirectories. If it did, then that directory would get picked up and mask the one in the original $GOPATH. In your case it doesn't matter, but in others it does. You could just copy all the originals over, but that's expensive.

Try this: pkg, err := build.Import("github.com/imosquera/uploadthis/fixtures", "", build.FindOnly)

Since you're passing "FindOnly", it doesn't care that there's no Go files in it.

from gocov.

imosquera avatar imosquera commented on July 19, 2024

Ok that worked! thanks again.

from gocov.

imosquera avatar imosquera commented on July 19, 2024

One more question. This might be out of your control, but thought I'd ask incase you can quickly help:

I'm using gocov with withmock (http://godoc.org/github.com/qur/withmock) and it comes back with this error:

cannot find package "github.com/imosquera/uploadthis/fixtures" in any of:
/var/folders/qy/zmrxj1t14mnbxsxrz9gtknxc0000gn/T/gocov761928724/src/pkg/github.com/imosquera/uploadthis/fixtures (from $GOROOT)
/var/folders/qy/zmrxj1t14mnbxsxrz9gtknxc0000gn/T/withmock190339487/path/src/github.com/imosquera/uploadthis/fixtures (from $GOPATH)

any quick fixes?

from gocov.

axw avatar axw commented on July 19, 2024

Ok that worked! thanks again.

Cool. You're welcome. I'll close this now that the original issue is resolved.

I'm using gocov with withmock (http://godoc.org/github.com/qur/withmock) and it comes back with this error:
...
any quick fixes?

Sorry, I have never used withmock, so I'm not sure what that error is about.

from gocov.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.