github.com/wtfutil/wtf@v0.43.0/modules/hibp/hibp_status.go (about) 1 package hibp 2 3 // Status represents the status of an account in the HIBP system 4 type Status struct { 5 Account string 6 Breaches []Breach 7 } 8 9 // NewStatus creates and returns an instance of Status 10 func NewStatus(acct string, breaches []Breach) *Status { 11 stat := Status{ 12 Account: acct, 13 Breaches: breaches, 14 } 15 16 return &stat 17 } 18 19 // HasBeenCompromised returns TRUE if the specified account has any breaches associated 20 // with it, FALSE if no breaches are associated with it 21 func (stat *Status) HasBeenCompromised() bool { 22 return stat.Len() > 0 23 } 24 25 // Len returns the number of breaches found for the specified account 26 func (stat *Status) Len() int { 27 if stat == nil || stat.Breaches == nil { 28 return 0 29 } 30 31 return len(stat.Breaches) 32 }