<h3 id="bufio">The compress/flate, compress/gzip and compress/zlib packages</h3>
<p>
-In Go 1, the NewWriterXxx functions in compress/flate, compress/gzip and
-compress/zlib all return (*Writer, error) if they take a compression level,
-and *Writer otherwise. Package gzip's Compressor and Decompressor types have
-been renamed to Writer and Reader.
+In Go 1, the <code>NewWriterXxx</code> functions in
+<a href="/pkg/compress/flate"><code>compress/flate</code></a>,
+<a href="/pkg/compress/gzip"><code>compress/gzip</code></a> and
+<a href="/pkg/compress/zlib"><code>compress/zlib</code></a>
+all return <code>(*Writer, error)</code> if they take a compression level,
+and <code>*Writer</code> otherwise. Package <code>gzip</code>'s
+<code>Compressor</code> and <code>Decompressor</code> types have been renamed
+to <code>Writer</code> and <code>Reader</code>. Package <code>flate</code>'s
+<code>WrongValueError</code> type has been removed.
</p>
<p>
<h3 id="bufio">The compress/flate, compress/gzip and compress/zlib packages</h3>
<p>
-In Go 1, the NewWriterXxx functions in compress/flate, compress/gzip and
-compress/zlib all return (*Writer, error) if they take a compression level,
-and *Writer otherwise. Package gzip's Compressor and Decompressor types have
-been renamed to Writer and Reader.
+In Go 1, the <code>NewWriterXxx</code> functions in
+<a href="/pkg/compress/flate"><code>compress/flate</code></a>,
+<a href="/pkg/compress/gzip"><code>compress/gzip</code></a> and
+<a href="/pkg/compress/zlib"><code>compress/zlib</code></a>
+all return <code>(*Writer, error)</code> if they take a compression level,
+and <code>*Writer</code> otherwise. Package <code>gzip</code>'s
+<code>Compressor</code> and <code>Decompressor</code> types have been renamed
+to <code>Writer</code> and <code>Reader</code>. Package <code>flate</code>'s
+<code>WrongValueError</code> type has been removed.
</p>
<p>
package flate
import (
+ "fmt"
"io"
"math"
)
d.fill = (*compressor).fillDeflate
d.step = (*compressor).deflate
default:
- return WrongValueError{"level", 0, 9, int32(level)}
+ return fmt.Errorf("flate: invalid compression level %d: want value in range [-1, 9]", level)
}
return nil
}
import (
"io"
"math"
- "strconv"
)
const (
err error
}
-type WrongValueError struct {
- name string
- from int32
- to int32
- value int32
-}
-
func newHuffmanBitWriter(w io.Writer) *huffmanBitWriter {
return &huffmanBitWriter{
w: w,
}
}
-func (err WrongValueError) Error() string {
- return "huffmanBitWriter: " + err.name + " should belong to [" + strconv.FormatInt(int64(err.from), 10) + ";" +
- strconv.FormatInt(int64(err.to), 10) + "] but actual value is " + strconv.FormatInt(int64(err.value), 10)
-}
-
func (w *huffmanBitWriter) flushBits() {
if w.err != nil {
w.nbits = 0