# HG changeset patch # User Sascha L. Teichmann # Date 1546855368 -3600 # Node ID f1c3fe8b79f562c68346bcbc091802299801a6fd # Parent ad5e1cddaa09da77d58ee5739bcdf5872ddd59d6 Imports: Fixed some golint issues. diff -r ad5e1cddaa09 -r f1c3fe8b79f5 pkg/models/user.go --- a/pkg/models/user.go Fri Jan 04 13:41:07 2019 +0100 +++ b/pkg/models/user.go Mon Jan 07 11:02:48 2019 +0100 @@ -23,11 +23,17 @@ ) type ( - Email string - Country string - Role string + // Email is a string formed by a valid EMail address. + Email string + // Country is a valid country 2 letter code. + Country string + // Role is a string with a valid gemma role. + Role string + // UserName is a string forming a valid user name. UserName string + // BoundingBox is a spatial bounding box of user's + // responsibility area. BoundingBox struct { X1 float64 `json:"x1"` Y1 float64 `json:"y1"` @@ -35,6 +41,7 @@ Y2 float64 `json:"y2"` } + // User is a serialized JSON form of user data. User struct { User UserName `json:"user"` Role Role `json:"role"` @@ -44,6 +51,7 @@ Extent *BoundingBox `json:"extent"` } + // PWResetUser is send to request a password reset for a user. PWResetUser struct { User string `json:"user"` } @@ -65,6 +73,7 @@ errNoEmailAddress = errors.New("Not a valid email address") ) +// UnmarshalJSON ensures that the given string forms a valid email address. func (e *Email) UnmarshalJSON(data []byte) error { var s string if err := json.Unmarshal(data, &s); err != nil { @@ -77,10 +86,12 @@ return nil } +// Value implements the driver.Valuer interface. func (e Email) Value() (driver.Value, error) { return string(e), nil } +// Scan implements the sql.Scanner interface. func (e *Email) Scan(src interface{}) (err error) { if s, ok := src.(string); ok { *e = Email(s) @@ -92,10 +103,12 @@ var errNoValidUser = errors.New("Not a valid user") +// IsValid checks if a given user name is valid. func (u UserName) IsValid() bool { return u != "" } +// UnmarshalJSON ensures that the given string forms a valid user name. func (u *UserName) UnmarshalJSON(data []byte) error { var s string if err := json.Unmarshal(data, &s); err != nil { @@ -108,6 +121,7 @@ return errNoValidUser } +// Scan implements the sql.Scanner interface. func (u *UserName) Scan(src interface{}) (err error) { if s, ok := src.(string); ok { *u = UserName(s) @@ -125,6 +139,8 @@ errNoValidCountry = errors.New("Not a valid country") ) +// UnmarshalJSON ensures that the given string forms a valid +// two letter country code. func (c *Country) UnmarshalJSON(data []byte) error { var s string if err := json.Unmarshal(data, &s); err != nil { @@ -140,10 +156,12 @@ return errNoValidCountry } +// Value implements the driver.Valuer interface. func (c Country) Value() (driver.Value, error) { return string(c), nil } +// Scan implements the sql.Scanner interfaces. func (c *Country) Scan(src interface{}) (err error) { if s, ok := src.(string); ok { *c = Country(s) @@ -162,10 +180,12 @@ errNoValidRole = errors.New("Not a valid role") ) +// Value implements the driver.Valuer interface. func (r Role) Value() (driver.Value, error) { return string(r), nil } +// Scan implements the sql.Scanner interface. func (r *Role) Scan(src interface{}) (err error) { if s, ok := src.(string); ok { *r = Role(s) @@ -175,6 +195,7 @@ return } +// UnmarshalJSON ensure that the given string is a valid user name. func (r *Role) UnmarshalJSON(data []byte) error { var s string if err := json.Unmarshal(data, &s); err != nil { diff -r ad5e1cddaa09 -r f1c3fe8b79f5 pkg/models/waterway.go --- a/pkg/models/waterway.go Fri Jan 04 13:41:07 2019 +0100 +++ b/pkg/models/waterway.go Mon Jan 07 11:02:48 2019 +0100 @@ -13,9 +13,15 @@ package models +// WaterwayAxisImport specifies an import of the waterway axis. type WaterwayAxisImport struct { - URL string `json:"url"` + // URL is the capabilities URL of the WFS. + URL string `json:"url"` + // FeatureType is the layer to use. FeatureType string `json:"feature-type"` - SortBy string `json:"sort-by"` - SendEmail bool `json:"send-email"` + // SortBy sorts the feature by this key. + SortBy string `json:"sort-by"` + // SendEmail is set to true if an email should be send after + // importing the axis. + SendEmail bool `json:"send-email"` }