Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/gohugoio/hugo.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com>2020-12-02 15:23:25 +0300
committerBjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com>2020-12-03 15:12:58 +0300
commitd90e37e0c6e812f9913bf256c9c81aa05b7a08aa (patch)
tree7b1b14464eefec1188ca2eed53c64e4823453cc9 /scripts
parent32471b57bde51c55a15dbf1db75d6e5f7232c347 (diff)
all: Format code with gofumpt
See https://github.com/mvdan/gofumpt
Diffstat (limited to 'scripts')
-rw-r--r--scripts/fork_go_templates/main.go39
1 files changed, 21 insertions, 18 deletions
diff --git a/scripts/fork_go_templates/main.go b/scripts/fork_go_templates/main.go
index 04202b254..c295ab734 100644
--- a/scripts/fork_go_templates/main.go
+++ b/scripts/fork_go_templates/main.go
@@ -35,7 +35,6 @@ func main() {
goimports(htmlRoot)
gofmt(forkRoot)
-
}
const (
@@ -97,36 +96,41 @@ package parse
}
return content
-
}
var goPackages = []goPackage{
- goPackage{srcPkg: "text/template", dstPkg: "texttemplate",
- replacer: func(name, content string) string { return textTemplateReplacers.Replace(commonReplace(name, content)) }},
- goPackage{srcPkg: "html/template", dstPkg: "htmltemplate", replacer: func(name, content string) string {
- if strings.HasSuffix(name, "content.go") {
- // Remove template.HTML types. We need to use the Go types.
- content = removeAll(`(?s)// Strings of content.*?\)\n`, content)
- }
+ {
+ srcPkg: "text/template", dstPkg: "texttemplate",
+ replacer: func(name, content string) string { return textTemplateReplacers.Replace(commonReplace(name, content)) },
+ },
+ {
+ srcPkg: "html/template", dstPkg: "htmltemplate", replacer: func(name, content string) string {
+ if strings.HasSuffix(name, "content.go") {
+ // Remove template.HTML types. We need to use the Go types.
+ content = removeAll(`(?s)// Strings of content.*?\)\n`, content)
+ }
- content = commonReplace(name, content)
+ content = commonReplace(name, content)
- return htmlTemplateReplacers.Replace(content)
- },
+ return htmlTemplateReplacers.Replace(content)
+ },
rewriter: func(name string) {
for _, s := range []string{"CSS", "HTML", "HTMLAttr", "JS", "JSStr", "URL", "Srcset"} {
rewrite(name, fmt.Sprintf("%s -> htmltemplate.%s", s, s))
}
rewrite(name, `"text/template/parse" -> "github.com/gohugoio/hugo/tpl/internal/go_templates/texttemplate/parse"`)
- }},
- goPackage{srcPkg: "internal/fmtsort", dstPkg: "fmtsort", rewriter: func(name string) {
+ },
+ },
+ {srcPkg: "internal/fmtsort", dstPkg: "fmtsort", rewriter: func(name string) {
rewrite(name, `"internal/fmtsort" -> "github.com/gohugoio/hugo/tpl/internal/go_templates/fmtsort"`)
}},
- goPackage{srcPkg: "internal/testenv", dstPkg: "testenv",
+ {
+ srcPkg: "internal/testenv", dstPkg: "testenv",
replacer: func(name, content string) string { return testEnvReplacers.Replace(content) }, rewriter: func(name string) {
rewrite(name, `"internal/testenv" -> "github.com/gohugoio/hugo/tpl/internal/go_templates/testenv"`)
- }},
- goPackage{srcPkg: "internal/cfg", dstPkg: "cfg", rewriter: func(name string) {
+ },
+ },
+ {srcPkg: "internal/cfg", dstPkg: "cfg", rewriter: func(name string) {
rewrite(name, `"internal/cfg" -> "github.com/gohugoio/hugo/tpl/internal/go_templates/cfg"`)
}},
}
@@ -196,7 +200,6 @@ func doWithGoFiles(dir string,
func removeAll(expression, content string) string {
re := regexp.MustCompile(expression)
return re.ReplaceAllString(content, "")
-
}
func rewrite(filename, rule string) {