Just carrying a gun will not save your life.
Proper training and understanding aspects of any possible attack will improve your survival odds greatly.
See this knife attack training video and understand how quickly action is necessary.
In the current light of knife attacks that have become, sadly, very common, the pistol-carrying citizen or law enforcement officer needs to see this video.
When a knife-wielding attacker gets close enough to his or her target, too much damage can occur before reactive action can be taken.
An attack is as quick as a blink, as the video shows. The answer to defending yourself against knife attacks is keeping a distance from possible attackers and proper training.