<commit_before>package generator

const writeDoubleMethod = `
func writeDouble(r float64, w io.Writer) error {
	bits := uint64(math.Float64bits(r))
	const byteCount = 8
	return encodeFloat(w, byteCount, bits)
}
`

type doubleField struct {
	name         string
	defaultValue float64
	hasDefault   bool
}

func (s *doubleField) Name() string {
	return toPublicName(s.name)
}

func (s *doubleField) FieldType() string {
	return "Double"
}

func (s *doubleField) GoType() string {
	return "float64"
}

func (s *doubleField) SerializerMethod() string {
	return "writeDouble"
}

func (s *doubleField) AddStruct(*Package) {}

func (s *doubleField) AddSerializer(p *Package) {
	p.addStruct(UTIL_FILE, "ByteWriter", byteWriterInterface)
	p.addFunction(UTIL_FILE, "", "writeDouble", writeDoubleMethod)
	p.addFunction(UTIL_FILE, "", "encodeFloat", encodeFloatMethod)
	p.addImport(UTIL_FILE, "io")
}<commit_msg>Add "math" import for double primitives<commit_after>package generator

const writeDoubleMethod = `
func writeDouble(r float64, w io.Writer) error {
	bits := uint64(math.Float64bits(r))
	const byteCount = 8
	return encodeFloat(w, byteCount, bits)
}
`

type doubleField struct {
	name         string
	defaultValue float64
	hasDefault   bool
}

func (s *doubleField) Name() string {
	return toPublicName(s.name)
}

func (s *doubleField) FieldType() string {
	return "Double"
}

func (s *doubleField) GoType() string {
	return "float64"
}

func (s *doubleField) SerializerMethod() string {
	return "writeDouble"
}

func (s *doubleField) AddStruct(*Package) {}

func (s *doubleField) AddSerializer(p *Package) {
	p.addStruct(UTIL_FILE, "ByteWriter", byteWriterInterface)
	p.addFunction(UTIL_FILE, "", "writeDouble", writeDoubleMethod)
	p.addFunction(UTIL_FILE, "", "encodeFloat", encodeFloatMethod)
	p.addImport(UTIL_FILE, "io")
	p.addImport(UTIL_FILE, "math")
}
{'fraction_non_alphanumeric': 0.12486544671689989, 'fraction_numerical': 0.011840688912809472, 'mean_word_length': 5.592198581560283, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7348606', 'n_tokens_mistral': 647, 'n_tokens_neox': 632, 'n_words': 159}