One goldfish could live in a five-gallon tank. I would not try to keep more. Because of their physiologies, goldfish pollute water quickly. One fish and a good maintenance routine will be fine for the short term.
However, if the question was how many goldfish should live in a five-gallon tank the answer is: zero. Most species of goldfish grow very large, believe it or not, and require huge tanks or outdoor ponds as adults. Even a common goldfish can surpass a foot in length if allowed to reach its full potential; obviously much too large for a 5-gallon tank.
If you haven’t yet purchased a fish for your tank, consider a betta fish instead. They are appropriate for 5-gallon tanks, where a goldfish really isn’t. If you have your heart set on goldfish, take some time to research their true care requirements before you get one. If you start out with a juvenile in a 5-gallon tank, have a plan to move it into a more appropriate environment as it gets older.