How can I avoid metagaming when I know things my character doesn’t?

One common problem I run into, as a player, is having to feign not-knowing things my character doesn’t but I do, be it rules about certain creatures (“Hmm that rock golem sure looks weak against […]”), or simply some my character did not witness but I did because other players at the table had their characters there and the GM did not split the group.

For example, it can be hard to act like you don’t know your friends are in trouble in the next building, and not go over there just to have a “random look” and oh surprise find something you, as a player, already knew you’d find. Finding myself in such a situation can be avoided if the GM splits the group of players or uses other information-control tricks, but that’s not always done.

When in such a situation, what are good techniques or things I can do to force myself into an “oblivious” state of mind about those things?

How can I more easily feign ignorance of in-game/in-universe information, and have my character act with more accordance to what he knows and not what I know?