changeset 1697:f1c3fe8b79f5

Imports: Fixed some golint issues.
author Sascha L. Teichmann <sascha.teichmann@intevation.de>
date Mon, 07 Jan 2019 11:02:48 +0100
parents ad5e1cddaa09
children 0c0e658fcfc8
files pkg/models/user.go pkg/models/waterway.go
diffstat 2 files changed, 33 insertions(+), 6 deletions(-) [+]
line wrap: on
line diff
--- 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 {
--- 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"`
 }