From a774338ccd753c78e3e4cc1e5d9ee7309c3fb28e Mon Sep 17 00:00:00 2001 From: dhax Date: Mon, 30 Oct 2017 00:00:20 +0100 Subject: [PATCH] remove slice pointers --- api/admin/accounts.go | 8 ++++---- auth/account.go | 2 +- database/admAccountStore.go | 4 ++-- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/api/admin/accounts.go b/api/admin/accounts.go index cdee723..fd0859c 100644 --- a/api/admin/accounts.go +++ b/api/admin/accounts.go @@ -20,7 +20,7 @@ var ( // AccountStore defines database operations for account management. type AccountStore interface { - List(f auth.AccountFilter) (*[]auth.Account, int, error) + List(f auth.AccountFilter) ([]auth.Account, int, error) Create(*auth.Account) error Get(id int) (*auth.Account, error) Update(*auth.Account) error @@ -87,11 +87,11 @@ func newAccountResponse(a *auth.Account) *accountResponse { } type accountListResponse struct { - Accounts *[]auth.Account `json:"accounts"` - Count int `json:"count"` + Accounts []auth.Account `json:"accounts"` + Count int `json:"count"` } -func newAccountListResponse(a *[]auth.Account, count int) *accountListResponse { +func newAccountListResponse(a []auth.Account, count int) *accountListResponse { resp := &accountListResponse{ Accounts: a, Count: count, diff --git a/auth/account.go b/auth/account.go index 6c68ec5..3b43125 100644 --- a/auth/account.go +++ b/auth/account.go @@ -23,7 +23,7 @@ type Account struct { Active bool `sql:",notnull" json:"active"` Roles []string `pg:",array" json:"roles,omitempty"` - Token []*Token `json:"token,omitempty"` + Token []Token `json:"token,omitempty"` } // BeforeInsert hook executed before database insert operation. diff --git a/database/admAccountStore.go b/database/admAccountStore.go index c0325ea..3e58c5c 100644 --- a/database/admAccountStore.go +++ b/database/admAccountStore.go @@ -26,7 +26,7 @@ func NewAdmAccountStore(db *pg.DB) *AdmAccountStore { } // List applies a filter and returns paginated array of matching results and total count. -func (s *AdmAccountStore) List(f auth.AccountFilter) (*[]auth.Account, int, error) { +func (s *AdmAccountStore) List(f auth.AccountFilter) ([]auth.Account, int, error) { a := []auth.Account{} count, err := s.db.Model(&a). Apply(f.Filter). @@ -34,7 +34,7 @@ func (s *AdmAccountStore) List(f auth.AccountFilter) (*[]auth.Account, int, erro if err != nil { return nil, 0, err } - return &a, count, nil + return a, count, nil } // Create creates a new account.