I am working on a Go project with the structure as this:
pages (folder)
-> faculty (folder)
> instructors.go
> professors.go
generalpages.go (inside pages folder)
generalpages.go
handles my Repository
pattern struct with the following declaration:
type Repository struct {
App *config.AppConfig
}
All common pages (eg "Home", "About") works properly having this type of declaration:
func (m *Repository) AboutPage(w http.ResponseWriter, r *http.Request) {
// some functionality
}
However, if I want to structure my pages and use the same declaration for my InstructorsPage
(inside instructor.go
) as follows, it doesn't work and the error in VSCode says: undeclared name
.
My understanding is that an object should be visible within the same package, but still it doesn't work. go build
is not throwing any error but when I use a routing package (chi
), it can't reference it correctly.