I am aware that some pilots do drink. We are not Saints, that's for sure. Some will tell you that they drink because of the stress, so they need something to calm their nerves and let them get some sleep. As with most airlines, we had a booklet that pointed out what was expected of us among other issues that were discussed in the pages. United has a zero tolerance for using drugs or drinking alcohol eight hours before a flight. (This is also an FAA rule.) We were always subject to random tests for alcohol and/or drugs. I remember deplaning in Salt Lake City and being led to the crew's lounge where I was handed a cup and told to use the men's room. The water had been shut off and locked out, so the test could be controlled. The specimen was immediately checked. That was the one and only time that I was tested.
I made a commitment to myself to never drink or use some medicines, like cough or cold remedies, the night before I flew. I flew with a young F/O once that had taken some cough syrup just before boarding. We had been in the cockpit maybe 40 minutes before taking off and he was already yawning and I could see his eyes were drooping. I asked him what was up with him. He said he took some XYZ cough syrup just before boarding, which is also against company policy. That put me between a rock and a hard place. We are supposed to rat out our fellow associates when we discover an issue like that, but I decided to forego doing that and instead gave him a lecture after we landed some five hours later. Of course, I was taking a chance for not reporting him. Had he been a "plant" by the company, I may have lost my job, or at least been disciplined somehow.
I am more concerned about pilots that use drugs, especially pain killers. We see them as the silent killers. I think that a lot more of railroad engineers have been caught using drugs than pilots, but it's not like it's a contest. No matter which uses them more. Both are dangerous and puts the passengers at risk.