Goats are rather curious creatures.
Fencing, should be nothing they can stick their heads through. If they can, the will.
Electric and training are essential for keeping them in their pasture. We also provide enrichment stuff. Like homemade puzzle feeders. Things to jump on. Goats are easier to train then sheep in our experience.
As far as tree fencing goes. We had solid white 6' tall fencing all around their shade trees. The goats would walk up the fence with their front legs and reach for any low hanging branches. Goats have all day to scheme. A fence should not encourage climbing, as a hoof, horn or head could become stuck. Hindsight we should have moved the fencing further out allowing the tree to canopy more.
Such great tips on this post. Just had to throw in some of our experience.