You are an expert in writing code in many different languages. Your goal is to perform code completion for the following code, keeping in mind the rest of the code and the file meta data.
    Metadata details:
    filename: writer.go
    path of file: ./repos/caire/vendor/golang.org/x/image/ccitt
    
    the code of the file until where you have to start completion: // Copyright 2019 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.

package ccitt

import (
	"encoding/binary"
	"io"
)

type bitWriter struct {
	w i
    
func (b *bitWriter) writeCode(bs bitString) error {
	bits := bs.bits
	nBits := bs.nBits
	if 64-b.nBits >= nBits {
		// b.bits has sufficient room for storing nBits bits.
		b.bits |= uint64(bits) << (64 - nBits - b.nBits)
		b.nBits += nBits
		if b.nBits == 64 {
			return b.flushBits()
		}
		return nil
	}

	// Number of leading bits that fill b.bits.
	i := 64 - b.nBits

	// Fill b.bits then flush and write remaining bits.
	b.bits |= uint64(bits) >> (nBits - i)
	b.nBits = 64

	if err := b.flushBits(); err != nil {
		return err
	}

	nBits -= i
	b.bits = uint64(bits) << (64 - nBits)
	b.nBits = nBits
	return nil
}