Go 语言

Go 语言教程 Go 语言环境安装 Go 语言结构 Go 语言基础语法 Go 语言数据类型 Go 语言变量 Go 语言常量 Go 语言运算符 Go 语言条件语句 Go 语言 if 语句 Go 语言 if...else 语句 Go 语言 if 语句嵌套 Go 语言 switch 语句 Go 语言 select 语句 Go 语言循环语句 Go 语言 for 循环 Go 语言循环嵌套 Go 语言 break 语句 Go 语言 continue 语句 Go 语言 goto 语句 Go 语言函数 Go 语言函数值传递值 Go 语言函数引用传递值 Go 语言函数作为值 Go 语言函数闭包 Go 语言函数方法 Go 语言变量作用域 Go 语言数组 Go 语言多维数组 Go 语言向函数传递数组 Go 语言指针 Go 语言指针数组 Go 语言指向指针的指针 Go 语言指针作为函数参数 Go 语言结构体 Go 语言切片(Slice) Go 语言范围(Range) Go 语言Map(集合) Go 语言递归函数 Go 语言类型转换 Go 语言接口 Go 错误处理 Go 语言开发工具Go 语言标准库

Go 语言标准库


package hash

import "hash"

hash包提供hash函数的接口。

Go语言标准库 >>


  • type Hash
  • type Hash32
  • type Hash64
  • type Hash

    type Hash interface {
        // 通过嵌入的匿名io.Writer接口的Write方法向hash中添加更多数据,永远不返回错误
        io.Writer
        // 返回添加b到当前的hash值后的新切片,不会改变底层的hash状态
        Sum(b []byte) []byte
        // 重设hash为无数据输入的状态
        Reset()
        // 返回Sum会返回的切片的长度
        Size() int
        // 返回hash底层的块大小;Write方法可以接受任何大小的数据,
        // 但提供的数据是块大小的倍数时效率更高
        BlockSize() int
    }

    Hash是一个被所有hash函数实现的公共接口。

    type Hash32

    type Hash32 interface {
        Hash
        Sum32() uint32
    }

    Hash32是一个被所有32位hash函数实现的公共接口。

    type Hash64

    type Hash64 interface {
        Hash
        Sum64() uint64
    }

    Hash64是一个被所有64位hash函数实现的公共接口。