Many different proteins are synthesized on the rough endoplasmic reticulum (RER) and transported to the Golgi apparatus in transport vesicles. From the Golgi apparatus these proteins are then sent to their proper locations in the cell. For example:
lysosomal proteins are packaged into primary lysosomes
integral membrane proteins are sent to the plasma membrane or to particular regions of the plasma membrane
secretory proteins like peptide hormones or digestive enzymes must be packaged into secretory vesicles
acrosomal proteins must be packaged into acrosomal vesicles
To insure that these different proteins are sent to their proper locations, they must be sorted, one from the other, in the Golgi apparatus. Thus one function of the Golgi apparatus is protein sorting.
In the following diagram the Golgi apparatus is indicated and in the lumen of the Golgi are different proteins indicated by the red, green and blue dots. The different proteins are intermixed in the Golgi but are sorted from each other before they are packaged into vesicles.

There are many different way inwhich proteins are modified in the Golgi apparatus. One very well studied way involves the addition of carbohydrtes to proteins.
The lumen of the golgi apparatus has enzymes that will covalently bond carbohydrates to proteins.
In the diagram below an integral membrane protein is indicated by a red line
The green hexagons represent carbohydrates.
the carbohydrates are covalently bonded to the part of the integral membrane protein that is in the lumen of the golgi (1)
the glycosylated protein is budded from the Golgi (2-4)
the vesicle that has the integral membrane protein, fuses with the plasma membrane by the process of exocytosis (5-8)
the glycosylated part of the integral membrane protein is now on the outside of the cell (9)
