The Swiss, seeking his eighth title in Ohio, saved all five break points he faced against the German and moves on to a third-round matchup with Argentine Leonardo Mayer.
Federer shakes off early rust to claim opening set
Early on it was a surprise break chance for Gojowczyk as he unloaded on a forehand, but he couldn't convert after sending a return long. He would get a second chance when Federer double-faulted, but his serve was on point as he hit three straight that were unreturnable.
Gojowczyk misfired on a forehand to set up break point for the Swiss, only to use that same wing to draw an error from Federer to wipe away the breakpoint and hold for a 2-1 lead.
The German was in trouble on his next service game, falling behind 15-40. The first break point was saved when the world number two sent a forehand wide but it was Gojowczyk who hit a backhand wide on the second to give Federer a 4-3 lead.
The rustiness continued to show in Federer's game as he needed to save three more break points in the eighth game, but he was able to fend off Gojowczyk's advances.
Serving for the set, the Swiss held to love to wrap up the opening set.
Swiss gets through in straight sets
Still not in top gear, Federer nevertheless battled to deuce in Gojowczyk's opening service game of the second set.
He was gifted a break point when the German double-faulted and was on top after the world number 47 sent a backhand wide.
The final half-chance for Gojowczyk came in the next Federer service game as he rallied from a 40-15 deficit to deuce, but it was the Swiss who held on. He seemed to find his groove, holding with much more ease and bossing the rallies.
Serving for the match, the seven-time champion held to love as he did to close out the first set, wrapping up the victory. Firing 12 aces and having almost half of his serves unreturned, the Swiss won his 11th consecutive match in Cincinnati.