<commit_before>package main

/*

parse and generate function ti parse http.Request form

structs may be something like this

type reqProfile struct {
	ID       int64  `req:"id,nempty,nzero",json:"id"`
	Name     string `req:"name,sphinx,nempty,len>3,len<64",json:"name"`
	Language string `req:"language,nempty,len=2",json:"language"`
	Params   map[string]string `req:"prefix=param_",json:"params"`
	Groups   map[string][]string `req:"prefix=group_",json:"groups"`
	Passwd   string `req:"password,len>8",json:"-"`
}

will result in function
func reqProfileParse(request *http.Request) (reqProfile,string) {...}

*/

import (
	"fmt"
	"log"
	"os"
	"strings"

	"github.com/kanocz/goparse"
)

func main() {
	s, err := goparse.GetFileStructs(os.Args[1], "req", "req")
	if nil != err {
		fmt.Println("Error parsing file:", err)
		return
	}

	fmt.Print("package main\n\n")
	fmt.Print("import (\n\t\"net/http\"\n\t\"github.com/julienschmidt/httprouter\"\n\t\"github.com/vincent-petithory/dataurl\"\n\t\"strconv\"\n\t\"strings\"\n\t\"time\"\n)\n\n")

	for _, st := range s {
		fmt.Printf("func %sParse(request *http.Request, params httprouter.Params) (%s,string) {\n", st.Name, st.Name)
		fmt.Print("\tvar err error\n\t_ = err\n")
		fmt.Printf("\tres := %s{}\n", st.Name)
		fmt.Print("\trequest.ParseMultipartForm(0)\n\n")
		for _, f := range st.Field {

			pname := f.Name
			if nil != f.Tags && len(f.Tags) > 0 {
				pname = f.Tags[0]
			}

			checks := []string{}
			if nil != f.Tags && len(f.Tags) > 1 {
				checks = f.Tags[1:]
			}
<commit_msg>fix warning about unused params<commit_after>package main

/*

parse and generate function ti parse http.Request form

structs may be something like this

type reqProfile struct {
	ID       int64  `req:"id,nempty,nzero",json:"id"`
	Name     string `req:"name,sphinx,nempty,len>3,len<64",json:"name"`
	Language string `req:"language,nempty,len=2",json:"language"`
	Params   map[string]string `req:"prefix=param_",json:"params"`
	Groups   map[string][]string `req:"prefix=group_",json:"groups"`
	Passwd   string `req:"password,len>8",json:"-"`
}

will result in function
func reqProfileParse(request *http.Request) (reqProfile,string) {...}

*/

import (
	"fmt"
	"log"
	"os"
	"strings"

	"github.com/kanocz/goparse"
)

func main() {
	s, err := goparse.GetFileStructs(os.Args[1], "req", "req")
	if nil != err {
		fmt.Println("Error parsing file:", err)
		return
	}

	fmt.Print("package main\n\n")
	fmt.Print("import (\n\t\"net/http\"\n\t\"github.com/julienschmidt/httprouter\"\n\t\"github.com/vincent-petithory/dataurl\"\n\t\"strconv\"\n\t\"strings\"\n\t\"time\"\n)\n\n")

	for _, st := range s {
		fmt.Printf("func %sParse(request *http.Request, params httprouter.Params) (%s,string) {\n", st.Name, st.Name)
		fmt.Print("\t_ = params\n")
		fmt.Print("\tvar err error\n\t_ = err\n")
		fmt.Printf("\tres := %s{}\n", st.Name)
		fmt.Print("\trequest.ParseMultipartForm(0)\n\n")
		for _, f := range st.Field {

			pname := f.Name
			if nil != f.Tags && len(f.Tags) > 0 {
				pname = f.Tags[0]
			}

			checks := []string{}
			if nil != f.Tags && len(f.Tags) > 1 {
				checks = f.Tags[1:]
			}

{'fraction_non_alphanumeric': 0.2003841229193342, 'fraction_numerical': 0.008322663252240717, 'mean_word_length': 3.860031104199067, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 11, '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': '2250925', 'n_tokens_mistral': 1285, 'n_tokens_neox': 1217, 'n_words': 232}