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: charclass.go
    path of file: ./repos/corteza/server/vendor/github.com/dlclark/regexp2/syntax
    
    the code of the file until where you have to start completion: package syntax

import (
	"bytes"
	"encoding/binary"
	"fmt"
	"sort"
	"unicode"
	"unicode/utf8"
)

// CharSet combines start-end rune ranges and unicode categories representing a set of characters
type CharSet struct {
	ranges     []singleRange
	categories []category
	sub        *CharSet //optional subtractor
	negate     bool
	anything   bool
}

type category struct {
	negate bool
	cat    string
}

type singleRange struct {
	first rune
	last  rune
}

const (
	spaceCate
    
func getCharSetFromOldString(setText []rune, negate bool) func() *CharSet {
	c := CharSet{}
	if len(setText) > 0 {
		fillFirst := false
		l := len(setText)
		if negate {
			if setText[0] == 0 {
				setText = setText[1:]
			} else {
				l++
				fillFirst = true
			}
		}

		if l%2 == 0 {
			c.ranges = make([]singleRange, l/2)
		} else {
			c.ranges = make([]singleRange, l/2+1)
		}

		first := true
		if fillFirst {
			c.ranges[0] = singleRange{first: 0}
			first = false
		}

		i := 0
		for _, r := range setText {
			if first {
				// lower bound in a new range
				c.ranges[i] = singleRange{first: r}
				first = false
			} else {
				c.ranges[i].last = r - 1
				i++
				first = true
			}
		}
		if !first {
			c.ranges[i].last = utf8.MaxRune
		}
	}

	return func() *CharSet {
		local := c
		return &local
	}
}