This is really two questions about yourself that only you can answer.
One: If you self-learn, will you really learn it? Or will you know how to slap a hello world together and not much more?
Two: Do you enjoy coding? Go self-learn enough of a language (python, javascript, pick one it doesn't matter) to start doing hacker rank or advent of code exercises. Do you get joy from it? If not, learning to code may not be your ticket.
To be successful and pulling a sacks-of-cash CS-based salary, you want need One and Two to be true. If you follow-through for One is sketchy, then you probably should look at a degree program to guide you. If you're good learning on your own, the sure, do that. Use a university's "required courses" to guide subjects you should make sure to explore, and you can optionally get the textbooks for their courses if that's how you roll.