1
0
mirror of https://github.com/golang/go synced 2024-11-05 17:36:15 -07:00
go/godoc/vfs/mapfs
Dmitri Shuralyov ead0a56930 godoc/vfs/mapfs: panic on invalid New usage
mapfs.New documentation says:

> Map keys should be forward slash-separated pathnames
> and not contain a leading slash.

It is invalid input if a provided path contains a leading slash, and it
causes the returned filesystem to have undefined behavior. Package mapfs
is often used in tests, so this can lead to a serious problem elsewhere.

Help detect invalid API usage sooner by validating input, and panicking
when it contains leading slashes. Programs that use mapfs API correctly
will be unaffected, and it will be faster for incorrect programs—if any
exist today or will be created in the future—to detect and correct such
problems.

Fixes golang/go#34591.

Change-Id: I77e5f0f4628edf83480604135f58bfb62e521d80
Reviewed-on: https://go-review.googlesource.com/c/tools/+/197859
Run-TryBot: Dmitri Shuralyov <dmitshur@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Jay Conrod <jayconrod@google.com>
2020-05-08 23:23:36 +00:00
..
mapfs_test.go godoc: feed indexer concurrently, add selective indexing hook, tests 2013-11-05 09:35:58 -05:00
mapfs.go godoc/vfs/mapfs: panic on invalid New usage 2020-05-08 23:23:36 +00:00