Standard library / hash/maphash

hash/maphash.Hash.WriteString()

Append string bytes, not Unicode code points; returns byte count and nil error. This is not a cryptographic authentication primitive. Expected stdout: '2 <nil> true\n'.

Formal Syntax & Structure

go syntaxgo
func (h *Hash) WriteString(s string) (int, error)

Parameters & Attributes

NameTypeDescription
sstringString whose bytes are hashed.

Return Value

(int, error)

Full input byte count and nil error.

Working Example

Example Snippetgo
package main
import (  "fmt"  "hash/maphash")
func main() {  var h maphash.Hash  n, e := h.WriteString("é")  fmt.Println(n, e, h.Sum64() == maphash.String(h.Seed(), "é"))}
Go Reference