model pointer string representation.

This commit is contained in:
Matthew Dillon 2015-01-09 06:40:18 -09:00
parent 52a680dcd7
commit 6cd80ca66a
7 changed files with 35 additions and 0 deletions

View file

@ -2,6 +2,7 @@ package models
import ( import (
"errors" "errors"
"fmt"
"net/http" "net/http"
"strconv" "strconv"
"time" "time"
@ -18,6 +19,10 @@ type CharacteristicType struct {
DeletedAt NullTime `db:"deleted_at" json:"deletedAt"` DeletedAt NullTime `db:"deleted_at" json:"deletedAt"`
} }
func (m *CharacteristicType) String() string {
return fmt.Sprintf("%v", *m)
}
func NewCharacteristicType() *CharacteristicType { func NewCharacteristicType() *CharacteristicType {
return &CharacteristicType{ return &CharacteristicType{
CharacteristicTypeName: "Test Char Type", CharacteristicTypeName: "Test Char Type",

View file

@ -2,6 +2,7 @@ package models
import ( import (
"errors" "errors"
"fmt"
"net/http" "net/http"
"strconv" "strconv"
"time" "time"
@ -19,6 +20,10 @@ type Characteristic struct {
DeletedAt NullTime `db:"deleted_at" json:"deletedAt"` DeletedAt NullTime `db:"deleted_at" json:"deletedAt"`
} }
func (m *Characteristic) String() string {
return fmt.Sprintf("%v", *m)
}
func NewCharacteristic() *Characteristic { func NewCharacteristic() *Characteristic {
return &Characteristic{ return &Characteristic{
CharacteristicName: "Test Characteristic", CharacteristicName: "Test Characteristic",

View file

@ -2,6 +2,7 @@ package models
import ( import (
"errors" "errors"
"fmt"
"net/http" "net/http"
"strconv" "strconv"
"time" "time"
@ -18,6 +19,10 @@ type Genus struct {
DeletedAt NullTime `db:"deleted_at" json:"deletedAt"` DeletedAt NullTime `db:"deleted_at" json:"deletedAt"`
} }
func (m *Genus) String() string {
return fmt.Sprintf("%v", *m)
}
func NewGenus() *Genus { func NewGenus() *Genus {
return &Genus{GenusName: "Test Genus"} return &Genus{GenusName: "Test Genus"}
} }

View file

@ -2,6 +2,7 @@ package models
import ( import (
"errors" "errors"
"fmt"
"net/http" "net/http"
"strconv" "strconv"
"time" "time"
@ -19,6 +20,10 @@ type Species struct {
DeletedAt NullTime `db:"deleted_at" json:"deletedAt"` DeletedAt NullTime `db:"deleted_at" json:"deletedAt"`
} }
func (m *Species) String() string {
return fmt.Sprintf("%v", *m)
}
func NewSpecies() *Species { func NewSpecies() *Species {
return &Species{SpeciesName: "Test Species"} return &Species{SpeciesName: "Test Species"}
} }

View file

@ -2,6 +2,7 @@ package models
import ( import (
"errors" "errors"
"fmt"
"net/http" "net/http"
"strconv" "strconv"
"time" "time"
@ -18,6 +19,10 @@ type TextMeasurementType struct {
DeletedAt NullTime `db:"deleted_at" json:"deletedAt"` DeletedAt NullTime `db:"deleted_at" json:"deletedAt"`
} }
func (m *TextMeasurementType) String() string {
return fmt.Sprintf("%v", *m)
}
func NewTextMeasurementType() *TextMeasurementType { func NewTextMeasurementType() *TextMeasurementType {
return &TextMeasurementType{ return &TextMeasurementType{
TextMeasurementName: "Test Text Measurement Type", TextMeasurementName: "Test Text Measurement Type",

View file

@ -2,6 +2,7 @@ package models
import ( import (
"errors" "errors"
"fmt"
"net/http" "net/http"
"strconv" "strconv"
"time" "time"
@ -19,6 +20,10 @@ type UnitType struct {
DeletedAt NullTime `db:"deleted_at" json:"deletedAt"` DeletedAt NullTime `db:"deleted_at" json:"deletedAt"`
} }
func (m *UnitType) String() string {
return fmt.Sprintf("%v", *m)
}
func NewUnitType() *UnitType { func NewUnitType() *UnitType {
return &UnitType{ return &UnitType{
Name: "Test Unit Type", Name: "Test Unit Type",

View file

@ -2,6 +2,7 @@ package models
import ( import (
"errors" "errors"
"fmt"
"net/http" "net/http"
"strconv" "strconv"
"time" "time"
@ -20,6 +21,10 @@ type User struct {
DeletedAt NullTime `db:"deleted_at" json:"deletedAt"` DeletedAt NullTime `db:"deleted_at" json:"deletedAt"`
} }
func (m *User) String() string {
return fmt.Sprintf("%v", *m)
}
func NewUser() *User { func NewUser() *User {
return &User{Username: "Test User"} return &User{Username: "Test User"}
} }