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

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

示例1: TestMultiCoreChecksummedWriter

func TestMultiCoreChecksummedWriter(t *testing.T) {
    buf := &bytes.Buffer{}
    cw := NewMultiCoreChecksummedWriter(buf, 16, crc32.NewIEEE, runtime.GOMAXPROCS(0))
    if cw == nil {
        t.Fatal(cw)
    }
    n, err := cw.Write([]byte("12345678901234567890"))
    if n != 20 {
        t.Fatal(n)
    }
    if err != nil {
        t.Fatal(err)
    }
    hash := crc32.NewIEEE()
    hash.Write([]byte("1234567890123456"))
    n, err = cw.Write([]byte("ghijklmnopqrstuvwxyz"))
    if n != 20 {
        t.Fatal(n)
    }
    if err != nil {
        t.Fatal(err)
    }
    hash2 := crc32.NewIEEE()
    hash2.Write([]byte("7890ghijklmnopqr"))
    err = cw.Close()
    if err != nil {
        t.Fatal(err)
    }
    hash3 := crc32.NewIEEE()
    hash3.Write([]byte("stuvwxyz"))
    if !bytes.Equal(buf.Bytes(), []byte("1234567890123456"+string(hash.Sum(nil))+"7890ghijklmnopqr"+string(hash2.Sum(nil))+"stuvwxyz"+string(hash3.Sum(nil)))) {
        t.Fatalf("%#v", string(buf.Bytes()))
    }
}

开发者ID:wreese,项目名称:valuestore,代码行数:34,代码来源:checksummedio_test.go

示例2: makeOuts

func makeOuts(testIntents []*intents.Intent, demux *Demultiplexer, outChecksum map[string]hash.Hash, demuxOuts map[string]*RegularCollectionReceiver, outLengths map[string]*int, errCh chan<- error) {
    for _, dbc := range testIntents {
        ns := dbc.Namespace()
        sum := crc32.NewIEEE()
        muxOut := &RegularCollectionReceiver{
            Intent: dbc,
            Demux:  demux,
            Origin: ns,
        }
        outLength := 0

        outChecksum[ns] = sum
        demuxOuts[ns] = muxOut
        outLengths[ns] = &outLength

        demuxOuts[ns].Open()
        go func() {
            bs := make([]byte, db.MaxBSONSize)
            var err error
            for {
                var length int
                length, err = muxOut.Read(bs)
                if err != nil {
                    break
                }
                sum.Write(bs[:length])
                outLength += len(bs[:length])
            }
            if err == io.EOF {
                err = nil
            }
            errCh <- err
        }()
    }
}

开发者ID:Machyne,项目名称:mongo,代码行数:35,代码来源:multiplexer_roundtrip_test.go

示例3: ChecksumValid

func (m *Dot11) ChecksumValid() bool {
    // only for CTRL and MGMT frames
    h := crc32.NewIEEE()
    h.Write(m.Contents)
    h.Write(m.Payload)
    return m.Checksum == h.Sum32()
}

开发者ID:nplanel,项目名称:gopacket,代码行数:7,代码来源:dot11.go

示例4: run

func (d *decoder) run() error {
    // init hash
    d.crcHash = crc32.NewIEEE()
    // for each part
    for {
        // create a part
        d.part = new(Part)
        // read the header
        if err := d.readHeader(); err != nil {
            return err
        }
        // read part header if available
        if d.multipart {
            if err := d.readPartHeader(); err != nil {
                return err
            }
        }
        // decode the part body
        if err := d.readBody(); err != nil {
            return err
        }
        // add part to list
        d.parts = append(d.parts, d.part)
        // validate part
        if err := d.part.validate(); err != nil {
            return err
        }
    }
    return nil
}

开发者ID:dominikh,项目名称:yenc,代码行数:30,代码来源:yenc.go

示例5: Open

// Open returns a ReadCloser that provides access to the File's contents.
// Multiple files may be read concurrently.
func (f *File) Open() (rc io.ReadCloser, err error) {
    bodyOffset, err := f.findBodyOffset()
    if err != nil {
        return
    }
    size := int64(f.CompressedSize64)
    r := io.NewSectionReader(f.zipr, f.headerOffset+bodyOffset, size)
    switch f.Method {
    case Store: // (no compression)
        rc = ioutil.NopCloser(r)
    case Deflate:
        rc, err = zlib.NewReader(r)
        if err != nil {
            return
        }
    default:
        err = ErrAlgorithm
        return
    }
    var desr io.Reader
    if f.hasDataDescriptor() {
        desr = io.NewSectionReader(f.zipr, f.headerOffset+bodyOffset+size, dataDescriptorLen)
    }
    rc = &checksumReader{rc, crc32.NewIEEE(), f, desr, nil}
    return
}

开发者ID:uwedeportivo,项目名称:torrentzip,代码行数:28,代码来源:reader.go

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