mirror of
https://github.com/tinygo-org/tinygo.git
synced 2026-07-26 06:38:42 +00:00
c810628a20
There were a few problems with the go/packages package. While it is more
or less designed for our purpose, it didn't work quite well as it didn't
provide access to indirectly imported packages (most importantly the
runtime package). This led to a workaround that sometimes broke
`tinygo test`.
This PR contains a number of related changes:
* It uses `go list` directly to retrieve the list of packages/files to
compile, instead of relying on the go/packages package.
* It replaces our custom TestMain replace code with the standard code
for running tests (generated by `go list`).
* It adds a dummy runtime/pprof package and modifies the testing
package, to get tests to run again with the code generated by
`go list`.
26 lines
529 B
Go
26 lines
529 B
Go
package loader
|
|
|
|
import "go/scanner"
|
|
|
|
// Errors contains a list of parser errors or a list of typechecker errors for
|
|
// the given package.
|
|
type Errors struct {
|
|
Pkg *Package
|
|
Errs []error
|
|
}
|
|
|
|
func (e Errors) Error() string {
|
|
return "could not compile: " + e.Errs[0].Error()
|
|
}
|
|
|
|
// Error is a regular error but with an added import stack. This is especially
|
|
// useful for debugging import cycle errors.
|
|
type Error struct {
|
|
ImportStack []string
|
|
Err scanner.Error
|
|
}
|
|
|
|
func (e Error) Error() string {
|
|
return e.Err.Error()
|
|
}
|