<commit_before>package main

import (
	"bytes"
	"fmt"
	"go/token"

	"github.com/davyxu/gosproto/meta"
)

const goCodeTemplate = `// Generated by github.com/davyxu/gosproto/sprotogen
// DO NOT EDIT!

package {{.PackageName}}

import (
	"reflect"
	"github.com/davyxu/gosproto"
	"github.com/davyxu/goobjfmt"
	{{if .CellnetReg}}"github.com/davyxu/cellnet/codec/sproto"{{end}}
)

{{range $a, $enumobj := .Enums}}
type {{.Name}} int32
const (	{{range .StFields}}
	{{$enumobj.Name}}_{{.Name}} {{$enumobj.Name}} = {{.TagNumber}} {{end}}
)

var {{$enumobj.Name}}MapperValueByName = map[string]int32{ {{range .StFields}}
	"{{.Name}}": {{.TagNumber}}, {{end}}
}

var {{$enumobj.Name}}MapperNameByValue = map[int32]string{ {{range .StFields}}
	{{.TagNumber}}: "{{.Name}}" , {{end}}
}

func (self {{$enumobj.Name}}) String() string {
	return sproto.EnumName({{$enumobj.Name}}MapperNameByValue, int32(self))
}
{{end}}

{{range $a, $stobj := .Structs}}
type {{.Name}} struct{
	{{range .StFields}}
		{{.GoFieldName}} {{.GoTypeName}} {{.GoTags}} 
	{{end}}
}

func (self *{{.Name}}) String() string { return goobjfmt.CompactTextString(self) }

{{range .StFields}}{{if .IsExtendType}}
func (self *{{$stobj.Name}}) {{.GoExtendFieldGetterName}}() {{.GoExtendFieldGetterType}} {
	{{.GoExtendFieldGetter}}
}
func (self *{{$stobj.Name}}) Set{{.GoExtendFieldGetterName}}(v {{.GoExtendFieldGetterType}})  {
	{{.GoExtendFieldSetter}}
}
{{end}} {{end}}
{{end}}

var SProtoStructs = []reflect.Type{
{{range .Structs}}
	reflect.TypeOf((*{{.Name}})(nil)).Elem(), // {{.MsgID}} {{end}}
}

{{if .CellnetReg}}
func init() {
	sprotocodec.AutoRegisterMessageMeta(SProtoStructs)
}
{{end}}<commit_msg>added: golang enum iterate map<commit_after>package main

import (
	"bytes"
	"fmt"
	"go/token"

	"github.com/davyxu/gosproto/meta"
)

const goCodeTemplate = `// Generated by github.com/davyxu/gosproto/sprotogen
// DO NOT EDIT!

package {{.PackageName}}

import (
	"reflect"
	"github.com/davyxu/gosproto"
	"github.com/davyxu/goobjfmt"
	{{if .CellnetReg}}"github.com/davyxu/cellnet/codec/sproto"{{end}}
)

{{range $a, $enumobj := .Enums}}
type {{.Name}} int32
const (	{{range .StFields}}
	{{$enumobj.Name}}_{{.Name}} {{$enumobj.Name}} = {{.TagNumber}} {{end}}
)

var {{$enumobj.Name}}MapperValueByName = map[string]int32{ {{range .StFields}}
	"{{.Name}}": {{.TagNumber}}, {{end}}
}

var {{$enumobj.Name}}MapperNameByValue = map[int32]string{ {{range .StFields}}
	{{.TagNumber}}: "{{.Name}}" , {{end}}
}

func (self {{$enumobj.Name}}) String() string {
	return sproto.EnumName({{$enumobj.Name}}MapperNameByValue, int32(self))
}
{{end}}

{{range $a, $stobj := .Structs}}
type {{.Name}} struct{
	{{range .StFields}}
		{{.GoFieldName}} {{.GoTypeName}} {{.GoTags}} 
	{{end}}
}

func (self *{{.Name}}) String() string { return goobjfmt.CompactTextString(self) }

{{range .StFields}}{{if .IsExtendType}}
func (self *{{$stobj.Name}}) {{.GoExtendFieldGetterName}}() {{.GoExtendFieldGetterType}} {
	{{.GoExtendFieldGetter}}
}
func (self *{{$stobj.Name}}) Set{{.GoExtendFieldGetterName}}(v {{.GoExtendFieldGetterType}})  {
	{{.GoExtendFieldSetter}}
}
{{end}} {{end}}
{{end}}

var SProtoStructs = []reflect.Type{
{{range .Structs}}
	reflect.TypeOf((*{{.Name}})(nil)).Elem(), // {{.MsgID}} {{end}}
}

var SProtoEnumValue = map[string]map[int32]string{ {{range .Enums}}
	"{{.Name}}": {{.Name}}MapperNameByValue,{{end}}
}

{{if .CellnetReg}}
func init() {
	sprotocodec.AutoRegisterMessageMeta(SProtoStructs)
}
{{end}}
{'fraction_non_alphanumeric': 0.2388102801039561, 'fraction_numerical': 0.0051978053710655505, 'mean_word_length': 5.623326959847036, 'pattern_counts': {'":': 3, '<': 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': '468401', 'n_tokens_mistral': 1384, 'n_tokens_neox': 1363, 'n_words': 238}