They're best in pairs - many will pine away if they're kept as singles. I had a beautiful pair of V. sexgutatta (sixspots) that did well on a wide variety of frozen foods. I found the key was using a long pipette to inject the food (3 cubes worth daily - these fish are BIG eaters) beneath the sand, where the other fish can't get it. The gobies need time to sift it out at their leisure.
I lost my pair when a pair of saddleback clowns matured and suddenly decided the entire 65g tank belonged to them. Within a day, before I could remove either pair, the clowns had hunted down and killed both gobies. I bought the gobies when they were quite small, about 2.5" and 1.5", and when they died they were over 4" so we had them quite a while. I'm not sure how long they live, or how long it's possible to keep them in captivity, but I think if you start with a healthy, eating pair and feed them very well your chances of having them around for a long time are good.