Goalkeepers are subject to all of the same rules as any field player with a few exceptions, including the obvious fact that they are allowed to handle the ball inside their own penalty area. They can also be called for handling infractions, however, which could include handling the ball after an intentional pass from a teammate, handling it twice, or holding the ball for more than six seconds. Other than handling-related offences (while in the penalty area), the goalkeeper is subject to the exact same rules as any other player on the field.
Outside of the penalty area, the goalkeeper is considered exactly the same as any other player on the field, disallowed from using his/her hands to control the ball and as cautionable and expellable as any player on the field.
Chat with our AI personalities
There are two answers to this question. First, if you're wanting to know about a substitute coming from the bench to play in the game, then the goalkeeper is treated the same as any other player: both players will be cautioned at the next stoppage of play, and if the incoming substitute interferes with play or the referee decides to stop play for this infraction, the opposing team is awarded an indirect free kick.
If an outfield player switches positions with the goalkeeper (probably switching jerseys and gloves as well) without the referee's permission, the referee will allow play to continue and caution both players at the next stoppage of play. Note that the player wearing the differently-colored jersey is considered to be the goalkeeper, and if that jersey is worn by another player, that player becomes the goalkeeper with or without the referee's permission (but will still get a yellow card for his trouble), which means that the "new" goalkeeper can make a save without being guilty of a handling foul so long as he is clearly identified as being the one and only current goalkeeper for his team by virtue of the jersey.
Technically this is a cautionable offense. In reality this never happens during live play.