risking to give some folks a good reason for a facepalm I want to
present the following question:
Why is "hash.Hash" not having a "Writer"?
I tried.
> Sha1Hash := sha1.New()
> Sha1Hash.Writer.WriteString('SecretPasskey')
> print(Sha1Hash.Sum())
an received the error
> Sha1Hash.Writer undefined (type hash.Hash has no field Writer)
but the documentation says (http://golang.org/pkg/hash/):
> type Hash interface {
> ...
> io.Writer
> ...
> }
So I only see one possible explanation which is unsatisfying and
therefore I assume worng:
a) I can not access io.Writer because the "i" of "io" is lowercase or
b) hence I can not give any string to hash to my previous Sha1Hash-Func
I'd be glad if someone could help me out here,
Greetings,
B-Ranger
> type Hash interface {
> ...
> io.Writer
> ...
> }
Does NOT say, that there is a field called "Writer" on which methods
working on "io.Writer" work BUT it says, that this type "Hash"
implements the methods that "io.Writer" implement. And this method(s)
are (http://golang.org/pkg/io/#Writer):
> type Writer interface {
> Write(p []byte) (n int, err os.Error)
> }
The solution of jimmy:
> Sha1Hash.Writer.Write([]byte("SecretPasskey"))
is also NOT working because, again it assumes the existence of an
embedded object. Instead the following works and is what I was looking for:
> Sha1Hash.Write([]byte("SecretPasskey"))
Thank you,
B-Ranger