1
0
mirror of https://github.com/goreleaser/goreleaser.git synced 2025-03-17 20:47:50 +02:00

Merge pull request #536 from alicebob/mainerr

fix: Fix segfault by catching all stat errors
This commit is contained in:
Carlos Alexandro Becker 2018-02-01 11:13:17 -02:00 committed by GitHub
commit 3e05553418
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 3 additions and 3 deletions

View File

@ -161,8 +161,8 @@ func checkMain(ctx *context.Context, build config.Build) error {
main = "."
}
stat, ferr := os.Stat(main)
if os.IsNotExist(ferr) {
return errors.Wrapf(ferr, "could not open %s", main)
if ferr != nil {
return ferr
}
if stat.IsDir() {
packs, err := parser.ParseDir(token.NewFileSet(), main, nil, 0)

View File

@ -246,7 +246,7 @@ func TestRunPipeWithoutMainFunc(t *testing.T) {
ctx.Config.Builds[0].Main = "foo.go"
assert.EqualError(t, Default.Build(ctx, ctx.Config.Builds[0], api.Options{
Target: runtimeTarget,
}), `could not open foo.go: stat foo.go: no such file or directory`)
}), `stat foo.go: no such file or directory`)
})
t.Run("glob", func(t *testing.T) {
ctx.Config.Builds[0].Main = "."