Merge types package into root lemmy package
This commit is contained in:
		@@ -28,11 +28,11 @@ func (r *RoutesGenerator) Generate(routes []extractor.Route) error {
 | 
			
		||||
		).Id(transformName(r.Name)).ParamsFunc(func(g *jen.Group) {
 | 
			
		||||
			g.Id("ctx").Qual("context", "Context")
 | 
			
		||||
			if r.ParamsName != "" {
 | 
			
		||||
				g.Id("data").Qual("go.elara.ws/go-lemmy/types", r.ParamsName)
 | 
			
		||||
				g.Id("data").Id(r.ParamsName)
 | 
			
		||||
			}
 | 
			
		||||
		}).ParamsFunc(func(g *jen.Group) {
 | 
			
		||||
			if r.ReturnName != "" {
 | 
			
		||||
				g.Op("*").Qual("go.elara.ws/go-lemmy/types", r.ReturnName)
 | 
			
		||||
				g.Op("*").Id(r.ReturnName)
 | 
			
		||||
			}
 | 
			
		||||
			g.Error()
 | 
			
		||||
		}).BlockFunc(func(g *jen.Group) {
 | 
			
		||||
@@ -47,7 +47,7 @@ func (r *RoutesGenerator) Generate(routes []extractor.Route) error {
 | 
			
		||||
				returnName = "EmptyResponse"
 | 
			
		||||
			}
 | 
			
		||||
 | 
			
		||||
			g.Id("resData").Op(":=").Op("&").Qual("go.elara.ws/go-lemmy/types", returnName).Block()
 | 
			
		||||
			g.Id("resData").Op(":=").Op("&").Id(returnName).Block()
 | 
			
		||||
 | 
			
		||||
			funcName := "req"
 | 
			
		||||
			if r.Method == "GET" {
 | 
			
		||||
 
 | 
			
		||||
@@ -27,18 +27,13 @@ func main() {
 | 
			
		||||
 | 
			
		||||
	routes, structs := e.Extract()
 | 
			
		||||
 | 
			
		||||
	err = os.MkdirAll(filepath.Join(*outDir, "types"), 0o755)
 | 
			
		||||
	if err != nil {
 | 
			
		||||
		log.Fatal("Error creating types directory").Err(err).Send()
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	otf, err := os.Create(filepath.Join(*outDir, "types/types.gen.go"))
 | 
			
		||||
	otf, err := os.Create(filepath.Join(*outDir, "types.gen.go"))
 | 
			
		||||
	if err != nil {
 | 
			
		||||
		log.Fatal("Error creating types output file").Err(err).Send()
 | 
			
		||||
	}
 | 
			
		||||
	defer otf.Close()
 | 
			
		||||
 | 
			
		||||
	err = generator.NewStruct(otf, "types").Generate(structs)
 | 
			
		||||
	err = generator.NewStruct(otf, "lemmy").Generate(structs)
 | 
			
		||||
	if err != nil {
 | 
			
		||||
		log.Fatal("Error generating output routes file").Err(err).Send()
 | 
			
		||||
	}
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user