From 6cd80ca66a1f706ff099a08571d60164eebe623d Mon Sep 17 00:00:00 2001 From: Matthew Dillon Date: Fri, 9 Jan 2015 06:40:18 -0900 Subject: [PATCH] model pointer string representation. --- models/characteristic_types.go | 5 +++++ models/characteristics.go | 5 +++++ models/genera.go | 5 +++++ models/species.go | 5 +++++ models/text_measurement_types.go | 5 +++++ models/unit_types.go | 5 +++++ models/users.go | 5 +++++ 7 files changed, 35 insertions(+) diff --git a/models/characteristic_types.go b/models/characteristic_types.go index ede904b..9f107c9 100644 --- a/models/characteristic_types.go +++ b/models/characteristic_types.go @@ -2,6 +2,7 @@ package models import ( "errors" + "fmt" "net/http" "strconv" "time" @@ -18,6 +19,10 @@ type CharacteristicType struct { DeletedAt NullTime `db:"deleted_at" json:"deletedAt"` } +func (m *CharacteristicType) String() string { + return fmt.Sprintf("%v", *m) +} + func NewCharacteristicType() *CharacteristicType { return &CharacteristicType{ CharacteristicTypeName: "Test Char Type", diff --git a/models/characteristics.go b/models/characteristics.go index 545933d..53e1606 100644 --- a/models/characteristics.go +++ b/models/characteristics.go @@ -2,6 +2,7 @@ package models import ( "errors" + "fmt" "net/http" "strconv" "time" @@ -19,6 +20,10 @@ type Characteristic struct { DeletedAt NullTime `db:"deleted_at" json:"deletedAt"` } +func (m *Characteristic) String() string { + return fmt.Sprintf("%v", *m) +} + func NewCharacteristic() *Characteristic { return &Characteristic{ CharacteristicName: "Test Characteristic", diff --git a/models/genera.go b/models/genera.go index 6bbd614..f33150d 100644 --- a/models/genera.go +++ b/models/genera.go @@ -2,6 +2,7 @@ package models import ( "errors" + "fmt" "net/http" "strconv" "time" @@ -18,6 +19,10 @@ type Genus struct { DeletedAt NullTime `db:"deleted_at" json:"deletedAt"` } +func (m *Genus) String() string { + return fmt.Sprintf("%v", *m) +} + func NewGenus() *Genus { return &Genus{GenusName: "Test Genus"} } diff --git a/models/species.go b/models/species.go index c705ca8..c8afebc 100644 --- a/models/species.go +++ b/models/species.go @@ -2,6 +2,7 @@ package models import ( "errors" + "fmt" "net/http" "strconv" "time" @@ -19,6 +20,10 @@ type Species struct { DeletedAt NullTime `db:"deleted_at" json:"deletedAt"` } +func (m *Species) String() string { + return fmt.Sprintf("%v", *m) +} + func NewSpecies() *Species { return &Species{SpeciesName: "Test Species"} } diff --git a/models/text_measurement_types.go b/models/text_measurement_types.go index 85a4ffd..d674169 100644 --- a/models/text_measurement_types.go +++ b/models/text_measurement_types.go @@ -2,6 +2,7 @@ package models import ( "errors" + "fmt" "net/http" "strconv" "time" @@ -18,6 +19,10 @@ type TextMeasurementType struct { DeletedAt NullTime `db:"deleted_at" json:"deletedAt"` } +func (m *TextMeasurementType) String() string { + return fmt.Sprintf("%v", *m) +} + func NewTextMeasurementType() *TextMeasurementType { return &TextMeasurementType{ TextMeasurementName: "Test Text Measurement Type", diff --git a/models/unit_types.go b/models/unit_types.go index 841fc26..a893242 100644 --- a/models/unit_types.go +++ b/models/unit_types.go @@ -2,6 +2,7 @@ package models import ( "errors" + "fmt" "net/http" "strconv" "time" @@ -19,6 +20,10 @@ type UnitType struct { DeletedAt NullTime `db:"deleted_at" json:"deletedAt"` } +func (m *UnitType) String() string { + return fmt.Sprintf("%v", *m) +} + func NewUnitType() *UnitType { return &UnitType{ Name: "Test Unit Type", diff --git a/models/users.go b/models/users.go index 9e067f4..60f3fc4 100644 --- a/models/users.go +++ b/models/users.go @@ -2,6 +2,7 @@ package models import ( "errors" + "fmt" "net/http" "strconv" "time" @@ -20,6 +21,10 @@ type User struct { DeletedAt NullTime `db:"deleted_at" json:"deletedAt"` } +func (m *User) String() string { + return fmt.Sprintf("%v", *m) +} + func NewUser() *User { return &User{Username: "Test User"} }