Gophers will eat almost anything, even the roots of fairly Well-established trees and are the curse of many western gardeners (or should I say many western gardeners curse Gophers). They are most often kept under control by trapping (especially in early spring before they breed), or with hunting cats, but they are difficult to eliminate entirely.
These animals generally prefer to tunnel and won’t usually walk on to the bed and dig down from the surface. You can keep them out of a bed by lining it with wire mesh. This is expensive and time consuming for a large garden, but you could line some special beds for growing those crops most favored by them. The mesh must be put down carefully. These creatures aren’t stupid, they seem to know there is something good on the other side and will work to find chinks in the barrier.
Image: USDA Forest Service - Northeastern Area Archive, USDA Forest Service, Bugwood.org