Kant’s categorical imperative holds that people should only do what they think should be the rule, or law, for all. The categorical imperative is similar to the golden rule in the fact that they both deal with how people ought to be treated. The big difference is that the golden rule is more subjective since it deals with how an individual wants to be treated, which can differ for each person, whereas the categorical imperative is objective since it deals with how an individual thinks all people should be treated, which is controlled by the law.
As a society, we have certain moral rules that everyone agrees on: murder is wrong, you should not steal, or hurting kids is wrong. Generally, everyone agrees that this is wrong even if some people do commit these acts—this does not imply that these people think this is right, just that it feels necessary in that moment. However, these basic moral codes have been established through our changing ideals and experiences. In the past, revenge for a death was common, allowed, and even admired. In this day and age, this is no longer the case. We decided these moral “laws” based on past experiences. I do not think it is possible to develop a moral code without it relying on experience in some way. At our hearts, we are still animals, and, therefore, we do not have anything to stop us from committing “sins”. This has been exemplified in literature and entertainment throughout the ages like Lord of the Flies and the horror series The Purge. When people are no longer kept in line by a moral code, they will do whatever benefits them or brings them joy. If people had a built in, experience free moral code, then this sort of idea would not happen. Moral codes are built on experiences and advice given by those who have raised you. Some parts of moral codes seem to come from within us, but that is because they have been so deeply engraved into our societies that we can no longer tell that they are not developed from experience. An example of this would be out understanding that a person should not hurt others intentionally. This would seem like common sense, but this understanding comes from centuries of understanding and trial-and-error. Moral codes are not innate; they must be developed.