aboutsummaryrefslogtreecommitdiff
path: root/go
diff options
context:
space:
mode:
Diffstat (limited to 'go')
-rwxr-xr-xgo/cbrotli/cgo.go13
-rwxr-xr-xgo/cbrotli/writer.go9
2 files changed, 17 insertions, 5 deletions
diff --git a/go/cbrotli/cgo.go b/go/cbrotli/cgo.go
new file mode 100755
index 0000000..f953f72
--- /dev/null
+++ b/go/cbrotli/cgo.go
@@ -0,0 +1,13 @@
+// Copyright 2017 Google Inc. All Rights Reserved.
+//
+// Distributed under MIT license.
+// See file LICENSE for detail or copy at https://opensource.org/licenses/MIT
+
+package cbrotli
+
+// Inform golang build system that it should link brotli libraries.
+
+// #cgo LDFLAGS: -lbrotlicommon
+// #cgo LDFLAGS: -lbrotlidec
+// #cgo LDFLAGS: -lbrotlienc
+import "C"
diff --git a/go/cbrotli/writer.go b/go/cbrotli/writer.go
index 279a2f2..9fa75ab 100755
--- a/go/cbrotli/writer.go
+++ b/go/cbrotli/writer.go
@@ -56,9 +56,6 @@ type WriterOptions struct {
// LGWin is the base 2 logarithm of the sliding window size.
// Range is 10 to 24. 0 indicates automatic configuration based on Quality.
LGWin int
- // BufferSize is the number of bytes to use to buffer encoded output.
- // 0 indicates an implementation-defined default.
- BufferSize int
}
// Writer implements io.WriteCloser by writing Brotli-encoded data to an
@@ -80,8 +77,10 @@ func NewWriter(dst io.Writer, options WriterOptions) *Writer {
state := C.BrotliEncoderCreateInstance(nil, nil, nil)
C.BrotliEncoderSetParameter(
state, C.BROTLI_PARAM_QUALITY, (C.uint32_t)(options.Quality))
- C.BrotliEncoderSetParameter(
- state, C.BROTLI_PARAM_LGWIN, (C.uint32_t)(options.LGWin))
+ if options.LGWin > 0 {
+ C.BrotliEncoderSetParameter(
+ state, C.BROTLI_PARAM_LGWIN, (C.uint32_t)(options.LGWin))
+ }
return &Writer{
dst: dst,
state: state,