Relationships are based on trust, primarily.
I can’t have a relationship with you if I can’t blindly trust you.
Most relationships start with a mid-to-high trust percentage, then it increases over time, hopefully, as we perform actions for and with each other, and stay consistent with who we are, what we say, and what we do.
If we ever make a mistake or do something we know we should not have done, then the most ideal case would be to bring it up as soon as possible because the longer you wait, the more difficult it will be to open up and talk about it. The longer that secret stays with you, the more difficult you will make it for your partner to trust you wholeheartedly in the future. And the more guilty you might feel.
Guilt is a powerful feeling. Guilt will slowly kill your inner self; it will make you run around wondering dozen of things; it will make you doubt about what type of person you truly want to be when looking yourself in the mirror.
The best thing you can do when you know you have broken that trust in your relationship is to confess. Say it like it is. The truth should make you free. But at what cost? At the expense of your partner’s feelings because the truth hurts, but it’s always the best alternative.
The problem with telling the truth is that you’ll hurt people. But you have to tell the truth because it’s all that matters in relationships.
Telling the truth exposes so many other aspects of yourself: honesty, sincerity, open communication, love… If you are not able to tell the truth, then you should reconsider being in a relationship, as much as you want to be in one.