goglide-golang

How to use custom package with glide


I use golang Masterminds/glide to manage package. here is my project:

$GOPATH/    
      bin/  
      pkg/
      src/
         go_test/
            long(own custom package: just print a "hello")  
            main.go  
            glide.yaml  
            vendor/  
                github.com/lib/pq   

the long package is used in main.go like :

 package main 
   import(
    "database/sql"
    "github.com/lib/pq"
    "long"
  )
  func main(
    ...
  }

the glide.yaml is:

package:  go_test
import:   
- package: github.com/lib/pq 

  when go run main.go the error is: can not found package long . if I put the long package into the vendor/ and then glide up
 it will show can not detect vcs about the "long" dependencies. but can run with project.
 so I want to know how to set that glide will skip the long package detect and the project can run .

note: I use the ignore: in the yaml. if add long to ignore .the project will can run because can't find long package.


Solution

  • Because the correct package name is a full path starting from /src directory in you project you should use "go_test/long" instead on just "long" in you import statement. And because it is your own code and not a vendor dependency it must not be under vendor directory.