0

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!

Sekhmet
  • 523
  • 1
  • 7
  • 21

1 Answers1

5

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

Not_a_Golfer
  • 47,012
  • 14
  • 126
  • 92
  • 1
    It's one of the most important idioms in Go, and same goes for struct members - it's a simplistic way of saying public/private. Some people like it, some people hate it. Personally I like it. – Not_a_Golfer May 16 '14 at 19:43