go/packages: pass through packages with error in the fallback
This applies a part of golang.org/cl/137075 to the fallback. If go list doesn't find a package, it returns an almost empty package structure with an error set on it. That change passed through those packages from the 1.11+ go list, so users could determine there wasn't a match. This change does the same from the go 1.10 fallback go list code. Change-Id: I98acc186c0a9eeef0416e9fec0e1fe0e29ddc51c Reviewed-on: https://go-review.googlesource.com/c/139158 Reviewed-by: Alan Donovan <adonovan@google.com>
This commit is contained in:
		
							parent
							
								
									2f84ea8ef8
								
							
						
					
					
						commit
						cb0b336180
					
				|  | @ -49,7 +49,7 @@ func golistDriverFallback(cfg *Config, words ...string) (*driverResponse, error) | ||||||
| 	addPackage := func(p *jsonPackage) { | 	addPackage := func(p *jsonPackage) { | ||||||
| 		id := p.ImportPath | 		id := p.ImportPath | ||||||
| 
 | 
 | ||||||
| 		if p.Name == "" || allPkgs[id] { | 		if allPkgs[id] { | ||||||
| 			return | 			return | ||||||
| 		} | 		} | ||||||
| 		allPkgs[id] = true | 		allPkgs[id] = true | ||||||
|  | @ -133,6 +133,12 @@ func golistDriverFallback(cfg *Config, words ...string) (*driverResponse, error) | ||||||
| 			Imports:         importMap(p.Imports), | 			Imports:         importMap(p.Imports), | ||||||
| 			// TODO(matloob): set errors on the Package to cgoErrors
 | 			// TODO(matloob): set errors on the Package to cgoErrors
 | ||||||
| 		} | 		} | ||||||
|  | 		if p.Error != nil { | ||||||
|  | 			pkg.Errors = append(pkg.Errors, Error{ | ||||||
|  | 				Pos: p.Error.Pos, | ||||||
|  | 				Msg: p.Error.Err, | ||||||
|  | 			}) | ||||||
|  | 		} | ||||||
| 		response.Packages = append(response.Packages, pkg) | 		response.Packages = append(response.Packages, pkg) | ||||||
| 		if cfg.Tests && isRoot { | 		if cfg.Tests && isRoot { | ||||||
| 			testID := fmt.Sprintf("%s [%s.test]", id, id) | 			testID := fmt.Sprintf("%s [%s.test]", id, id) | ||||||
|  |  | ||||||
		Loading…
	
		Reference in New Issue