The word was military shorthand for "prostitute" as far back as the late 1800s. It didn't stick to Asians until around the Korean War. You see, in Korean 국 ("gook") roughly means "nation." Likewise, 미국 ("me-gook") is a person from America, and 한국 ("han-gook") is a person from Korea. This is about the time that it became an ethnic slur that carried over to the Vietnam War and beyond.

