3of11SANTA CLARA, CA - JUNE 12: Mike McGlinchey #69 and Joe Staley #74 of the San Francisco 49ers stand on the field during the team Mini Camp at the SAP Training Facility on June 12, 2018 in Santa Clara, California. (Photo by Michael Zagaris/San Francisco 49ers/Getty Images)Photo: Michael Zagaris / Getty Images

4of11LOS ANGELES, CA - DECEMBER 30: Joe Staley #74 and Mike McGlinchey #69 of the San Francisco 49ers talk in the locker room prior to the game against the Los Angeles Rams at the LA Memorial Coliseum on December 30, 2018 in Los Angeles, California. The Rams defeated the 49ers 48-32. (Photo by Michael Zagaris/San Francisco 49ers/Getty Images)Photo: Michael Zagaris / Getty Images

6of11Mike McGlinchey (69) celebrates as running back Alfred Morris (46) scores a touchdown during the first half of an NFL football game against the Kansas City Chiefs in Kansas City, Mo., Sunday, Sept. 23, 2018. (AP Photo/Charlie Riedel)Photo: Charlie Riedel / AP

10of11TAMPA, FL - NOVEMBER 25: Mike McGlinchey #69 of the San Francisco 49ers blocks during the game against the Tampa Bay Buccaneers at Raymond James Stadium on November 25, 2018 in Tampa, Florida. The Buccaneers defeated the 49ers 27-9. (Photo by Michael Zagaris/San Francisco 49ers/Getty Images)Photo: Michael Zagaris / Getty Images

11of11Mike McGlinchey is the 49ers’ likely replacement for Joe Staley on the left side of the offensive line.Photo: Scott Strazzante / The Chronicle 2018

There aren’t many feel-good stories in a 4-12 year, but here was one from the 49ers’ 2018 season: The bookends of their offensive line became best buddies.

It didn’t take long for rookie right tackle Mike McGlinchey, 23, and left tackle Joe Staley, 34, to click as their “bromance” was a running joke long before training camp. In fact, the bond between the hyper-competitive goofballs might have been sealed in the spring when they were captured on video singing a Backstreet Boys hit at a karaoke bar. (They also sang together at a charity dinner, for a show on the team’s website ...)

Last week, about six months after their, um, interesting karaoke-bar rendition of “Everybody,” McGlinchey and Staley turned serious when reflecting on their connection.

McGlinchey, the No. 9 overall pick who started all 16 games, had someone who could relate to his pressure-filled NFL baptism. Staley, also a first-round pick, was a 16-game starter as a rookie in 2007.

“I’m just thankful that I had that opportunity, because this year wouldn’t have gone the way it did without him,” McGlinchey said. “He taught me a lot of different things early ... and then we started competing with each other: Trying to push each other to the best we could be. When you have somebody who can do that, that’s what makes this job a lot of fun.”

Meanwhile, Staley, who has contemplated retirement in recent years, repeatedly said he had a better year than he did in 2017. He noted he was healthier and was in his second season in head coach Kyle Shanahan’s system, but he also credited McGlinchey’s influence.

“Mike has been huge,” Staley said. “I’d never tell this to his face ... how much I appreciate him. (I’m) always going to make sure he has a little bit of that trying to get his father’s approval with me. But he’s been huge for me this year just because we’ve gotten along so well from Day 1. And just the competitive nature of football kind of brings that out.

“I’m already super-competitive, but it’s a challenge for me to compete with a guy that’s 23 and just starting his career and trying to keep up with the stuff that he’s doing. And challenge him in the same way.”

The least surprising news of the offseason: Staley and McGlinchey won’t stay apart for long.

McGlinchey, who is from suburban Philadelphia, plans to return to California around late February to train with Staley in San Diego, where he lives in the offseason. They will work together before reporting for the offseason program in mid-April.

Last year, Staley began incorporating twice-weekly yoga sessions into his routine to improve his flexibility and mobility. Is McGlinchey up for some downward facing dogs?

It’s possible their first time training together in the offseason also will be the last time they do so.

Staley will be in the final year of his contract next season, and he hasn’t committed to playing beyond 2019. The 49ers drafted McGlinchey with the idea he eventually would supplant Staley at left tackle.

McGlinchey’s first season left little doubt he could handle the most glamorous spot on the offensive line, which has been occupied by his buddy for the past 12 seasons.

With Staley’s help, he hopes eventually to be better than the five-time Pro Bowler.

“I’m not satisfied with the way I played this year,” McGlinchey said. “Everyone says, ‘Oh, it was a great rookie year.’ I’m not playing to be a great rookie: I’m playing to be the best in the league.

“And, hopefully, in year two, I’ll be able to take a huge step forward in accomplishing that goal. Going to have a hell of an offseason getting ready to do it.”

Eric Branch has worked at the San Francisco Chronicle since 2011 as the 49ers beat writer. Before that, he covered the 49ers for the Santa Rosa Press Democrat in 2010. Since he began his career in journalism in 1997 in Logansport, Ind., he’s covered events ranging from archery tournaments to the NCAA Men’s Basketball Tournament.