diff --git a/cmd/backend/firebase.go b/cmd/backend/firebase.go index 8fc03a3..b208576 100644 --- a/cmd/backend/firebase.go +++ b/cmd/backend/firebase.go @@ -8,9 +8,7 @@ import ( "google.golang.org/api/option" ) -type Client struct { - *auth.Client -} +type Client struct{ *auth.Client } func NewClient(c *Config) (*Client, error) { var err error diff --git a/cmd/backend/sessions.go b/cmd/backend/sessions.go index 971fc7f..eb55dfc 100644 --- a/cmd/backend/sessions.go +++ b/cmd/backend/sessions.go @@ -10,9 +10,7 @@ import ( "github.com/gorilla/sessions" ) -type CookieStore struct { - sessions.CookieStore -} +type CookieStore struct{ sessions.CookieStore } func NewKey() ([]byte, error) { key := make([]byte, 32) diff --git a/cmd/frontend/articles.go b/cmd/frontend/articles.go index d788cd3..d90baa0 100644 --- a/cmd/frontend/articles.go +++ b/cmd/frontend/articles.go @@ -29,7 +29,7 @@ func WriteArticle(c *b.Config, db *b.DB, s *b.CookieStore) http.HandlerFunc { return } - type editorHTMLData struct { + type htmlData struct { Title string Description string Content string @@ -37,12 +37,12 @@ func WriteArticle(c *b.Config, db *b.DB, s *b.CookieStore) http.HandlerFunc { Tags []*b.Tag Mode int } + var data htmlData - var data editorHTMLData if session.Values["article"] == nil { - data = editorHTMLData{} + data = htmlData{} } else { - data = session.Values["article"].(editorHTMLData) + data = session.Values["article"].(htmlData) } data.Mode = EditMode @@ -211,11 +211,10 @@ func ShowRejectedArticles(c *b.Config, db *b.DB, s *b.CookieStore) http.HandlerF return } - type htmlData struct { + data := new(struct { MyIDs map[int64]bool RejectedArticles []*b.Article - } - data := new(htmlData) + }) data.RejectedArticles, err = db.GetCertainArticles(false, true) if err != nil { @@ -530,16 +529,14 @@ func ReviewArticleForDeletion(c *b.Config, db *b.DB, s *b.CookieStore) http.Hand return } - type htmlData struct { + var err error + data := new(struct { Title string Description string Content template.HTML Tags []*b.Tag ID int64 - } - - var err error - data := new(htmlData) + }) data.ID, err = strconv.ParseInt(r.PathValue("id"), 10, 64) if err != nil { diff --git a/cmd/frontend/users.go b/cmd/frontend/users.go index 848a033..fc38db4 100644 --- a/cmd/frontend/users.go +++ b/cmd/frontend/users.go @@ -277,12 +277,12 @@ func ShowAllUsers(c *b.Config, db *b.DB, s *b.CookieStore, action string) http.H return } - type htmlData struct { + data := new(struct { Users map[int64]*b.User Action string - } + }) - data := &htmlData{Action: action} + data.Action = action data.Users, err = db.GetAllUsers() if err != nil { log.Println(err)