deoren / notes

Various notes for topics I'm learning
2 stars 0 forks source link

Golang | Relative import paths #66

Open deoren opened 5 years ago

deoren commented 5 years ago

Found. I was able import local package with GOPATH by creating a subfolder of package1 and then importing with import "./package1" in binary1.go and binary2.go scripts like this :

binary1.go

...
import (
        "./package1"
      )
...

So my current directory structure looks like this:

myproject/
├── binary1.go
├── binary2.go
├── package1/
│   └── package1.go
└── package2.go

I should also note that relative paths (at least in go 1.5) also work; for example:

import "../packageX"