-2

I have following folder structure in my project folder. vendor folder added as suggested here.

my_project
   |
   main.go
   - vendor
       |
       - user_register
           | 
           - user_register.go

In user_register.go I have following function


func getEmail(register_response http.ResponseWriter, register_request *http.Request) {
...
}

When I try to import user_register package in my main.go, it gives an error.

I tried go install from my project folder, and I got

go install: no install location for directory /home/sachith/Documents/Personal/Projects/my_project outside GOPATH

Is there a way to solve this problem? Without moving my project into /home/sachith/go directory?

I have refereed following SO threads, but they didnt solve my problem. Golang import package inside package

Golang import package error

Sachith Muhandiram
  • 2,819
  • 10
  • 45
  • 94

1 Answers1

1

Is there a way to solve this problem? Without moving my project into [GOPATH]?

Yes: Use Go modules by turning GO111MODULE=on.

Volker
  • 40,468
  • 7
  • 81
  • 87