If the subject of your sentence is "I", then Barrie's brief explanation correctly summarizes the essential difference between going to and will. Example:
- I'm going to go shopping after work today.
means that you have already planned what to do later.
- What are you doing after work today? - Haven't thought about it. Maybe I 'll go shopping.
indicates a plan made at the time of speaking.
Of course, you are not always the subject when talking about the future, and the focus may be on predictions rather than plans. In such cases there is no simple rule to follow. For example:
- She's going to have baby (not: She will have a baby)
and
- The baby will be her second child (questionable: The baby is going to be her second child)
Talking about the future is one of the most difficult aspects of English grammar for non-native speakers, and includes many more than the two forms discussed here. I recommend investing in a good reference such as Swan's Practical English Usage, and asking specific questions here on this site if you are not sure which form you need in any given context.