Convención de nomenclatura de interfaz Golang
Solo publicaré mi código:
/*
* Role will ALWAYS reserve the session key "role".
*/
package goserver
const (
ROLE_KEY string = "role"
)
type Role string
//if index is higher or equal than role, will pass
type RolesHierarchy []Role
func (r Role) String() string {
return string(r)
}
func NewRole(session ServerSession) Role {
return session.GetValue(ROLE_KEY).(Role)
}
func (this Role) IsRole(role Role, hierarchy RolesHierarchy) bool {
if role == this {
return true
}
if len(hierarchy) == 0 {
return false
}
var thisI int = 0
var roleI int = 0
//Duped roles in hierarchy are verified in verifyConfig during parse
for i, r := range hierarchy {
if this == r {
thisI = i
}
if role == r {
roleI = i
}
}
//TODO I can probably condense what follows into one if
if thisI == 0 && roleI == 0 {
return false
}
return thisI >= roleI
}
func (this *Role) AssumeRole(session ServerSession, role Role) {
session.SetValue(ROLE_KEY, role)
*this = role
}
Cabe señalar que ServerSession también es una interfaz, llamar a "ServerSessioner" me parece raro.
Estoy jugando con la idea de crear una interfaz con IsRole () y AssumeRole (), sin embargo, "Roler" parece muy inestable. Me di cuenta de que realmente no conozco o nunca me he encontrado con convenciones de nombres para interfaces, aparte del sufijo estándar "er". Me parece recordar que la convención VS C ++ es simplemente lanzar una "I" frente a todo. ¿Es esto "idiomático"?
¿Alguna sugerencia?