so I want to make my project having a project sets like this
GoTraining
-Controllers
ListController
-Service
ListService that doing business process and
calling data Access Object (DAO) to get data
-DAO
List query and Model(Const)
-.gitignore
-config.conf
-main.go
-readme.md
that just the picture of my structure , and now come where I get confused I create a package in dao called customerDao.go and write all of my query inside const and I try to make a function called queryFilter with queryType as the parameter and I want to search the const base on the queryType I got as parameter for some reason it give me an error message said that
"Syntax Error : unexpected const, expecting expression(8,16)"
can anyone tell me what I do wrong here?
It seems you're assuming that queryGetAllCustomer
"belongs to" const
. Const is not a scope but just an access modifier though, these two snippets produce identical results:
const (
queryGetAllCustomer = "..."
queryGetOneCustomer = "..."
)
// and...
const queryGetAllCustomer = "..."
const queryGetOneCustomer = "..."
You can therefore simply reference the value with queryGetAllCustomer
(or dao.QueryGetAllCustomer
from another package, had it been exported):
queryText := queryGetAllCustomer