Skip to content
This repository has been archived by the owner on Feb 26, 2019. It is now read-only.

Godep save issue when importing lib/pq #348

Closed
njohns-grovo opened this issue Dec 8, 2015 · 2 comments
Closed

Godep save issue when importing lib/pq #348

njohns-grovo opened this issue Dec 8, 2015 · 2 comments

Comments

@njohns-grovo
Copy link

Hello,
I'm running into a little bit of an issue vendoring dependencies that includes import _ "github/lib/pq"

Error:
godep: found packages oid (doc.go) and main (gen.go) in $GOPATH/src/github.com/lib/pq/oid

Directory Tree

.
├── main.go
└── subp
    └── subp.go

main.go:

package main

import (
    "fmt"
    "github.com/taion809/godeptest/subp"
    "log"
)

func main() {
    fmt.Println("Testing godep save -r ./...")
    s, err := subp.NewSubp("postgres", "postgres://root:root@localhost:5432/db")
    if err != nil {
        log.Fatal(err)
    }

    defer s.Close()
    err = s.Ping()
    if err != nil {
        log.Fatal(err)
    }

    fmt.Println("Worked")
}

subp/subp.go:

package subp

import (
    "github.com/jmoiron/sqlx"
    _ "github.com/lib/pq"
)

type Subp struct {
    db *sqlx.DB
}

func NewSubp(driver, addr string) (*Subp, error) {
    db, err := sqlx.Open(driver, addr)
    if err != nil {
        return nil, err
    }

    return &Subp{db: db}, nil
}

func (s *Subp) Close() error {
    if s.db != nil {
        return s.db.Close()
    }

    return nil
}

func (s *Subp) Ping() error {
    return s.db.Ping()
}
@njohns-grovo njohns-grovo changed the title Godep save issue when using lib/pq Godep save issue when importing lib/pq Dec 8, 2015
@njohns-grovo
Copy link
Author

Update, I reverted to 8956568 and it's functioning as expected

@freeformz
Copy link

@njohns-grovo Yeah v32 should be okay atm. Sorry about that. I think I was being too optimistic with my use of build.Context. I'll add a test to duplicate this and bang on the new package evaluation code to fix it.

freeformz pushed a commit that referenced this issue Dec 8, 2015
freeformz pushed a commit that referenced this issue Dec 8, 2015
I tried to use build.Context to handle most of the grunt work, but that
didn't work out that well.

So now we use it to help us find the package and then we use
ast.ParseFile to parse the *.go files in a package and then fill in the
rest of the build.Package

We ignore all `// +build ignore` tagged files.

Fixes #348
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants