I am using bufio.Reader and binary.Read
to read binary from file, I want to seek in the file or bufio.Reader
Below code does not work
fi.Seek(0, os.SEEK_SET) Does not work for bufio.Reader
below definition shows that r control the position , but I did not see any
method to set it
On 01/19/2017 02:00 AM, hui zhang wrote:
> so the file seek does not work in bufio.Read ?
>
It looks like this has been answered before:
https://groups.google.com/forum/#!topic/golang-nuts/mOvX0bmJoeI
You could also create another bufio.Reader after you seek like:
rd :=
On Wed, 18 Jan 2017 23:00:33 -0800 (PST)
hui zhang wrote:
> so the file seek does not work in bufio.Read ?
You might need to use the Reset() method of your bufio.Reader value
before you reposition the pointer in the underlying opened file.
Please see `go doc
On Wed, 18 Jan 2017 22:54:31 -0800 (PST)
hui zhang wrote:
[...]
> > 2. So we now read the docs on os.File:
> >
> > $ go doc os.File
> >
> >...and see all of its methods there, inclusing Seek().
> >
> > 3. So we read the docs on it:
> >
> > $ go doc
so the file seek does not work in bufio.Read ?
在 2017年1月19日星期四 UTC+8下午2:59:39,hui zhang写道:
>
> fi.Seek(0, os.SEEK_SET )?
>
>
> I set this in the code and I expected to print 3.13 twice , but this code
> print 3.13 3.14
> why?
>
> package main
>
> import (
>_ "bytes"
>"fmt"
>
fi.Seek(0, os.SEEK_SET )?
I set this in the code and I expected to print 3.13 twice , but this code
print 3.13 3.14
why?
package main
import (
_ "bytes"
"fmt"
_ "math"
"bufio"
"encoding/binary"
"os"
)
func main() {
var pi float64
//b := []byte{0x18, 0x2d,
thanks all, I use ide go to definition, it go to the file_unix.go
in this file seek is a private method.
So I am confused
在 2017年1月19日星期四 UTC+8下午2:45:16,Konstantin Khomoutov写道:
>
> On Wed, 18 Jan 2017 22:22:48 -0800 (PST)
> hui zhang wrote:
>
> [...]
> >fi, err
On Wed, 18 Jan 2017 22:22:48 -0800 (PST)
hui zhang wrote:
[...]
>fi, err := os.Open("./output.bin")
[...]
>fi.seek()?
The usual drill is:
1. Get the documentation on os.Open():
$ go doc os.Open
Notice what it returns in its 1st return value has
On 01/19/2017 01:22 AM, hui zhang wrote:
> I am using encoding/binary to read/write (struct)data to/from file.
> Some times , I need to seek in the file while reading .
> how to do this in go.
> Check the code below
[snip!]
>
>
> fi, err := os.Open("./output.bin")
>if err != nil {
>
I am using encoding/binary to read/write (struct)data to/from file.
Some times , I need to seek in the file while reading .
how to do this in go.
Check the code below
package main
import (
_ "bytes"
"fmt"
_ "math"
"bufio"
"encoding/binary"
"os"
)
func main() {
var pi
On Wed, Jan 18, 2017 at 9:55 PM, Bryan Chan wrote:
> On Wednesday, 18 January 2017 16:39:03 UTC-5, rog wrote:
>>
>> On 18 January 2017 at 18:45, Bryan Chan wrote:
>> > But I couldn't find a way to bind a receiver to a method expression,
>> such
>> > that
No, but you can create a function/closure which gets the receiver as first arg,
and either executes the method with the given args, or returns such a function,
as you wish.
--
You received this message because you are subscribed to the Google Groups
"golang-nuts" group.
To unsubscribe from
The bufio.NewWriter is unneeded here, as both the gzip.Writer and csv.Writer
are buffered.
The concept of csv.Writer(gzip.Writer(os.File)) is ok.
Compression is cpu bound, and csv.Writer may need some optimization.
But first measure, use testing package's benchmark functionality.
--
You
On Wednesday, 18 January 2017 16:39:03 UTC-5, rog wrote:
>
> On 18 January 2017 at 18:45, Bryan Chan
> wrote:
> > But I couldn't find a way to bind a receiver to a method expression,
> such
> > that the resulting method value can be invoked at a later time. Would
> this
I'm trying to play with go:linkname, and I wrote a demo for this.
directory structure:
[test]$ tree
.
├── main.go
├── pri
│ └── a.go
└── pub
├── issue15006.s
└── b.go
a.go:
package pri
import (
"fmt"
)
func rua() int64 {
fmt.Println("rua in pri")
return 1
}
b.go:
Thanks for you reply, I got it done: https://play.golang.org/p/oOEELLyaVv
This is how I did it, pass *interface{} to gob.Encode, not interface{}
the same with gob.Decode, then get the type info from the decoded value
interface{}
在 2017年1月18日星期三 UTC+8下午10:51:51,Jordan Krage写道:
>
> Actually,
Thanks for time in responding.
Appreciate.
On Wed, Jan 18, 2017 at 1:46 PM, roger peppe wrote:
>
>
> On 17 January 2017 at 19:14, Deepak Jain wrote:
>
>> I fixed the error by invoking Copy command with abs source path.
>>
>> srcPath, _ :=
>> e :=
With more and more sites / apps built with the "thick-client" mindset
(SPAs, React/React Native, etc) I found that I needed something like
Wordpress for a great CMS, but for JSON clients, not HTML pages. I wanted
something like Rails CLI for really fast dev experience, but with better
Hi,
I have some code to write out a .csv file and then gzip it. I am using a
bufio.NewWriter to link the two:
x := gzip.NewWriter(outputFile)
outBuf := bufio.NewWriter(x)
w := csv.NewWriter(outBuf)
It seems slow.
Would I be better off just writing first a .csv file to disk and then
On Wednesday, 18 January 2017 06:07:00 UTC+1, Tomi Häsä wrote:
>
> What is the difference between Encoder and MarshalIndent? They both write
> to a stream. When do you use Encoder?
>
MarshallIndent is a shortcut that creates an encoder, calls
encoder.Indent() and then calls encoder.Encode():
On 17 January 2017 at 19:14, Deepak Jain wrote:
> I fixed the error by invoking Copy command with abs source path.
>
> srcPath, _ :=
> e := util.Copy(srcPath, dst)
>
> If i could modify into a single line
>
> util.Copy(filepath.Abs(filepath.Dir(src)), dst)
> Throws error as
On 18 January 2017 at 18:45, Bryan Chan wrote:
> In Go, you could pass a method value around so that the method can be
> invoked later on a pre-determined receiver, e.g.
>
> func (a *A) foo() bool { ... }
>
> func bar(f func () bool) {
> if f() {
> ...
> }
> }
+golang-nuts, bcc: golang-dev
On Tue, Jan 17, 2017 at 2:38 PM, Brad Fitzpatrick
wrote:
> https://groups.google.com/forum/#!forum/google-appengine-go looks like
> the right place.
>
>
> On Tue, Jan 17, 2017 at 2:30 PM, Dewey Gaedcke wrote:
>
>> Yesthat
Hi,
go-funk has been released (https://github.com/thoas/go-funk), the 0.1 has
been tagged.
This library provides multiple generic implementations:
- Map
- Contains
- Keys
- Values
- Filter
- Find
- etc.
and also typesafe implementations.
More helpers are coming in the
Hi,
I'm trying to create an gtk.Image from a Go image.Image (or similar,
image.RGBA would be fine too), and am stuck. It looks like I need to create
a gdk.Pixbuf to feed to the GTK image widget, but I can't figure out how to
use the gdk.Pixbuf, to create a useful picture.
All the examples of
Actually, it looks like the int/int8 distinction doesn't matter for gob.
> There is no int8, int16 etc. discrimination in the gob format; there are
> only signed and unsigned integers.
>
https://golang.org/pkg/encoding/gob/
On Wednesday, January 18, 2017 at 8:43:27 AM UTC-6, Jordan Krage
I experimented using the function options (e.g. withFunc() ) in PHP. I know
its unnecessary as PHP functions and methods can accept optional
parameters, and I know that you cant have function types in PHP, but the
approach is still so clean and self documenting I'd like to use it for much
more
27 matches
Mail list logo