It's true that nothing on the surface will last forever, but there are some lubes that bond to the surfaces for awhile. Sprinco's Machine Gunner's Lube (scroll to bottom of
this page) is one I've found to work extremely well. It uses the ring shaped polyester molecules that bond to the surface of iron-containing alloys and an acid-inhibited sub-micron sized moly suspension that does the same. It takes it two to three days at room temperature to complete bonding. It keeps working after the wet lube is gone.
That company also has a product called
Plate+ Silver that is a thinner and more concentrated version of that same lube that will work inside a barrel. You can also use it to pretreat other bare steel parts before you start using the Machine Gunner's Lube. Again, after about 48-72 hours of being wet with the stuff, it is bonded to the steel. I believe it'll withstand around a 1000 rounds in a rifle barrel before having to be re-coated. Probably more in a pistol. They just recommend reapplying with a swab. They show in rifles that it produces the same velocity decrease that moly-coating bullets does (reduced friction reduces start pressure and the peak pressure that follows it by a couple of percent, and in rifles you have to compensate with about 1% additional powder charge to keep your load velocities up, IME; but it's within normal powder measure variation for most pistol rounds and may be ignored with them).