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
type
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 := bufio.NewReade
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 bufio.Reader.Reset`.
But this pose
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 os.File.Seek
> >
> thanks all
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, 0
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 := os.Open("./output.
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 the
type *File. Sinc
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 {
> pa
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 flo
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 the resulting method value can be invoked
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 thi
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 recei
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
> > be a useful addi
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:
pack
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, it
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 := util.Copy(srcPath, dst)
>>
>> If i could modify
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
concurr
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
gzi
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():
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() {
...
}
}
func main() {
a := &A{ ... }
bar(a.foo)
}
You could also create a method e
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 filepath.Abs(filepath.
On 17 January 2017 at 18:50, Deepak Jain wrote:
> Thanks for pointing to https://github.com/juju/
> utils/blob/master/fs/copy.go
>
>
> I was testing Copy function that recursively copies directories. I am able
> to copy first level of files and it creates directories. It fails to copy
> the conte
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() {
> ...
> }
> }
>
> func main() {
>
+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 project has not been updated in 7 month
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 nex
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 h
On Tuesday, January 17, 2017 at 11:07:00 PM UTC-6, Tomi Häsä wrote:
>
> What is the difference between Encoder and MarshalIndent? They both write
> to a stream. When do you use Encoder?
>
I think julian.klode already answered this, not sure why it has not shown
up here.
First, they do *not* bo
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 wrote:
How about a compromise with denser type info? (could consider an int8 as
well)
type infoType int
const (
firstType infoType = iota
secondType
...
)
type Info struct{
infoType
IData interface{}
}
On Wednesday, January 18, 2017 at 12:07:49 AM UTC-6, casp...@gmail.com
wrot
On Wed, 18 Jan 2017, at 02:23 PM, Tomi Häsä wrote:
> What is the difference between XML Encoder and Marshal (or
> MarshalIndent)? They both are used when writing to a stream. When do
> you use Encoder?
Marshal doesn't write to a stream. It returns a byte slice which you
could then use directly
What is the difference between XML Encoder and Marshal (or MarshalIndent)?
They both are used when writing to a stream. When do you use Encoder?
--
You received this message because you are subscribed to the Google Groups
"golang-nuts" group.
To unsubscribe from this group and stop receiving em
Hi,
I am trying to get DiskIO -
Using Psutil pkg
https://godoc.org/github.com/shirou/gopsutil/disk#IOCounters
IOCounters()
IN Linux able to get But Not IN MAC OS X
In Python Using Sigar Pkg
sobj = sigar.open()
tcp_stats = sobj.tcp()
tcp_stats.activ
On Tuesday, January 17, 2017 at 12:01:43 PM UTC+1, la...@namsral.com wrote:
>
> Thanks, Damian Gryski has a nice tutorial on how to write Go assembly
> functions with PeachPy.
>
> https://blog.gopheracademy.com/advent-2016/peachpy/
>
Thanks! I've written a bunch more assembly code using Peach
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
On 18-01-2017, Felipe Spinolo wrote:
>
> I think it's a mistake to try to apply one language's idioms to another
> language. I don't write Go the way I would write Java or Python, and I
> don't write either of them the way I would write Go. Idiomatic Go is
> idiomatic because it fits with the
36 matches
Mail list logo