Hi Paul,
Thanks for your feedback!

2016-09-20 0:02 GMT+09:00 Paul Borman <bor...@google.com>:
> Adding an scp package is a nice addition.

I agree.
Should I send a pull request to https://github.com/golang/crypto?
If yes, what package? golang.org/x/crypto/scp or golang.org/x/crypto/ssh/scp?

> You might want to consider simple names like:
>
> Send - Sends from []byte to file on remote host
> SendDir - Send files in dir to a remote host
> SendFile - Sends the contents of a file to the remote host
> Fetch - Fetches the contents of a file on remote host into memory
> FetchFile - Fetches a file from remote host into file on local host
> FetchDir - Fetches the files in a directory from the remote host
>
> These would translate in code to names like scp.SendFile, which is pretty
> descriptive all by itself.

Thanks for simple and descriptive function names.
I renamed functions.
https://github.com/hnakamur/go-scp/commit/8cd6d9e5ab17187556e5efc3a666d29b4b561c78

>
> For the directory copy, it might be better to have a function return the
> io.Writer to write the file to, rather than force the files into a
> directory.  This would make it easy to keep the contents in memory, change
> file names, or whatever.

Yes, I agree it might be better not to force the files in a directory.
However I don't think having a function return the io.Writer will do
since we need to read a reply for each scp protocol header or body.

I had read the article below and the openssh source code and
implemented my scp package https://github.com/hnakamur/go-scp.

"How the SCP protocol works (Jan Pechanec's weblog)"
https://blogs.oracle.com/janp/entry/how_the_scp_protocol_works

I built two structs sourceProtocol and sinkProtocol
https://github.com/hnakamur/go-scp/blob/master/protocol.go

I had thought to export these structs or make interfaces for that.
However the implementation of two functions SendDir and FetchDir
which using these structs become somewhat complex.

https://github.com/hnakamur/go-scp/blob/8cd6d9e5ab17187556e5efc3a666d29b4b561c78/source.go#L81-L175
https://github.com/hnakamur/go-scp/blob/8cd6d9e5ab17187556e5efc3a666d29b4b561c78/sink.go#L111-L223

So I was not confident about exporting sourceProtocol and sinkProtocol,
and I did not export them at the time.

If we can define structs, functions or interfaces which are easy to use,
I'm glad to export them.

Do you have an idea about such structs, functions or interfaces?
Thanks!

Hiroaki Nakamura

>
> On Fri, Sep 16, 2016 at 9:41 AM, Hiroaki Nakamura <hnaka...@gmail.com>
> wrote:
>>
>> Hi all,
>>
>> I noticed the golang.org/x/crypto/ssh package exists, but the scp
>> package does not.
>> So I wrote a scp client library in go.
>> https://github.com/hnakamur/go-scp
>>
>> I also wrote a sshd server just usable for testing go-scp.
>> https://github.com/hnakamur/go-sshd
>>
>> Right now, go-scp only exports high level functions which are supposed
>> to be easy to use.
>> https://godoc.org/github.com/hnakamur/go-scp
>>
>> However I wonder if there APIs can be improved. For example,
>> better function names and better arguments.
>>
>> Could you tell me what you think?
>> Thanks!
>>
>> Hiroaki Nakamura
>>
>> --
>> 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.
>
>

-- 
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.

Reply via email to