Skip to content

cmd/doc: Stops walking directories in case of open fails #16240

@i4ki

Description

@i4ki
  1. What version of Go are you using (go version)?
    go version devel +29f0984 Fri Jul 1 01:12:24 2016 +0000 linux/amd64
  2. What operating system and processor architecture are you using (go env)?
    GOARCH="amd64"
    GOBIN=""
    GOEXE=""
    GOHOSTARCH="amd64"
    GOHOSTOS="linux"
    GOOS="linux"
    GOPATH="/home/i4k/projects/go-workspace"
    GORACE=""
    GOROOT="/home/i4k/projects/personal/go"
    GOTOOLDIR="/home/i4k/projects/personal/go/pkg/tool/linux_amd64"
    CC="gcc"
    GOGCCFLAGS="-fPIC -m64 -pthread -fmessage-length=0 -fdebug-prefix-map=/tmp/go-build340179415=/tmp/go-build -gno-record-gcc-switches"
    CXX="g++"
    CGO_ENABLED="1"
  3. What did you do?

The go doc tool fail to work in case of failing to open some directory inside GOPATH. In my case I have some projects with directories owned by root inside GOPATH (because of some programs doing sudo make build-rootfs and things like that) and then go doc stop walking dirs in the first permission denied error... Making it unusable to find deep packages inside projects on my machine.

Changing the return to a continue in the line below gets what I expect, but I don't know if it's acceptable.
https://github.com/golang/go/blob/master/src/cmd/doc/dirs.go#L81

  1. What did you expect to see?
λ> go doc somepkg.SomeFunc
doc: error opening /home/i4k/projects/go-workspace/src/XXXXX/build/rootfs/root: open /home/i4k/projects/go-workspace/src/XXXXX/build/rootfs/root: permission denied
doc: error opening /home/i4k/projects/go-workspace/src/YYYYYY/build/rootfs/root: open /home/i4k/projects/go-workspace/src/YYYYYY/build/rootfs/root: permission denied
doc: error opening /home/i4k/projects/go-workspace/src/ZZZZZZ/build/rootfs/tmp/go-build247046776: open /home/i4k/projects/go-workspace/src/ZZZZZ/build/rootfs: permission denied

func SomeFunc(format string, arg ...interface{}) error
        Documentation
  1. What did you see instead?
λ> go doc somepkg.SomeFunc
doc: error opening /home/i4k/projects/go-workspace/src/XXXXX/build/root: open /home/i4k/projects/go-workspace/src/XXXXX/build/root: permission denied
doc: no buildable Go source files in /home/i4k
exit status 1

Metadata

Metadata

Assignees

No one assigned

    Labels

    FrozenDueToAgeNeedsFixThe path to resolution is known, but the work has not been done.

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions