As BarfingWhale said, the only fish suitable for a 5 gallon tank is a Betta. They require a hood (or they will jump out), a heater (they are high-end tropical, contrary to popular belief), and a gentle filter (they don't like turbulence in their water). Bettas are one of the easiest fish to keep that there is, providing you do plenty of research on proper Betta care beforehand.
Goldfish can grow to be huge, depending on species. A single Fancy Goldfish requires a 30 gallon tank, a Common or Comet a 75 gallon tank. Some species can live 25 years or more, with excellent care. All goldfish are very messy fish and require a filter rated for double the tank size, 30% weekly water changes, and thorough gravel vacuuming. They are extremely labor-intensive to keep them properly. Unless you have the time and relish the idea of all that work, Goldfish are not for you.
Do plenty of research, read some beginner's aquarium keeping books, then decide if a Betta is a good idea for you. Another option would be a few shrimp, or possibly two African Dwarf Frogs. Some people say ADFs need a 10 gallon tank, but most agree that 5 gallons is fine. Just make sure you get 2 ADFs, not ACFs (African Clawed Frogs). ACFs get much larger and definitely do need a 10 gallon tank. You should get 2 ADFs, they are social and one will get lonely. Make sure they are same sex or they will breed. That can bring with it all sorts of problems best avoided.
Hope this helps. Good luck!
Hobbyist for many years.