Re: [go-nuts] [ERROR] invalid argument when executing bufio.NewWriter.Flush()

2017-06-03 Thread Harry
Thanks Jan!

You are great!

On Saturday, 3 June 2017 13:00:51 UTC+2, Jan Mercl wrote:
>
> On Sat, Jun 3, 2017 at 12:42 PM Harry  
> wrote:
>
> > How can I handle to write something out using bufio.NewWriter?
>
> Just fine. The problem is you haven't created any file to write to in the 
> first place, which checking the error could have told you.
>
> -- 
>
> -j
>

-- 
You received this message because you are subscribed to the Google Groups 
"golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to golang-nuts+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [go-nuts] [ERROR] invalid argument when executing bufio.NewWriter.Flush()

2017-06-03 Thread Jan Mercl
On Sat, Jun 3, 2017 at 12:42 PM Harry  wrote:

> How can I handle to write something out using bufio.NewWriter?

Just fine. The problem is you haven't created any file to write to in the
first place, which checking the error could have told you.

-- 

-j

-- 
You received this message because you are subscribed to the Google Groups 
"golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to golang-nuts+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[go-nuts] [ERROR] invalid argument when executing bufio.NewWriter.Flush()

2017-06-03 Thread Harry
Hi guys,

How can I handle to write something out using bufio.NewWriter?

My code is like below,

var writer *bufio.Writer
var err error
file, _ := os.OpenFile(*fileName, os.O_WRONLY | os.O_APPEND, 0644)
defer file.Close()

writer = bufio.NewWriter(file)

writer.WriteString(strings.Join("something\n")

err = writer.Flush()
if err != nil {
//invalid argument
log.Fatal(err)
}


What is wrong?


Thanks guys!!

-- 
You received this message because you are subscribed to the Google Groups 
"golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to golang-nuts+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.