Home > Blockchain >  Import a specific package inside a GitHub repository
Import a specific package inside a GitHub repository

Time:11-22

Intention

I intend to import exactly this package (subdirectory) to reuse its methods and types:

https://github.com/hemantasapkota/go-convexhull/tree/master/convexhull

Which is inside this repository:

https://github.com/hemantasapkota/go-convexhull

Tried

I tried to import the whole repository:

import (
    "github.com/hemantasapkota/go-convexhull"
)

But go get github.com/hemantasapkota/go-convexhull is throwing errors. Since its main.go file contains import "github.com/hemantasapkota/glu" which is a private repository.

Question

How can I import just the package convexhull inside a sub-directory of that repository? I mean, I don't need its main.go and its troubles.

Of course, I can copy over the files of convexhull sub-directory/package into my project. But I'm looking for a way to just simply import it from GitHub. Any idea?

CodePudding user response:

This worked:


import (
    "github.com/hemantasapkota/go-convexhull/convexhull"
)

However, when building, I received this error which I need to figure out:

Build Error: go test -c -o /tmp/__debug_bin930480706 -gcflags all=-N -l .
package printer/app/threed/detect/dental
    imports github.com/hemantasapkota/go-convexhull/convexhull
    imports github.com/go-gl/gl: build constraints exclude all Go files in /home/m3/go/pkg/mod/github.com/go-gl/gl@v0.0.0-20190320180904-bf2b1f2f34d7 (exit status 1)
  •  Tags:  
  • go
  • Related