Skip to content

cmd/go: go run always returns exit code 1, no matter what the real exit code was #13440

@viktorbenei

Description

@viktorbenei

What version of Go are you using (go version)?

$ go version
go version go1.5.1 darwin/amd64

What operating system and processor architecture are you using?

Mac OS X 10.11.1

What did you do?

Saved this Go program into main.go:

package main

import "os"

func main() {
    os.Exit(3)
}

And then ran go run main.go:

$ go run main.go
exit status 3
$ echo $?
1

What did you expect to see?

$ echo $? should be 3 instead of 1

What did you see instead?

The exit code reported by $ echo $? is always 1 if the program exits with a non zero exit code.

If you compile the example with $ go build -o gotest it returns the expected exit code:

$ ./gotest
$ echo $?
3

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions