My textbook has the latter sentence mentioned in the title. I didn't know 行く could take the を particle. Can someone explain the difference between the two sentences (を vs. に)?
を can indicate the location of moving (e.g. 通りを歩く, 廊下を走る, 海を渡る), so 我が道を行く, 荒野を行く or like that are possible. However, 学校を行かなくてもいいです doesn't make sense. Is that really written in your textbook?