github.com/goreleaser/goreleaser@v1.25.1/internal/deprecate/deprecate.go (about) 1 // Package deprecate provides simple functions to standardize the output 2 // of deprecation notices on goreleaser 3 package deprecate 4 5 import ( 6 "bytes" 7 "strings" 8 "text/template" 9 10 "github.com/caarlos0/log" 11 "github.com/goreleaser/goreleaser/internal/logext" 12 "github.com/goreleaser/goreleaser/pkg/context" 13 ) 14 15 const baseURL = "https://goreleaser.com/deprecations#" 16 17 // Notice warns the user about the deprecation of the given property. 18 func Notice(ctx *context.Context, property string) { 19 NoticeCustom(ctx, property, "{{ .Property }} should not be used anymore, check {{ .URL }} for more info") 20 } 21 22 // NoticeCustom warns the user about the deprecation of the given property. 23 func NoticeCustom(ctx *context.Context, property, tmpl string) { 24 // replaces . and _ with - 25 url := baseURL + strings.NewReplacer( 26 ".", "", 27 "_", "", 28 ":", "", 29 " ", "-", 30 ).Replace(property) 31 var out bytes.Buffer 32 if err := template. 33 Must(template.New("deprecation").Parse("DEPRECATED: "+tmpl)). 34 Execute(&out, templateData{ 35 URL: logext.URL(url), 36 Property: logext.Keyword(property), 37 }); err != nil { 38 panic(err) // this should never happen 39 } 40 41 ctx.Deprecated = true 42 log.Warn(logext.Warning(out.String())) 43 } 44 45 type templateData struct { 46 URL string 47 Property string 48 }