How do I reference project packages correctly? I have the following folder structure:
/sbp
/models.go
/controllers.go
/main.go
In main.go
I'd like to call my controller action from sbp.controllers
. I can't seem to find a way to correctly reference it
main.go
package main
import (
"net/http"
...
"github.com/pressly/chi"
)
var sess = session.Must(session.NewSession(&aws.Config{
Region: aws.String("ap-southeast-1"),
}))
var dynamo = dynamodb.New(sess)
func main() {
r := chi.NewRouter()
r.Get("/", GetInvestments) // How do I call sbp.controller.GetInvestments?
r.Post("/", AddInvestment)
http.ListenAndServe(":8080", r)
}
sbp/controller.go
package sbp
import (
"net/http"
"time"
"github.com/pressly/chi/render"
)
// AddInvestment Adds an investment
func AddInvestment(w http.ResponseWriter, r *http.Request) {
...
}
// GetInvestments Gets list of investments
func GetInvestments(w http.ResponseWriter, r *http.Request) {
...
}
I tried importing "sbp/controller", or even "github.com/jiewmeng/finance/sbp/controller" but they seem to be auto removed my VSCode, so I think its invalid?