changeset 4166:04876d865528

Made 'golint' and 'staticcheck' happy with wfs package.
author Sascha L. Teichmann <sascha.teichmann@intevation.de>
date Mon, 05 Aug 2019 14:35:54 +0200
parents 8dd59e2c9d3d
children 8d6f43894f09
files pkg/wfs/capabilities.go pkg/wfs/download.go pkg/wfs/global.go
diffstat 3 files changed, 26 insertions(+), 14 deletions(-) [+]
line wrap: on
line diff
--- a/pkg/wfs/capabilities.go	Mon Aug 05 13:51:08 2019 +0200
+++ b/pkg/wfs/capabilities.go	Mon Aug 05 14:35:54 2019 +0200
@@ -354,7 +354,7 @@
 
 var (
 	// ErrInvalidCRS is returned if a given string is not valid CRS URN.
-	ErrInvalidCRS = errors.New("Invalid CRS string")
+	ErrInvalidCRS = errors.New("invalid CRS string")
 	crsRe         = regexp.MustCompile(`urn:ogc:def:crs:EPSG:[^:]*:(\d+)`)
 )
 
--- a/pkg/wfs/download.go	Mon Aug 05 13:51:08 2019 +0200
+++ b/pkg/wfs/download.go	Mon Aug 05 14:35:54 2019 +0200
@@ -31,16 +31,16 @@
 
 var (
 	// ErrNoSuchFeatureType is returned when a feature is not supported.
-	ErrNoSuchFeatureType = errors.New("No such feature type")
+	ErrNoSuchFeatureType = errors.New("no such feature type")
 	// ErrGetFeatureNotSupported is returned when GetFeature is not supported.
-	ErrGetFeatureNotSupported = errors.New("GetFeature not supported")
+	ErrGetFeatureNotSupported = errors.New("method GetFeature not supported")
 	// ErrMethodGetNotSupported is returned when the GET is not supported.
-	ErrMethodGetNotSupported = errors.New("GET not supported")
+	ErrMethodGetNotSupported = errors.New("method GET not supported")
 	// ErrNoNumberMatchedFound is returned if feature count cannot be extracted.
-	ErrNoNumberMatchedFound = errors.New("No numberMatched attribute found")
+	ErrNoNumberMatchedFound = errors.New("no numberMatched attribute found")
 	// ErrOutputFormatNotSupported is returned if a output format is
 	// not supported.
-	ErrOutputFormatNotSupported = errors.New("Output format not supported")
+	ErrOutputFormatNotSupported = errors.New("output format not supported")
 )
 
 // GetCapabilities downloads a capabilities document for a given URL.
@@ -268,7 +268,7 @@
 		return err
 	}
 	if resp.StatusCode < 200 || resp.StatusCode > 299 {
-		return fmt.Errorf("Invalid HTTP status code: %d (%s)",
+		return fmt.Errorf("invalid HTTP status code: %d (%s)",
 			resp.StatusCode, resp.Status)
 	}
 	defer resp.Body.Close()
@@ -287,6 +287,8 @@
 	return handler(url, multi)
 }
 
+// ExceptionReport is an error with the extract code and
+// text from an OWS exception document.
 type ExceptionReport struct {
 	Code string
 	Text string
--- a/pkg/wfs/global.go	Mon Aug 05 13:51:08 2019 +0200
+++ b/pkg/wfs/global.go	Mon Aug 05 14:35:54 2019 +0200
@@ -28,8 +28,12 @@
 )
 
 var (
+	// FormatGeoJSON is a list of MIME types of
+	// GeoJSON documents.
 	FormatGeoJSON = []string{"geojson", "application/json"}
-	FormatGML     = []string{
+	// FormatGML is a list of MIME types
+	// GML documents.
+	FormatGML = []string{
 		"application/gml+xml; version=3.2",
 		"gml2", "gml3", "gml32",
 		"text/xml; subtype=gml/2.1.2",
@@ -39,27 +43,31 @@
 )
 
 type (
+	// Downloader abstracts the idea of a download function for WFS.
 	Downloader interface {
 		Download(user, password string, handler func(string, io.Reader) error) error
 	}
 
+	// GeoJSONDownloader is a Downloader for GeoJSON.
 	GeoJSONDownloader []string
-	GMLDownloader     []string
+	// GMLDownloader is a Downloader for GML.
+	GMLDownloader []string
 )
 
+// GetFeatures is the default Downloader in this Gemma server.
 var GetFeatures = setup()
 
 func setup() func(*Capabilities, string, string) (Downloader, error) {
 	path, err := exec.LookPath("ogr2ogr")
 	if err != nil {
 		log.Println("info: ogr2ogr not installed. Using direct GeoJSON WFS download.")
-		return GetFeaturesGeoJSON
+		return getFeaturesGeoJSON
 	}
 	log.Printf("info: ogr2ogr found at %s. Using GML WFS download.\n", path)
-	return GetFeaturesGML
+	return getFeaturesGML
 }
 
-func GetFeaturesGeoJSON(
+func getFeaturesGeoJSON(
 	caps *Capabilities,
 	featureTypeName string,
 	sortBy string,
@@ -72,7 +80,7 @@
 	return GeoJSONDownloader(urls), err
 }
 
-func GetFeaturesGML(
+func getFeaturesGML(
 	caps *Capabilities,
 	featureTypeName string,
 	sortBy string,
@@ -85,6 +93,7 @@
 	return GMLDownloader(urls), err
 }
 
+// Download is the GeoJSON implementation of the Downloader.
 func (gjd GeoJSONDownloader) Download(user, password string, handler func(string, io.Reader) error) error {
 	return DownloadURLs(user, password, []string(gjd), handler)
 }
@@ -101,10 +110,11 @@
 	return places
 }
 
+// Download is GML implementaion of the Downloader.
 func (gmd GMLDownloader) Download(user, password string, handler func(string, io.Reader) error) error {
 
 	if len(gmd) == 0 {
-		return errors.New("Nothing to download")
+		return errors.New("nothing to download")
 	}
 
 	tmpDir := config.TmpDir()