File:GolemFarmVillage.jpg - minecraft.fandom.com
Summary[]
This is a prototype survival-mode iron golem farm built in an existing village, with many happy villagers free to roam, multiply, and trade with you. This can be built fairly easily in Survival mode, using 36 doors, 40 glass blocks, fencing, water, lava, signs, and any building blocks. Build the fenced area first, being sure not to trap any villagers. Add the buildings without doors. Then add the doors and destroy all other doors in the village.
Improvement: A subsequent farm was built with the buildings set back 1 block from the pit with no glass barriers; instead, a fence goes all the way around the perimeter of the pit. This was simpler in that it didn't require so much glass. Also, the 2-block channel on either side of the center hole isn't required, it works fine without the channel as long as all the water blocks are still used (16 on each of two opposing sides of the pit, and two water blocks each at the center of the other two sides).
If a golem spawns outside the pit due to door asymmetry while you are placing the doors, that's OK. You can fence the golem into a small corral against the edge of the pit, break the inner fence, and dump in a bucket of water to sweep the golem into the pit. Or you can just leave him to patrol the village like I did.
With a golem already patrolling the village, the farm's production drops to about 10 ingots per hour as a second golem will spawn occasionally inside the pit. This turned out to be fine with me, for two reasons: (1) the village golem protected me from hostile mobs on multiple occasions, and (2) I was often busy doing other things in survival and when I got back to my village I'd find the farm had collected sufficient iron for my needs (eventually enough to build an anvil). Even at the reduced production rate, I now have more iron than I ever expect to use.