Goldfish and many other animals change color in response to light levels. Pigment production in response to light is something we're all familiar with, since this is the basis for a suntan. Fish have cells called chromatophores that produce the pigments that give coloration or reflect light. The color of a fish is determined in part by which pigments are in the cells (there are several colors), how many pigment molecules there are, and whether the pigment is clustered inside the cell or is distributed throughout the cytoplasm.
If your goldfish is kept in the dark at night, you may notice it appears a little paler when you turn on the lights in the morning. Goldfish kept indoors without full-spectrum lighting are also less-brightly colored than fish exposed to natural sunlight or artificial lighting that includes ultraviolet light (UVA and UVB). If you keep your fish in the dark all the time, the chromatophores won't produce more pigment, so the fish's color will start to fade as the chromatophores that already have color naturally die, while the new cells aren't stimulated to produce pigment.
However, your goldfish won't become white if you keep it in the dark because fish also get some of their coloration from the foods they eat. Shrimp, spirulina, and fish meal naturally contain pigments called carotenoids. Also, many fish foods contain canthaxanthin, a pigment added for the purpose of enhancing fish color.