本文整理汇总了Golang中hash/fnv.New64函数的典型用法代码示例。如果您正苦于以下问题:Golang New64函数的具体用法?Golang New64怎么用?Golang New64使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。

在下文中一共展示了New64函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Golang代码示例。

示例1: BenchmarkFnv64

func BenchmarkFnv64(b *testing.B) {
    h := fnv.New64()
    for i := 0; i < b.N; i++ {
        h.Write(in)
        h.Sum(nil)
    }
}

开发者ID:panamafrancis,项目名称:xxhash,代码行数:7,代码来源:xxhash_test.go

示例2: Example

func Example() {
    // As usual in examples, this ignores all errors. Don't do this in your program.

    // setup and find start point for centering
    s := "Hello, World!"
    size := image.Rect(0, 0, 120, 20)
    dst := image.NewRGBA(size)
    c := freetype.NewContext()
    c.SetFont(font)
    c.SetFontSize(14.0)
    c.SetSrc(image.NewUniform(color.Black))
    c.SetDst(dst)
    start, _ := fontutil.CenterX(c, s, size) // CenterX calls c.SetClip(size)

    // perform draw at start.X + y 16
    c.DrawString(s, start.Add(freetype.Pt(0, 16)))

    // write the image out to a file
    // out, _ := os.Create("helloworld.png")
    // defer out.Close()

    // write image to hash for testing purposes
    out := fnv.New64()
    _ = png.Encode(out, dst)
    fmt.Printf("Hash of compressed image: %x", out.Sum64())
    // Output: Hash of compressed image: fa83a1b8d8abf5f2
}

开发者ID:infogulch,项目名称:fontutil,代码行数:27,代码来源:example_test.go

示例3: newFilter

func newFilter(m, k uint32) *filter {
    return &filter{
        m: m,
        k: k,
        h: fnv.New64(),
    }
}

开发者ID:patrickmn,项目名称:go-bloom,代码行数:7,代码来源:bloom.go

示例4: cmdServerNick

func (i *IRCServer) cmdServerNick(s *Session, reply *Replyctx, msg *irc.Message) {
    // e.g. “NICK OperServ 1 1422134861 services localhost.net services.localhost.net 0 :Operator Server”
    // <nickname> <hopcount> <username> <host> <servertoken> <umode> <realname>

    // Could be either a nickchange or the introduction of a new user.
    if len(msg.Params) == 1 {
        // TODO(secure): handle nickchanges. not sure when/if those are used. botserv maybe?
        return
    }

    if _, ok := i.nicks[NickToLower(msg.Params[0])]; ok {
        i.sendServices(reply, &irc.Message{
            Prefix:   i.ServerPrefix,
            Command:  irc.ERR_NICKNAMEINUSE,
            Params:   []string{"*", msg.Params[0]},
            Trailing: "Nickname is already in use",
        })
        return
    }

    h := fnv.New64()
    h.Write([]byte(msg.Params[0]))
    id := types.RobustId{
        Id:    s.Id.Id,
        Reply: int64(h.Sum64()),
    }

    i.CreateSession(id, "")
    ss := i.sessions[id]
    ss.Nick = msg.Params[0]
    i.nicks[NickToLower(ss.Nick)] = ss
    ss.Username = msg.Params[3]
    ss.Realname = msg.Trailing
    ss.updateIrcPrefix()
}

开发者ID:aftran,项目名称:robustirc,代码行数:35,代码来源:server_commands.go

示例5: hash

func hash(s ...[]byte) uint64 {
    h := fnv.New64()
    for _, b := range s {
        h.Write(b)
    }
    return h.Sum64()
}

开发者ID:fanyang01,项目名称:crawler,代码行数:7,代码来源:fingerprint.go

最后编辑: kuteng  文档更新时间: 2021-08-23 19:14   作者:kuteng