Good idea to clean your tank before feeding them. You need to visit them frequently for them to stay alive.
I visit my goldfish everyday. I'm not sure what the maximum time is before visiting them before they die. I think you have two or three days before they die without a visit or doing tank maintenance.
There's an auto-feeder which will feed fish for around a week.
Also, there's something to be bought to bring fish back to life.
Both the above have to be bought.
I have the auto-feeder but not the bring fish back to life option.
There's also a reset option but I haven't used it as I'm assuming it resets everything to the beginning.