FAQ
I have a small go program that I would like to copy files and run
cryto.hash on the file as it is being copied.

The Copy Method will take a source file reader and a destination file
writer and a different copy method would take a source file reader and
crytop.hash writer seperatly but this seems to be repeating myself.

Is there a way in Go to take a single file reader and copy the bytes from
it and pass it through both the crypto.hash.writer and file.writer methods
at the same time?

Thanks for any info.

--
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+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

Search Discussions

  • James Bardin at Jun 18, 2013 at 1:58 pm
    I believe what you're looking for is the
    TeeReader http://golang.org/pkg/io/#TeeReader.
    It will write to a specified writer as it's being read.


    On Tuesday, June 18, 2013 9:55:12 AM UTC-4, Scott Turnbull wrote:

    I have a small go program that I would like to copy files and run
    cryto.hash on the file as it is being copied.

    The Copy Method will take a source file reader and a destination file
    writer and a different copy method would take a source file reader and
    crytop.hash writer seperatly but this seems to be repeating myself.

    Is there a way in Go to take a single file reader and copy the bytes from
    it and pass it through both the crypto.hash.writer and file.writer methods
    at the same time?

    Thanks for any info.
    --
    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+unsubscribe@googlegroups.com.
    For more options, visit https://groups.google.com/groups/opt_out.
  • Chris Hines at Jun 18, 2013 at 2:30 pm

    On Tuesday, June 18, 2013 9:58:42 AM UTC-4, James Bardin wrote:

    I believe what you're looking for is the TeeReader
    http://golang.org/pkg/io/#TeeReader.
    It will write to a specified writer as it's being read.
    That will work. Also consider MultiWriter<http://golang.org/pkg/io/#MultiWriter>
    .

    --
    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+unsubscribe@googlegroups.com.
    For more options, visit https://groups.google.com/groups/opt_out.
  • James Bardin at Jun 18, 2013 at 2:34 pm

    On Tue, Jun 18, 2013 at 10:30 AM, Chris Hines wrote:

    That will work. Also consider MultiWriter<http://golang.org/pkg/io/#MultiWriter>
    .
    Ah, that's the one I really wanted, but I was looking for "tee"! The
    function closest to "tee" happens to not be the one with that in the name :)

    --
    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+unsubscribe@googlegroups.com.
    For more options, visit https://groups.google.com/groups/opt_out.

Related Discussions

Discussion Navigation
viewthread | post
Discussion Overview
groupgolang-nuts @
categoriesgo
postedJun 18, '13 at 1:55p
activeJun 18, '13 at 2:34p
posts4
users3
websitegolang.org

People

Translate

site design / logo © 2021 Grokbase