fmt.Printf("%v\n",abigslice) has no output on windows

697 views
Skip to first unread message

Morven

unread,
Jul 17, 2012, 9:52:23 PM7/17/12
to golan...@googlegroups.com
Sample program could be run at goplay: http://play.golang.org/p/sMrf3TN7kZ
which is correct

but on windows there's no ouput for the big silce, and there's No warnings & No errors.
the go version cmd output is: go version go1.0.2

package main

import (
"fmt"
)

type S struct {
A int
B string
}

func main() {
var slice []S
for i := 0; i < 10000; i++ {
s := S{i, "asdf"}
slice = append(slice, s)
}
fmt.Printf("len(slice):%d\n", len(slice))
fmt.Printf("slice:%v\n", slice)
}

What's wrong?

Jesse McNelis

unread,
Jul 17, 2012, 10:02:21 PM7/17/12
to Morven, golan...@googlegroups.com
On Wed, Jul 18, 2012 at 11:52 AM, Morven <sun...@gmail.com> wrote:
> Sample program could be run at goplay: http://play.golang.org/p/sMrf3TN7kZ
> which is correct
>
> but on windows there's no ouput for the big silce, and there's No warnings &
> No errors.

It's very strange to have a problem printing to stdout, so people
rarely check the error value returned from fmt.Printf()
But if you're having problems it might be reasonable to see what that error is.


--
=====================
http://jessta.id.au

Morven

unread,
Jul 17, 2012, 10:33:01 PM7/17/12
to golan...@googlegroups.com


在 2012年7月18日星期三UTC+8上午10时02分21秒,Jesse McNelis写道:

It's very strange to have a problem printing to stdout, so people
rarely check the error value returned from fmt.Printf()
But if you're having problems it might be reasonable to see what that error is.


Well, actually there's no problem about my own program, it's fine running, but i'm surprised to  notice
there's nothing printed to stdout.

There must be wrong somewhere with things like this, so what's that?

Steve McCoy

unread,
Jul 17, 2012, 10:36:59 PM7/17/12
to golan...@googlegroups.com
On Tuesday, July 17, 2012 10:33:01 PM UTC-4, Morven wrote:


Well, actually there's no problem about my own program, it's fine running, but i'm surprised to  notice
there's nothing printed to stdout.

There must be wrong somewhere with things like this, so what's that?

He means, don't ignore the return values from fmt.Printf, because they might hold a clue. 

brainman

unread,
Jul 17, 2012, 11:17:48 PM7/17/12
to golan...@googlegroups.com
On Wednesday, 18 July 2012 11:52:23 UTC+10, Morven wrote:

What's wrong?

Perhaps it is similar to what I have seen:
http://code.google.com/p/go/issues/detail?id=3767

Alex

peterGo

unread,
Jul 17, 2012, 11:55:49 PM7/17/12
to golan...@googlegroups.com
Morven,

You didn't check for errors. For example,


package main

import (
    "fmt"
)

type S struct {
    A   int
    B   string
}

func main() {
    var slice []S
    for i := 0; i < 10000; i++ {
        s := S{i, "asdf"}
        slice = append(slice, s)
    }
    n, err := fmt.Printf("len(slice):%d\n", len(slice))
    n, err = fmt.Printf("slice:%v\n", slice)
    if err != nil {
        fmt.Println(n, err)
    }
}

Output:
len(slice):10000
0 write /dev/stdout: Not enough storage is available to process this command.

Peter

peterGo

unread,
Jul 18, 2012, 12:07:01 AM7/18/12
to golan...@googlegroups.com
Morven,

It's:

Issue 3376: windows: detect + handle console in os.File.Write
http://code.google.com/p/go/issues/detail?id=3376

Peter

Morven

unread,
Jul 20, 2012, 4:30:04 AM7/20/12
to golan...@googlegroups.com

Thank you for all you reply , i finally got it!

I've some misunderstandings about the return values of fmt.Printf
Reply all
Reply to author
Forward
0 new messages