Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

html/template: make FuncMap an alias for text/template.FuncMap #46121

Closed
rogpeppe opened this issue May 12, 2021 · 8 comments
Closed

html/template: make FuncMap an alias for text/template.FuncMap #46121

rogpeppe opened this issue May 12, 2021 · 8 comments

Comments

@rogpeppe
Copy link
Contributor

As discussed on Twitter recently, when generics come around, the html/template and text/template APIs can reasonably be abstracted into a single generic interface, but the fact that FuncMap is defined as two separate types makes it a bit harder than it could be.

I propose that in html/template, FuncMap shall be defined as an alias as follows:

package template
import "text/template"

type FuncMap = template.FuncMap

As html/template already imports text/template, there's no problem with a change in the dependency graph, and I can't currently see any potential issues from combining the two types.

@gopherbot gopherbot added this to the Proposal milestone May 12, 2021
@mvdan
Copy link
Member

mvdan commented May 12, 2021

Do you think any reasonable user programs could break because of this change? I can imagine some artificial cases, like requiring the two types to be different via e.g. reflection, but I don't imagine anyone would be doing that.

@ianlancetaylor ianlancetaylor added this to Incoming in Proposals (old) May 12, 2021
@rsc rsc changed the title proposal: alias html/template.FuncMap to text/template.FuncMap proposal: html/template: make FuncMap an alias for text/template.FuncMap May 12, 2021
@rsc
Copy link
Contributor

rsc commented May 12, 2021

Seems reasonable to me. Adding to minutes. /cc @robpike

@rsc
Copy link
Contributor

rsc commented May 12, 2021

This proposal has been added to the active column of the proposals project
and will now be reviewed at the weekly proposal review meetings.
— rsc for the proposal review group

@rsc rsc moved this from Incoming to Active in Proposals (old) May 12, 2021
@robpike
Copy link
Contributor

robpike commented May 12, 2021

Seems sound.

@rogpeppe
Copy link
Contributor Author

I can imagine some artificial cases, like requiring the two types to be different via e.g. reflection, but I don't imagine anyone would be doing that.

I thought about that, but I couldn't think of a realistic case where it might be a problem, Hyrum's Law notwithstanding.

@rsc
Copy link
Contributor

rsc commented May 19, 2021

Based on the discussion above, this proposal seems like a likely accept.
— rsc for the proposal review group

@rsc rsc moved this from Active to Likely Accept in Proposals (old) May 19, 2021
@rsc rsc moved this from Likely Accept to Accepted in Proposals (old) May 26, 2021
@rsc
Copy link
Contributor

rsc commented May 26, 2021

No change in consensus, so accepted. 🎉
This issue now tracks the work of implementing the proposal.
— rsc for the proposal review group

@rsc rsc changed the title proposal: html/template: make FuncMap an alias for text/template.FuncMap html/template: make FuncMap an alias for text/template.FuncMap May 26, 2021
@rsc rsc modified the milestones: Proposal, Backlog May 26, 2021
@gopherbot
Copy link

Change https://go.dev/cl/389156 mentions this issue: html/template: make FuncMap a type alias of text/template.FuncMap

@dmitshur dmitshur modified the milestones: Backlog, Go1.19 Aug 16, 2022
@golang golang locked and limited conversation to collaborators Aug 16, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
No open projects
Development

No branches or pull requests

6 participants