summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--common/errors/errors.go4
-rw-r--r--common/maps/scratch.go7
-rw-r--r--common/types/types.go2
-rw-r--r--resource/postcss/postcss.go2
-rw-r--r--resource/tocss/scss/tocss_notavailable.go2
-rw-r--r--resource/transform.go2
6 files changed, 12 insertions, 7 deletions
diff --git a/common/errors/errors.go b/common/errors/errors.go
index eff65ff92..673cd23ff 100644
--- a/common/errors/errors.go
+++ b/common/errors/errors.go
@@ -18,6 +18,8 @@ import (
"errors"
)
+// ErrFeatureNotAvailable denotes that a feature is unavailable.
+//
// We will, at least to begin with, make some Hugo features (SCSS with libsass) optional,
// and this error is used to signal those situations.
-var FeatureNotAvailableErr = errors.New("this feature is not available in your current Hugo version")
+var ErrFeatureNotAvailable = errors.New("this feature is not available in your current Hugo version")
diff --git a/common/maps/scratch.go b/common/maps/scratch.go
index d00971435..4b062d139 100644
--- a/common/maps/scratch.go
+++ b/common/maps/scratch.go
@@ -73,7 +73,7 @@ func (c *Scratch) Set(key string, value interface{}) string {
return ""
}
-// Reset deletes the given key
+// Delete deletes the given key.
func (c *Scratch) Delete(key string) string {
c.mu.Lock()
delete(c.values, key)
@@ -81,7 +81,7 @@ func (c *Scratch) Delete(key string) string {
return ""
}
-// Get returns a value previously set by Add or Set
+// Get returns a value previously set by Add or Set.
func (c *Scratch) Get(key string) interface{} {
c.mu.RLock()
val := c.values[key]
@@ -104,7 +104,7 @@ func (c *Scratch) SetInMap(key string, mapKey string, value interface{}) string
return ""
}
-// GetSortedMapValues returns a sorted map previously filled with SetInMap
+// GetSortedMapValues returns a sorted map previously filled with SetInMap.
func (c *Scratch) GetSortedMapValues(key string) interface{} {
c.mu.RLock()
@@ -130,6 +130,7 @@ func (c *Scratch) GetSortedMapValues(key string) interface{} {
return sortedArray
}
+// NewScratch returns a new instance Scratch.
func NewScratch() *Scratch {
return &Scratch{values: make(map[string]interface{})}
}
diff --git a/common/types/types.go b/common/types/types.go
index a5805d07a..fca58edcb 100644
--- a/common/types/types.go
+++ b/common/types/types.go
@@ -41,6 +41,8 @@ func (k KeyValues) String() string {
return fmt.Sprintf("%v: %v", k.Key, k.Values)
}
+// NewKeyValuesStrings takes a given key and slice of values and returns a new
+// KeyValues struct.
func NewKeyValuesStrings(key string, values ...string) KeyValues {
iv := make([]interface{}, len(values))
for i := 0; i < len(values); i++ {
diff --git a/resource/postcss/postcss.go b/resource/postcss/postcss.go
index 3b2b4175a..202b4c06b 100644
--- a/resource/postcss/postcss.go
+++ b/resource/postcss/postcss.go
@@ -111,7 +111,7 @@ func (t *postcssTransformation) Transform(ctx *resource.ResourceTransformationCt
binary = binaryName
if _, err := exec.LookPath(binary); err != nil {
// This may be on a CI server etc. Will fall back to pre-built assets.
- return errors.FeatureNotAvailableErr
+ return errors.ErrFeatureNotAvailable
}
}
diff --git a/resource/tocss/scss/tocss_notavailable.go b/resource/tocss/scss/tocss_notavailable.go
index 69b4fc655..2ec5a4832 100644
--- a/resource/tocss/scss/tocss_notavailable.go
+++ b/resource/tocss/scss/tocss_notavailable.go
@@ -26,5 +26,5 @@ func Supports() bool {
}
func (t *toCSSTransformation) Transform(ctx *resource.ResourceTransformationCtx) error {
- return errors.FeatureNotAvailableErr
+ return errors.ErrFeatureNotAvailable
}
diff --git a/resource/transform.go b/resource/transform.go
index 5c01c7129..9e6215b9e 100644
--- a/resource/transform.go
+++ b/resource/transform.go
@@ -386,7 +386,7 @@ func (r *transformedResource) transform(setContent bool) (err error) {
}
if err := tr.transformation.Transform(tctx); err != nil {
- if err == errors.FeatureNotAvailableErr {
+ if err == errors.ErrFeatureNotAvailable {
// This transformation is not available in this
// Hugo installation (scss not compiled in, PostCSS not available etc.)
// If a prepared bundle for this transformation chain is available, use that.