Convenção de nomenclatura da interface Golang
Vou apenas postar meu 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
}
Deve-se notar que o ServerSession também é uma interface, chamando "ServerSessioner" apenas para mim.
Estou brincando com a idéia de criar uma interface com IsRole () e AssumeRole (), no entanto "Roler" parece muito instável. Me ocorre que eu realmente não conheço ou já deparei com convenções de nomenclatura para interfaces, além do sufixo "er" padrão. Parece que me lembro que a convenção do VS C ++ é apenas jogar um "eu" na frente de tudo. Isso é "idiomático"?
Alguma sugestão?