1

I was working on a Go project in a directory that was not in my GOPATH. I was using relative imports.

I am trying to move the project into my GOPATH so I can stop using relative imports, but I keep getting unexpected directory layout errors.

I've checked the Go docs "how to write Go code" but I still can't see what the problem is.

The GOPATH is currently

/Users/M/go

The GOROOT is currently

/usr/local/Cellar/go/1.14.1/libexec

The project is currently located in

/Users/M/go/src/github.com/code/project

I am trying to make the following imports:

package aws_service

import (
    "github.com/project/server/DB"
)

Where "github.com/project/server/DB" is another package I created within my project.

What am I doing wrong?

mii
  • 11
  • 1
  • It is hard to tell from your description what is `project` and what is `code` and if `project` in `github.com/code/project` and `github.com/project/server/DB` is same. When using `GOPATH` your projects need to be checked out in predefined [GitHub Layout](https://github.com/golang/go/wiki/GithubCodeLayout) which is `$GOPATH/src/github.com///packages...`. Try to fix your example to be less ambiguous. – blami May 27 '20 at 03:35
  • This may help https://stackoverflow.com/a/59015137/1349518 – dwurf May 27 '20 at 03:43
  • Use Go modules. Read How to Write Go Code and show your go.mod. – Volker May 27 '20 at 04:34

0 Answers0