Constipation in goldfish is usually treatable, but it sounds like its too late. You could add melafix to the water, it heals a lot of fish wounds. Goldfish need to eat a lot of plant materials or they get constipated. Boiled peas and spinach are often recomendedI'm not sure anything can be done to save your fish at this point though.