From da9bcc7504a1d47b0cb1389a9a822e9793d03462 Mon Sep 17 00:00:00 2001 From: Andre Moeller Date: Thu, 30 Jun 2022 16:24:22 +0200 Subject: [PATCH] fix(template functions): Use function Title instead of ToTitle to get Capitalize strings instead of upper strings using cases.Title because the strings.Title function is deprecated and refs to cases.Title --- go.mod | 2 +- internal/provider/template.go | 4 +++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/go.mod b/go.mod index ea695132..5b8fc031 100644 --- a/go.mod +++ b/go.mod @@ -12,6 +12,7 @@ require ( github.com/mitchellh/cli v1.1.4 github.com/russross/blackfriday v1.6.0 github.com/zclconf/go-cty v1.10.0 + golang.org/x/text v0.3.7 ) require ( @@ -37,5 +38,4 @@ require ( github.com/spf13/cast v1.5.0 // indirect golang.org/x/crypto v0.0.0-20220622213112-05595931fe9d // indirect golang.org/x/sys v0.0.0-20220627191245-f75cf1eec38b // indirect - golang.org/x/text v0.3.7 // indirect ) diff --git a/internal/provider/template.go b/internal/provider/template.go index 0aa777a6..683c0b7f 100644 --- a/internal/provider/template.go +++ b/internal/provider/template.go @@ -7,6 +7,8 @@ import ( "strings" "text/template" + "golang.org/x/text/cases" + tfjson "github.com/hashicorp/terraform-json" "github.com/hashicorp/terraform-plugin-docs/internal/mdplain" @@ -39,7 +41,7 @@ func newTemplate(name, text string) (*template.Template, error) { "prefixlines": tmplfuncs.PrefixLines, "split": strings.Split, "tffile": terraformCodeFile, - "title": strings.ToTitle, + "title": cases.Title, "trimspace": strings.TrimSpace, "upper": strings.ToUpper, })