Use pointer receiver more offen
This commit is contained in:
parent
6999b4e728
commit
c7569b5e54
59 changed files with 688 additions and 672 deletions
|
|
@ -5,7 +5,7 @@ import (
|
|||
)
|
||||
|
||||
// GetTags returns tags associated with this exercice.
|
||||
func (e Exercice) GetTags() (tags []string, err error) {
|
||||
func (e *Exercice) GetTags() (tags []string, err error) {
|
||||
if rows, errr := DBQuery("SELECT tag FROM exercice_tags WHERE id_exercice = ?", e.Id); errr != nil {
|
||||
return nil, errr
|
||||
} else {
|
||||
|
|
@ -25,7 +25,7 @@ func (e Exercice) GetTags() (tags []string, err error) {
|
|||
}
|
||||
|
||||
// AddTag assign a new tag to the exercice and registers it into the database.
|
||||
func (e Exercice) AddTag(tag string) (string, error) {
|
||||
func (e *Exercice) AddTag(tag string) (string, error) {
|
||||
tag = strings.Title(tag)
|
||||
if _, err := DBExec("INSERT INTO exercice_tags (id_exercice, tag) VALUES (?, ?)", e.Id, tag); err != nil {
|
||||
return "", err
|
||||
|
|
@ -35,7 +35,7 @@ func (e Exercice) AddTag(tag string) (string, error) {
|
|||
}
|
||||
|
||||
// DeleteTag delete a tag assigned to the current exercice from the database.
|
||||
func (e Exercice) DeleteTag(tag string) (int64, error) {
|
||||
func (e *Exercice) DeleteTag(tag string) (int64, error) {
|
||||
if res, err := DBExec("DELETE FROM exercice_tags WHERE id_exercice = ? AND tag = ?", e.Id, tag); err != nil {
|
||||
return 0, err
|
||||
} else if nb, err := res.RowsAffected(); err != nil {
|
||||
|
|
@ -46,7 +46,7 @@ func (e Exercice) DeleteTag(tag string) (int64, error) {
|
|||
}
|
||||
|
||||
// WipeTags delete all tag assigned to the current exercice from the database.
|
||||
func (e Exercice) WipeTags() (int64, error) {
|
||||
func (e *Exercice) WipeTags() (int64, error) {
|
||||
if res, err := DBExec("DELETE FROM exercice_tags WHERE id_exercice = ?", e.Id); err != nil {
|
||||
return 0, err
|
||||
} else if nb, err := res.RowsAffected(); err != nil {
|
||||
|
|
|
|||
Reference in a new issue