Interjections are words or phrases that express strong emotion. In this case, "Gosh" usually expresses surprise, amazement, or mild annoyance.
While it can occasionally be used as a noun (like "Oh my gosh!"), its primary function is as an interjection.