〜に行く
Go somewhere to do something (purpose of movement)machine translation
FormationVerb ます-form (drop ます) + に + 行きます/来ます
Use this pattern to say you go (or come, or return) somewhere IN ORDER TO do something: 「買いに行きます」= go to buy.
How to form it: ます-form, drop ます, + に + a movement verb (行きます, 来ます, 帰ります). With activity nouns like 買い物, 旅行, just use noun + に行きます.
Note: the に here marks the purpose of the movement; the destination still takes へ or に as usual: デパートへ買いに行きます.
Examples
デパートへかばんを買いに行きます。
I'm going to the department store to buy a bag.
図書館へ本を借りに行きます。
I'm going to the library to borrow books.
友達が日本へ遊びに来ました。
My friend came to Japan for a visit.