Roger Federer's straight sets victory over David Goffin at the Shanghai Open wasn't as comfortable as the scoreline suggests.