• Dmitri Shuralyov's avatar
    go/build: fix lack of error for Import of nonexistent local import path · e646d073
    Dmitri Shuralyov authored
    When calling build.Import, normally, an error is returned if the
    directory doesn't exist. However, that didn't happen for local
    import paths when build.FindOnly ImportMode was used.
    
    This change fixes that, and adds tests. It also makes the error
    value more consistent in all scenarios where it occurs.
    
    When calling build.Import with a local import path, the package
    can only exist in a single deterministic directory. That makes
    it possible verify that directory exists earlier in the path,
    and return a "cannot find package" error if it doesn't.
    Previously, this occurred only when build.FindOnly ImportMode
    was not set. It occurred quite late, after getting past Found
    label, to line that calls ctxt.readDir. Doing so would return
    an error like "no such file or directory" when the directory
    does not exist.
    
    Fixes #17863.
    Updates #17888 (relevant issue I ran into while working on this CL).
    
    Change-Id: If6a6996ac6176ac203a88bd31419748f88d89d7c
    Reviewed-on: https://go-review.googlesource.com/33158Reviewed-by: 's avatarIan Lance Taylor <iant@golang.org>
    Run-TryBot: Ian Lance Taylor <iant@golang.org>
    TryBot-Result: Gobot Gobot <gobot@golang.org>
    e646d073
Name
Last commit
Last update
.github Loading commit data...
api Loading commit data...
doc Loading commit data...
lib/time Loading commit data...
misc Loading commit data...
src Loading commit data...
test Loading commit data...
.gitattributes Loading commit data...
.gitignore Loading commit data...
AUTHORS Loading commit data...
CONTRIBUTING.md Loading commit data...
CONTRIBUTORS Loading commit data...
LICENSE Loading commit data...
PATENTS Loading commit data...
README.md Loading commit data...
favicon.ico Loading commit data...
robots.txt Loading commit data...