I have created a dao level to wrap the database operations, each table has its own dao type.

Now, each dao need to write a Get() method to get a record by id. And I have repeat that code for each new table.

Wondering is it possible to write a BaseDao in go, with a single Get() method, so that I don't have to write this code 2 times?

(This is very common & easy in Java, due to its oo feature, since go is very different, I'm not sure is this possible)

Refer: - Question I have asked on SO: https://stackoverflow.com/questions/66996922

Comment From: github-actions[bot]

This issue has been automatically marked as stale because it has been open 60 days with no activity. Remove stale label or comment or this will be closed in 30 days

Comment From: NoSugarCoffee

Maybe can't. Because go dose not support genrics before go 1.18.

I think extract dao layer maybe a anti-pattern if you want to use hook.

Comment From: kuchaguangjie

But go 1.18 is here now.

Comment From: jinzhu

yeah, so it is possible now, and nothing related to GORM?