summaryrefslogtreecommitdiffstats
path: root/tpl/template_resources.go
diff options
context:
space:
mode:
Diffstat (limited to 'tpl/template_resources.go')
-rw-r--r--tpl/template_resources.go18
1 files changed, 9 insertions, 9 deletions
diff --git a/tpl/template_resources.go b/tpl/template_resources.go
index 0ac7686cf..96f0b69ab 100644
--- a/tpl/template_resources.go
+++ b/tpl/template_resources.go
@@ -31,7 +31,7 @@ import (
"github.com/spf13/viper"
)
-var remoteUrlLock = &remoteLock{m: make(map[string]*sync.Mutex)}
+var remoteURLLock = &remoteLock{m: make(map[string]*sync.Mutex)}
type remoteLock struct {
sync.RWMutex
@@ -39,7 +39,7 @@ type remoteLock struct {
}
// resLock locks an URL during download
-func (l *remoteLock) UrlLock(url string) {
+func (l *remoteLock) URLLock(url string) {
l.Lock()
if _, ok := l.m[url]; !ok {
l.m[url] = &sync.Mutex{}
@@ -49,7 +49,7 @@ func (l *remoteLock) UrlLock(url string) {
}
// resUnlock unlocks an URL when the download has been finished. Use only in defer calls.
-func (l *remoteLock) UrlUnlock(url string) {
+func (l *remoteLock) URLUnlock(url string) {
l.RLock()
defer l.RUnlock()
if um, ok := l.m[url]; ok {
@@ -111,8 +111,8 @@ func resGetRemote(url string, fs afero.Fs, hc *http.Client) ([]byte, error) {
}
// avoid race condition with locks, block other goroutines if the current url is processing
- remoteUrlLock.UrlLock(url)
- defer func() { remoteUrlLock.UrlUnlock(url) }()
+ remoteURLLock.URLLock(url)
+ defer func() { remoteURLLock.URLUnlock(url) }()
// avoid multiple locks due to calling resGetCache twice
c, err = resGetCache(url, fs, viper.GetBool("IgnoreCache"))
@@ -176,7 +176,7 @@ func resGetResource(url string) ([]byte, error) {
// GetJson expects one or n-parts of a URL to a resource which can either be a local or a remote one.
// If you provide multiple parts they will be joined together to the final URL.
// GetJson returns nil or parsed JSON to use in a short code.
-func GetJson(urlParts ...string) interface{} {
+func GetJSON(urlParts ...string) interface{} {
url := strings.Join(urlParts, "")
c, err := resGetResource(url)
if err != nil {
@@ -194,7 +194,7 @@ func GetJson(urlParts ...string) interface{} {
}
// parseCsv parses bytes of csv data into a slice slice string or an error
-func parseCsv(c []byte, sep string) ([][]string, error) {
+func parseCSV(c []byte, sep string) ([][]string, error) {
if len(sep) != 1 {
return nil, errors.New("Incorrect length of csv separator: " + sep)
}
@@ -211,14 +211,14 @@ func parseCsv(c []byte, sep string) ([][]string, error) {
// The data separator can be a comma, semi-colon, pipe, etc, but only one character.
// If you provide multiple parts for the URL they will be joined together to the final URL.
// GetCsv returns nil or a slice slice to use in a short code.
-func GetCsv(sep string, urlParts ...string) [][]string {
+func GetCSV(sep string, urlParts ...string) [][]string {
url := strings.Join(urlParts, "")
c, err := resGetResource(url)
if err != nil {
jww.ERROR.Printf("Failed to get csv resource %s with error message %s", url, err)
return nil
}
- d, err := parseCsv(c, sep)
+ d, err := parseCSV(c, sep)
if err != nil {
jww.ERROR.Printf("Failed to read csv resource %s with error message %s", url, err)
return nil