Search code examples
gomartini

Can't use struct from own package


I created following file structure in $GOPATH/src

bitbucket.org/MyName/ProjectName

I have follwoing files here

ProjectName
 - controllers/
    - meController.go
 - app.go

In app.go I'm importing my controller like that:

import "bitbucket.org/MyName/ProjectName/controllers"

And in main func I'm trying to use it's method.

meController = new(controllers.meController)
m.Get("/", meController.Index)

My meController.go looks like this

package controllers

type meController struct {

}

func (controller *meController) Index () string {
  return "Hello World"
}

But I'm getting this error:

./app.go:5: imported and not used: "bitbucket.org/MyName/ProjectName/controllers"
./app.go:12: undefined: meController

I don't have any idea how to get this to work.

Any ideas?

Thanks!


Solution

  • In Go, every symbol that starts with lowercase is not exported by the package. call your struct MeController and you'll be fine.