golang/go

html/template: export stripTags func from html.go

anotherGoogleFan opened this issue · 2 comments

There is a very handy "stripTags" function in html/template
(http://golang.org/src/pkg/html/template/html.go) that's currently unexported(go 1.9.2). I cannot understand why such a useful function is unexported.

mvdan commented

@anotherGoogleFan being agressive in what is exported is generally a bad idea. Once something is importable and released, it falls under the Go1 compatibility guarantee and it must be maintained with backwards compatibility.

There needs to be good reason for something to be exported in a package. In general, that means that it's very commonly useful and that it's non-trivial to do or get right otherwise. There are always the alternatives of third party libraries and copying the code yourself, if it remains unexported.

I'm not the one to decide what to do with it - I'm simply trying to explain the likely reason why it hasn't been exported.

stripTags doesn't really have anything to do with the html/template package. We aren't going to export it from there. I suggest that you copy it into a different package.

Closing.