[verb masu-stem] + に行く(にいく)
Optionally with destination:
The structure V[masu stem] + にいく expresses going somewhere in order to do something. The particle に marks the purpose of the movement, and いく行く (to go) indicates the direction of travel. This is one of the most fundamental ways to express purpose of movement in Japanese.
The verb before に is always in its masu-stem form (the form you get by removing ます from the polite form). For example, たべます食べます → たべ食べ + にいく, かいます買います → かい買い + にいく.
You can also include the destination using へ or に. The destination comes before the purpose phrase.
The tense and politeness are determined by the final verb いく行く. It can be conjugated into any form – past, negative, polite, etc.
The same structure works with くる来る (to come) instead of いく行く, expressing coming somewhere in order to do something.