func genErrorCodes(htmlFile string, w io.Writer) { root := gs.WebPage{}.Load(htmlFile).Parse() table := root.Find(id("AGuideToTheKafkaProtocol-ErrorCodes")).FindNext(class("table-wrap")).Find(tbody) var errors []errorInfo table.Children(tr).For(func(row *query.Node) { cols := row.Children(td).All() errors = append(errors, errorInfo{ name: *cols[0].PlainText(), code: *cols[1].PlainText(), msg: cleanMsg(*cols[2].PlainText()), }) }) fpl(w, "package "+packageName) fpl(w, "const (") for _, e := range errors { if e.code != "0" { fp(w, "Err") } fp(w, e.name) fp(w, " ErrorCode = ") fpl(w, e.code) } fpl(w, ")") fpl(w, "var errTexts = []string{") for _, e := range errors { if e.code != "-1" { fp(w, e.code) fp(w, ":") fp(w, `"proto(`) fp(w, e.code) fp(w, "): ") fp(w, e.msg) fpl(w, `",`) } } fpl(w, "}") }