Re: [golang-dev] go version inconsistency with Linux and Windows

183 views
Skip to first unread message

Russ Cox

unread,
Dec 5, 2016, 11:53:54 AM12/5/16
to jerome....@gmail.com, golang-nuts
[+golang-nuts, bcc golang-dev, per golang.org/wiki/Questions]

On Mon, Dec 5, 2016 at 10:24 AM, <jerome....@gmail.com> wrote:
Hello,
I just notice that go version is inconsistency on Linux and Windows.
I have unexpected return carriage on Windows (not on Linux).
I don't know whether you can fix it w/o break the Go 1 promise of compatibility or not.

Example:
When I do it on Linux:
go version
go version go1.7.4 linux/amd64
me@home ~/go/>

when I do it on Windows:
go version 
go version go1.7.4 windows/amd64 

me@home ~/go/

Are you sure the extra line is coming from 'go version' and not (for example) your shell prompt or some other piece in your system? The code that implements 'go version' is one line:

        fmt.Printf("go version %s %s/%s\n", runtime.Version(), runtime.GOOS, runtime.GOARCH)

I submitted https://golang.org/cl/33917 to make sure we never put a \r or \n into the runtime.Version() (here, "go1.7.4"). The other two come from a fixed set of choices, none of which have \r or \n in them. 

You might try redirecting the output of 'go version' to a file and looking at the file to confirm that there's only the one \n at the end.

Russ



Björn Graf

unread,
Dec 5, 2016, 1:46:06 PM12/5/16
to Russ Cox, jerome....@gmail.com, golang-nuts
CMD.EXE seems to append that newline after any final command print
out, e.g., "echo test" has an empty line separating test from the
prompt. PowerShell doesn't do this.

-- bg

Jérôme LAFORGE

unread,
Dec 5, 2016, 2:36:44 PM12/5/16
to Björn Graf, Russ Cox, golang-nuts
Thx all for the support. 

brainman

unread,
Dec 5, 2016, 7:27:42 PM12/5/16
to golang-dev, jerome....@gmail.com, golan...@googlegroups.com
This is what my system prints:

```
C:\dev\go\src>go version
go version devel +69313ee Thu Nov 17 19:44:05 2016 +1100 windows/386

C:\dev\go\src>echo "AAA"
"AAA"

C:\dev\go\src>
```

Alex
Reply all
Reply to author
Forward
0 new messages