@@ -841,7 +841,20 @@ func invokeGo(cfg *Config, args ...string) (*bytes.Buffer, error) {
841
841
return bytes .NewBufferString (output ), nil
842
842
}
843
843
844
+ // Backwards compatibility for Go 1.11 because 1.12 and 1.13 put the directory in the ImportPath.
845
+ // If the package doesn't exist, put the absolute path of the directory into the error message,
846
+ // as Go 1.13 list does.
847
+ const noSuchDirectory = "no such directory"
848
+ if len (stderr .String ()) > 0 && strings .Contains (stderr .String (), noSuchDirectory ) {
849
+ errstr := stderr .String ()
850
+ abspath := strings .TrimSpace (errstr [strings .Index (errstr , noSuchDirectory )+ len (noSuchDirectory ):])
851
+ output := fmt .Sprintf (`{"ImportPath": %q,"Incomplete": true,"Error": {"Pos": "","Err": %q}}` ,
852
+ abspath , strings .Trim (stderr .String (), "\n " ))
853
+ return bytes .NewBufferString (output ), nil
854
+ }
855
+
844
856
// Workaround for #29280: go list -e has incorrect behavior when an ad-hoc package doesn't exist.
857
+ // Note that the error message we look for in this case is different that the one looked for above.
845
858
if len (stderr .String ()) > 0 && strings .Contains (stderr .String (), "no such file or directory" ) {
846
859
output := fmt .Sprintf (`{"ImportPath": "command-line-arguments","Incomplete": true,"Error": {"Pos": "","Err": %q}}` ,
847
860
strings .Trim (stderr .String (), "\n " ))
0 commit comments