the goat dance
The only way I have found to keep a goat in a pen is to either use panels (read solid) made for sheep and goats with well-spaced metal or wooden fence posts, or electric netting or wire. At my own farm I learned this the hard way. My first goat, Finn, was not happy as the lone goat amongst a flock of sheep and would not stay inside the woven wire fences. He got out and into the road, into poisonous plants, and all other sorts of trouble and made sure the sheep got out too. I didn't have the pen I have now (originally built for a horse!) to contain goats, and so he went to live on another farm.
Now my set up is goat-proof. Inside the barn are large 1x8 inch boards strong and sturdy, three high with about 12 inches between each board. They have woven wire stapled to them in case little Francis wanted to crawl though. Outside a large metal horsegate (also reinforced with woven wire to prevent crawl-throughs) is strong enough to handle any goat arms. And, the fencing all around the outside area is electric. So my goat pen is more of a goat jail, but that's what it takes in small spaces. If I had a 7-acre field it would be a different story, they could roam a little more and be as interested in escaping (at first!), but here at Cold Antler goats have to be smartly contained.
My advice to anyone considering goats, go for it. But consider your fences and barn first. Get an experienced goat farmer, homesteader or Extension agent to check your set up or help you prepare. As someone who learned the hard way, I can not stress enough how much having people with goat experience in my life with Bonita and Francis has improved things. Goats are dear friends and treasures here now, not a hassle. Not something all farmers can say and it took some hard lessons to get there. But you got to start somewhere, right?