Casbin Forum runs on Casnode, the open-source Discourse-style forum. Try the Casnode demo →
Casbin Forum

What do you think about golang generics instead of using interface{} for the Response? Tho generics requires go 1.18 and go.mod is currently set to 1.16.

Generic

type Response[T1, T2 any] struct {
    Status string `json:"status"`
    Msg    string `json:"msg"`
    Sub    string `json:"sub"`
    Name   string `json:"name"`
    Data   T1     `json:"data"`
    Data2  T2     `json:"data2"`
}

var resp Response[object.Organization, object.User]
1views
2users
1 minread

Want to share a tip I learnt somewhere: if something does work, don't change it.

1 / 2
Jan 2024