Package leading to undefined variables, not importing correctly, read how to write go code

I read “how to write go code”, and my project is organized

src
github.com
package controllers
package models
main.go

Inside the project there are two packages,

models and controllers

When I import I use the

github.com/user/models” /
"github.com/user/controllers "

However whenever I try to actually use a package in my main.go file I cannot, and it comes up as undefined.

Ex. c:=models.NewController() where NewController() is a function in the models package.

Not sure how to proceed, any help greatly appreciated.

Are you missing the user directory between github.com and your packages?

Ideally it should be

$GOPATH/src/github.com/username/project/main.go
$GOPATH/src/github.com/username/project/models/
$GOPATH/src/github.com/username/project/controllers/

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.