x/tools/godoc/vfs/mapfs: easy to accidentally misuse API, causing severe problems #34591
Labels
FrozenDueToAge
NeedsFix
The path to resolution is known, but the work has not been done.
Tools
This label describes issues relating to any tools in the x/tools repository.
Milestone
mapfs.New
documentation says:However, there is no validation on the input. If the user accidentally provides map keys with leading slashes, it results in incorrect programs and hard-to-diagnose problems.
For example:
It produces output:
When
mapfs.New
is used correctly, like so:Then the output is as expected:
I think it would be net helpful to perform validation in
New
and help users learn as quickly as possible when they're misusing the API by panicking with a descriptive error message. Panics aren't good, but incorrect results can be even worse. Mostmapfs.New
usage happens at program initialization time and in tests./cc @jayconrod
The text was updated successfully, but these errors were encountered: