collections via markdown files
All checks were successful
continuous-integration/drone/push Build is passing

This commit is contained in:
Sebastian Frank
2019-03-22 17:22:03 +01:00
parent 4a9a3eec06
commit ff1da084af
46 changed files with 547 additions and 362 deletions

View File

@@ -2,7 +2,6 @@ package helper
import (
"os"
"strings"
)
// CreateDirectory creates direcory with all missing parents and panic if error
@@ -25,14 +24,3 @@ func CreateDirectory(dir string) {
Log.Panicf("unknown error for output directory '%s': %s", dir, err)
}
}
// BackToRoot builds ../../ string
func BackToRoot(curNavPath string) string {
tmpPath := ""
if curNavPath != "" {
for i := strings.Count(curNavPath, "/") + 1; i > 0; i-- {
tmpPath += "../"
}
}
return tmpPath
}

18
pkg/helper/regexp.go Normal file
View File

@@ -0,0 +1,18 @@
package helper
import "regexp"
// GetRegexpParams gets a map of named regexp group matches
// use pe. (?P<Year>\d{4})-(?P<Month>\d{2})-(?P<Day>\d{2}) as regexp
func GetRegexpParams(regEx *regexp.Regexp, str string) (paramsMap map[string]string) {
match := regEx.FindStringSubmatch(str)
paramsMap = make(map[string]string)
for i, name := range regEx.SubexpNames() {
if i > 0 && i <= len(match) {
paramsMap[name] = match[i]
}
}
return
}