Your dog might be having a condition called conjunctivitis which is inflammation of conjunctiva. This is usually cause by bacteria or virus. Glaucoma and corneal ulceration are 2 other factors that can cause this condition. Infection of the eyelids is another possibility. Foreign material trapped in the eyes causes irritation leading secondary infection which can result in goop in the eyes of the dogs. You should clean the eyes of your dog with saline water and take him to vet for proper diagnosis and treatment.