This depends on the behavior of both the betta fish and the goldfish. It isn't a good idea to mix them if the betta fish is aggressive, and the same goes for the goldfish. If the betta fish is more easy going and the goldfish doesn't nip at the betta's fins, most cases are okay. However, it might not be a good idea to mix the two because they have different tank requirements, including size.
Male betta fish will fight other male betta because they are very territorial. As a result, it isn't advisable to house betta with other fish. They are also called Siamese fighting fish because of their territorial nature. Goldfish and bettas also need different water temperatures.