mirror of
https://github.com/gohugoio/hugo.git
synced 2024-12-01 15:19:09 -05:00
common: Fix golint errors
common/errors/errors.go:21:1: comment on exported var FeatureNotAvailableErr should be of the form "FeatureNotAvailableErr ..." common/errors/errors.go:23:5: error var FeatureNotAvailableErr should have name of the form ErrFoo common/maps/scratch.go:76:1: comment on exported method Scratch.Delete should be of the form "Delete ..." common/maps/scratch.go:133:1: exported function NewScratch should have comment or be unexported common/types/types.go:44:1: exported function NewKeyValuesStrings should have comment or be unexported
This commit is contained in:
parent
f0effac804
commit
b8b91f5506
6 changed files with 12 additions and 7 deletions
|
@ -18,6 +18,8 @@ import (
|
||||||
"errors"
|
"errors"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
// ErrFeatureNotAvailable denotes that a feature is unavailable.
|
||||||
|
//
|
||||||
// We will, at least to begin with, make some Hugo features (SCSS with libsass) optional,
|
// We will, at least to begin with, make some Hugo features (SCSS with libsass) optional,
|
||||||
// and this error is used to signal those situations.
|
// 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")
|
||||||
|
|
|
@ -73,7 +73,7 @@ func (c *Scratch) Set(key string, value interface{}) string {
|
||||||
return ""
|
return ""
|
||||||
}
|
}
|
||||||
|
|
||||||
// Reset deletes the given key
|
// Delete deletes the given key.
|
||||||
func (c *Scratch) Delete(key string) string {
|
func (c *Scratch) Delete(key string) string {
|
||||||
c.mu.Lock()
|
c.mu.Lock()
|
||||||
delete(c.values, key)
|
delete(c.values, key)
|
||||||
|
@ -81,7 +81,7 @@ func (c *Scratch) Delete(key string) string {
|
||||||
return ""
|
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{} {
|
func (c *Scratch) Get(key string) interface{} {
|
||||||
c.mu.RLock()
|
c.mu.RLock()
|
||||||
val := c.values[key]
|
val := c.values[key]
|
||||||
|
@ -104,7 +104,7 @@ func (c *Scratch) SetInMap(key string, mapKey string, value interface{}) string
|
||||||
return ""
|
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{} {
|
func (c *Scratch) GetSortedMapValues(key string) interface{} {
|
||||||
c.mu.RLock()
|
c.mu.RLock()
|
||||||
|
|
||||||
|
@ -130,6 +130,7 @@ func (c *Scratch) GetSortedMapValues(key string) interface{} {
|
||||||
return sortedArray
|
return sortedArray
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// NewScratch returns a new instance Scratch.
|
||||||
func NewScratch() *Scratch {
|
func NewScratch() *Scratch {
|
||||||
return &Scratch{values: make(map[string]interface{})}
|
return &Scratch{values: make(map[string]interface{})}
|
||||||
}
|
}
|
||||||
|
|
|
@ -41,6 +41,8 @@ func (k KeyValues) String() string {
|
||||||
return fmt.Sprintf("%v: %v", k.Key, k.Values)
|
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 {
|
func NewKeyValuesStrings(key string, values ...string) KeyValues {
|
||||||
iv := make([]interface{}, len(values))
|
iv := make([]interface{}, len(values))
|
||||||
for i := 0; i < len(values); i++ {
|
for i := 0; i < len(values); i++ {
|
||||||
|
|
|
@ -111,7 +111,7 @@ func (t *postcssTransformation) Transform(ctx *resource.ResourceTransformationCt
|
||||||
binary = binaryName
|
binary = binaryName
|
||||||
if _, err := exec.LookPath(binary); err != nil {
|
if _, err := exec.LookPath(binary); err != nil {
|
||||||
// This may be on a CI server etc. Will fall back to pre-built assets.
|
// This may be on a CI server etc. Will fall back to pre-built assets.
|
||||||
return errors.FeatureNotAvailableErr
|
return errors.ErrFeatureNotAvailable
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -26,5 +26,5 @@ func Supports() bool {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (t *toCSSTransformation) Transform(ctx *resource.ResourceTransformationCtx) error {
|
func (t *toCSSTransformation) Transform(ctx *resource.ResourceTransformationCtx) error {
|
||||||
return errors.FeatureNotAvailableErr
|
return errors.ErrFeatureNotAvailable
|
||||||
}
|
}
|
||||||
|
|
|
@ -386,7 +386,7 @@ func (r *transformedResource) transform(setContent bool) (err error) {
|
||||||
}
|
}
|
||||||
|
|
||||||
if err := tr.transformation.Transform(tctx); err != nil {
|
if err := tr.transformation.Transform(tctx); err != nil {
|
||||||
if err == errors.FeatureNotAvailableErr {
|
if err == errors.ErrFeatureNotAvailable {
|
||||||
// This transformation is not available in this
|
// This transformation is not available in this
|
||||||
// Hugo installation (scss not compiled in, PostCSS not available etc.)
|
// Hugo installation (scss not compiled in, PostCSS not available etc.)
|
||||||
// If a prepared bundle for this transformation chain is available, use that.
|
// If a prepared bundle for this transformation chain is available, use that.
|
||||||
|
|
Loading…
Reference in a new issue